From a1a4dc8a6784cf6e2af4551993aff81acfb1876f Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Tue, 10 Jan 2017 10:01:33 +0100 Subject: [PATCH] #499, #555 optionable DMSF columns --- app/models/dmsf_file.rb | 9 +- app/models/dmsf_file_revision.rb | 2 +- app/models/dmsf_folder.rb | 99 +++++++++++++++-- app/views/dmsf/_dir.html.erb | 92 ++++++++++------ app/views/dmsf/_dir_trash.html.erb | 62 +++++++---- app/views/dmsf/_file.html.erb | 120 +++++++++++++-------- app/views/dmsf/_file_trash.html.erb | 62 ++++++++--- app/views/dmsf/_list_view.erb | 48 ++++++--- app/views/dmsf/_tree_view.erb | 38 +++++-- app/views/dmsf/_url.html.erb | 62 +++++++---- app/views/dmsf/_url_trash.html.erb | 52 ++++++--- app/views/dmsf/show.html.erb | 37 +++++-- app/views/dmsf/trash.html.erb | 87 +++++++++++---- app/views/settings/_dmsf_settings.html.erb | 39 ++++++- config/locales/cs.yml | 4 + config/locales/de.yml | 4 + config/locales/en.yml | 4 + config/locales/es.yml | 4 + config/locales/fr.yml | 4 + config/locales/it.yml | 4 + config/locales/ja.yml | 4 + config/locales/pl.yml | 4 + config/locales/pt-BR.yml | 4 + config/locales/ru.yml | 6 +- config/locales/sl.yml | 4 + config/locales/zh-TW.yml | 4 + config/locales/zh.yml | 4 + init.rb | 31 +++--- 28 files changed, 669 insertions(+), 225 deletions(-) diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index d0bc697f..300257ad 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -51,7 +51,7 @@ class DmsfFile < ActiveRecord::Base scope :deleted, -> { where(:deleted => STATUS_DELETED) } validates :name, :presence => true - validates_format_of :name, :with => DmsfFolder.invalid_characters, + validates_format_of :name, :with => DmsfFolder::INVALID_CHARACTERS, :message => l(:error_contains_invalid_character) validate :validates_name_uniqueness @@ -470,4 +470,11 @@ class DmsfFile < ActiveRecord::Base false end + def custom_value(custom_field) + self.last_revision.custom_field_values.each do |cv| + return cv.value if cv.custom_field == custom_field + end + nil + end + end diff --git a/app/models/dmsf_file_revision.rb b/app/models/dmsf_file_revision.rb index 5a8a165e..8adc0cd4 100644 --- a/app/models/dmsf_file_revision.rb +++ b/app/models/dmsf_file_revision.rb @@ -55,7 +55,7 @@ class DmsfFileRevision < ActiveRecord::Base where("#{DmsfFile.table_name}.deleted = ?", STATUS_ACTIVE) validates :title, :presence => true - validates_format_of :name, :with => DmsfFolder.invalid_characters, + validates_format_of :name, :with => DmsfFolder::INVALID_CHARACTERS, :message => l(:error_contains_invalid_character) def project diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index b7a8ff36..208d0972 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.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 @@ -24,9 +24,6 @@ class DmsfFolder < ActiveRecord::Base include RedmineDmsf::Lockable - cattr_reader :invalid_characters - @@invalid_characters = /\A[^\/\\\?":<>]*\z/ - belongs_to :project belongs_to :dmsf_folder belongs_to :deleted_by_user, :class_name => 'User', :foreign_key => 'deleted_by_user_id' @@ -46,8 +43,11 @@ class DmsfFolder < ActiveRecord::Base has_many :locks, -> { where(entity_type: 1).order("#{DmsfLock.table_name}.updated_at DESC") }, :class_name => 'DmsfLock', :foreign_key => 'entity_id', :dependent => :destroy - STATUS_DELETED = 1 - STATUS_ACTIVE = 0 + INVALID_CHARACTERS = /\A[^\/\\\?":<>]*\z/.freeze + STATUS_DELETED = 1.freeze + STATUS_ACTIVE = 0.freeze + AVAILABLE_COLUMNS = %w(id title extension size modified version workflow author).freeze + DEFAULT_COLUMNS = %w(title size modified version workflow author).freeze scope :visible, -> { where(:deleted => STATUS_ACTIVE) } scope :deleted, -> { where(:deleted => STATUS_DELETED) } @@ -69,7 +69,7 @@ class DmsfFolder < ActiveRecord::Base validates :title, :presence => true validates_uniqueness_of :title, :scope => [:dmsf_folder_id, :project_id, :deleted], conditions: -> { where(:deleted => STATUS_ACTIVE) } - validates_format_of :title, :with => @@invalid_characters, + validates_format_of :title, :with => INVALID_CHARACTERS, :message => l(:error_contains_invalid_character) validate :check_cycle @@ -296,6 +296,91 @@ class DmsfFolder < ActiveRecord::Base url_links.visible.count end + def self.is_column_on?(column) + columns = Setting.plugin_redmine_dmsf['dmsf_columns'] + columns = DmsfFolder::DEFAULT_COLUMNS unless columns + columns.include? column + end + + def custom_value(custom_field) + self.custom_field_values.each do |cv| + return cv.value if cv.custom_field == custom_field + end + nil + end + + def self.get_column_position(column) + pos = 0 + # 0 - checkbox + # 1 - id + if Setting.plugin_redmine_dmsf['dmsf_columns'].include?('id') + pos += 1 + end + # 2 - title + if Setting.plugin_redmine_dmsf['dmsf_columns'].include?('title') + pos += 1 + return pos if column == 'title' + else + return nil if column == 'title' + end + # 3 - extension + if Setting.plugin_redmine_dmsf['dmsf_columns'].include?('extension') + pos += 1 + end + # 4 - size + if Setting.plugin_redmine_dmsf['dmsf_columns'].include?('size') + pos += 1 + return pos if column == 'size' + else + return nil if column == 'size' + end + # 5 - modified + if Setting.plugin_redmine_dmsf['dmsf_columns'].include?('modified') + pos += 1 + return pos if column == 'modified' + else + return nil if column == 'modified' + end + # 6 - version + if Setting.plugin_redmine_dmsf['dmsf_columns'].include?('version') + pos += 1 + return pos if column == 'version' + else + return nil if column == 'version' + end + # 7 - workflow + if Setting.plugin_redmine_dmsf['dmsf_columns'].include?('workflow') + pos += 1 + end + # 8 - author + if Setting.plugin_redmine_dmsf['dmsf_columns'].include?('author') + pos += 1 + end + # 9 - custom fields + cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField') + cfs.each do |c| + if DmsfFolder.is_column_on?(c.name) + pos += 1 + end + end + # 10 - commands + pos += 1 + return pos if column == 'commands' + # 11 - (position) + pos += 1 + return pos if column == 'position' + # 12 - (size) + pos += 1 + return pos if column == 'size_calculated' + # 13 - (modified) + pos += 1 + return pos if column == 'modified_calculated' + # 14 - (version) + pos += 1 + return pos if column == 'version_calculated' + nil + end + private def self.directory_subtree(tree, folder, level, current_folder) diff --git a/app/views/dmsf/_dir.html.erb b/app/views/dmsf/_dir.html.erb index 1410cade..d4139aae 100644 --- a/app/views/dmsf/_dir.html.erb +++ b/app/views/dmsf/_dir.html.erb @@ -3,7 +3,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 @@ -25,39 +25,65 @@ <%= check_box_tag(name, id, false, :title => l(:title_check_for_zip_download_or_email), :id => "subfolder_#{id}") %> - - <% if @tree_view %> - > - <% end %> - <%= link_to(h(title), - dmsf_folder_path(:id => project, :folder_id => subfolder), - :class => 'icon icon-folder', - :title => subfolder ? h(subfolder.description) : nil) %> - <% if link %> -
<%= link.path %>
- <% else %> -
[<%= subfolder.items %>]
- <% end %> - - -<%= format_time(subfolder.modified) if subfolder %> - <% if locked_for_user %> - <% if subfolder.lock.reverse[0].user %> - <%= link_to(image_tag(link ? 'locked_gray.png' : 'locked.png', :plugin => 'redmine_dmsf'), - user_path(subfolder.lock.reverse[0].user), - :title => l(:title_locked_by_user, :user => subfolder.lock.reverse[0].user)) %> - <% else %> - <%= content_tag(:span, image_tag(link ? 'locked_gray.png' : 'locked.png', :plugin => 'redmine_dmsf'), - :title => l(:notice_account_unknown_email)) %> +<% if DmsfFolder.is_column_on?('id') %> + <%= link_to(subfolder.id, edit_dmsf_path(:id => project, :folder_id => subfolder)) %> +<% end %> +<% if DmsfFolder.is_column_on?('title') %> + + <% if @tree_view %> + > <% end %> - <% elsif locked %> - <%= content_tag(:span, image_tag(link ? 'lockedbycurrent_gray.png' : 'lockedbycurrent.png', :plugin => 'redmine_dmsf'), - :title => l(:title_locked_by_you)) %> - <% end %> - - - -<%= h(subfolder.user) if subfolder %> + <%= link_to(h(title), + dmsf_folder_path(:id => project, :folder_id => subfolder), + :class => 'icon icon-folder', + :title => subfolder ? h(subfolder.description) : nil) %> + <% if link %> +
<%= link.path %>
+ <% else %> +
[<%= subfolder.items %>]
+ <% end %> + +<% end %> +<% if DmsfFolder.is_column_on?('extension') %> + +<% end %> +<% if DmsfFolder.is_column_on?('size') %> + +<% end %> +<% if DmsfFolder.is_column_on?('modified') %> + <%= format_time(subfolder.modified) if subfolder %> + <% if locked_for_user %> + <% if subfolder.lock.reverse[0].user %> + <%= link_to(image_tag(link ? 'locked_gray.png' : 'locked.png', :plugin => 'redmine_dmsf'), + user_path(subfolder.lock.reverse[0].user), + :title => l(:title_locked_by_user, :user => subfolder.lock.reverse[0].user)) %> + <% else %> + <%= content_tag(:span, image_tag(link ? 'locked_gray.png' : 'locked.png', :plugin => 'redmine_dmsf'), + :title => l(:notice_account_unknown_email)) %> + <% end %> + <% elsif locked %> + <%= content_tag(:span, image_tag(link ? 'lockedbycurrent_gray.png' : 'lockedbycurrent.png', :plugin => 'redmine_dmsf'), + :title => l(:title_locked_by_you)) %> + <% end %> + +<% end %> +<% if DmsfFolder.is_column_on?('version') %> + +<% end %> +<% if DmsfFolder.is_column_on?('workflow') %> + +<% end %> +<% if DmsfFolder.is_column_on?('author') %> + <%= h(subfolder.user) if subfolder %> +<% end %> +<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %> +<% cfs.each do |c| %> + <% if DmsfFolder.is_column_on?(c.name) %> + + <%= subfolder.custom_value(c) %> + + <% end %> +<% end %> <% if @folder_manipulation_allowed %> <% unless locked_for_user %> diff --git a/app/views/dmsf/_dir_trash.html.erb b/app/views/dmsf/_dir_trash.html.erb index 3b825178..eb5cb81a 100644 --- a/app/views/dmsf/_dir_trash.html.erb +++ b/app/views/dmsf/_dir_trash.html.erb @@ -3,7 +3,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 @@ -22,23 +22,49 @@ <%= check_box_tag(name, id, false, :title => l(:title_check_for_restore_or_delete), :id => "subfolder_#{id}") %> - - <%= content_tag(:span, h(title), - :title => subfolder ? h(subfolder.description) : nil, - :class => 'icon icon-folder') %> - <% if link %> -
<%= link.path %>
- <% else %> -
[<%= subfolder.items %>]
- <% end %> - - - - <%= format_time(subfolder.modified) if subfolder %> - - - -<%= h(subfolder.user) %> +<% if DmsfFolder.is_column_on?('id') %> + <%= link_to(subfolder.id, edit_dmsf_path(:id => project, :folder_id => subfolder)) %> +<% end %> +<% if DmsfFolder.is_column_on?('title') %> + + <%= content_tag(:span, h(title), + :title => subfolder ? h(subfolder.description) : nil, + :class => 'icon icon-folder') %> + <% if link %> +
<%= link.path %>
+ <% else %> +
[<%= subfolder.items %>]
+ <% end %> + +<% end %> +<% if DmsfFolder.is_column_on?('extension') %> + +<% end %> +<% if DmsfFolder.is_column_on?('size') %> + +<% end %> +<% if DmsfFolder.is_column_on?('modified') %> + + <%= format_time(subfolder.modified) if subfolder %> + +<% end %> +<% if DmsfFolder.is_column_on?('version') %> + +<% end %> +<% if DmsfFolder.is_column_on?('workflow') %> + +<% end %> +<% if DmsfFolder.is_column_on?('author') %> + <%= h(subfolder.user) %> +<% end %> +<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %> +<% cfs.each do |c| %> + <% if DmsfFolder.is_column_on?(c.name) %> + + <%= subfolder.custom_value(c) %> + + <% end %> +<% end %> <% if @folder_manipulation_allowed %> <% if link %> diff --git a/app/views/dmsf/_file.html.erb b/app/views/dmsf/_file.html.erb index ba02e120..beab186c 100644 --- a/app/views/dmsf/_file.html.erb +++ b/app/views/dmsf/_file.html.erb @@ -3,7 +3,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 @@ -24,52 +24,80 @@ <%= check_box_tag(name, id, false, :title => l(:title_check_for_zip_download_or_email), :id => "file_#{id}") %> - - <% if @tree_view %> - - <% end %> - <% file_view_url = url_for({:controller => :dmsf_files, :action => 'view', :id => file}) %> - <%= link_to(h(title), - file_view_url, - :target => '_blank', - :class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}", - :title => h(file.last_revision.try(:tooltip)), - 'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_view_url}") %> -
<%= h(link ? link.path : file.display_name) %>
- -<%= number_to_human_size(file.last_revision.size) %> - - <%= format_time(file.last_revision.updated_at) %> - <% if file.locked_for_user? %> - <% if file.lock.reverse[0].user %> - <%= link_to(image_tag(link ? 'locked_gray.png' : 'locked.png', :plugin => 'redmine_dmsf'), - user_path(file.lock.reverse[0].user), - :title => l(:title_locked_by_user, :user => file.lock.reverse[0].user)) %> - <% else %> - <%= content_tag(:span, image_tag(link ? 'locked_gray.png' : 'locked.png', :plugin => 'redmine_dmsf'), - :title => l(:notice_account_unknown_email)) %> +<% if DmsfFolder.is_column_on?('id') %> + <%= link_to(file.id, dmsf_file_path(:id => file)) %> +<% end %> +<% if DmsfFolder.is_column_on?('title') %> + + <% if @tree_view %> + <% end %> - <% elsif file.locked? %> - <%= content_tag(:span, image_tag(link ? 'lockedbycurrent_gray.png' : 'lockedbycurrent.png', :plugin => 'redmine_dmsf'), - :title => l(:title_locked_by_you)) %> - <% end %> - -<%= file.last_revision.version %> - - <% if wf && @file_approval_allowed %> - <%= link_to( - file.last_revision.workflow_str(false), - log_dmsf_workflow_path( - :project_id => project.id, - :id => wf.id, - :dmsf_file_revision_id => file.last_revision.id), - :title => DmsfWorkflow.assignments_to_users_str(wf.next_assignments(file.last_revision.id)), - :remote => true) %> - <% else %> - <%= file.last_revision.workflow_str(false) %> - <% end %> - -<%= h(file.last_revision.user) %> + <% file_view_url = url_for({:controller => :dmsf_files, :action => 'view', :id => file}) %> + <%= link_to(h(title), + file_view_url, + :target => '_blank', + :class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}", + :title => h(file.last_revision.try(:tooltip)), + 'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_view_url}") %> +
<%= h(link ? link.path : file.display_name) %>
+ +<% end %> +<% if DmsfFolder.is_column_on?('extension') %> + + <%= $1 if file.last_revision.disk_filename =~ /\.(.+)$/ %> + +<% end %> +<% if DmsfFolder.is_column_on?('size') %> + <%= number_to_human_size(file.last_revision.size) %> +<% end %> +<% if DmsfFolder.is_column_on?('modified') %> + + <%= format_time(file.last_revision.updated_at) %> + <% if file.locked_for_user? %> + <% if file.lock.reverse[0].user %> + <%= link_to(image_tag(link ? 'locked_gray.png' : 'locked.png', :plugin => 'redmine_dmsf'), + user_path(file.lock.reverse[0].user), + :title => l(:title_locked_by_user, :user => file.lock.reverse[0].user)) %> + <% else %> + <%= content_tag(:span, image_tag(link ? 'locked_gray.png' : 'locked.png', :plugin => 'redmine_dmsf'), + :title => l(:notice_account_unknown_email)) %> + <% end %> + <% elsif file.locked? %> + <%= content_tag(:span, image_tag(link ? 'lockedbycurrent_gray.png' : 'lockedbycurrent.png', :plugin => 'redmine_dmsf'), + :title => l(:title_locked_by_you)) %> + <% end %> + +<% end %> +<% if DmsfFolder.is_column_on?('version') %> + <%= file.last_revision.version %> +<% end %> +<% if DmsfFolder.is_column_on?('workflow') %> + + <% if wf && @file_approval_allowed %> + <%= link_to( + file.last_revision.workflow_str(false), + log_dmsf_workflow_path( + :project_id => project.id, + :id => wf.id, + :dmsf_file_revision_id => file.last_revision.id), + :title => DmsfWorkflow.assignments_to_users_str(wf.next_assignments(file.last_revision.id)), + :remote => true) %> + <% else %> + <%= file.last_revision.workflow_str(false) %> + <% end %> + +<% end %> +<% if DmsfFolder.is_column_on?('author') %> + <%= h(file.last_revision.user) %> +<% end %> +<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %> +<% cfs.each do |c| %> + <% if DmsfFolder.is_column_on?(c.name) %> + + <%= file.custom_value(c) %> + + <% end %> +<% end %> <% if @file_manipulation_allowed %> <%= link_to(image_tag('filedetails.png', :plugin => 'redmine_dmsf'), diff --git a/app/views/dmsf/_file_trash.html.erb b/app/views/dmsf/_file_trash.html.erb index bd84be1f..62bba0e5 100644 --- a/app/views/dmsf/_file_trash.html.erb +++ b/app/views/dmsf/_file_trash.html.erb @@ -3,7 +3,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 @@ -22,21 +22,49 @@ <%= check_box_tag(name, id, false, :title => l(:title_check_for_restore_or_delete), :id => "file_#{id}") %> - - <%= content_tag(:span, h(title), - :title => h(file.last_revision.try(:tooltip)), - :class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}") %> -
<%= h(link ? link.path : file.display_name) %>
- -<%= number_to_human_size(file.last_revision.size) %> - - <%= format_time(file.last_revision.updated_at) %> - -<%= file.last_revision.version %> - - <%= file.last_revision.workflow_str(false) %> - -<%= h(file.last_revision.user) %> +<% if DmsfFolder.is_column_on?('id') %> + <%= file.id %> +<% end %> +<% if DmsfFolder.is_column_on?('title') %> + + <%= content_tag(:span, h(title), + :title => h(file.last_revision.try(:tooltip)), + :class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}") %> +
<%= h(link ? link.path : file.display_name) %>
+ +<% end %> +<% if DmsfFolder.is_column_on?('extension') %> + + <%= $1 if file.last_revision.disk_filename =~ /\.(.+)$/ %> + +<% end %> +<% if DmsfFolder.is_column_on?('size') %> + <%= number_to_human_size(file.last_revision.size) %> +<% end %> +<% if DmsfFolder.is_column_on?('modified') %> + + <%= format_time(file.last_revision.updated_at) %> + +<% end %> +<% if DmsfFolder.is_column_on?('version') %> + <%= file.last_revision.version %> +<% end %> +<% if DmsfFolder.is_column_on?('workflow') %> + + <%= file.last_revision.workflow_str(false) %> + +<% end %> +<% if DmsfFolder.is_column_on?('author') %> + <%= h(file.last_revision.user) %> +<% end %> +<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %> +<% cfs.each do |c| %> + <% if DmsfFolder.is_column_on?(c.name) %> + + <%= file.custom_value(c) %> + + <% end %> +<% end %> <% if @file_manipulation_allowed %> <% if link %> @@ -63,4 +91,4 @@ 1 <%= file.last_revision.size %> <%= file.last_revision.updated_at.to_i %> -<%= file.last_revision.iversion %> \ No newline at end of file +<%= file.last_revision.iversion %> diff --git a/app/views/dmsf/_list_view.erb b/app/views/dmsf/_list_view.erb index c89f9113..c40e9a0b 100644 --- a/app/views/dmsf/_list_view.erb +++ b/app/views/dmsf/_list_view.erb @@ -3,7 +3,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 @@ -26,17 +26,41 @@ - <%= l(:link_title) %> - <%= l(:link_size) %> - <%= l(:link_modified) %> - <%= l(:link_ver) %> - <%= l(:link_workflow) %> - <%= l(:link_author) %> - - - - - + <% if DmsfFolder.is_column_on?('id') %> + # + <% end %> + <% if DmsfFolder.is_column_on?('title') %> + <%= l(:link_title) %> + <% end %> + <% if DmsfFolder.is_column_on?('extension') %> + <%= l(:link_extension) %> + <% end %> + <% if DmsfFolder.is_column_on?('size') %> + <%= l(:link_size) %> + <% end %> + <% if DmsfFolder.is_column_on?('modified') %> + <%= l(:link_modified) %> + <% end %> + <% if DmsfFolder.is_column_on?('version') %> + <%= l(:link_ver) %> + <% end %> + <% if DmsfFolder.is_column_on?('workflow') %> + <%= l(:link_workflow) %> + <% end %> + <% if DmsfFolder.is_column_on?('author') %> + <%= l(:link_author) %> + <% end %> + <% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %> + <% cfs.each do |c| %> + <% if DmsfFolder.is_column_on?(c.name) %> + <%= h(c.name) %> + <% end %> + <% end %> + <%# controls %> + <%# position %> + <%# size %> + <%# updated %> + <%# version %> diff --git a/app/views/dmsf/_tree_view.erb b/app/views/dmsf/_tree_view.erb index 4af50a5c..895088b9 100644 --- a/app/views/dmsf/_tree_view.erb +++ b/app/views/dmsf/_tree_view.erb @@ -26,17 +26,41 @@ - <%= l(:link_title) %> - <%= l(:link_size) %> - <%= l(:link_modified) %> - <%= l(:link_ver) %> - <%= l(:link_workflow) %> - <%= l(:link_author) %> + <% if DmsfFolder.is_column_on?('id') %> + # + <% end %> + <% if DmsfFolder.is_column_on?('title') %> + <%= l(:link_title) %> + <% end %> + <% if DmsfFolder.is_column_on?('extension') %> + <%= l(:link_extension) %> + <% end %> + <% if DmsfFolder.is_column_on?('size') %> + <%= l(:link_size) %> + <% end %> + <% if DmsfFolder.is_column_on?('modified') %> + <%= l(:link_modified) %> + <% end %> + <% if DmsfFolder.is_column_on?('version') %> + <%= l(:link_ver) %> + <% end %> + <% if DmsfFolder.is_column_on?('workflow') %> + <%= l(:link_workflow) %> + <% end %> + <% if DmsfFolder.is_column_on?('author') %> + <%= l(:link_author) %> + <% end %> + <% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %> + <% cfs.each do |c| %> + <% if DmsfFolder.is_column_on?(c.name) %> + <%= c.name %> + <% end %> + <% end %> <%# controls %> <%# position %> <%# size %> <%# updated %> - <%# revision %> + <%# version %> diff --git a/app/views/dmsf/_url.html.erb b/app/views/dmsf/_url.html.erb index cafab4a4..776b7e72 100644 --- a/app/views/dmsf/_url.html.erb +++ b/app/views/dmsf/_url.html.erb @@ -3,7 +3,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 @@ -21,24 +21,48 @@ %> - - <% if @tree_view %> - > - <% end %> - <%= link_to(h(title), - link.external_url, - :target => '_blank', - :class => 'icon dmsf_icon-link') %> -
- <%= link.external_url %> -
- <%= ''.html_safe if @tree_view %> - - -<%= format_time(link.updated_at) %> - - -<%= h(link.user) %> +<% if DmsfFolder.is_column_on?('id') %> + +<% end %> +<% if DmsfFolder.is_column_on?('title') %> + + <% if @tree_view %> + > + <% end %> + <%= link_to(h(title), + link.external_url, + :target => '_blank', + :class => 'icon dmsf_icon-link') %> +
+ <%= link.external_url %> +
+ <%= ''.html_safe if @tree_view %> + +<% end %> +<% if DmsfFolder.is_column_on?('extension') %> + +<% end %> +<% if DmsfFolder.is_column_on?('size') %> + +<% end %> +<% if DmsfFolder.is_column_on?('modified') %> + <%= format_time(link.updated_at) %> +<% end %> +<% if DmsfFolder.is_column_on?('version') %> + +<% end %> +<% if DmsfFolder.is_column_on?('workflow') %> + +<% end %> +<% if DmsfFolder.is_column_on?('author') %> + <%= h(link.user) %> +<% end %> +<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %> +<% cfs.each do |c| %> + <% if DmsfFolder.is_column_on?(c.name) %> + + <% end %> +<% end %> diff --git a/app/views/dmsf/_url_trash.html.erb b/app/views/dmsf/_url_trash.html.erb index 73eaf83f..de4623f1 100644 --- a/app/views/dmsf/_url_trash.html.erb +++ b/app/views/dmsf/_url_trash.html.erb @@ -3,7 +3,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 @@ -22,18 +22,42 @@ <%= check_box_tag(name, id, false, :title => l(:title_check_for_restore_or_delete)) %> - - <%= link_to(h(title), - link.external_url, - :target => '_blank', - :class => 'icon dmsf_icon-link') %> -
<%= link.external_url %>
- - -<%= format_time(link.updated_at) %> - - -<%= h(link.user) %> +<% if DmsfFolder.is_column_on?('id') %> + +<% end %> +<% if DmsfFolder.is_column_on?('title') %> + + <%= link_to(h(title), + link.external_url, + :target => '_blank', + :class => 'icon dmsf_icon-link') %> +
<%= link.external_url %>
+ +<% end %> +<% if DmsfFolder.is_column_on?('extension') %> + +<% end %> +<% if DmsfFolder.is_column_on?('size') %> + +<% end %> +<% if DmsfFolder.is_column_on?('modified') %> + <%= format_time(link.updated_at) %> +<% end %> +<% if DmsfFolder.is_column_on?('version') %> + +<% end %> +<% if DmsfFolder.is_column_on?('workflow') %> + +<% end %> +<% if DmsfFolder.is_column_on?('author') %> + <%= h(link.user) %> +<% end %> +<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %> +<% cfs.each do |c| %> + <% if DmsfFolder.is_column_on?(c.name) %> + + <% end %> +<% end %> <% if @file_manipulation_allowed %> <%= link_to(image_tag('restore.png', :plugin => 'redmine_dmsf'), @@ -49,4 +73,4 @@ 1 link.updated_at.to_i - \ No newline at end of file + diff --git a/app/views/dmsf/show.html.erb b/app/views/dmsf/show.html.erb index 18ac069b..2d4e3c3b 100644 --- a/app/views/dmsf/show.html.erb +++ b/app/views/dmsf/show.html.erb @@ -5,7 +5,7 @@ # # Copyright (C) 2011 Vít Jonáš # Copyright (C) 2012 Daniel Munn -# 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 @@ -132,6 +132,17 @@ <%= stylesheet_link_tag 'jquery.dataTables/jquery-ui.dataTables.css', :plugin => 'redmine_dmsf' %> <%= javascript_include_tag 'jquery.dataTables/jquery.dataTables.min.js', :plugin => 'redmine_dmsf' %> + <% 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') %> + -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/settings/_dmsf_settings.html.erb b/app/views/settings/_dmsf_settings.html.erb index 534a8ca9..b810921a 100644 --- a/app/views/settings/_dmsf_settings.html.erb +++ b/app/views/settings/_dmsf_settings.html.erb @@ -1,8 +1,11 @@ -<%# Redmine plugin for Document Management System "Features" +<% +# encoding: utf-8 +# +# Redmine plugin for Document Management System "Features" # # Copyright (C) 2011 Vít Jonáš # Copyright (C) 2012 Daniel Munn -# Copyright (C) 2011-15 Karel Picman +# 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 @@ -16,7 +19,12 @@ # # 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.%> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +%> + + + <%= l(:label_general) %> +

<%= content_tag(:label, l(:label_maximum_files_upload)) %> @@ -121,6 +129,28 @@


+ + <%= 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 %> +

+ +
+ + <%= l(:label_webdav) %> +

<%= content_tag(:label, l(:label_webdav)) %> @@ -149,6 +179,9 @@ <% end %>


+ + <%= l(:label_full_text) %> + <% begin %> <% require 'xapian' %> diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 6362be37..6a8dcb71 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -335,3 +335,7 @@ cs: error_maximum_upload_filecount: "Nelze nahrát více než %{filecount} soubor(ů)." label_public_urls: Veřejné URL platné do + + label_webdav: WebDAV + label_full_text: Full-textové vyhledávání + link_extension: Příp. diff --git a/config/locales/de.yml b/config/locales/de.yml index 306d11fa..731f4690 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -335,3 +335,7 @@ de: error_maximum_upload_filecount: "Nicht mehr als %{filecount} Datai(en) kann man hochladen." label_public_urls: Öffentliches URLs gültig bis + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext diff --git a/config/locales/en.yml b/config/locales/en.yml index 418ed7c3..12f5eac2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -335,3 +335,7 @@ en: error_maximum_upload_filecount: "No more than %{filecount} file(s) can be uploaded." label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/config/locales/es.yml b/config/locales/es.yml index e5bea88d..49141754 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -335,3 +335,7 @@ es: error_maximum_upload_filecount: "No more than %{filecount} file(s) can be uploaded." label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 7b77ba88..5477734a 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -335,3 +335,7 @@ fr: error_maximum_upload_filecount: "No more than %{filecount} file(s) can be uploaded." label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/config/locales/it.yml b/config/locales/it.yml index c1f22f4c..92c12c0e 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -335,3 +335,7 @@ it: # Italian strings thx 2 Matteo Arceci! error_maximum_upload_filecount: "No more than %{filecount} file(s) can be uploaded." label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/config/locales/ja.yml b/config/locales/ja.yml index a33272fb..4632a843 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -335,3 +335,7 @@ ja: error_maximum_upload_filecount: "No more than %{filecount} file(s) can be uploaded." label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 05aa1c0a..43cb5fda 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -335,3 +335,7 @@ pl: error_maximum_upload_filecount: "No more than %{filecount} file(s) can be uploaded." label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index efcb52d0..7639bb07 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -335,3 +335,7 @@ pt-BR: error_maximum_upload_filecount: "No more than %{filecount} file(s) can be uploaded." label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/config/locales/ru.yml b/config/locales/ru.yml index bfd9373b..c81dabd2 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -334,4 +334,8 @@ ru: error_maximum_upload_filecount: "Не более %{filecount} файла(ов) может быть загружено." - label_public_urls: Public URLs valid to \ No newline at end of file + label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 6db3bc31..c5891296 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -335,3 +335,7 @@ sl: error_maximum_upload_filecount: "No more than %{filecount} file(s) can be uploaded." label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 55a6f743..54e98b3b 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -335,3 +335,7 @@ zh-TW: error_maximum_upload_filecount: "No more than %{filecount} file(s) can be uploaded." label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index fa8702e9..9150a7f4 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -335,3 +335,7 @@ zh: error_maximum_upload_filecount: "No more than %{filecount} file(s) can be uploaded." label_public_urls: Public URLs valid to + + label_webdav: WebDAV + label_full_text: Full-text search + link_extension: Ext \ No newline at end of file diff --git a/init.rb b/init.rb index f970e137..a7a5090b 100644 --- a/init.rb +++ b/init.rb @@ -4,7 +4,7 @@ # # Copyright (C) 2011 Vít Jonáš # Copyright (C) 2012 Daniel Munn -# 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 @@ -28,26 +28,27 @@ Redmine::Plugin.register :redmine_dmsf do name 'DMSF' author 'Vít Jonáš / Daniel Munn / Karel Pičman' description 'Document Management System Features' - version '1.5.8' + version '1.5.9 - devel' url 'http://www.redmine.org/plugins/dmsf' author_url 'https://github.com/danmunn/redmine_dmsf/graphs/contributors' requires_redmine :version_or_higher => '3.3.0' settings :partial => 'settings/dmsf_settings', - :default => { - 'dmsf_max_file_upload' => '0', - 'dmsf_max_file_download' => '0', - 'dmsf_max_email_filesize' => '0', - 'dmsf_max_ajax_upload_filesize' => '100', - 'dmsf_storage_directory' => Rails.root.join('files/dmsf').to_s, - 'dmsf_index_database' => Rails.root.join('files/dmsf_index').to_s, - 'dmsf_stemming_lang' => 'english', - 'dmsf_stemming_strategy' => 'STEM_NONE', - 'dmsf_webdav' => '1', - 'dmsf_display_notified_recipients' => 0, - 'dmsf_global_title_format' => '' - } + :default => { + 'dmsf_max_file_upload' => '0', + 'dmsf_max_file_download' => '0', + 'dmsf_max_email_filesize' => '0', + 'dmsf_max_ajax_upload_filesize' => '100', + 'dmsf_storage_directory' => Rails.root.join('files/dmsf').to_s, + 'dmsf_index_database' => Rails.root.join('files/dmsf_index').to_s, + 'dmsf_stemming_lang' => 'english', + 'dmsf_stemming_strategy' => 'STEM_NONE', + 'dmsf_webdav' => '1', + 'dmsf_display_notified_recipients' => 0, + 'dmsf_global_title_format' => '', + 'dmsf_columns' => %w(title size modified version workflow author) + } menu :project_menu, :dmsf, { :controller => 'dmsf', :action => 'show' }, :caption => :menu_dmsf, :before => :documents, :param => :id