#823 context menu
This commit is contained in:
parent
7f728e7d14
commit
b2ade58d73
@ -4,9 +4,11 @@ Changelog for Redmine DMSF
|
|||||||
1.6.1 *2018-??-??*
|
1.6.1 *2018-??-??*
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Javascript on pages is loaded asynchronously.
|
Javascript on pages is loaded asynchronously
|
||||||
Obsolete Dav4Rack gem replaced with an up to date fork by Planio (Consequently WebDAV caching has been removed, sorry...).
|
Obsolete Dav4Rack gem replaced with an up to date fork by Planio (Consequently WebDAV caching has been removed, sorry...)
|
||||||
Project members can be chosen as recipients when sending documents by email.
|
Project members can be chosen as recipients when sending documents by email
|
||||||
|
Responsive view
|
||||||
|
Direct editing of document in MS Office
|
||||||
|
|
||||||
1.6.0 *2017-09-12*
|
1.6.0 *2017-09-12*
|
||||||
------------------
|
------------------
|
||||||
|
|||||||
@ -49,8 +49,9 @@ def init
|
|||||||
:dmsf_files_copy => [:new, :copy, :move],
|
:dmsf_files_copy => [:new, :copy, :move],
|
||||||
:dmsf_context_menus => [:dmsf]}
|
:dmsf_context_menus => [:dmsf]}
|
||||||
pmap.permission :file_delete,
|
pmap.permission :file_delete,
|
||||||
{ :dmsf => [:trash, :delete_entries],
|
{:dmsf => [:trash, :delete_entries],
|
||||||
:dmsf_files => [:delete]}
|
:dmsf_files => [:delete],
|
||||||
|
:dmsf_trash_context_menus => [:trash]}
|
||||||
pmap.permission :force_file_unlock, {}
|
pmap.permission :force_file_unlock, {}
|
||||||
pmap.permission :file_approval,
|
pmap.permission :file_approval,
|
||||||
{:dmsf_workflows => [:action, :new_action, :autocomplete_for_user, :start, :assign, :assignment]}
|
{:dmsf_workflows => [:action, :new_action, :autocomplete_for_user, :start, :assign, :assignment]}
|
||||||
|
|||||||
@ -22,19 +22,45 @@ class DmsfContextMenusController < ApplicationController
|
|||||||
|
|
||||||
helper :context_menus
|
helper :context_menus
|
||||||
|
|
||||||
|
before_action :find_project
|
||||||
|
before_action :find_folder
|
||||||
|
before_action :find_file, :except => [:trash]
|
||||||
|
|
||||||
def dmsf
|
def dmsf
|
||||||
selected_files = params[:ids].select{ |x| x =~ /file-\d+/ }.map{ |x| $1.to_i if x =~ /file-(\d+)/ }
|
@disabled = params[:ids].blank?
|
||||||
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) && (params[:ids].size == 1)
|
|
||||||
@file = DmsfFile.find selected_files[0]
|
|
||||||
end
|
|
||||||
render :layout => false
|
render :layout => false
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def trash
|
||||||
|
render :layout => false
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_folder
|
||||||
|
@folder = DmsfFolder.find params[:folder_id] if params[:folder_id].present?
|
||||||
|
rescue DmsfAccessError
|
||||||
|
render_403
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_file
|
||||||
|
if params[:ids].present?
|
||||||
|
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) && (params[:ids].size == 1)
|
||||||
|
@file = DmsfFile.find selected_files[0]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -100,11 +100,19 @@ class DmsfController < ApplicationController
|
|||||||
|
|
||||||
def entries_operation
|
def entries_operation
|
||||||
# Download/Email
|
# Download/Email
|
||||||
selected_folders = params[:ids].select{ |x| x =~ /folder-\d+/ }.map{ |x| $1.to_i if x =~ /folder-(\d+)/ }
|
if params[:ids].present?
|
||||||
selected_files = params[:ids].select{ |x| x =~ /file-\d+/ }.map{ |x| $1.to_i if x =~ /file-(\d+)/ }
|
selected_folders = params[:ids].select{ |x| x =~ /folder-\d+/ }.map{ |x| $1.to_i if x =~ /folder-(\d+)/ }
|
||||||
selected_dir_links = params[:ids].select{ |x| x =~ /folder-link-\d+/ }.map{ |x| $1.to_i if x =~ /folder-link-(\d+)/ }
|
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_dir_links = params[:ids].select{ |x| x =~ /folder-link-\d+/ }.map{ |x| $1.to_i if x =~ /folder-link-(\d+)/ }
|
||||||
selected_url_links = params[:ids].select{ |x| x =~ /url-link-\d+/ }.map{ |x| $1.to_i if x =~ /url-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+)/ }
|
||||||
|
else
|
||||||
|
selected_folders = []
|
||||||
|
selected_files = []
|
||||||
|
selected_dir_links = []
|
||||||
|
selected_file_links = []
|
||||||
|
selected_url_links = []
|
||||||
|
end
|
||||||
|
|
||||||
if selected_folders.blank? && selected_files.blank? &&
|
if selected_folders.blank? && selected_files.blank? &&
|
||||||
selected_dir_links.blank? && selected_file_links.blank? &&
|
selected_dir_links.blank? && selected_file_links.blank? &&
|
||||||
@ -143,6 +151,7 @@ class DmsfController < ApplicationController
|
|||||||
redirect_to :back
|
redirect_to :back
|
||||||
else
|
else
|
||||||
download_entries(selected_folders, selected_files)
|
download_entries(selected_folders, selected_files)
|
||||||
|
redirect_to :back
|
||||||
end
|
end
|
||||||
rescue FileNotFound
|
rescue FileNotFound
|
||||||
render_404
|
render_404
|
||||||
@ -359,47 +368,45 @@ class DmsfController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def email_entries(selected_folders, selected_files)
|
def email_entries(selected_folders, selected_files)
|
||||||
begin
|
zip = DmsfZip.new
|
||||||
zip = DmsfZip.new
|
zip_entries(zip, selected_folders, selected_files)
|
||||||
zip_entries(zip, selected_folders, selected_files)
|
|
||||||
|
|
||||||
zipped_content = DmsfHelper.temp_dir.join(DmsfHelper.temp_filename('dmsf_email_sent_documents.zip'))
|
zipped_content = DmsfHelper.temp_dir.join(DmsfHelper.temp_filename('dmsf_email_sent_documents.zip'))
|
||||||
|
|
||||||
File.open(zipped_content, 'wb') do |f|
|
File.open(zipped_content, 'wb') do |f|
|
||||||
zip_file = File.open(zip.finish, 'rb')
|
zip_file = File.open(zip.finish, 'rb')
|
||||||
while (buffer = zip_file.read(8192))
|
while (buffer = zip_file.read(8192))
|
||||||
f.write(buffer)
|
f.write(buffer)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
max_filesize = Setting.plugin_redmine_dmsf['dmsf_max_email_filesize'].to_f
|
|
||||||
if max_filesize > 0 && File.size(zipped_content) > max_filesize * 1048576
|
|
||||||
raise EmailMaxFileSize
|
|
||||||
end
|
|
||||||
|
|
||||||
zip.files.each do |f|
|
|
||||||
audit = DmsfFileRevisionAccess.new
|
|
||||||
audit.user = User.current
|
|
||||||
audit.dmsf_file_revision = f.last_revision
|
|
||||||
audit.action = DmsfFileRevisionAccess::EmailAction
|
|
||||||
audit.save!
|
|
||||||
end
|
|
||||||
|
|
||||||
@email_params = {
|
|
||||||
:zipped_content => zipped_content,
|
|
||||||
:folders => selected_folders,
|
|
||||||
:files => selected_files,
|
|
||||||
:subject => "#{@project.name} #{l(:label_dmsf_file_plural).downcase}",
|
|
||||||
:from => Setting.plugin_redmine_dmsf['dmsf_documents_email_from'].blank? ?
|
|
||||||
"#{User.current.name} <#{User.current.mail}>" : Setting.plugin_redmine_dmsf['dmsf_documents_email_from'],
|
|
||||||
:reply_to => Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to']
|
|
||||||
}
|
|
||||||
render :action => 'email_entries'
|
|
||||||
rescue Exception
|
|
||||||
raise
|
|
||||||
ensure
|
|
||||||
zip.close if zip
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
max_filesize = Setting.plugin_redmine_dmsf['dmsf_max_email_filesize'].to_f
|
||||||
|
if max_filesize > 0 && File.size(zipped_content) > max_filesize * 1048576
|
||||||
|
raise EmailMaxFileSize
|
||||||
|
end
|
||||||
|
|
||||||
|
zip.files.each do |f|
|
||||||
|
audit = DmsfFileRevisionAccess.new
|
||||||
|
audit.user = User.current
|
||||||
|
audit.dmsf_file_revision = f.last_revision
|
||||||
|
audit.action = DmsfFileRevisionAccess::EmailAction
|
||||||
|
audit.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
@email_params = {
|
||||||
|
:zipped_content => zipped_content,
|
||||||
|
:folders => selected_folders,
|
||||||
|
:files => selected_files,
|
||||||
|
:subject => "#{@project.name} #{l(:label_dmsf_file_plural).downcase}",
|
||||||
|
:from => Setting.plugin_redmine_dmsf['dmsf_documents_email_from'].blank? ?
|
||||||
|
"#{User.current.name} <#{User.current.mail}>" : Setting.plugin_redmine_dmsf['dmsf_documents_email_from'],
|
||||||
|
:reply_to => Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to']
|
||||||
|
}
|
||||||
|
render :action => 'email_entries'
|
||||||
|
rescue Exception
|
||||||
|
raise
|
||||||
|
ensure
|
||||||
|
zip.close if zip
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_entries(selected_folders, selected_files)
|
def download_entries(selected_folders, selected_files)
|
||||||
|
|||||||
@ -36,12 +36,16 @@ class DmsfFileRevision < ActiveRecord::Base
|
|||||||
|
|
||||||
PROTOCOLS = {
|
PROTOCOLS = {
|
||||||
'application/msword' => 'ms-word',
|
'application/msword' => 'ms-word',
|
||||||
|
'application/excel' => 'ms-excel',
|
||||||
'application/vnd.ms-excel' => 'ms-excel',
|
'application/vnd.ms-excel' => 'ms-excel',
|
||||||
'application/vnd.ms-powerpoint' => 'ms-powerpoint',
|
'application/vnd.ms-powerpoint' => 'ms-powerpoint',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'ms-word',
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'ms-word',
|
||||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'ms-excel',
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'ms-excel',
|
||||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'ms-powerpoint',
|
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'ms-powerpoint',
|
||||||
'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'ms-powerpoint'
|
'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'ms-powerpoint',
|
||||||
|
'application/vnd.oasis.opendocument.spreadsheet' => 'ms-excel',
|
||||||
|
'application/vnd.oasis.opendocument.text' => 'ms-word',
|
||||||
|
'application/vnd.oasis.opendocument.presentation' => 'ms-powerpoint',
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
scope :visible, -> { where(:deleted => STATUS_ACTIVE) }
|
scope :visible, -> { where(:deleted => STATUS_ACTIVE) }
|
||||||
|
|||||||
@ -24,7 +24,9 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="dmsf_checkbox dmsf_th">
|
<th class="dmsf_checkbox dmsf_th">
|
||||||
<input id="check_all_entries" title="<%= l(:title_check_uncheck_all_for_zip_download_or_email) %>" type="checkbox" />
|
<% if !@system_folder %>
|
||||||
|
<input id="check_all_entries" title="<%= l(:title_check_uncheck_all_for_zip_download_or_email) %>" type="checkbox" />
|
||||||
|
<% end %>
|
||||||
</th>
|
</th>
|
||||||
<% if DmsfFolder.is_column_on?('id') %>
|
<% if DmsfFolder.is_column_on?('id') %>
|
||||||
<th class="dmsf_th">#</th>
|
<th class="dmsf_th">#</th>
|
||||||
|
|||||||
@ -24,8 +24,10 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="dmsf_checkbox dmsf_th">
|
<th class="dmsf_checkbox dmsf_th">
|
||||||
<%= check_box_tag 'check_all', '', false, :class => 'toggle-selection',
|
<% if !@system_folder %>
|
||||||
|
<%= check_box_tag 'check_all', '', false, :class => 'toggle-selection',
|
||||||
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
|
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
|
||||||
|
<% end %>
|
||||||
</th>
|
</th>
|
||||||
<% if DmsfFolder.is_column_on?('id') %>
|
<% if DmsfFolder.is_column_on?('id') %>
|
||||||
<th class="dmsf_th">#</th>
|
<th class="dmsf_th">#</th>
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<td class="dmsf_checkbox"></td>
|
<td class="dmsf_checkbox"><%= check_box_tag('ids[]', "#{name}-#{id}", false) %></td>
|
||||||
<% if DmsfFolder.is_column_on?('id') %>
|
<% if DmsfFolder.is_column_on?('id') %>
|
||||||
<td class="id"></td>
|
<td class="id"></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -86,16 +86,18 @@
|
|||||||
<%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post,
|
<%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post,
|
||||||
:class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_context_menu_path}) do %>
|
:class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_context_menu_path}) do %>
|
||||||
<%= hidden_field_tag('action') %>
|
<%= hidden_field_tag('action') %>
|
||||||
<div id="dmsf_buttons" class="dmsf_controls" style="float: left">
|
<% if !@system_folder %>
|
||||||
<%= submit_tag(l(:button_download), :title => l(:title_download_checked), :name => 'download_entries',
|
<div id="dmsf_buttons" class="dmsf_controls" style="float: left">
|
||||||
:class => 'toggle-selection') if @file_view_allowed %>
|
<%= submit_tag(l(:button_download), :title => l(:title_download_checked), :name => 'download_entries',
|
||||||
<%= submit_tag(l(:field_mail), :title => l(:title_send_checked_by_email), :name => 'email_entries',
|
:class => 'toggle-selection') if @file_view_allowed %>
|
||||||
:class => 'toggle-selection') if (@file_view_allowed && User.current.allowed_to?(:email_documents, @project)) %>
|
<%= submit_tag(l(:field_mail), :title => l(:title_send_checked_by_email), :name => 'email_entries',
|
||||||
<% if @file_delete_allowed %>
|
:class => 'toggle-selection') if (@file_view_allowed && User.current.allowed_to?(:email_documents, @project)) %>
|
||||||
<%= submit_tag(l(:button_delete), :title => l(:title_delete_checked), :name => 'delete_entries',
|
<% if @file_delete_allowed %>
|
||||||
:class => 'toggle-selection') if @file_delete_allowed %>
|
<%= submit_tag(l(:button_delete), :title => l(:title_delete_checked), :name => 'delete_entries',
|
||||||
<% end %>
|
:class => 'toggle-selection') if @file_delete_allowed %>
|
||||||
</div>
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<% unless @system_folder %>
|
<% unless @system_folder %>
|
||||||
<% values = @folder ? @folder.custom_field_values : DmsfFolder.new.custom_field_values %>
|
<% values = @folder ? @folder.custom_field_values : DmsfFolder.new.custom_field_values %>
|
||||||
<% unless values.empty? %>
|
<% unless values.empty? %>
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
<%= error_messages_for('dmsf_workflow') %>
|
<%= error_messages_for('dmsf_workflow') %>
|
||||||
|
|
||||||
<%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post,
|
<%= form_tag(entries_operations_dmsf_path(:id => @project, :folder_id => @folder), :method => :post,
|
||||||
:class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_context_menu_path}) do %>
|
:class => 'dmsf_entries', :id => 'entries_form', :data => {:cm_url => dmsf_trash_context_menu_path}) do %>
|
||||||
<%= hidden_field_tag('action') %>
|
<%= hidden_field_tag('action') %>
|
||||||
<div class="dmsf_controls" style="float: left">
|
<div class="dmsf_controls" style="float: left">
|
||||||
<% if @file_manipulation_allowed && @folder_manipulation_allowed %>
|
<% if @file_manipulation_allowed && @folder_manipulation_allowed %>
|
||||||
@ -99,7 +99,7 @@
|
|||||||
:subfolder => subfolder,
|
:subfolder => subfolder,
|
||||||
:link => nil,
|
:link => nil,
|
||||||
:id => subfolder.id,
|
:id => subfolder.id,
|
||||||
:name => 'subfolders[]',
|
:name => 'folder',
|
||||||
:title => subfolder.title }) %>
|
:title => subfolder.title }) %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -112,7 +112,7 @@
|
|||||||
:subfolder => link.target_folder,
|
:subfolder => link.target_folder,
|
||||||
:link => link,
|
:link => link,
|
||||||
:id => link.id,
|
:id => link.id,
|
||||||
:name => 'dir_links[]',
|
:name => 'folder-link',
|
||||||
:title => link.name }) %>
|
:title => link.name }) %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -128,7 +128,7 @@
|
|||||||
:file => file,
|
:file => file,
|
||||||
:link => nil,
|
:link => nil,
|
||||||
:id => file.id,
|
:id => file.id,
|
||||||
:name => 'files[]',
|
:name => 'file',
|
||||||
:title => file.title }) %>
|
:title => file.title }) %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -148,7 +148,7 @@
|
|||||||
:file => link.target_file,
|
:file => link.target_file,
|
||||||
:link => link,
|
:link => link,
|
||||||
:id => link.id,
|
:id => link.id,
|
||||||
:name => 'file_links[]',
|
:name => 'file-link',
|
||||||
:title => link.name }) %>
|
:title => link.name }) %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -21,8 +21,24 @@
|
|||||||
%>
|
%>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>
|
||||||
|
<%= context_menu_link l(:button_download), entries_operations_dmsf_path(:id => @project, :folder_id => @folder,
|
||||||
|
:ids => params[:ids], :download_entries => true), :method => :post, :class => 'icon-download',
|
||||||
|
:disabled => @disabled %>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<%= context_menu_link l(:field_mail), entries_operations_dmsf_path(:id => @project, :folder_id => @folder,
|
||||||
|
:ids => params[:ids], :email_entries => true), :method => :post, :class => 'icon-email',
|
||||||
|
:disabled => @disabled %>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<%= context_menu_link l(:button_delete), entries_operations_dmsf_path(:id => @project, :folder_id => @folder,
|
||||||
|
:ids => params[:ids], :destroy_entries => true), :method => :post, :class => 'icon-del',
|
||||||
|
:disabled => @disabled %>
|
||||||
|
</li>
|
||||||
|
<% if @file %>
|
||||||
<li>
|
<li>
|
||||||
<% if @file && @file.last_revision && @file.last_revision.protocol %>
|
<% if @file.last_revision && @file.last_revision.protocol %>
|
||||||
<% url = "#{@file.last_revision.protocol}:ofe|u|#{Setting.protocol.strip}://#{Setting.host_name.strip}/dmsf/webdav/#{Addressable::URI.escape(@file.project.identifier)}/" %>
|
<% url = "#{@file.last_revision.protocol}:ofe|u|#{Setting.protocol.strip}://#{Setting.host_name.strip}/dmsf/webdav/#{Addressable::URI.escape(@file.project.identifier)}/" %>
|
||||||
<% if @file.dmsf_folder %>
|
<% if @file.dmsf_folder %>
|
||||||
<% url << @file.dmsf_folder.dmsf_path_str %>
|
<% url << @file.dmsf_folder.dmsf_path_str %>
|
||||||
@ -31,4 +47,5 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<%= context_menu_link l(:button_edit), url, :class => 'icon-edit', :disabled => url.blank? %>
|
<%= context_menu_link l(:button_edit), url, :class => 'icon-edit', :disabled => url.blank? %>
|
||||||
</li>
|
</li>
|
||||||
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
32
app/views/dmsf_context_menus/trash.html.erb
Normal file
32
app/views/dmsf_context_menus/trash.html.erb
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<%
|
||||||
|
# encoding: utf-8
|
||||||
|
#
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright © 2011-18 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.
|
||||||
|
%>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<%= context_menu_link l(:button_delete), entries_operations_dmsf_path(:id => @project, :folder_id => @folder,
|
||||||
|
:ids => params[:ids], :destroy_entries => true), :method => :post, :class => 'icon-del' %>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<%= context_menu_link l(:title_restore), entries_operations_dmsf_path(:id => @project, :folder_id => @folder,
|
||||||
|
:ids => params[:ids], :restore_entries => true), :method => :post, :class => 'icon-cancel' %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
@ -55,6 +55,7 @@ if Redmine::Plugin.installed? :redmine_dmsf
|
|||||||
|
|
||||||
# dmsf_context_menu_controller
|
# dmsf_context_menu_controller
|
||||||
match '/projects/:id/dmsf/context_menu', :to => 'dmsf_context_menus#dmsf', :as => 'dmsf_context_menu', :via => [:get, :post]
|
match '/projects/:id/dmsf/context_menu', :to => 'dmsf_context_menus#dmsf', :as => 'dmsf_context_menu', :via => [:get, :post]
|
||||||
|
match '/projects/:id/dmsf/trash/context_menu', :to => 'dmsf_context_menus#trash', :as => 'dmsf_trash_context_menu', :via => [:get, :post]
|
||||||
|
|
||||||
#
|
#
|
||||||
# dmsf_state controller
|
# dmsf_state controller
|
||||||
|
|||||||
72
test/functional/dmsf_context_menus_controller_test.rb
Normal file
72
test/functional/dmsf_context_menus_controller_test.rb
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
#
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright © 2011-18 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.
|
||||||
|
|
||||||
|
require File.expand_path('../../test_helper', __FILE__)
|
||||||
|
|
||||||
|
class DmsfContextMenusControllerTest < RedmineDmsf::Test::TestCase
|
||||||
|
include Redmine::I18n
|
||||||
|
|
||||||
|
fixtures :users, :email_addresses, :projects, :members, :roles, :member_roles, :dmsf_folders,
|
||||||
|
:dmsf_files, :dmsf_file_revisions
|
||||||
|
|
||||||
|
def setup
|
||||||
|
@user_member = User.find_by_id 2 # John Smith - manager
|
||||||
|
@project1 = Project.find_by_id 1
|
||||||
|
assert_not_nil @project1
|
||||||
|
@project1.enable_module! :dmsf
|
||||||
|
@file1 = DmsfFile.find_by_id 1
|
||||||
|
@folder1 = DmsfFolder.find_by_id 1
|
||||||
|
User.current = nil
|
||||||
|
@request.session[:user_id] = @user_member.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_truth
|
||||||
|
assert_kind_of User, @user_member
|
||||||
|
assert_kind_of Project, @project1
|
||||||
|
assert_kind_of DmsfFile, @file1
|
||||||
|
assert_kind_of DmsfFolder, @folder1
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_dmsf
|
||||||
|
get :dmsf, :id => @project1.id, :ids => ["file-#{@file1.id}"]
|
||||||
|
assert_response :success
|
||||||
|
assert_select 'a.icon-edit', :text => l(:button_edit)
|
||||||
|
assert_select 'a.icon-del', :text => l(:button_delete)
|
||||||
|
assert_select 'a.icon-download', :text => l(:button_download)
|
||||||
|
assert_select 'a.icon-email', :text => l(:field_mail)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_dmsf_no_edit
|
||||||
|
get :dmsf, :id => @project1.id, :ids => ["folder-#{@folder1.id}"]
|
||||||
|
assert_response :success
|
||||||
|
assert_select 'a.icon-edit', :text => l(:button_edit), :count => 0
|
||||||
|
assert_select 'a.icon-del', :text => l(:button_delete)
|
||||||
|
assert_select 'a.icon-download', :text => l(:button_download)
|
||||||
|
assert_select 'a.icon-email', :text => l(:field_mail)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_trash
|
||||||
|
get :trash, :id => @project1.id, :ids => ["file-#{@file1.id}"]
|
||||||
|
assert_response :success
|
||||||
|
assert_select 'a.icon-cancel', :text => l(:title_restore)
|
||||||
|
assert_select 'a.icon-del', :text => l(:button_delete)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@ -140,8 +140,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
def test_delete_restore_entries_forbidden
|
def test_delete_restore_entries_forbidden
|
||||||
# Missing permissions
|
# Missing permissions
|
||||||
get :entries_operation, :id => @project, :delete_entries => 'Delete',
|
get :entries_operation, :id => @project, :delete_entries => 'Delete',
|
||||||
:subfolders => [@folder1.id.to_s], :files => [@file1.id.to_s],
|
:ids => ["folder-#{@folder1.id}", "file-#{@file1.id}", "folder-link-#{@folder_link1.id}", "file-link-#{@file_link2.id}"]
|
||||||
:dir_links => [@folder_link1.id.to_s], :file_links => [@file_link2.id.to_s]
|
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -150,8 +149,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
@request.env['HTTP_REFERER'] = dmsf_folder_path(:id => @project.id)
|
@request.env['HTTP_REFERER'] = dmsf_folder_path(:id => @project.id)
|
||||||
@role.add_permission! :view_dmsf_files
|
@role.add_permission! :view_dmsf_files
|
||||||
get :entries_operation, :id => @project, :delete_entries => 'Delete',
|
get :entries_operation, :id => @project, :delete_entries => 'Delete',
|
||||||
:subfolders => [@folder1.id.to_s], :files => [@file1.id.to_s],
|
:ids => ["folder-#{@folder1.id}", "file-#{@file1.id}", "folder-link-#{@folder_link1.id}", "file-link-#{@file_link2.id}"]
|
||||||
:dir_links => [@folder_link1.id.to_s], :file_links => [@file_link2.id.to_s]
|
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_equal flash[:error].to_s, l(:error_folder_is_not_empty)
|
assert_equal flash[:error].to_s, l(:error_folder_is_not_empty)
|
||||||
end
|
end
|
||||||
@ -162,8 +160,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
@role.add_permission! :view_dmsf_files
|
@role.add_permission! :view_dmsf_files
|
||||||
flash[:error] = nil
|
flash[:error] = nil
|
||||||
get :entries_operation, :id => @project, :delete_entries => 'Delete',
|
get :entries_operation, :id => @project, :delete_entries => 'Delete',
|
||||||
:subfolders => [], :files => [@file1.id.to_s],
|
:ids => ["file-#{@file1.id}", "file-link-#{@file_link2.id}"]
|
||||||
:dir_links => [], :file_links => [@file_link2.id.to_s]
|
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_nil flash[:error]
|
assert_nil flash[:error]
|
||||||
end
|
end
|
||||||
@ -173,8 +170,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
@role.add_permission! :view_dmsf_files
|
@role.add_permission! :view_dmsf_files
|
||||||
@request.env['HTTP_REFERER'] = trash_dmsf_path(:id => @project.id)
|
@request.env['HTTP_REFERER'] = trash_dmsf_path(:id => @project.id)
|
||||||
get :entries_operation, :id => @project, :restore_entries => 'Restore',
|
get :entries_operation, :id => @project, :restore_entries => 'Restore',
|
||||||
:subfolders => [], :files => [@file1.id.to_s],
|
:ids => ["file-#{@file1.id}", "file-link-#{@file_link2.id}"]
|
||||||
:dir_links => [], :file_links => [@file_link2.id.to_s]
|
|
||||||
assert_response :redirect
|
assert_response :redirect
|
||||||
assert_nil flash[:error]
|
assert_nil flash[:error]
|
||||||
end
|
end
|
||||||
@ -229,7 +225,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
Setting.plugin_redmine_dmsf['dmsf_documents_email_from'] = 'karel.picman@kontron.com'
|
Setting.plugin_redmine_dmsf['dmsf_documents_email_from'] = 'karel.picman@kontron.com'
|
||||||
Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path '../../fixtures/files', __FILE__
|
Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path '../../fixtures/files', __FILE__
|
||||||
@role.add_permission! :view_dmsf_files
|
@role.add_permission! :view_dmsf_files
|
||||||
get :entries_operation, :id => @project, :email_entries => 'Email', :files => [@file1.id]
|
get :entries_operation, :id => @project, :email_entries => 'Email', :ids => ["file-#{@file1.id}"]
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "input:match('value', ?)", Setting.plugin_redmine_dmsf['dmsf_documents_email_from']
|
assert_select "input:match('value', ?)", Setting.plugin_redmine_dmsf['dmsf_documents_email_from']
|
||||||
end
|
end
|
||||||
@ -238,7 +234,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to'] = 'karel.picman@kontron.com'
|
Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to'] = 'karel.picman@kontron.com'
|
||||||
Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path '../../fixtures/files', __FILE__
|
Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path '../../fixtures/files', __FILE__
|
||||||
@role.add_permission! :view_dmsf_files
|
@role.add_permission! :view_dmsf_files
|
||||||
get :entries_operation, :id => @project, :email_entries => 'Email', :files => [@file1.id]
|
get :entries_operation, :id => @project, :email_entries => 'Email', :ids => ["file-#{@file1.id}"]
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "input:match('value', ?)", Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to']
|
assert_select "input:match('value', ?)", Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to']
|
||||||
end
|
end
|
||||||
@ -247,7 +243,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
|||||||
Setting.plugin_redmine_dmsf['dmsf_documents_email_links_only'] = '1'
|
Setting.plugin_redmine_dmsf['dmsf_documents_email_links_only'] = '1'
|
||||||
Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path '../../fixtures/files', __FILE__
|
Setting.plugin_redmine_dmsf['dmsf_storage_directory'] = File.expand_path '../../fixtures/files', __FILE__
|
||||||
@role.add_permission! :view_dmsf_files
|
@role.add_permission! :view_dmsf_files
|
||||||
get :entries_operation, :id => @project, :email_entries => 'Email', :files => [@file1.id]
|
get :entries_operation, :id => @project, :email_entries => 'Email', :ids => ["file-#{@file1.id}"]
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "input:match('value', ?)", Setting.plugin_redmine_dmsf['dmsf_documents_email_links_only']
|
assert_select "input:match('value', ?)", Setting.plugin_redmine_dmsf['dmsf_documents_email_links_only']
|
||||||
end
|
end
|
||||||
|
|||||||
@ -41,19 +41,19 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
|||||||
assert_kind_of DmsfFileRevision, @revision8
|
assert_kind_of DmsfFileRevision, @revision8
|
||||||
assert_kind_of DmsfWorkflow, @wf1
|
assert_kind_of DmsfWorkflow, @wf1
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_delete_restore
|
def test_delete_restore
|
||||||
@revision5.delete false
|
@revision5.delete false
|
||||||
assert @revision5.deleted?,
|
assert @revision5.deleted?,
|
||||||
"File revision #{@revision5.name} hasn't been deleted"
|
"File revision #{@revision5.name} hasn't been deleted"
|
||||||
@revision5.restore
|
@revision5.restore
|
||||||
assert !@revision5.deleted?,
|
assert !@revision5.deleted?,
|
||||||
"File revision #{@revision5.name} hasn't been restored"
|
"File revision #{@revision5.name} hasn't been restored"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy
|
def test_destroy
|
||||||
@revision5.delete true
|
@revision5.delete true
|
||||||
assert_nil DmsfFileRevision.find_by_id @revision5.id
|
assert_nil DmsfFileRevision.find_by_id @revision5.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_digest
|
def test_create_digest
|
||||||
@ -69,7 +69,7 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
|||||||
@revision1.create_digest
|
@revision1.create_digest
|
||||||
assert_equal 'SHA256', @revision1.digest_type
|
assert_equal 'SHA256', @revision1.digest_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_storage_filename
|
def test_new_storage_filename
|
||||||
# Create a file.
|
# Create a file.
|
||||||
f = DmsfFile.new
|
f = DmsfFile.new
|
||||||
@ -78,7 +78,7 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
|||||||
f.dmsf_folder = nil
|
f.dmsf_folder = nil
|
||||||
f.notification = !Setting.plugin_redmine_dmsf['dmsf_default_notifications'].blank?
|
f.notification = !Setting.plugin_redmine_dmsf['dmsf_default_notifications'].blank?
|
||||||
f.save
|
f.save
|
||||||
|
|
||||||
# Create two new revisions, r1 and r2
|
# Create two new revisions, r1 and r2
|
||||||
r1 = DmsfFileRevision.new
|
r1 = DmsfFileRevision.new
|
||||||
r1.minor_version = 0
|
r1.minor_version = 0
|
||||||
@ -91,13 +91,13 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
|||||||
r1.comment = nil
|
r1.comment = nil
|
||||||
r1.mime_type = nil
|
r1.mime_type = nil
|
||||||
r1.size = 4
|
r1.size = 4
|
||||||
|
|
||||||
r2 = r1.clone
|
r2 = r1.clone
|
||||||
r2.minor_version = 1
|
r2.minor_version = 1
|
||||||
|
|
||||||
assert r1.valid?
|
assert r1.valid?
|
||||||
assert r2.valid?
|
assert r2.valid?
|
||||||
|
|
||||||
# This is a very stupid since the generation and storing of files below must be done during the
|
# This is a very stupid since the generation and storing of files below must be done during the
|
||||||
# same second, so wait until the microsecond part of the DateTime is less than 10 ms, should be
|
# same second, so wait until the microsecond part of the DateTime is less than 10 ms, should be
|
||||||
# plenty of time to do the rest then.
|
# plenty of time to do the rest then.
|
||||||
@ -109,7 +109,7 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
|||||||
end
|
end
|
||||||
sleep 0.01
|
sleep 0.01
|
||||||
end
|
end
|
||||||
|
|
||||||
# First, generate the r1 storage filename and save the file
|
# First, generate the r1 storage filename and save the file
|
||||||
r1.disk_filename = r1.new_storage_filename
|
r1.disk_filename = r1.new_storage_filename
|
||||||
assert r1.save
|
assert r1.save
|
||||||
@ -117,12 +117,12 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
|||||||
File.open(r1.disk_file, 'wb') do |f|
|
File.open(r1.disk_file, 'wb') do |f|
|
||||||
f.write('1234')
|
f.write('1234')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Directly after the file has been stored generate the r2 storage filename.
|
# Directly after the file has been stored generate the r2 storage filename.
|
||||||
# Hopefully the seconds part of the DateTime.now has not changed and the generated filename will
|
# Hopefully the seconds part of the DateTime.now has not changed and the generated filename will
|
||||||
# be on the same second but it should then be increased by 1.
|
# be on the same second but it should then be increased by 1.
|
||||||
r2.disk_filename = r2.new_storage_filename
|
r2.disk_filename = r2.new_storage_filename
|
||||||
|
|
||||||
assert_not_equal r1.disk_filename, r2.disk_filename, "The disk filename should not be equal for two revisions."
|
assert_not_equal r1.disk_filename, r2.disk_filename, "The disk filename should not be equal for two revisions."
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -182,11 +182,45 @@ class DmsfFileRevisionTest < RedmineDmsf::Test::UnitTest
|
|||||||
assert_equal -(' '.ord), @revision1.minor_version
|
assert_equal -(' '.ord), @revision1.minor_version
|
||||||
end
|
end
|
||||||
|
|
||||||
def description_max_length
|
def test_description_max_length
|
||||||
@revision1.description = 2.megabytes * 'a'
|
@revision1.description = 'a' * 2.megabytes
|
||||||
assert !@revision1.save
|
assert !@revision1.save
|
||||||
@revision1.description = 1.megabyte * 'a'
|
@revision1.description = 'a' * 1.megabyte
|
||||||
assert @revision1.save
|
assert @revision1.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_protocol_txt
|
||||||
|
assert !@revision1.protocol
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_protocol_doc
|
||||||
|
@revision1.mime_type = Redmine::MimeType.of('test.doc')
|
||||||
|
assert_equal 'ms-word', @revision1.protocol
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_protocol_docx
|
||||||
|
@revision1.mime_type = Redmine::MimeType.of('test.docx')
|
||||||
|
assert_equal 'ms-word', @revision1.protocol
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_protocol_odt
|
||||||
|
@revision1.mime_type = Redmine::MimeType.of('test.odt')
|
||||||
|
assert_equal 'ms-word', @revision1.protocol
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_protocol_xls
|
||||||
|
@revision1.mime_type = Redmine::MimeType.of('test.xls')
|
||||||
|
assert_equal 'ms-excel', @revision1.protocol
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_protocol_xlsx
|
||||||
|
@revision1.mime_type = Redmine::MimeType.of('test.xlsx')
|
||||||
|
assert_equal 'ms-excel', @revision1.protocol
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_protocol_ods
|
||||||
|
@revision1.mime_type = Redmine::MimeType.of('test.ods')
|
||||||
|
assert_equal 'ms-excel', @revision1.protocol
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user