diff --git a/app/controllers/dmsf_workflows_controller.rb b/app/controllers/dmsf_workflows_controller.rb index 80aea615..d47d790f 100644 --- a/app/controllers/dmsf_workflows_controller.rb +++ b/app/controllers/dmsf_workflows_controller.rb @@ -233,6 +233,18 @@ class DmsfWorkflowsController < ApplicationController end def log + if params[:dmsf_file_revision_id].present? + @revision = DmsfFileRevision.find_by(id: params[:dmsf_file_revision_id]) + elsif params[:dmsf_file_id].present? + dmsf_file = DmsfFile.find_by(id: params[:dmsf_file_id]) + @revision = dmsf_file.last_revision if dmsf_file + elsif params[:dmsf_link_id].present? + dmsf_link = DmsfLink.find_by(id: params[:dmsf_link_id]) + if dmsf_link + dmsf_file = dmsf_link.target_file + @revision = dmsf_file.last_revision + end + end respond_to do |format| format.html format.js diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index 6ba4a6c9..c36245e8 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -239,6 +239,12 @@ class DmsfFile < ActiveRecord::Base self.project_id = project.id self.dmsf_folder = folder new_revision = last_revision.clone + new_revision.workflow = nil + new_revision.dmsf_workflow_id = nil + new_revision.dmsf_workflow_assigned_by_user_id = nil + new_revision.dmsf_workflow_assigned_at = nil + new_revision.dmsf_workflow_started_by_user_id = nil + new_revision.dmsf_workflow_started_at = nil new_revision.dmsf_file = self new_revision.comment = l(:comment_moved_from, source: source) new_revision.custom_values = [] diff --git a/app/models/dmsf_query.rb b/app/models/dmsf_query.rb index b8596cac..3f63a694 100644 --- a/app/models/dmsf_query.rb +++ b/app/models/dmsf_query.rb @@ -186,8 +186,10 @@ class DmsfQuery < Query users.lastname AS lastname, users.id AS author, 'folder' AS type, + dmsf_folders.deleted AS deleted, 0 AS sort #{cf_columns}}). - joins('LEFT JOIN users ON dmsf_folders.user_id = users.id') + joins('LEFT JOIN users ON dmsf_folders.user_id = users.id')#. + #visible(!deleted) if deleted scope.where(dmsf_folders: { project_id: project.id, deleted: deleted }) else @@ -218,6 +220,7 @@ class DmsfQuery < Query users.lastname AS lastname, users.id AS author, 'folder-link' AS type, + dmsf_links.deleted AS deleted, 0 AS sort #{cf_columns}}). joins('LEFT JOIN dmsf_folders ON dmsf_links.target_id = dmsf_folders.id'). joins('LEFT JOIN users ON users.id = COALESCE(dmsf_folders.user_id, dmsf_links.user_id)') @@ -252,6 +255,7 @@ class DmsfQuery < Query users.lastname AS lastname, users.id AS author, 'file' AS type, + dmsf_files.deleted AS deleted, 1 AS sort #{cf_columns}}). joins(:dmsf_file_revisions). joins('LEFT JOIN users ON dmsf_file_revisions.user_id = users.id '). @@ -286,6 +290,7 @@ class DmsfQuery < Query users.lastname AS lastname, users.id AS author, 'file-link' AS type, + dmsf_links.deleted AS deleted, 1 AS sort #{cf_columns}}). joins('JOIN dmsf_files ON dmsf_files.id = dmsf_links.target_id'). joins('JOIN dmsf_file_revisions ON dmsf_file_revisions.dmsf_file_id = dmsf_files.id'). @@ -321,6 +326,7 @@ class DmsfQuery < Query users.lastname AS lastname, users.id AS author, 'url-link' AS type, + dmsf_links.deleted AS deleted, 1 AS sort #{cf_columns}}). joins('LEFT JOIN users ON dmsf_links.user_id = users.id ') if deleted diff --git a/app/models/dmsf_workflow.rb b/app/models/dmsf_workflow.rb index 6abd5bb5..6bde0300 100644 --- a/app/models/dmsf_workflow.rb +++ b/app/models/dmsf_workflow.rb @@ -39,6 +39,21 @@ class DmsfWorkflow < ActiveRecord::Base STATUS_LOCKED = 0 STATUS_ACTIVE = 1 + def self.workflow_str(workflow) + case workflow + when STATE_WAITING_FOR_APPROVAL + l(:title_waiting_for_approval) + when STATE_APPROVED + l(:title_approved) + when STATE_ASSIGNED + l(:title_assigned) + when STATE_REJECTED + l(:title_rejected) + when DmsfWorkflow::STATE_OBSOLETE + l(:title_obsolete) + end + end + def participiants users = Array.new dmsf_workflow_steps.each do |step| diff --git a/app/views/dmsf_files/_file_new_revision.html.erb b/app/views/dmsf_files/_file_new_revision.html.erb index a38e478e..7680e1f4 100644 --- a/app/views/dmsf_files/_file_new_revision.html.erb +++ b/app/views/dmsf_files/_file_new_revision.html.erb @@ -23,8 +23,8 @@ %>
- <%= l(:heading_new_revision) %> [-] -
+ <%= l(:heading_new_revision) %> [+] +
<% if @file.locked_for_user? %>

