From 134076aa0586d7e6795265c47ba2705af892c2c3 Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Thu, 2 Feb 2017 14:09:44 +0100 Subject: [PATCH] Documents export #641 --- app/controllers/dmsf_controller.rb | 10 ++- app/controllers/dmsf_files_controller.rb | 2 +- app/helpers/dmsf_helper.rb | 35 +++++++- app/models/dmsf_file.rb | 85 ++++++++++++++----- app/models/dmsf_folder.rb | 36 ++++++++ app/models/dmsf_link.rb | 36 +++++++- app/views/dmsf/_file.html.erb | 2 +- app/views/dmsf/show.html.erb | 19 +++++ app/views/dmsf/trash.html.erb | 4 + .../dmsf_files/_file_new_revision.html.erb | 2 +- app/views/dmsf_upload/_form.html.erb | 6 +- app/views/dmsf_upload/_multi_upload.html.erb | 2 +- app/views/settings/_dmsf_columns.html.erb | 36 ++++++++ app/views/settings/_dmsf_settings.html.erb | 14 +-- assets/javascripts/attachments_dmsf.js | 63 ++++++++++++-- config/locales/cs.yml | 5 +- config/locales/en.yml | 5 +- config/locales/es.yml | 5 +- config/locales/fr.yml | 5 +- config/locales/it.yml | 5 +- config/locales/ja.yml | 5 +- config/locales/pl.yml | 5 +- config/locales/pt-BR.yml | 5 +- config/locales/ru.yml | 5 +- config/locales/sl.yml | 5 +- config/locales/zh-TW.yml | 5 +- config/locales/zh.yml | 5 +- .../hooks/views/issue_view_hooks.rb | 3 +- test/functional/dmsf_controller_test.rb | 10 ++- test/unit/dmsf_file_test.rb | 6 ++ test/unit/dmsf_folder_test.rb | 8 +- test/unit/dmsf_link_test.rb | 9 ++ 32 files changed, 379 insertions(+), 69 deletions(-) create mode 100644 app/views/settings/_dmsf_columns.html.erb diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 259af311..a085f557 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -31,9 +31,10 @@ class DmsfController < ApplicationController accept_api_auth :show, :create, :save - skip_before_action :verify_authenticity_token, if: -> { request.headers["HTTP_X_REDMINE_API_KEY"].present? } + skip_before_action :verify_authenticity_token, if: -> { request.headers['HTTP_X_REDMINE_API_KEY'].present? } helper :all + #helper :dmsf def expand_folder @tree_view = true @@ -58,6 +59,10 @@ class DmsfController < ApplicationController render :layout => !request.xhr? } format.api + format.csv { + send_data(DmsfHelper.dmsf_to_csv(@folder ? @folder : @project, params[:settings][:dmsf_columns]), + :type => 'text/csv; header=present', :filename => 'dmsf.csv') + } end end @@ -594,6 +599,7 @@ class DmsfController < ApplicationController @file_approval_allowed = User.current.allowed_to?(:file_approval, @project) tag = params[:custom_field_id].present? && params[:custom_value].present? @folder = nil if tag + @extra_columns = [l(:label_document_url), l(:label_last_revision_id)] if @tree_view @locked_for_user = false else @@ -688,7 +694,7 @@ class DmsfController < ApplicationController @file_delete_allowed && !@locked_for_user && !@folder @trash_enabled = DmsfFolder.deleted.where(:project_id => @project.id).any? || DmsfFile.deleted.where(:container_id => @project.id, :container_type => 'Project').any? || - DmsfLink.deleted.where(:container_id => @project.id, :container_type => 'Project').any? + DmsfLink.deleted.where(:project_id => @project.id).any? end end diff --git a/app/controllers/dmsf_files_controller.rb b/app/controllers/dmsf_files_controller.rb index eb808007..58cf2d54 100644 --- a/app/controllers/dmsf_files_controller.rb +++ b/app/controllers/dmsf_files_controller.rb @@ -109,7 +109,7 @@ class DmsfFilesController < ApplicationController else revision.increase_version(version) end - file_upload = params[:attachments]['1'] if params[:attachments].present? + file_upload = params[:dmsf_attachments]['1'] if params[:dmsf_attachments].present? unless file_upload revision.size = last_revision.size revision.disk_filename = last_revision.disk_filename diff --git a/app/helpers/dmsf_helper.rb b/app/helpers/dmsf_helper.rb index 383eb82c..e63bca78 100644 --- a/app/helpers/dmsf_helper.rb +++ b/app/helpers/dmsf_helper.rb @@ -3,7 +3,7 @@ # Redmine plugin for Document Management System "Features" # # Copyright (C) 2011 Vít Jonáš -# Copyright (C) 2011-16 Karel Pičman +# Copyright (C) 2011-17 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 @@ -117,4 +117,37 @@ module DmsfHelper tree end + def self.dmsf_to_csv(parent, columns) + Redmine::Export::CSV.generate do |csv| + # Header + csv << columns.map { |c| c.capitalize } + # Lines + DmsfHelper.object_to_csv(csv, parent, columns) + end + end + + def self.object_to_csv(csv, parent, columns, level = -1) + # Folder + if level >= 0 + csv << parent.to_csv(columns, level + 1) + end + # Sub-folders + folders = parent.dmsf_folders.visible.to_a + folders.concat(parent.folder_links.visible.to_a.map{ |l| l.folder }) + folders.compact! + folders.sort!{ |x, y| x.title <=> y.title} + folders.each do |f| + DmsfHelper.object_to_csv(csv, f, columns, level + 1) + end + # Files + files = parent.dmsf_files.visible.to_a + files.concat(parent.file_links.visible.to_a.map{ |l| l.target_file }) + files.concat(parent.url_links.visible.to_a) + files.compact! + files.sort!{ |x, y| x.title <=> y.title} + files.each do |file_or_link| + csv << file_or_link.to_csv(columns, level + 1) + end + end + end diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index f57e02ac..ed74e477 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -523,29 +523,74 @@ class DmsfFile < ActiveRecord::Base end end + def extension + $1 if self.last_revision && self.last_revision.disk_filename =~ /\.(.+)$/ + end + include ActionView::Helpers::NumberHelper include Rails.application.routes.url_helpers - def to_csv - csv = "\"#{self.title}\"" - csv << ';' - csv << "\"#{number_to_human_size(self.last_revision.size)}\"" - csv << ';' - csv << "\"#{format_time(self.last_revision.updated_at)}\"" - csv << ';' - csv << "\"#{self.last_revision.version}\"" - csv << ';' - csv << "\"#{self.last_revision.workflow_str(false)}\"" - csv << ';' - csv << "\"#{self.last_revision.user}\"" - csv << ';' - csv << "\"#{self.id}\"" - csv << ';' - csv << "\"r#{self.last_revision.id}\"" - csv << ';' - default_url_options[:host] = Setting.host_name - csv << "\"#{url_for(:controller => :dmsf_files, :action => 'view', :id => self)}\"" - csv << ';' + def to_csv(columns, level) + csv = [] + # Id + csv << self.id if columns.include?('id') + # Title + csv << self.title.insert(0, ' ' * level) if columns.include?('title') + # Extension + csv << self.extension if columns.include?('extension') + # Size + csv << number_to_human_size(self.last_revision.size) if columns.include?('size') + # Modified + if columns.include?('modified') + if self.last_revision + csv << format_time(self.last_revision.updated_at) + else + csv << '' + end + end + # Version + if columns.include?('version') + if self.last_revision + csv << self.last_revision.version + else + csv << '' + end + end + # Workflow + if columns.include?('workflow') + if self.last_revision + csv << self.last_revision.workflow_str(false) + else + csv << '' + end + end + # Author + if columns.include?('author') + if self.last_revision && self.last_revision.user + csv << self.last_revision.user.name + else + csv << '' + end + end + # Url + if columns.include?(l(:label_document_url)) + default_url_options[:host] = Setting.host_name + url = url_for(:controller => :dmsf_files, :action => 'view', :id => self.id) + csv << url_for(:controller => :dmsf_files, :action => 'view', :id => self.id) + end + # Revision + if columns.include?(l(:label_last_revision_id)) + if self.last_revision + csv << self.last_revision.id + else + csv << '' + end + end + # Custom fields + cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) + cfs.each do |c| + csv << self.custom_value(c) if columns.include?(c.name) + end csv end diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index 5bdfc1dd..642e7299 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -424,6 +424,42 @@ class DmsfFolder < ActiveRecord::Base end end + include ActionView::Helpers::NumberHelper + include Rails.application.routes.url_helpers + + def to_csv(columns, level) + csv = [] + # Id + csv << self.id if columns.include?('id') + # Title + csv << self.title.insert(0, ' ' * level) if columns.include?('title') + # Extension + csv << '' if columns.include?('extension') + # Size + csv << '' if columns.include?('size') + # Modified + csv << format_time(self.updated_at) if columns.include?('modified') + # Version + csv << '' if columns.include?('version') + # Workflow + csv << '' if columns.include?('workflow') + # Author + csv << self.user.name if columns.include?('author') + # Url + if columns.include?(l(:label_document_url)) + default_url_options[:host] = Setting.host_name + csv << url_for(:controller => :dmsf, :action => 'show', :id => self.project_id, :folder_id => self.id) + end + # Revision + csv << '' if columns.include?(l(:label_last_revision_id)) + # Custom fields + cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) + cfs.each do |c| + csv << self.custom_value(c) if columns.include?(c.name) + end + csv + end + private def self.directory_subtree(tree, folder, level, current_folder) diff --git a/app/models/dmsf_link.rb b/app/models/dmsf_link.rb index 89807d04..386308a6 100644 --- a/app/models/dmsf_link.rb +++ b/app/models/dmsf_link.rb @@ -46,8 +46,8 @@ class DmsfLink < ActiveRecord::Base end end - STATUS_DELETED = 1 - STATUS_ACTIVE = 0 + STATUS_DELETED = 1.freeze + STATUS_ACTIVE = 0.freeze scope :visible, -> { where(:deleted => STATUS_ACTIVE) } scope :deleted, -> { where(:deleted => STATUS_DELETED) } @@ -150,4 +150,36 @@ class DmsfLink < ActiveRecord::Base !is_folder? end + def to_csv(columns, level) + csv = [] + if self.target_type == 'DmsfUrl' + # Id + csv << '' if columns.include?('id') + # Title + csv << self.title.insert(0, ' ' * level) if columns.include?('title') + # Extension + csv << '' if columns.include?('extension') + # Size + csv << '' if columns.include?('size') + # Modified + csv << format_time(self.updated_at) if columns.include?('modified') + # Version + csv << '' if columns.include?('version') + # Workflow + csv << '' if columns.include?('workflow') + # Author + csv << self.last_revision.user.name if columns.include?('author') + # Url + csv << self.external_url if columns.include?('url') + # Revision + csv << '' if columns.include?('revision') + # Custom fields + cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) + cfs.each do |c| + csv << '' if columns.include?(c.name) + end + end + csv + end + end \ No newline at end of file diff --git a/app/views/dmsf/_file.html.erb b/app/views/dmsf/_file.html.erb index beab186c..8690e904 100644 --- a/app/views/dmsf/_file.html.erb +++ b/app/views/dmsf/_file.html.erb @@ -44,7 +44,7 @@ <% end %> <% if DmsfFolder.is_column_on?('extension') %> - <%= $1 if file.last_revision.disk_filename =~ /\.(.+)$/ %> + <%= file.extension %> <% end %> <% if DmsfFolder.is_column_on?('size') %> diff --git a/app/views/dmsf/show.html.erb b/app/views/dmsf/show.html.erb index 48ad4a51..318c5dd7 100644 --- a/app/views/dmsf/show.html.erb +++ b/app/views/dmsf/show.html.erb @@ -207,3 +207,22 @@ <% if (@file_manipulation_allowed && !@locked_for_user) %> <%= render(:partial => 'dmsf_upload/multi_upload') %> <% end %> + +<% other_formats_links do |f| %> + <%= f.link_to 'CSV', :url => params, :onclick => "showModal('csv-export-options', '350px'); return false;" %> +<% end %> + + diff --git a/app/views/dmsf/trash.html.erb b/app/views/dmsf/trash.html.erb index c309b2a0..af30a55b 100644 --- a/app/views/dmsf/trash.html.erb +++ b/app/views/dmsf/trash.html.erb @@ -128,6 +128,10 @@ <% end %> <% @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 %> diff --git a/app/views/dmsf_files/_file_new_revision.html.erb b/app/views/dmsf_files/_file_new_revision.html.erb index 38e664e4..99cff30a 100644 --- a/app/views/dmsf_files/_file_new_revision.html.erb +++ b/app/views/dmsf_files/_file_new_revision.html.erb @@ -77,7 +77,7 @@

