#1080 Trash bin
This commit is contained in:
parent
e8560ebfca
commit
7469988dbe
@ -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],
|
||||
|
||||
@ -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+)/
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 = []
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) %>
|
||||
<div class="autoscroll">
|
||||
<table class="list dmsf odd-even <%= query.css_classes %>">
|
||||
@ -43,16 +43,17 @@
|
||||
<tbody>
|
||||
<% level = 0 %>
|
||||
<% query.dmsf_nodes.each do |node| %>
|
||||
<tr id="node-<%= node.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= node.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
|
||||
<% system = node.title =~ /^\./ %>
|
||||
<tr id="node-<%= node.id %>" class="<%= cycle('odd', 'even') %> <%= node.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
|
||||
<td class="checkbox hide-when-print">
|
||||
<% 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 %>
|
||||
</td>
|
||||
<% query.inline_columns.each do |column| %>
|
||||
<%= content_tag('td', column_content(column, node), class: column.css_classes) %>
|
||||
<% end %>
|
||||
<td class="buttons"><%= link_to_context_menu %></td>
|
||||
<td class="buttons">
|
||||
<%= link_to_context_menu unless system %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@ -24,9 +24,13 @@
|
||||
|
||||
<% html_title l(:dmsf) %>
|
||||
<div class="contextual">
|
||||
<%= 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 %>
|
||||
|
||||
|
||||
@ -26,213 +26,221 @@
|
||||
|
||||
<div class="dmsf-header">
|
||||
<div class="wiki">
|
||||
<%= textilizable(@folder ? @folder.description : @project.dmsf_description) %>
|
||||
<%= textilizable(@project.dmsf_description) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="dmsf_ajax_loading" class="ajax-loading"></div>
|
||||
<%= 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') %>
|
||||
<div id="dmsf_buttons" class="dmsf_controls">
|
||||
<% 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 } %>
|
||||
<span class="pagination"><%= pagination_links_full @dmsf_pages, @dmsf_count %></span>
|
||||
<% else %>
|
||||
<div id="dmsf_ajax_loading" class="ajax-loading"></div>
|
||||
<%= 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') %>
|
||||
<div id="dmsf_buttons" class="dmsf_controls">
|
||||
<% 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 %>
|
||||
</div>
|
||||
<table class="display list dmsf_list" id="browser">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="dmsf_checkbox dmsf_th">
|
||||
<%= 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>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('title') %>
|
||||
<th class="dmsf_th"><%= l(:link_title) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('extension') %>
|
||||
<th class="dmsf_th"><%= l(:link_extension) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('size') %>
|
||||
<th class="dmsf_th"><%= l(:link_size) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('modified') %>
|
||||
<th class="dmsf_th"><%= l(:link_modified) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('version') %>
|
||||
<th title="<%= l(:label_dmsf_version) %>" class="dmsf_th"><%= l(:link_ver) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('workflow') %>
|
||||
<th class="dmsf_th"><%= l(:link_workflow) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<th class="dmsf_th"><%= l(:link_author) %></th>
|
||||
<% end %>
|
||||
<% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<th class="dmsf_th"><%= h(c.name) %></th>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<th class ="dmsf_th"><%# controls %></th>
|
||||
<th class="none"><%# position %></th>
|
||||
<th class="none"><%# size calculated %></th>
|
||||
<th class="none"><%# modified calculated %></th>
|
||||
<th class="none"><%# version calculated %></th>
|
||||
<th class="none"><%# clear title %></th>
|
||||
</div>
|
||||
<table class="display list dmsf_list" id="browser">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="dmsf_checkbox dmsf_th">
|
||||
<%= 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>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('title') %>
|
||||
<th class="dmsf_th"><%= l(:link_title) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('extension') %>
|
||||
<th class="dmsf_th"><%= l(:link_extension) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('size') %>
|
||||
<th class="dmsf_th"><%= l(:link_size) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('modified') %>
|
||||
<th class="dmsf_th"><%= l(:link_modified) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('version') %>
|
||||
<th title="<%= l(:label_dmsf_version) %>" class="dmsf_th"><%= l(:link_ver) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('workflow') %>
|
||||
<th class="dmsf_th"><%= l(:link_workflow) %></th>
|
||||
<% end %>
|
||||
<% if DmsfFolder.is_column_on?('author') %>
|
||||
<th class="dmsf_th"><%= l(:link_author) %></th>
|
||||
<% end %>
|
||||
<% DmsfFileRevisionCustomField.visible.order(:position).each do |c| %>
|
||||
<% if DmsfFolder.is_column_on?(c.name) %>
|
||||
<th class="dmsf_th"><%= h(c.name) %></th>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<th class ="dmsf_th"><%# controls %></th>
|
||||
<th class="none"><%# position %></th>
|
||||
<th class="none"><%# size calculated %></th>
|
||||
<th class="none"><%# modified calculated %></th>
|
||||
<th class="none"><%# version calculated %></th>
|
||||
<th class="none"><%# clear title %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% classes = 'dir hascontextmenu' %>
|
||||
<% @subfolders.each do |subfolder| %>
|
||||
<tr class="<%= classes %>">
|
||||
<%= render(:partial => 'dir_trash',
|
||||
:locals => {
|
||||
:project => @project,
|
||||
:subfolder => subfolder,
|
||||
:link => nil,
|
||||
:id => subfolder.id,
|
||||
:name => 'folder',
|
||||
:title => subfolder.title }) %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% classes = 'dir hascontextmenu' %>
|
||||
<% @subfolders.each do |subfolder| %>
|
||||
<tr class="<%= classes %>">
|
||||
<%= render(:partial => 'dir_trash',
|
||||
:locals => {
|
||||
:project => @project,
|
||||
:subfolder => subfolder,
|
||||
:link => nil,
|
||||
:id => subfolder.id,
|
||||
:name => 'folder',
|
||||
:title => subfolder.title }) %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% classes = 'dmsf_gray hascontextmenu' %>
|
||||
<% @dir_links.each do |link| %>
|
||||
<tr class="<%= classes %>">
|
||||
<%= render(:partial => 'dir_trash',
|
||||
:locals => {
|
||||
:project => link.target_project,
|
||||
:subfolder => link.target_folder,
|
||||
:link => link,
|
||||
:id => link.id,
|
||||
:name => 'folder-link',
|
||||
:title => link.name }) %>
|
||||
</tr>
|
||||
<% 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 %>
|
||||
<tr class="<%= classes %>">
|
||||
<%= render(:partial => 'file_trash', :locals => {
|
||||
:project => @project,
|
||||
:file => file,
|
||||
:link => nil,
|
||||
:id => file.id,
|
||||
:name => 'file',
|
||||
:title => file.title }) %>
|
||||
</tr>
|
||||
<% 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| %>
|
||||
<tr class="<%= classes %>">
|
||||
<%= render(:partial => 'dir_trash',
|
||||
:locals => {
|
||||
:project => link.target_project,
|
||||
:subfolder => link.target_folder,
|
||||
:link => link,
|
||||
:id => link.id,
|
||||
:name => 'folder-link',
|
||||
:title => link.name }) %>
|
||||
</tr>
|
||||
<% 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 %>
|
||||
<tr class="<%= classes %>">
|
||||
<%= render(:partial => 'file_trash', :locals => {
|
||||
:project => link.target_project,
|
||||
:file => link.target_file,
|
||||
:link => link,
|
||||
:id => link.id,
|
||||
:name => 'file-link',
|
||||
:title => link.name }) %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% @url_links.each do |link| %>
|
||||
<tr class="<%= classes %>">
|
||||
<%= 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 %>
|
||||
<tr class="<%= classes %>">
|
||||
<%= render(:partial => 'file_trash', :locals => {
|
||||
:project => @project,
|
||||
:file => file,
|
||||
:link => nil,
|
||||
:id => file.id,
|
||||
:name => 'file',
|
||||
:title => file.title }) %>
|
||||
</tr>
|
||||
<% 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 %>
|
||||
<tr class="<%= classes %>">
|
||||
<%= render(:partial => 'file_trash', :locals => {
|
||||
:project => link.target_project,
|
||||
:file => link.target_file,
|
||||
:link => link,
|
||||
:id => link.id,
|
||||
:name => 'file-link',
|
||||
:title => link.name }) %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% @url_links.each do |link| %>
|
||||
<tr class="<%= classes %>">
|
||||
<%= render(:partial => 'url_trash', :locals => {
|
||||
:project => link.target_project,
|
||||
:file => link.target_file,
|
||||
:link => link,
|
||||
:id => link.id,
|
||||
:name => 'url-link',
|
||||
:title => link.name }) %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% 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 %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% 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 %>
|
||||
|
||||
@ -36,9 +36,7 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% unless rlf %>
|
||||
<h3><%= l(:label_upload) %></h3>
|
||||
<% end %>
|
||||
<h3><%= l(:button_add) %></h3>
|
||||
|
||||
</div>
|
||||
<%= form_tag({ controller: 'dmsf_upload', action: 'upload_files', id: @project, folder_id: @folder },
|
||||
|
||||
34
app/views/dmsf_upload/multi_upload.html.erb
Normal file
34
app/views/dmsf_upload/multi_upload.html.erb
Normal file
@ -0,0 +1,34 @@
|
||||
<%
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright © 2011-20 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# 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 %>
|
||||
<div>
|
||||
<span class="dmsf_uploader">
|
||||
<%= render partial: 'dmsf_upload/form',
|
||||
locals: { multiple: true, container: nil, description: true, awf: false } %>
|
||||
</span>
|
||||
<%= submit_tag l(:label_upload) %>
|
||||
</div>
|
||||
<% end %>
|
||||
@ -70,6 +70,7 @@ if Redmine::Plugin.installed? :redmine_dmsf
|
||||
# /projects/<project>/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'
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user