<%= l(:info_file_locked) %>

<% else %> diff --git a/app/views/dmsf_files/show.html.erb b/app/views/dmsf_files/show.html.erb index a7db2f39..31bc5aa6 100644 --- a/app/views/dmsf_files/show.html.erb +++ b/app/views/dmsf_files/show.html.erb @@ -79,21 +79,25 @@
-
- <%= link_to_function image_tag('group.png'), - "$('#revision_access-#{revision.id}').toggle()", - title: l(:title_download_entries) %> - <%= link_to image_tag('download.png'), - view_dmsf_file_path(@file, download: revision), - title: l(:title_title_version_version_download, title: h(revision.title), version: revision.version) %> - <%= link_to image_tag('close_hl.png'), - obsolete_revision_path(revision), - data: { confirm: l(:text_are_you_sure) }, - title: l(:title_obsolete_revision) if @file_manipulation_allowed && (revision.workflow == DmsfWorkflow::STATE_APPROVED) %> - <%= link_to image_tag('delete.png'), - delete_revision_path(revision), - data: { confirm: l(:text_are_you_sure) }, - title: l(:title_delete_revision) if @file_delete_allowed && (@file.dmsf_file_revisions.visible.count > 1) %> +
+ <%= actions_dropdown do %> + <%= link_to_function l(:title_download_entries), + "$('#revision_access-#{revision.id}').toggle()", + class: 'icon icon-group' %> + <%= link_to l(:title_download), + view_dmsf_file_path(@file, download: revision), + title: l(:title_title_version_version_download, title: h(revision.title), version: revision.version), + class: 'icon icon-download' %> + <%= link_to l(:title_obsolete_revision), + obsolete_revision_path(revision), + data: { confirm: l(:text_are_you_sure) }, + class: 'icon icon-close' if @file_manipulation_allowed && (revision.workflow == DmsfWorkflow::STATE_APPROVED) %> + <%= link_to l(:button_delete), + delete_revision_path(revision), + data: { confirm: l(:text_are_you_sure) }, + title: l(:title_delete_revision), + class: 'icon icon-del' if @file_delete_allowed && (@file.dmsf_file_revisions.visible.count > 1) %> + <% end %>
<%= l(:info_revision, rev: revision.id) %> <%= (revision.source_revision.nil? ? l(:label_created) : l(:label_changed)).downcase %> @@ -199,14 +203,14 @@ } $('#version_0').prop('disabled', true); }); - $('#newRevisionFormContentToggle').click(function() { - if($('#newRevisionFormContent').is(':visible')) { + $('#new_revision_form_content_toggle').click(function() { + if($('#new_revision_form_content').is(':visible')) { $(this).text('[+]'); - $('#newRevisionFormContent').hide(); + $('#new_revision_form_content').hide(); } else { $(this).text('[-]'); - $('#newRevisionFormContent').show(); + $('#new_revision_form_content').show(); } }); $('.dmsf_list').dataTable({ @@ -218,12 +222,6 @@ } }); <% end %> -<% if @revision.valid? && @file.valid? %> - <%= late_javascript_tag do %> - $('#newRevisionFormContentToggle').text('[+]'); - $('#newRevisionFormContent').hide(); - <% end %> -<% end %> <% content_for :header_tags do %> <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', plugin: :redmine_dmsf %> diff --git a/app/views/dmsf_workflows/_log.html.erb b/app/views/dmsf_workflows/_log.html.erb index 887dea21..add39a2c 100644 --- a/app/views/dmsf_workflows/_log.html.erb +++ b/app/views/dmsf_workflows/_log.html.erb @@ -22,86 +22,83 @@

<%= l(:title_dmsf_workflow_log) %>

- <% if params[:dmsf_file_revision_id].present? %> - <% revision = DmsfFileRevision.find_by(id: params[:dmsf_file_revision_id]) %> - <% if revision %> -

-
- <%= label_tag 'workflow_name', "#{l(:link_workflow)} #{l(:field_name).downcase} " %> - <% if User.current.allowed_to?(:manage_workflows, @dmsf_workflow.project) %> - <%= link_to @dmsf_workflow.name, dmsf_workflow_path(@dmsf_workflow) %> - <% else %> - <%= @dmsf_workflow.name %> - <% end %> -
-
- <%= label_tag 'workflow_status', l(:field_status) %> - <%= revision.workflow_str false %> -
-
-
- - - - - - - - - - - - + <% if revision %> +
+
+ <%= label_tag 'workflow_name', "#{l(:link_workflow)} #{l(:field_name).downcase} " %> + <% if User.current.allowed_to?(:manage_workflows, @dmsf_workflow.project) %> + <%= link_to @dmsf_workflow.name, dmsf_workflow_path(@dmsf_workflow) %> + <% else %> + <%= @dmsf_workflow.name %> + <% end %> +
+
+ <%= label_tag 'workflow_status', l(:field_status) %> + <%= revision.workflow_str false %> +
+
+
+
<%= l(:label_dmsf_workflow_step) %><%= l(:label_user) %><%= l(:label_action) %><%= l(:link_workflow) %><%= l(:label_note) %><%= l(:label_date)%>
+ + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + <% sql = "SELECT c.action, c.note, c.created_at, c.author_id, a.user_id, s.step, s.name FROM dmsf_workflow_step_actions c RIGHT JOIN dmsf_workflow_step_assignments a ON a.id = c.dmsf_workflow_step_assignment_id RIGHT JOIN dmsf_workflow_steps s ON s.id = a.dmsf_workflow_step_id WHERE a.dmsf_file_revision_id = #{revision.id} ORDER BY s.step, s.id, c.action DESC, c.created_at" %> + <% result = DmsfWorkflowStep.connection.exec_query sql %> + <% last_step = 0 %> + <% result.each_with_index do |row, i| %> + + + <% last_step = row['step'] %> + + + + + + - - - - - - - - - - - - - - - - - - - <% sql = "SELECT c.action, c.note, c.created_at, c.author_id, a.user_id, s.step, s.name FROM dmsf_workflow_step_actions c RIGHT JOIN dmsf_workflow_step_assignments a ON a.id = c.dmsf_workflow_step_assignment_id RIGHT JOIN dmsf_workflow_steps s ON s.id = a.dmsf_workflow_step_id WHERE a.dmsf_file_revision_id = #{revision.id} ORDER BY s.step, s.id, c.action DESC, c.created_at" %> - <% result = DmsfWorkflowStep.connection.exec_query sql %> - <% last_step = 0 %> - <% result.each_with_index do |row, i| %> - - - <% last_step = row['step'] %> - - - - - - - - <% end %> - -
<%= l(:label_dmsf_workflow_step) %><%= l(:label_user) %><%= l(:label_action) %><%= l(:link_workflow) %><%= l(:label_note) %><%= l(:label_date)%>
<%= DmsfWorkflowStepAction.workflow_str(0) %>
<%= DmsfWorkflowStepAction.workflow_str(0) %><%= link_to_user revision.dmsf_workflow_assigned_by_user if revision.dmsf_workflow_assigned_by_user %><%= DmsfWorkflowStepAction.action_str(DmsfWorkflowStepAction::ACTION_ASSIGN) %><%= DmsfWorkflowStepAction.workflow_str(DmsfWorkflowStepAction::ACTION_ASSIGN) %><%= format_time(revision.dmsf_workflow_assigned_at) if revision.dmsf_workflow_assigned_at %>
<%= link_to_user revision.dmsf_workflow_started_by_user if revision.dmsf_workflow_started_by_user %><%= DmsfWorkflowStepAction.action_str(DmsfWorkflowStepAction::ACTION_START) %><%= DmsfWorkflowStepAction.workflow_str(DmsfWorkflowStepAction::ACTION_START) if revision.dmsf_workflow_started_by_user %><%= format_time(revision.dmsf_workflow_started_at) if revision.dmsf_workflow_started_at %>
<%= row['step'] unless row['step'] == last_step %><%= row['name'] %><%= link_to_user User.find_by(id: row['author_id'].present? ? row['author_id'] : row['user_id']) %><%= DmsfWorkflowStepAction.action_str(row['action']) %> + <% if (row['step'].to_i == @dmsf_workflow.dmsf_workflow_steps.last.step) && (revision.workflow == DmsfWorkflow::STATE_APPROVED) && (row['action'] != DmsfWorkflowStepAction::ACTION_DELEGATE) %> + <%= l(:title_approved) %> + <% else %> + <%= DmsfWorkflowStepAction.workflow_str(row['action']) %> + <% end %> + <%= row['note'] %><%= format_time(row['created_at']) if row['created_at'].present? %>
<%= link_to_user revision.dmsf_workflow_assigned_by_user if revision.dmsf_workflow_assigned_by_user %><%= DmsfWorkflowStepAction.action_str(DmsfWorkflowStepAction::ACTION_ASSIGN) %><%= DmsfWorkflowStepAction.workflow_str(DmsfWorkflowStepAction::ACTION_ASSIGN) %><%= format_time(revision.dmsf_workflow_assigned_at) if revision.dmsf_workflow_assigned_at %>
<%= link_to_user revision.dmsf_workflow_started_by_user if revision.dmsf_workflow_started_by_user %><%= DmsfWorkflowStepAction.action_str(DmsfWorkflowStepAction::ACTION_START) %><%= DmsfWorkflowStepAction.workflow_str(DmsfWorkflowStepAction::ACTION_START) if revision.dmsf_workflow_started_by_user %><%= format_time(revision.dmsf_workflow_started_at) if revision.dmsf_workflow_started_at %>
<%= row['step'] unless row['step'] == last_step %><%= row['name'] %><%= link_to_user User.find_by(id: row['author_id'].present? ? row['author_id'] : row['user_id']) %><%= DmsfWorkflowStepAction.action_str(row['action']) %> - <% if (row['step'].to_i == @dmsf_workflow.dmsf_workflow_steps.last.step) && (revision.workflow == DmsfWorkflow::STATE_APPROVED) && (row['action'] != DmsfWorkflowStepAction::ACTION_DELEGATE) %> - <%= l(:title_approved) %> - <% else %> - <%= DmsfWorkflowStepAction.workflow_str(row['action']) %> - <% end %> - <%= row['note'] %><%= format_time(row['created_at']) if row['created_at'].present? %>
-
- <% end %> - <% end %> + <% end %> + + +
+ <% end %>

\ No newline at end of file diff --git a/app/views/dmsf_workflows/log.html.erb b/app/views/dmsf_workflows/log.html.erb index 8060a12a..81e292fb 100644 --- a/app/views/dmsf_workflows/log.html.erb +++ b/app/views/dmsf_workflows/log.html.erb @@ -19,4 +19,4 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%> -<%= render :partial => 'log', :locals => {:workflow => @dmsf_workflow} %> \ No newline at end of file +<%= render partial: 'log', locals: { workflow: @dmsf_workflow, revision: @revision } %> \ No newline at end of file diff --git a/app/views/dmsf_workflows/log.js.erb b/app/views/dmsf_workflows/log.js.erb index 021dc0f7..62f0c424 100644 --- a/app/views/dmsf_workflows/log.js.erb +++ b/app/views/dmsf_workflows/log.js.erb @@ -21,6 +21,6 @@ var modal = $('#ajax-modal'); -modal.html('<%= escape_javascript(render :partial => 'log', :locals => {:workflow => @dmsf_workflow}) %>'); +modal.html('<%= escape_javascript(render partial: 'log', locals: { workflow: @dmsf_workflow, revision: @revision }) %>'); showModal('ajax-modal', '90%'); modal.addClass('workflow-log'); diff --git a/assets/stylesheets/redmine_dmsf.css b/assets/stylesheets/redmine_dmsf.css index 293c86c7..6f706f8d 100644 --- a/assets/stylesheets/redmine_dmsf.css +++ b/assets/stylesheets/redmine_dmsf.css @@ -196,6 +196,10 @@ table.display thead th div.DataTables_sort_wrapper span { .dmsf_workflows.locked a { color: #aaa; } /* DMSF revision box */ +#new_revision_form_content { + display: none; +} + .dmsf_revision_box { padding: 0 0 0 0; margin-bottom: 10px; diff --git a/lib/redmine_dmsf/patches/queries_helper_patch.rb b/lib/redmine_dmsf/patches/queries_helper_patch.rb index 2ae2ffb3..721bfa48 100644 --- a/lib/redmine_dmsf/patches/queries_helper_patch.rb +++ b/lib/redmine_dmsf/patches/queries_helper_patch.rb @@ -36,61 +36,101 @@ module RedmineDmsf when :id case item.type when 'file', 'file-link' - link_to h(value), dmsf_file_path(id: item.id) + if item.deleted && (item.deleted > 0) + super column, item, value + else + link_to h(value), dmsf_file_path(id: item.id) + end when 'folder', 'folder-link' if(item.id) - link_to h(value), edit_dmsf_path(id: item.project_id, folder_id: item.id) + if item.deleted && (item.deleted > 0) + super column, item, value + else + link_to h(value), edit_dmsf_path(id: item.project_id, folder_id: item.id) + end else - link_to h(item.project_id), edit_root_dmsf_path(id: item.project_id) + if item.deleted && (item.deleted > 0) + super column, item, item.project_id + else + link_to h(item.project_id), edit_root_dmsf_path(id: item.project_id) + end end else h(value) end when :author - link_to "#{item.firstname} #{item.lastname}", user_path(id: value) + if value + link_to "#{item.firstname} #{item.lastname}", user_path(id: value) + else + return super column, item, value + end when :title case item.type when 'folder' - "".html_safe + - link_to(h(value), - dmsf_folder_path(id: item.project_id, folder_id: item.id), - class: 'icon icon-folder', - title: h(value)) + - content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download)) + if item.deleted && (item.deleted > 0) + tag = content_tag('span', value, class: 'icon icon-folder') + else + tag = "".html_safe + + link_to(h(value), + dmsf_folder_path(id: item.project_id, folder_id: item.id), + class: 'icon icon-folder', + title: h(value)) + end + tag + content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download)) when 'folder-link' - "".html_safe + - link_to(h(value), - dmsf_folder_path(id: item.project_id, folder_id: item.id), - class: 'icon icon-folder', - title: h(value)) + - content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download)) + if item.deleted && (item.deleted > 0) + tag = content_tag('span', value, class: 'icon icon-folder') + else + tag = "".html_safe + + link_to(h(value), + dmsf_folder_path(id: item.project_id, folder_id: item.id), + class: 'icon icon-folder', + title: h(value)) + end + tag + content_tag('div', item.filename, class: 'dmsf_filename', title: l(:label_target_folder)) when 'file', 'file-link' - file_view_url = url_for({ controller: :dmsf_files, action: 'view', id: item.id }) - content_type = Redmine::MimeType.of(value) - content_type = 'application/octet-stream' if content_type.blank? - "".html_safe + - link_to(h(value), - file_view_url, - target: '_blank', - class: "icon icon-file #{DmsfHelper.filetype_css(item.filename)}", - title: h(value), - 'data-downloadurl': "#{content_type}:#{h(value)}:#{file_view_url}") + - content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download)) + if item.deleted && (item.deleted > 0) + tag = content_tag('span', value, class: "icon icon-file #{DmsfHelper.filetype_css(item.filename)}") + else + file_view_url = url_for({ controller: :dmsf_files, action: 'view', id: item.id }) + content_type = Redmine::MimeType.of(value) + content_type = 'application/octet-stream' if content_type.blank? + tag = "".html_safe + + link_to(h(value), + file_view_url, + target: '_blank', + class: "icon icon-file #{DmsfHelper.filetype_css(item.filename)}", + title: h(value), + 'data-downloadurl': "#{content_type}:#{h(value)}:#{file_view_url}") + end + tag + content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download)) when 'url-link' - "".html_safe + - link_to(h(value), item.filename, target: '_blank', class: 'icon icon-link') + - content_tag('div', item.filename, class: 'dmsf_filename', title: l(:title_filename_for_download)) + if item.deleted && (item.deleted > 0) + tag = content_tag('span', value, class: 'icon icon-link') + else + tag = "".html_safe + + link_to(h(value), item.filename, target: '_blank', class: 'icon icon-link') + end + tag + content_tag('div', item.filename, class: 'dmsf_filename', title: l(:field_url)) else h(value) end when :size number_to_human_size(value) when :workflow - if value && item.workflow_id - link_to h(DmsfWorkflowStepAction.workflow_str(value)), - log_dmsf_workflow_path(project_id: item.project_id, id: item.workflow_id, - dmsf_file_revision_id: item.revision_id), - remote: true + if value + if item.workflow_id && (!(item.deleted && (item.deleted > 0))) + if item.type == 'file' + url = log_dmsf_workflow_path(project_id: item.project_id, id: item.workflow_id, dmsf_file_id: item.id) + else + url = log_dmsf_workflow_path(project_id: item.project_id, id: item.workflow_id, dmsf_link_id: item.id) + end + link_to(h(DmsfWorkflow.workflow_str(value.to_i)), url, remote: true) + else + h(DmsfWorkflow.workflow_str(value.to_i)) + end + else + super column, item, value end else super column, item, value