<%= label_tag('file_upload', l(:label_new_content)) %> - <%= render :partial => 'upload_form' %> + <%= render :partial => 'dmsf_upload/form', :locals => { :multiple => false } %>

diff --git a/app/views/dmsf_upload/_form.html.erb b/app/views/dmsf_upload/_form.html.erb index fb35a154..3adc3b16 100644 --- a/app/views/dmsf_upload/_form.html.erb +++ b/app/views/dmsf_upload/_form.html.erb @@ -23,7 +23,7 @@ <% if defined?(container) && container && container.saved_attachments %> <% container.saved_attachments.each_with_index do |attachment, i| %> - + <%= text_field_tag("dmsf_attachments[p#{i}][filename]", attachment.filename, :class => 'filename') + text_field_tag("dmsf_attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description') + link_to(' '.html_safe, dmsf_attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> @@ -36,8 +36,8 @@ <%= file_field_tag 'dmsf_attachments[dummy][file]', :id => nil, :class => 'file_selector', - :multiple => true, - :onchange => 'dmsfAddInputFiles(this);', + :multiple => multiple, + :onchange => "dmsfAddInputFiles(this);", :data => { :max_file_size => Setting.attachment_max_size.to_i.kilobytes, :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), diff --git a/app/views/dmsf_upload/_multi_upload.html.erb b/app/views/dmsf_upload/_multi_upload.html.erb index 172f9f81..20e7434b 100644 --- a/app/views/dmsf_upload/_multi_upload.html.erb +++ b/app/views/dmsf_upload/_multi_upload.html.erb @@ -40,7 +40,7 @@

- <%= render :partial => 'dmsf_upload/form' %> + <%= render :partial => 'dmsf_upload/form', :locals => { :multiple => true } %>

<%= submit_tag l(:label_upload) %> diff --git a/app/views/settings/_dmsf_columns.html.erb b/app/views/settings/_dmsf_columns.html.erb new file mode 100644 index 00000000..0318f85f --- /dev/null +++ b/app/views/settings/_dmsf_columns.html.erb @@ -0,0 +1,36 @@ +<% +# encoding: utf-8 +# +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2011-17 Karel Picman +# +# 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. +%> + +

+ <%= content_tag(:label, l(:field_column_names)) %> + <% columns = DmsfFolder::AVAILABLE_COLUMNS.dup %> + <% columns.concat(extra_columns) if defined?(extra_columns) %> + <% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %> + <% columns.concat(cfs.map{ |c| c.name }) %> + <% selected_columns = settings[:dmsf_columns] %> + <% selected_columns = DmsfFolder::DEFAULT_COLUMNS unless selected_columns %> + <% columns.each_with_index do |column, i| %> + <%= check_box_tag('settings[dmsf_columns][]', column, selected_columns.include?(column)) %> + <%= h column.capitalize %> +
+ <% end %> +

diff --git a/app/views/settings/_dmsf_settings.html.erb b/app/views/settings/_dmsf_settings.html.erb index 7e5cd6cf..54aad1ca 100644 --- a/app/views/settings/_dmsf_settings.html.erb +++ b/app/views/settings/_dmsf_settings.html.erb @@ -133,19 +133,7 @@ <%= l(:menu_dmsf) %> <%= l(:field_column_names) %> -

- <%= content_tag(:label, l(:field_column_names)) %> - <% columns = DmsfFolder::AVAILABLE_COLUMNS.dup %> - <% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %> - <% columns.concat(cfs.map{ |c| c.name }) %> - <% selected_columns = @settings[:dmsf_columns] %> - <% selected_columns = DmsfFolder::DEFAULT_COLUMNS unless selected_columns %> - <% columns.each_with_index do |column, i| %> - <%= check_box_tag('settings[dmsf_columns][]', column, selected_columns.include?(column)) %> - <%= h column.capitalize %> -
- <% end %> -

+<%= render(:partial => 'settings/dmsf_columns', :locals => { :settings => @settings }) %>
diff --git a/assets/javascripts/attachments_dmsf.js b/assets/javascripts/attachments_dmsf.js index c22e7754..f72f8c33 100644 --- a/assets/javascripts/attachments_dmsf.js +++ b/assets/javascripts/attachments_dmsf.js @@ -1,5 +1,23 @@ -/* Redmine - project management software - Copyright (C) 2006-2016 Jean-Philippe Lang */ +/* encoding: utf-8 + * + * Redmine plugin for Document Management System "Features" + * + * Copyright (C) 2011-17 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. + */ function dmsfAddFile(inputEl, file, eagerUpload) { @@ -9,11 +27,35 @@ function dmsfAddFile(inputEl, file, eagerUpload) { var fileSpan = $('', { id: 'dmsf_attachments_' + attachmentId }); - fileSpan.append( - $('', { type: 'text', 'class': 'filename readonly', name: 'dmsf_attachments[' + attachmentId + '][filename]', readonly: 'readonly'} ).val(file.name), - $('', { type: 'text', 'class': 'description', name: 'dmsf_attachments[' + attachmentId + '][description]', maxlength: 255, placeholder: $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), - $(' ').attr({ href: "#", 'class': 'remove-upload' }).click(dmsfRemoveFile).toggle(!eagerUpload) - ).appendTo('#dmsf_attachments_fields'); + if($(inputEl).attr('multiple') == 'multiple') { + fileSpan.append( + $('', { + type: 'text', + 'class': 'filename readonly', + name: 'dmsf_attachments[' + attachmentId + '][filename]', + readonly: 'readonly' + }).val(file.name), + $('', { + type: 'text', + 'class': 'description', + name: 'dmsf_attachments[' + attachmentId + '][description]', + maxlength: 255, + placeholder: $(inputEl).data('description-placeholder') + }).toggle(!eagerUpload), + $(' ').attr({href: "#", 'class': 'remove-upload'}).click(dmsfRemoveFile).toggle(!eagerUpload) + ).appendTo('#dmsf_attachments_fields'); + } + else{ + fileSpan.append( + $('', { + type: 'text', + 'class': 'filename readonly', + name: 'dmsf_attachments[' + attachmentId + '][filename]', + readonly: 'readonly' + }).val(file.name) + ).appendTo('#dmsf_attachments_fields'); + $('#dmsf_file_revision_name').val(file.name); + } if(eagerUpload) { dmsfAjaxUpload(file, attachmentId, fileSpan, inputEl); @@ -58,7 +100,7 @@ function dmsfAjaxUpload(file, attachmentId, fileSpan, inputEl) { dmsfAjaxUpload.uploading--; fileSpan.removeClass('ajax-loading'); var form = fileSpan.parents('form'); - if (form.queue('upload').length == 0 && dmsfAjaxUpload.uploading == 0) { + if ((form.queue('upload').length == 0) && (dmsfAjaxUpload.uploading == 0)) { $('input:submit', form).removeAttr('disabled'); } form.dequeue('upload'); @@ -134,7 +176,10 @@ function dmsfAddInputFiles(inputEl) { } } - clearedFileInput.insertAfter('#dmsf_attachments_fields'); + if($(inputEl).attr('multiple') == 'multiple') + clearedFileInput.insertAfter('#dmsf_attachments_fields'); + else + $('.dmsf_add_attachment').toggle(); } function dmsfUploadAndAttachFiles(files, inputEl) { diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 5b79c5d1..0f8f61d9 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -344,4 +344,7 @@ cs: text_memcached_servers: Je podporován pouze jeden server. Pokud není vyplněno, kešování je vypnuté. Při změně adresy je potřeba restartovat aplikaci. label_webdav_ignore: Vzory názvů ignorovaných souborů - note_webdav_ignore: Regulární výraz pro názvy souborů, které budou ignorovány při volání PUT. \ No newline at end of file + note_webdav_ignore: Regulární výraz pro názvy souborů, které budou ignorovány při volání PUT. + + label_document_url: Url + label_last_revision_id: Revize \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index f2f40618..8ea935f2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -344,4 +344,7 @@ en: text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/config/locales/es.yml b/config/locales/es.yml index f44080c8..3917b9d4 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -344,4 +344,7 @@ es: text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 33b4e85d..dbd5d77a 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -344,4 +344,7 @@ fr: text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/config/locales/it.yml b/config/locales/it.yml index 04116394..272064df 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -344,4 +344,7 @@ it: # Italian strings thx 2 Matteo Arceci! text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/config/locales/ja.yml b/config/locales/ja.yml index f039fa63..94ba9b08 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -344,4 +344,7 @@ ja: text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/config/locales/pl.yml b/config/locales/pl.yml index af9928a7..57adc424 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -344,4 +344,7 @@ pl: text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 60150fdd..93ce9dc5 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -344,4 +344,7 @@ pt-BR: text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 7c40fa25..f0464246 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -344,4 +344,7 @@ ru: text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 06420dcb..ae38f33e 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -344,4 +344,7 @@ sl: text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 7439e6c6..67b5a3e2 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -344,4 +344,7 @@ zh-TW: text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index c438c482..883664aa 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -344,4 +344,7 @@ zh: text_memcached_servers: Only a single server is supported, if empty then caching is disabled. After changing this, the application must be restarted! label_webdav_ignore: Ignored files patterns - note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. \ No newline at end of file + note_webdav_ignore: A regular expresion with filenames to ignore by PUT requests. + + label_document_url: Url + label_last_revision_id: Revision \ No newline at end of file diff --git a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb index 48311387..e8682e04 100644 --- a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb +++ b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb @@ -31,7 +31,8 @@ module RedmineDmsf html = "
" html << '

' html << "" - html << context[:controller].send(:render_to_string, {:partial => 'dmsf_upload/form', :locals => context}) + html << context[:controller].send(:render_to_string, + {:partial => 'dmsf_upload/form', :locals => { :multiple => true }}) html << '

' html << '
' html.html_safe diff --git a/test/functional/dmsf_controller_test.rb b/test/functional/dmsf_controller_test.rb index e6872de2..ec8d3735 100644 --- a/test/functional/dmsf_controller_test.rb +++ b/test/functional/dmsf_controller_test.rb @@ -2,7 +2,7 @@ # # Redmine plugin for Document Management System "Features" # -# Copyright (C) 2011-16 Karel Pičman +# Copyright (C) 2011-17 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 @@ -196,4 +196,12 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase assert_select 'tr.dmsf_tree' end + def test_show_csv + @role.add_permission! :view_dmsf_files + @role.add_permission! :view_dmsf_folders + get :show, :id => @project.id, :format => 'csv', :settings => {:dmsf_columns => ['id', 'title']} + assert_response :success + assert_equal 'text/csv; header=present', @response.content_type + end + end \ No newline at end of file diff --git a/test/unit/dmsf_file_test.rb b/test/unit/dmsf_file_test.rb index 09322c7f..a5f75b5f 100644 --- a/test/unit/dmsf_file_test.rb +++ b/test/unit/dmsf_file_test.rb @@ -239,4 +239,10 @@ class DmsfFileTest < RedmineDmsf::Test::UnitTest assert_nil DmsfFile.find_file_by_name(@issue1, nil, 'test.odt') end + def test_to_csv + columns = ['id', 'title'] + csv = @file1.to_csv(columns, 0) + assert_equal 2, csv.size + end + end \ No newline at end of file diff --git a/test/unit/dmsf_folder_test.rb b/test/unit/dmsf_folder_test.rb index e45029ef..00b03c3c 100644 --- a/test/unit/dmsf_folder_test.rb +++ b/test/unit/dmsf_folder_test.rb @@ -142,5 +142,11 @@ class DmsfFolderTest < RedmineDmsf::Test::UnitTest assert RedmineDmsf::Webdav::Cache.exist?("#{cache_key}.invalid") RedmineDmsf::Webdav::Cache.init_nullcache - end + end + + def test_to_csv + columns = ['id', 'title'] + csv = @folder4.to_csv(columns, 0) + assert_equal 2, csv.size + end end \ No newline at end of file diff --git a/test/unit/dmsf_link_test.rb b/test/unit/dmsf_link_test.rb index a21ad8a9..0efed5b7 100644 --- a/test/unit/dmsf_link_test.rb +++ b/test/unit/dmsf_link_test.rb @@ -236,5 +236,14 @@ class DmsfLinksTest < RedmineDmsf::Test::UnitTest @folder_link.errors.full_messages.to_sentence assert_nil DmsfLink.find_by_id @folder_link.id end + + def test_to_csv + columns = ['id', 'title'] + csv = @file_link.to_csv(columns, 0) + assert_equal 0, csv.size + @file_link.target_type = 'DmsfUrl' + csv = @file_link.to_csv(columns, 0) + assert_equal 2, csv.size + end end \ No newline at end of file