diff --git a/after_init.rb b/after_init.rb index 0dde0f55..2a191f38 100644 --- a/after_init.rb +++ b/after_init.rb @@ -71,7 +71,7 @@ def dmsf_init {:dmsf_files => [:create_revision, :lock, :unlock, :delete_revision, :obsolete_revision, :notify_activate, :notify_deactivate, :restore], :dmsf_upload => [:upload_files, :upload_file, :upload, :commit_files, :commit, - :delete_dmsf_attachment, :delete_dmsf_link_attachment], + :delete_dmsf_attachment, :delete_dmsf_link_attachment, :multi_upload], :dmsf_links => [:new, :create, :destroy, :restore, :autocomplete_for_project, :autocomplete_for_folder], :dmsf_files_copy => [:new, :copy, :move], diff --git a/app/controllers/dmsf_context_menus_controller.rb b/app/controllers/dmsf_context_menus_controller.rb index e7cca722..90897756 100644 --- a/app/controllers/dmsf_context_menus_controller.rb +++ b/app/controllers/dmsf_context_menus_controller.rb @@ -82,7 +82,7 @@ class DmsfContextMenusController < ApplicationController end def find_dmsf_file - if (params[:ids].size == 1) && (!@dmsf_folder) + if (params[:ids].present? && (params[:ids].size == 1)) && (!@dmsf_folder) if params[:ids][0] =~ /file-(\d+)/ @dmsf_file = DmsfFile.find_by(id: $1) elsif params[:ids][0] =~ /(file|url)-link-(\d+)/ @@ -93,7 +93,7 @@ class DmsfContextMenusController < ApplicationController end def find_dmsf_folder - if (params[:ids].size == 1) && (!@dmsf_file) + if (params[:ids].present? && (params[:ids].size == 1)) && (!@dmsf_file) if params[:ids][0] =~ /folder-(\d+)/ @dmsf_folder = DmsfFolder.find_by(id: $1) elsif params[:ids][0] =~ /folder-link-(\d+)/ diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 4cf21d6a..df67ed79 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -67,8 +67,6 @@ class DmsfController < ApplicationController httponly: true } cookies[:dmsf_switch_rlf] = cookie_options - - Rails.logger.info ">>> RLF set: #{cookies[:dmsf_switch_rlf]}" redirect_to dmsf_folder_path(id: @project, folder_id: @folder) end @@ -77,13 +75,14 @@ class DmsfController < ApplicationController if @rlf @system_folder = @folder && @folder.system @locked_for_user = @folder && @folder.locked_for_user? - #@folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project) + @folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project) @file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project) #@file_delete_allowed = User.current.allowed_to?(:file_delete, @project) #@file_view_allowed = User.current.allowed_to?(:view_dmsf_files, @project) #@force_file_unlock_allowed = User.current.allowed_to?(:force_file_unlock, @project) #@workflows_available = DmsfWorkflow.where(['project_id = ? OR project_id IS NULL', @project.id]).exists? #@file_approval_allowed = User.current.allowed_to?(:file_approval, @project) + @trash_enabled = @folder_manipulation_allowed && @file_manipulation_allowed use_session = !request.format.csv? @query = retrieve_query(DmsfQuery, use_session) @query.dmsf_folder_id = @folder ? @folder.id : nil @@ -131,6 +130,23 @@ class DmsfController < ApplicationController end def trash + @rlf = cookies[:dmsf_switch_rlf] == 'true' + if @rlf + @folder_manipulation_allowed = User.current.allowed_to? :folder_manipulation, @project + @file_manipulation_allowed = User.current.allowed_to? :file_manipulation, @project + @file_delete_allowed = User.current.allowed_to? :file_delete, @project + @query = retrieve_query(DmsfQuery, true) + @query.deleted = true + respond_to do |format| + format.html { + @dmsf_count = @query.dmsf_count + @dmsf_pages = Paginator.new @dmsf_count, per_page_option, params['page'] + @dmsf_nodes = @query.dmsf_nodes(offset: @dmsf_pages.offset, limit: @dmsf_pages.per_page) + render layout: !request.xhr? + } + end + return + end @folder_manipulation_allowed = User.current.allowed_to? :folder_manipulation, @project @file_manipulation_allowed = User.current.allowed_to? :file_manipulation, @project @file_delete_allowed = User.current.allowed_to? :file_delete, @project diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index 335ac516..92783b46 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -40,6 +40,10 @@ class DmsfUploadController < ApplicationController true end + def multi_upload + @rlf = cookies[:dmsf_switch_rlf] == 'true' + end + def upload_files uploaded_files = params[:dmsf_attachments] @uploads = [] diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index e82a9ed8..f028757f 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -580,8 +580,11 @@ class DmsfFolder < ActiveRecord::Base classes = ['dir'] if title =~ /^\./ classes << 'dmsf_system' - elsif ['DmsfFolderLink', 'DmsfFileLink'].include?(type) - classes << 'dmsf_gray' + else + classes << 'hascontextmenu' + if ['folder-link', 'file-link'].include?(type) + classes << 'dmsf_gray' + end end classes.join(' ') end diff --git a/app/models/dmsf_query.rb b/app/models/dmsf_query.rb index 904e327e..8739b062 100644 --- a/app/models/dmsf_query.rb +++ b/app/models/dmsf_query.rb @@ -168,7 +168,7 @@ class DmsfQuery < Query DmsfFileRevisionCustomField.visible.order(:position).pluck(:id, :name).each do |id, name| cf_columns << ",(SELECT value from custom_values WHERE custom_field_id = #{id} AND customized_type = 'DmsfFolder' AND customized_id = dmsf_folders.id) AS `#{name}`" end - DmsfFolder. + scope = DmsfFolder. select(%{ dmsf_folders.id AS id, dmsf_folders.project_id AS project_id, @@ -185,10 +185,14 @@ class DmsfQuery < Query users.firstname AS firstname, users.lastname AS lastname, users.id AS author, - 'DmsfFolder' AS type, + 'folder' AS type, 0 AS sort #{cf_columns}}). - joins('LEFT JOIN users ON dmsf_folders.user_id = users.id'). - where(dmsf_folders: { project_id: project.id, dmsf_folder_id: dmsf_folder_id, deleted: deleted }) + joins('LEFT JOIN users ON dmsf_folders.user_id = users.id') + if deleted + scope.where(dmsf_folders: { project_id: project.id, deleted: deleted }) + else + scope.where(dmsf_folders: { project_id: project.id, dmsf_folder_id: dmsf_folder_id, deleted: deleted }) + end end def dmsf_folder_links_scope @@ -196,7 +200,7 @@ class DmsfQuery < Query DmsfFileRevisionCustomField.visible.order(:position).pluck(:id, :name).each do |id, name| cf_columns << ",(SELECT value from custom_values WHERE custom_field_id = #{id} AND customized_type = 'DmsfFolder' AND customized_id = dmsf_folders.id) AS `#{name}`" end - DmsfLink. + scope = DmsfLink. select(%{ dmsf_folders.id AS id, COALESCE(dmsf_folders.project_id, dmsf_links.project_id) AS project_id, @@ -213,12 +217,16 @@ class DmsfQuery < Query users.firstname AS firstname, users.lastname AS lastname, users.id AS author, - 'DmsfFolderLink' AS type, + 'folder-link' AS type, 0 AS sort #{cf_columns}}). joins('LEFT JOIN dmsf_folders ON dmsf_links.target_id = dmsf_folders.id'). - joins('LEFT JOIN users ON users.id = COALESCE(dmsf_folders.user_id, dmsf_links.user_id)'). - where(dmsf_links: { target_type: 'DmsfFolder', project_id: project.id, dmsf_folder_id: dmsf_folder_id, - deleted: deleted }) + joins('LEFT JOIN users ON users.id = COALESCE(dmsf_folders.user_id, dmsf_links.user_id)') + if deleted + scope.where(dmsf_links: { target_type: 'DmsfFolder', project_id: project.id, deleted: deleted }) + else + scope.where(dmsf_links: { target_type: 'DmsfFolder', project_id: project.id, dmsf_folder_id: dmsf_folder_id, + deleted: deleted }) + end end def dmsf_files_scope @@ -226,7 +234,7 @@ class DmsfQuery < Query DmsfFileRevisionCustomField.visible.order(:position).pluck(:id, :name).each do |id, name| cf_columns << ",(SELECT value from custom_values WHERE custom_field_id = #{id} AND customized_type = 'DmsfFolder' AND customized_id = dmsf_files.id) AS `#{name}`" end - DmsfFile. + scope = DmsfFile. select(%{ dmsf_files.id AS id, dmsf_files.project_id AS project_id, @@ -243,12 +251,16 @@ class DmsfQuery < Query users.firstname AS firstname, users.lastname AS lastname, users.id AS author, - 'DmsfFile' AS type, + 'file' AS type, 1 AS sort #{cf_columns}}). joins(:dmsf_file_revisions). joins('LEFT JOIN users ON dmsf_file_revisions.user_id = users.id '). - where('dmsf_file_revisions.created_at = (SELECT MAX(r.created_at) FROM dmsf_file_revisions r WHERE r.dmsf_file_id = dmsf_file_revisions.dmsf_file_id)'). - where(dmsf_files: { project_id: project.id, dmsf_folder_id: dmsf_folder_id, deleted: deleted }) + where('dmsf_file_revisions.created_at = (SELECT MAX(r.created_at) FROM dmsf_file_revisions r WHERE r.dmsf_file_id = dmsf_file_revisions.dmsf_file_id)') + if deleted + scope.where(dmsf_files: { project_id: project.id, deleted: deleted }) + else + scope.where(dmsf_files: { project_id: project.id, dmsf_folder_id: dmsf_folder_id, deleted: deleted }) + end end def dmsf_file_links_scope @@ -256,7 +268,7 @@ class DmsfQuery < Query DmsfFileRevisionCustomField.visible.order(:position).pluck(:id, :name).each do |id, name| cf_columns << ",(SELECT value from custom_values WHERE custom_field_id = #{id} AND customized_type = 'DmsfFolder' AND customized_id = dmsf_files.id) AS `#{name}`" end - DmsfLink. + scope = DmsfLink. select(%{ dmsf_files.id AS id, dmsf_files.project_id AS project_id, @@ -273,13 +285,17 @@ class DmsfQuery < Query users.firstname AS firstname, users.lastname AS lastname, users.id AS author, - 'DmsfFileLink' AS type, + 'file-link' AS type, 1 AS sort #{cf_columns}}). joins('JOIN dmsf_files ON dmsf_files.id = dmsf_links.target_id'). joins('JOIN dmsf_file_revisions ON dmsf_file_revisions.dmsf_file_id = dmsf_files.id'). joins('LEFT JOIN users ON dmsf_file_revisions.user_id = users.id '). - where('dmsf_file_revisions.created_at = (SELECT MAX(r.created_at) FROM dmsf_file_revisions r WHERE r.dmsf_file_id = dmsf_file_revisions.dmsf_file_id)'). - where(dmsf_files: { project_id: project.id, dmsf_folder_id: dmsf_folder_id, deleted: deleted }) + where('dmsf_file_revisions.created_at = (SELECT MAX(r.created_at) FROM dmsf_file_revisions r WHERE r.dmsf_file_id = dmsf_file_revisions.dmsf_file_id)') + if deleted + scope.where(dmsf_files: { project_id: project.id, deleted: deleted }) + else + scope.where(dmsf_files: { project_id: project.id, dmsf_folder_id: dmsf_folder_id, deleted: deleted }) + end end def dmsf_url_links_scope @@ -287,7 +303,7 @@ class DmsfQuery < Query DmsfFileRevisionCustomField.visible.order(:position).pluck(:name).each do |name| cf_columns << ",NULL AS `#{name}`" end - DmsfLink. + scope = DmsfLink. select(%{ dmsf_links.id AS id, dmsf_links.project_id AS project_id, @@ -304,10 +320,14 @@ class DmsfQuery < Query users.firstname AS firstname, users.lastname AS lastname, users.id AS author, - 'DmsfUrlLink' AS type, + 'url-link' AS type, 1 AS sort #{cf_columns}}). - joins('LEFT JOIN users ON dmsf_links.user_id = users.id '). - where(target_type: 'DmsfUrl', project_id: project.id, dmsf_folder_id: dmsf_folder_id, deleted: deleted) + joins('LEFT JOIN users ON dmsf_links.user_id = users.id ') + if deleted + scope.where(target_type: 'DmsfUrl', project_id: project.id, deleted: deleted) + else + scope.where(target_type: 'DmsfUrl', project_id: project.id, dmsf_folder_id: dmsf_folder_id, deleted: deleted) + end end end diff --git a/app/views/dmsf/_query_list.html.erb b/app/views/dmsf/_query_list.html.erb index 4a4cef55..3c856a09 100644 --- a/app/views/dmsf/_query_list.html.erb +++ b/app/views/dmsf/_query_list.html.erb @@ -23,8 +23,8 @@ <% query_options = nil unless defined?(query_options) %> <% query_options ||= {} %> -<%= form_tag({}, data: { cm_url: dmsf_context_menu_path }) do %> - <%= hidden_field_tag 'back_url', url_for( params: request.query_parameters), id: nil %> +<%= form_tag({}, data: { cm_url: query.deleted ? dmsf_trash_context_menu_path : dmsf_context_menu_path }) do %> + <%= hidden_field_tag 'back_url', url_for(params: request.query_parameters), id: nil %> <%= query_columns_hidden_tags(query) %>
@@ -43,16 +43,17 @@ <% level = 0 %> <% query.dmsf_nodes.each do |node| %> - "> + <% system = node.title =~ /^\./ %> + "> <% query.inline_columns.each do |column| %> <%= content_tag('td', column_content(column, node), class: column.css_classes) %> <% end %> - + <% end %> diff --git a/app/views/dmsf/show.html.erb b/app/views/dmsf/show.html.erb index 5cbc477f..36c117b1 100644 --- a/app/views/dmsf/show.html.erb +++ b/app/views/dmsf/show.html.erb @@ -24,9 +24,13 @@ <% html_title l(:dmsf) %>
- <%= link_to(l(:button_switch), switch_rlf_dmsf_path(id: @project, rlf: @rlf), + <%= link_to(l(:button_switch), switch_rlf_dmsf_path(id: @project, rlf: @rlf), title: l(:label_switch_rlf), class: 'icon icon-plugins') %> + <% if @rlf && @file_manipulation_allowed && !@locked_for_user && !@system_folder %> + <%= link_to l(:label_attachment_new), multi_dmsf_upload_path(id: @project, dmsf_folder_id: @folder), + class: 'icon icon-add' %> + <% end %> <%= actions_dropdown do %> <% if @folder_manipulation_allowed && !@system_folder %> <% if @folder.nil? %> @@ -236,7 +240,7 @@ <%= context_menu %> -<% if @file_manipulation_allowed && !@locked_for_user && !@system_folder %> +<% if !@rlf && @file_manipulation_allowed && !@locked_for_user && !@system_folder %> <%= render(:partial => 'dmsf_upload/multi_upload', locals: { rlf: @rlf }) %> <% end %> diff --git a/app/views/dmsf/trash.html.erb b/app/views/dmsf/trash.html.erb index 46b28d98..97174ea8 100644 --- a/app/views/dmsf/trash.html.erb +++ b/app/views/dmsf/trash.html.erb @@ -26,213 +26,221 @@
- <%= textilizable(@folder ? @folder.description : @project.dmsf_description) %> + <%= textilizable(@project.dmsf_description) %>
-
-<%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post, - :class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_trash_context_menu_path}) do %> - <%= hidden_field_tag('action') %> -
- <% if @file_manipulation_allowed && @folder_manipulation_allowed %> - <%= 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', - :class => 'toggle-selection', :data => { :confirm => l(:text_are_you_sure) } %> +<% if @query %> + <%= form_tag(trash_dmsf_path(id: @project), method: :get, id: 'query_form') do %> + <%= render partial: 'queries/query_form' %> + <% end %> + <%= render partial: 'query_list', locals: { query: @query } %> + <%= pagination_links_full @dmsf_pages, @dmsf_count %> +<% else %> +
+ <%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post, + :class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_trash_context_menu_path}) do %> + <%= hidden_field_tag('action') %> +
+ <% if @file_manipulation_allowed && @folder_manipulation_allowed %> + <%= 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', + :class => 'toggle-selection', :data => { :confirm => l(:text_are_you_sure) } %> + <% end %> <% end %> - <% end %> -
-
- <% unless node.title =~ /^\./ %> - <%= check_box_tag('ids[]', node.id, false, id: nil) %> - <% end %> + <%= check_box_tag('ids[]', "#{node.type}-#{node.id}", false, id: nil) unless system %> <%= link_to_context_menu %> + <%= link_to_context_menu unless system %> +
- - - - <% if DmsfFolder.is_column_on?('id') %> - - <% end %> - <% if DmsfFolder.is_column_on?('title') %> - - <% end %> - <% if DmsfFolder.is_column_on?('extension') %> - - <% end %> - <% if DmsfFolder.is_column_on?('size') %> - - <% end %> - <% if DmsfFolder.is_column_on?('modified') %> - - <% end %> - <% if DmsfFolder.is_column_on?('version') %> - - <% end %> - <% if DmsfFolder.is_column_on?('workflow') %> - - <% end %> - <% if DmsfFolder.is_column_on?('author') %> - - <% end %> - <% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> - <% if DmsfFolder.is_column_on?(c.name) %> - - <% end %> - <% end %> - - - - - - + +
- <%= check_box_tag 'check_all', '', false, :class => 'toggle-selection', - :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> - #<%= l(:link_title) %><%= l(:link_extension) %><%= l(:link_size) %><%= l(:link_modified) %><%= l(:link_ver) %><%= l(:link_workflow) %><%= l(:link_author) %><%= h(c.name) %><%# controls %><%# position %><%# size calculated %><%# modified calculated %><%# version calculated %><%# clear title %>
+ + + + <% if DmsfFolder.is_column_on?('id') %> + + <% end %> + <% if DmsfFolder.is_column_on?('title') %> + + <% end %> + <% if DmsfFolder.is_column_on?('extension') %> + + <% end %> + <% if DmsfFolder.is_column_on?('size') %> + + <% end %> + <% if DmsfFolder.is_column_on?('modified') %> + + <% end %> + <% if DmsfFolder.is_column_on?('version') %> + + <% end %> + <% if DmsfFolder.is_column_on?('workflow') %> + + <% end %> + <% if DmsfFolder.is_column_on?('author') %> + + <% end %> + <% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %> + <% if DmsfFolder.is_column_on?(c.name) %> + + <% end %> + <% end %> + + + + + + + + + + <% classes = 'dir hascontextmenu' %> + <% @subfolders.each do |subfolder| %> + + <%= render(:partial => 'dir_trash', + :locals => { + :project => @project, + :subfolder => subfolder, + :link => nil, + :id => subfolder.id, + :name => 'folder', + :title => subfolder.title }) %> - - - <% classes = 'dir hascontextmenu' %> - <% @subfolders.each do |subfolder| %> - - <%= render(:partial => 'dir_trash', - :locals => { - :project => @project, - :subfolder => subfolder, - :link => nil, - :id => subfolder.id, - :name => 'folder', - :title => subfolder.title }) %> - - <% end %> - <% classes = 'dmsf_gray hascontextmenu' %> - <% @dir_links.each do |link| %> - - <%= render(:partial => 'dir_trash', - :locals => { - :project => link.target_project, - :subfolder => link.target_folder, - :link => link, - :id => link.id, - :name => 'folder-link', - :title => link.name }) %> - - <% end %> - <% classes = 'file hascontextmenu' %> - <% @files.each do |file| %> - <% unless file.last_revision %> - <% Rails.logger.error "Error: dmsf_file id #{file.id} has no revision!" %> - <% next %> <% end %> - - <%= render(:partial => 'file_trash', :locals => { - :project => @project, - :file => file, - :link => nil, - :id => file.id, - :name => 'file', - :title => file.title }) %> - - <% end %> - <% classes = 'dmsf_gray hascontextmenu' %> - <% @file_links.each do |link| %> - <% unless link.target_file %> - <% Rails.logger.error "Error: dmsf_link id #{link.id} has no target file!" %> + <% classes = 'dmsf_gray hascontextmenu' %> + <% @dir_links.each do |link| %> + + <%= render(:partial => 'dir_trash', + :locals => { + :project => link.target_project, + :subfolder => link.target_folder, + :link => link, + :id => link.id, + :name => 'folder-link', + :title => link.name }) %> + + <% end %> + <% classes = 'file hascontextmenu' %> + <% @files.each do |file| %> + <% unless file.last_revision %> + <% Rails.logger.error "Error: dmsf_file id #{file.id} has no revision!" %> <% next %> - <% end %> - <% unless link.target_file.last_revision %> - <% Rails.logger.error "Error: dmsf_file id #{link.target_id} has no revision!" %> - <% next %> - <% end %> - - <%= render(:partial => 'file_trash', :locals => { - :project => link.target_project, - :file => link.target_file, - :link => link, - :id => link.id, - :name => 'file-link', - :title => link.name }) %> - - <% end %> - <% @url_links.each do |link| %> - - <%= render(:partial => 'url_trash', :locals => { - :project => link.target_project, - :file => link.target_file, - :link => link, - :id => link.id, - :name => 'url-link', - :title => link.name }) %> + <% end %> + + <%= render(:partial => 'file_trash', :locals => { + :project => @project, + :file => file, + :link => nil, + :id => file.id, + :name => 'file', + :title => file.title }) %> + <% end %> + <% classes = 'dmsf_gray hascontextmenu' %> + <% @file_links.each do |link| %> + <% unless link.target_file %> + <% Rails.logger.error "Error: dmsf_link id #{link.id} has no target file!" %> + <% next %> + <% end %> + <% unless link.target_file.last_revision %> + <% Rails.logger.error "Error: dmsf_file id #{link.target_id} has no revision!" %> + <% next %> + <% end %> + + <%= render(:partial => 'file_trash', :locals => { + :project => link.target_project, + :file => link.target_file, + :link => link, + :id => link.id, + :name => 'file-link', + :title => link.name }) %> + + <% end %> + <% @url_links.each do |link| %> + + <%= render(:partial => 'url_trash', :locals => { + :project => link.target_project, + :file => link.target_file, + :link => link, + :id => link.id, + :name => 'url-link', + :title => link.name }) %> + + <% end %> + +
+ <%= check_box_tag 'check_all', '', false, :class => 'toggle-selection', + :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %> + #<%= l(:link_title) %><%= l(:link_extension) %><%= l(:link_size) %><%= l(:link_modified) %><%= l(:link_ver) %><%= l(:link_workflow) %><%= l(:link_author) %><%= h(c.name) %><%# controls %><%# position %><%# size calculated %><%# modified calculated %><%# version calculated %><%# clear title %>
+ <% end %> + + <% content_for :header_tags do %> + <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', :plugin => :redmine_dmsf %> + <%= javascript_include_tag 'jquery.dataTables/datatables.min.js', :plugin => :redmine_dmsf, defer: true %> + + <% title = DmsfFolder.get_column_position('title') %> + <% position = DmsfFolder.get_column_position('position') %> + <% commands = DmsfFolder.get_column_position('commands') %> + <% position = DmsfFolder.get_column_position('position') %> + <% version = DmsfFolder.get_column_position('version') %> + <% size_calculated = DmsfFolder.get_column_position('size_calculated') %> + <% modified_calculated = DmsfFolder.get_column_position('modified_calculated') %> + <% version_calculated = DmsfFolder.get_column_position('version_calculated') %> + <% size = DmsfFolder.get_column_position('size') %> + <% modified = DmsfFolder.get_column_position('modified') %> + <% clear_title = DmsfFolder.get_column_position('clear_title') %> + + <%= late_javascript_tag do %> + $('#browser').dataTable({ + orderClasses: false, + responsive: { + details: false + }, + language: { + url: "<%= plugin_asset_path(:redmine_dmsf, 'javascripts', json_url) %>" + }, + oLanguage: { + sSearch: "<%= l(:description_filter) %>:" + }, + autoWidth: false, + paginate: false, + <% if title %> + order: [[<%= title %>, "asc"]], + <% end %> + sortingFixed: [[ <%= position %>, "asc"]], + columnDefs: [ + { responsivePriority: 1, targets: <%= title %> }, + { responsivePriority: 2, targets: <%= commands %> }, + { searchable: false, targets: [0, <%= commands %>, <%= position %>, <%= size_calculated %>, <%= modified_calculated %>, <%= version_calculated %>, <%= clear_title %>] }, + { sortable: false, targets: [0, <%= commands %>] } + <% if title %> + ,{ iDataSort: <%= clear_title %>, targets: [ <%= title %> ] } + <% end %> + <% if size %> + ,{ iDataSort: <%= size_calculated %>, targets: [ <%= size %> ] } + <% end %> + <% if modified %> + ,{ iDataSort: <%= modified_calculated %>, targets: [ <%= modified %> ] } + <% end %> + <% if version %> + ,{ iDataSort: <%= version_calculated %>, targets: [ <%= version %> ] } + <% end %> + ], + "fnInitComplete": function() { + $("#dmsf_buttons").insertBefore($("#browser_filter")); + $("#dmsf_ajax_loading").hide(); + $("#browser").show(); + $("#dmsf_buttons").show(); + }, + "fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) { + return "<%= l(:label_number_of_folders)%>: <%= @subfolders.count + @dir_links.count %>, <%= l(:label_number_of_documents)%>: <%= @files.count + @file_links.count + @url_links.count %>"; + } + }); + + $("#entries_form").submit(function () { + $(this).removeAttr("data-submitted"); + }); + <% end %> <% end %> - - <% end %> <%= context_menu %> - -<% content_for :header_tags do %> - <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', :plugin => :redmine_dmsf %> - <%= javascript_include_tag 'jquery.dataTables/datatables.min.js', :plugin => :redmine_dmsf, defer: true %> - - <% title = DmsfFolder.get_column_position('title') %> - <% position = DmsfFolder.get_column_position('position') %> - <% commands = DmsfFolder.get_column_position('commands') %> - <% position = DmsfFolder.get_column_position('position') %> - <% version = DmsfFolder.get_column_position('version') %> - <% size_calculated = DmsfFolder.get_column_position('size_calculated') %> - <% modified_calculated = DmsfFolder.get_column_position('modified_calculated') %> - <% version_calculated = DmsfFolder.get_column_position('version_calculated') %> - <% size = DmsfFolder.get_column_position('size') %> - <% modified = DmsfFolder.get_column_position('modified') %> - <% clear_title = DmsfFolder.get_column_position('clear_title') %> - - <%= late_javascript_tag do %> - $('#browser').dataTable({ - orderClasses: false, - responsive: { - details: false - }, - language: { - url: "<%= plugin_asset_path(:redmine_dmsf, 'javascripts', json_url) %>" - }, - oLanguage: { - sSearch: "<%= l(:description_filter) %>:" - }, - autoWidth: false, - paginate: false, - <% if title %> - order: [[<%= title %>, "asc"]], - <% end %> - sortingFixed: [[ <%= position %>, "asc"]], - columnDefs: [ - { responsivePriority: 1, targets: <%= title %> }, - { responsivePriority: 2, targets: <%= commands %> }, - { searchable: false, targets: [0, <%= commands %>, <%= position %>, <%= size_calculated %>, <%= modified_calculated %>, <%= version_calculated %>, <%= clear_title %>] }, - { sortable: false, targets: [0, <%= commands %>] } - <% if title %> - ,{ iDataSort: <%= clear_title %>, targets: [ <%= title %> ] } - <% end %> - <% if size %> - ,{ iDataSort: <%= size_calculated %>, targets: [ <%= size %> ] } - <% end %> - <% if modified %> - ,{ iDataSort: <%= modified_calculated %>, targets: [ <%= modified %> ] } - <% end %> - <% if version %> - ,{ iDataSort: <%= version_calculated %>, targets: [ <%= version %> ] } - <% end %> - ], - "fnInitComplete": function() { - $("#dmsf_buttons").insertBefore($("#browser_filter")); - $("#dmsf_ajax_loading").hide(); - $("#browser").show(); - $("#dmsf_buttons").show(); - }, - "fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) { - return "<%= l(:label_number_of_folders)%>: <%= @subfolders.count + @dir_links.count %>, <%= l(:label_number_of_documents)%>: <%= @files.count + @file_links.count + @url_links.count %>"; - } - }); - - $("#entries_form").submit(function () { - $(this).removeAttr("data-submitted"); - }); - <% end %> -<% end %> diff --git a/app/views/dmsf_upload/_multi_upload.html.erb b/app/views/dmsf_upload/_multi_upload.html.erb index b5b2f584..8822180f 100644 --- a/app/views/dmsf_upload/_multi_upload.html.erb +++ b/app/views/dmsf_upload/_multi_upload.html.erb @@ -36,9 +36,7 @@
<% end %> -<% unless rlf %> -

