#823 context menu
This commit is contained in:
parent
496a362800
commit
7f728e7d14
@ -23,15 +23,13 @@ class DmsfContextMenusController < ApplicationController
|
||||
helper :context_menus
|
||||
|
||||
def dmsf
|
||||
selected_files = params[:files] || []
|
||||
selected_file_links = params[:file_links] || []
|
||||
if selected_file_links.present?
|
||||
selected_file_links.each do |id|
|
||||
link = DmsfLink.find_by_id id
|
||||
selected_files << link.target_id if link && !selected_files.include?(link.target_id.to_s)
|
||||
end
|
||||
selected_files = params[:ids].select{ |x| x =~ /file-\d+/ }.map{ |x| $1.to_i if x =~ /file-(\d+)/ }
|
||||
selected_file_links = params[:ids].select{ |x| x =~ /file-link-\d+/ }.map{ |x| $1.to_i if x =~ /file-link-(\d+)/ }
|
||||
selected_file_links.each do |id|
|
||||
link = DmsfLink.find_by_id id
|
||||
selected_files << link.target_id if link && !selected_files.include?(link.target_id.to_s)
|
||||
end
|
||||
if selected_files.size == 1
|
||||
if (selected_files.size == 1) && (params[:ids].size == 1)
|
||||
@file = DmsfFile.find selected_files[0]
|
||||
end
|
||||
render :layout => false
|
||||
|
||||
@ -100,11 +100,11 @@ class DmsfController < ApplicationController
|
||||
|
||||
def entries_operation
|
||||
# Download/Email
|
||||
selected_folders = params[:subfolders] || []
|
||||
selected_files = params[:files] || []
|
||||
selected_dir_links = params[:dir_links] || []
|
||||
selected_file_links = params[:file_links] || []
|
||||
selected_url_links = params[:url_links] || []
|
||||
selected_folders = params[:ids].select{ |x| x =~ /folder-\d+/ }.map{ |x| $1.to_i if x =~ /folder-(\d+)/ }
|
||||
selected_files = params[:ids].select{ |x| x =~ /file-\d+/ }.map{ |x| $1.to_i if x =~ /file-(\d+)/ }
|
||||
selected_dir_links = params[:ids].select{ |x| x =~ /folder-link-\d+/ }.map{ |x| $1.to_i if x =~ /folder-link-(\d+)/ }
|
||||
selected_file_links = params[:ids].select{ |x| x =~ /file-link-\d+/ }.map{ |x| $1.to_i if x =~ /file-link-(\d+)/ }
|
||||
selected_url_links = params[:ids].select{ |x| x =~ /url-link-\d+/ }.map{ |x| $1.to_i if x =~ /url-link-(\d+)/ }
|
||||
|
||||
if selected_folders.blank? && selected_files.blank? &&
|
||||
selected_dir_links.blank? && selected_file_links.blank? &&
|
||||
@ -118,7 +118,7 @@ class DmsfController < ApplicationController
|
||||
(params[:email_entries].present? || params[:download_entries].present?)
|
||||
selected_dir_links.each do |id|
|
||||
link = DmsfLink.find_by_id id
|
||||
selected_folders << link.target_id if link && !selected_folders.include?(link.target_id.to_s)
|
||||
selected_folders << link.target_id if link && !selected_folders.include?(link.target_id)
|
||||
end
|
||||
end
|
||||
|
||||
@ -126,7 +126,7 @@ class DmsfController < ApplicationController
|
||||
(params[:email_entries].present? || params[:download_entries].present?)
|
||||
selected_file_links.each do |id|
|
||||
link = DmsfLink.find_by_id id
|
||||
selected_files << link.target_id if link && !selected_files.include?(link.target_id.to_s)
|
||||
selected_files << link.target_id if link && !selected_files.include?(link.target_id)
|
||||
end
|
||||
end
|
||||
|
||||
@ -403,50 +403,44 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
|
||||
def download_entries(selected_folders, selected_files)
|
||||
begin
|
||||
zip = DmsfZip.new
|
||||
zip_entries(zip, selected_folders, selected_files)
|
||||
zip.files.each do |f|
|
||||
audit = DmsfFileRevisionAccess.new
|
||||
audit.user = User.current
|
||||
audit.dmsf_file_revision = f.last_revision
|
||||
audit.action = DmsfFileRevisionAccess::DownloadAction
|
||||
audit.save!
|
||||
end
|
||||
send_file(zip.finish,
|
||||
:filename => filename_for_content_disposition("#{@project.name}-#{DateTime.now.strftime('%y%m%d%H%M%S')}.zip"),
|
||||
:type => 'application/zip',
|
||||
:disposition => 'attachment')
|
||||
rescue Exception
|
||||
raise
|
||||
ensure
|
||||
zip.close if zip
|
||||
zip = DmsfZip.new
|
||||
zip_entries(zip, selected_folders, selected_files)
|
||||
zip.files.each do |f|
|
||||
audit = DmsfFileRevisionAccess.new
|
||||
audit.user = User.current
|
||||
audit.dmsf_file_revision = f.last_revision
|
||||
audit.action = DmsfFileRevisionAccess::DownloadAction
|
||||
audit.save!
|
||||
end
|
||||
send_file(zip.finish,
|
||||
:filename => filename_for_content_disposition("#{@project.name}-#{DateTime.now.strftime('%y%m%d%H%M%S')}.zip"),
|
||||
:type => 'application/zip',
|
||||
:disposition => 'attachment')
|
||||
rescue Exception
|
||||
raise
|
||||
ensure
|
||||
zip.close if zip
|
||||
end
|
||||
|
||||
def zip_entries(zip, selected_folders, selected_files)
|
||||
member = Member.where(:user_id => User.current.id, :project_id => @project.id).first
|
||||
if selected_folders && selected_folders.is_a?(Array)
|
||||
selected_folders.each do |selected_folder_id|
|
||||
folder = DmsfFolder.visible.find_by_id selected_folder_id
|
||||
if folder
|
||||
zip.add_folder(folder, member, (folder.dmsf_folder.dmsf_path_str if folder.dmsf_folder))
|
||||
else
|
||||
raise FileNotFound
|
||||
end
|
||||
selected_folders.each do |selected_folder_id|
|
||||
folder = DmsfFolder.visible.find_by_id selected_folder_id
|
||||
if folder
|
||||
zip.add_folder(folder, member, (folder.dmsf_folder.dmsf_path_str if folder.dmsf_folder))
|
||||
else
|
||||
raise FileNotFound
|
||||
end
|
||||
end
|
||||
if selected_files && selected_files.is_a?(Array)
|
||||
selected_files.each do |selected_file_id|
|
||||
file = DmsfFile.visible.find_by_id selected_file_id
|
||||
unless file && file.last_revision && File.exist?(file.last_revision.disk_file)
|
||||
raise FileNotFound
|
||||
end
|
||||
unless (file.project == @project) || User.current.allowed_to?(:view_dmsf_files, file.project)
|
||||
raise DmsfAccessError
|
||||
end
|
||||
zip.add_file(file, member, (file.dmsf_folder.dmsf_path_str if file.dmsf_folder)) if file
|
||||
selected_files.each do |selected_file_id|
|
||||
file = DmsfFile.visible.find_by_id selected_file_id
|
||||
unless file && file.last_revision && File.exist?(file.last_revision.disk_file)
|
||||
raise FileNotFound
|
||||
end
|
||||
unless (file.project == @project) || User.current.allowed_to?(:view_dmsf_files, file.project)
|
||||
raise DmsfAccessError
|
||||
end
|
||||
zip.add_file(file, member, (file.dmsf_folder.dmsf_path_str if file.dmsf_folder)) if file
|
||||
end
|
||||
max_files = Setting.plugin_redmine_dmsf['dmsf_max_file_download'].to_i
|
||||
if max_files > 0 && zip.files.length > max_files
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
<td class="dmsf_checkbox">
|
||||
<% unless (subfolder && subfolder.system) %>
|
||||
<%= check_box_tag(name, id, false, :title => l(:title_check_for_zip_download_or_email), :id => "subfolder_#{id}") %>
|
||||
<%= check_box_tag('ids[]', "#{name}-#{id}", false, :id => "subfolder_#{id}") %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% if DmsfFolder.is_column_on?('id') %>
|
||||
|
||||
@ -20,8 +20,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
%>
|
||||
|
||||
<td class="dmsf_checkbox"><%= check_box_tag(name, id, false,
|
||||
:title => l(:title_check_for_restore_or_delete), :id => "subfolder_#{id}") %></td>
|
||||
<td class="dmsf_checkbox"><%= check_box_tag('ids[]', "#{name}-#{id}", false, :id => "subfolder_#{id}") %></td>
|
||||
<% if DmsfFolder.is_column_on?('id') %>
|
||||
<td class="id"><%= link_to(subfolder.id, edit_dmsf_path(:id => project, :folder_id => subfolder)) %></td>
|
||||
<% end %>
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
:subfolder => obj,
|
||||
:link => nil,
|
||||
:id => obj.id,
|
||||
:name => 'subfolders[]',
|
||||
:name => 'folder',
|
||||
:title => obj.title,
|
||||
:onclick => onclick,
|
||||
:position => position}) %>
|
||||
@ -64,7 +64,7 @@
|
||||
:subfolder => obj.target_folder,
|
||||
:link => obj,
|
||||
:id => obj.id,
|
||||
:name => 'dir_links[]',
|
||||
:name => 'folder-link',
|
||||
:title => obj.name,
|
||||
:onclick => onclick,
|
||||
:position => position}) %>
|
||||
@ -80,7 +80,7 @@
|
||||
:file => obj,
|
||||
:link => nil,
|
||||
:id => obj.id,
|
||||
:name => 'files[]',
|
||||
:name => 'file',
|
||||
:title => obj.title,
|
||||
:onclick => onclick,
|
||||
:position => position}) %>
|
||||
@ -96,7 +96,7 @@
|
||||
:file => obj.target_file,
|
||||
:link => obj,
|
||||
:id => obj.id,
|
||||
:name => 'file_links[]',
|
||||
:name => 'file-link',
|
||||
:title => obj.name,
|
||||
:onclick => onclick,
|
||||
:position => position}) %>
|
||||
@ -108,7 +108,7 @@
|
||||
:file => obj.target_file,
|
||||
:link => obj,
|
||||
:id => obj.id,
|
||||
:name => 'file_links[]',
|
||||
:name => 'file-link',
|
||||
:title => obj.name,
|
||||
:onclick => onclick,
|
||||
:position => position}) %>
|
||||
|
||||
@ -22,8 +22,7 @@
|
||||
|
||||
<% wf = DmsfWorkflow.find_by_id(file.last_revision.dmsf_workflow_id) if file.last_revision.dmsf_workflow_id %>
|
||||
|
||||
<td class="dmsf_checkbox"><%= check_box_tag(name, id, false,
|
||||
:title => l(:title_check_for_zip_download_or_email), :id => "file_#{id}") %></td>
|
||||
<td class="dmsf_checkbox"><%= check_box_tag('ids[]', "#{name}-#{id}", false, :id => "file_#{id}") %></td>
|
||||
<% if DmsfFolder.is_column_on?('id') %>
|
||||
<td class="id"><%= link_to(file.id, dmsf_file_path(:id => file)) %></td>
|
||||
<% end %>
|
||||
|
||||
@ -20,8 +20,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
%>
|
||||
|
||||
<td class="dmsf_checkbox"><%= check_box_tag(name, id, false,
|
||||
:title => l(:title_check_for_restore_or_delete), :id => "file_#{id}") %></td>
|
||||
<td class="dmsf_checkbox"><%= check_box_tag('ids[]', "#{name}-#{id}", false, :id => "file_#{id}") %></td>
|
||||
<% if DmsfFolder.is_column_on?('id') %>
|
||||
<td class="id"><%= file.id %></td>
|
||||
<% end %>
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
:subfolder => subfolder,
|
||||
:link => nil,
|
||||
:id => subfolder.id,
|
||||
:name => 'subfolders[]',
|
||||
:name => 'folder',
|
||||
:title => subfolder.title,
|
||||
:position => 0 }) %>
|
||||
</tr>
|
||||
@ -91,7 +91,7 @@
|
||||
:subfolder => link.target_folder,
|
||||
:link => link,
|
||||
:id => link.id,
|
||||
:name => 'dir_links[]',
|
||||
:name => 'folder-link',
|
||||
:title => link.name,
|
||||
:position => 0}) %>
|
||||
</tr>
|
||||
@ -108,7 +108,7 @@
|
||||
:file => file,
|
||||
:link => nil,
|
||||
:id => file.id,
|
||||
:name => 'files[]',
|
||||
:name => 'file',
|
||||
:title => file.title,
|
||||
:position => 1 }) %>
|
||||
</tr>
|
||||
@ -125,7 +125,7 @@
|
||||
:file => link.target_file,
|
||||
:link => link,
|
||||
:id => link.id,
|
||||
:name => 'file_links[]',
|
||||
:name => 'file-link',
|
||||
:title => link.name,
|
||||
:position => 1}) %>
|
||||
</tr>
|
||||
@ -137,7 +137,7 @@
|
||||
:file => link.target_file,
|
||||
:link => link,
|
||||
:id => link.id,
|
||||
:name => 'file_links[]',
|
||||
:name => 'url-link',
|
||||
:title => link.name,
|
||||
:position => 1}) %>
|
||||
</tr>
|
||||
|
||||
@ -24,7 +24,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="dmsf_checkbox dmsf_th">
|
||||
<input id="check_all_entries" title="<%= l(:title_check_uncheck_all_for_zip_download_or_email) %>" type="checkbox" />
|
||||
<%= check_box_tag 'check_all', '', false, :class => 'toggle-selection',
|
||||
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
|
||||
</th>
|
||||
<% if DmsfFolder.is_column_on?('id') %>
|
||||
<th class="dmsf_th">#</th>
|
||||
|
||||
@ -20,8 +20,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
%>
|
||||
|
||||
<td class="dmsf_checkbox"><%= check_box_tag(name, id, false,
|
||||
:title => l(:title_check_for_restore_or_delete)) %></td>
|
||||
<td class="dmsf_checkbox"><%= check_box_tag('ids[]', "#{name}-#{id}", false) %></td>
|
||||
<% if DmsfFolder.is_column_on?('id') %>
|
||||
<td class="id"></td>
|
||||
<% end %>
|
||||
|
||||
@ -28,6 +28,7 @@ hideOnLoad();
|
||||
<% modified = DmsfFolder.get_column_position('modified') %>
|
||||
|
||||
$('#browser').dataTable({
|
||||
orderClasses: false,
|
||||
responsive: {
|
||||
details: false
|
||||
},
|
||||
|
||||
@ -87,10 +87,13 @@
|
||||
:class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_context_menu_path}) do %>
|
||||
<%= hidden_field_tag('action') %>
|
||||
<div id="dmsf_buttons" class="dmsf_controls" style="float: left">
|
||||
<%= submit_tag(l(:button_download), :title => l(:title_download_checked), :name => 'download_entries') if @file_view_allowed %>
|
||||
<%= submit_tag(l(:field_mail), :title => l(:title_send_checked_by_email), :name => 'email_entries') if (@file_view_allowed && User.current.allowed_to?(:email_documents, @project)) %>
|
||||
<% if @file_delete_allowed%>
|
||||
<%= submit_tag(l(:button_delete), :title => l(:title_delete_checked), :name => 'delete_entries') if @file_delete_allowed %>
|
||||
<%= submit_tag(l(:button_download), :title => l(:title_download_checked), :name => 'download_entries',
|
||||
:class => 'toggle-selection') if @file_view_allowed %>
|
||||
<%= submit_tag(l(:field_mail), :title => l(:title_send_checked_by_email), :name => 'email_entries',
|
||||
:class => 'toggle-selection') if (@file_view_allowed && User.current.allowed_to?(:email_documents, @project)) %>
|
||||
<% if @file_delete_allowed %>
|
||||
<%= submit_tag(l(:button_delete), :title => l(:title_delete_checked), :name => 'delete_entries',
|
||||
:class => 'toggle-selection') if @file_delete_allowed %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% unless @system_folder %>
|
||||
@ -132,9 +135,6 @@
|
||||
$('#entries_form').attr('action', "<%= tag_changed_path(:id => @project, :folder_id => @folder) %>");
|
||||
$('#entries_form').submit();
|
||||
});
|
||||
$('#check_all_entries').click(function() {
|
||||
$('input[type=checkbox]', $('#browser > tbody')).prop('checked', this.checked);
|
||||
});
|
||||
<% end %>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
@ -155,6 +155,7 @@
|
||||
<%= late_javascript_tag do %>
|
||||
EASY.schedule.main(function() {
|
||||
$("#browser").dataTable({
|
||||
orderClasses: false,
|
||||
responsive: {
|
||||
details: false
|
||||
},
|
||||
|
||||
@ -37,9 +37,11 @@
|
||||
<%= hidden_field_tag('action') %>
|
||||
<div class="dmsf_controls" style="float: left">
|
||||
<% if @file_manipulation_allowed && @folder_manipulation_allowed %>
|
||||
<%= submit_tag(l(:title_restore), :title => l(:title_restore_checked), :name => 'restore_entries') %>
|
||||
<%= submit_tag(l(:title_restore), :title => l(:title_restore_checked), :name => 'restore_entries',
|
||||
:class => 'toggle-selection') %>
|
||||
<% if @file_delete_allowed%>
|
||||
<%= submit_tag(l(:button_delete), :title => l(:title_delete_checked), :name => 'destroy_entries') %>
|
||||
<%= submit_tag(l(:button_delete), :title => l(:title_delete_checked), :name => 'destroy_entries',
|
||||
:class => 'toggle-selection') %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -157,7 +159,7 @@
|
||||
:file => link.target_file,
|
||||
:link => link,
|
||||
:id => link.id,
|
||||
:name => 'url_links[]',
|
||||
:name => 'url-link',
|
||||
:title => link.name }) %>
|
||||
</tr>
|
||||
<% end %>
|
||||
@ -179,9 +181,6 @@
|
||||
$('#entries_form').attr('action', "<%= tag_changed_path(:id => @project, :folder_id => @folder) %>");
|
||||
$('#entries_form').submit();
|
||||
});
|
||||
$('#check_all_entries').click(function() {
|
||||
$('input[type=checkbox]', $('#browser > tbody')).prop('checked', this.checked);
|
||||
});
|
||||
<% end %>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
@ -202,6 +201,7 @@
|
||||
<%= late_javascript_tag do %>
|
||||
EASY.schedule.main(function() {
|
||||
$('#browser').dataTable({
|
||||
orderClasses: false,
|
||||
responsive: {
|
||||
details: false
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user