<%= l(:label_upload) %>

-<% end %> +

<%= l(:button_add) %>

<%= form_tag({ controller: 'dmsf_upload', action: 'upload_files', id: @project, folder_id: @folder }, diff --git a/app/views/dmsf_upload/multi_upload.html.erb b/app/views/dmsf_upload/multi_upload.html.erb new file mode 100644 index 00000000..dc1e7ae0 --- /dev/null +++ b/app/views/dmsf_upload/multi_upload.html.erb @@ -0,0 +1,34 @@ +<% +# encoding: utf-8 +# +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-20 Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +%> + +<%= render(partial: '/dmsf/path', + locals: { folder: @folder, filename: nil, title: l(:label_attachment_new) }) %> +<%= form_tag({ controller: 'dmsf_upload', action: 'upload_files', id: @project, folder_id: @folder }, + id: 'uploadform', method: :post, multipart: true) do %> +
+ + <%= render partial: 'dmsf_upload/form', + locals: { multiple: true, container: nil, description: true, awf: false } %> + + <%= submit_tag l(:label_upload) %> +
+<% end %> diff --git a/config/routes.rb b/config/routes.rb index aa8a4a5a..d18d7b09 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,6 +70,7 @@ if Redmine::Plugin.installed? :redmine_dmsf # /projects//dmsf/upload - dmsf_upload controller ## + get '/projects/:id/dmsf/upload/multi_upload', controller: 'dmsf_upload', action: 'multi_upload', as: 'multi_dmsf_upload' post '/projects/:id/dmsf/upload/files', :controller => 'dmsf_upload', :action => 'upload_files' post '/projects/:id/dmsf/upload/file', :controller => 'dmsf_upload', :action => 'upload_file' post '/projects/:id/dmsf/upload', :controller => 'dmsf_upload', :action => 'upload' diff --git a/lib/redmine_dmsf/patches/queries_helper_patch.rb b/lib/redmine_dmsf/patches/queries_helper_patch.rb index a80726cc..07109153 100644 --- a/lib/redmine_dmsf/patches/queries_helper_patch.rb +++ b/lib/redmine_dmsf/patches/queries_helper_patch.rb @@ -35,9 +35,9 @@ module RedmineDmsf case column.name when :id case item.type - when 'DmsfFile', 'DmsfFileLink' + when 'file', 'file-link' link_to h(value), dmsf_file_path(id: item.id) - when 'DmsfFolder', 'DmsfFolderLink' + when 'folder', 'folder-link' if(item.id) link_to h(value), edit_dmsf_path(id: item.project_id, folder_id: item.id) else @@ -50,13 +50,13 @@ module RedmineDmsf link_to "#{item.firstname} #{item.lastname}", user_path(id: value) when :title case item.type - when 'DmsfFolder', 'DmsfFolderLink' + when 'folder', 'folder-link' link_to(h(value), dmsf_folder_path(id: item.project_id, folder_id: item.id), class: 'icon icon-folder', title: h(value)) + content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download)) - when 'DmsfFile', 'DmsfFileLink' + when 'file', 'file-link' file_view_url = url_for({ controller: :dmsf_files, action: 'view', id: item.id }) content_type = Redmine::MimeType.of(value) content_type = 'application/octet-stream' if content_type.blank? @@ -67,7 +67,7 @@ module RedmineDmsf title: h(value), 'data-downloadurl': "#{content_type}:#{h(value)}:#{file_view_url}") + content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download)) - when 'DmsfUrlLink' + when 'url-link' link_to(h(value), item.filename, target: '_blank', class: 'icon icon-link') + content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download)) else