diff --git a/app/controllers/dmsf_workflows_controller.rb b/app/controllers/dmsf_workflows_controller.rb
index d08efde8..4e74838c 100644
--- a/app/controllers/dmsf_workflows_controller.rb
+++ b/app/controllers/dmsf_workflows_controller.rb
@@ -24,7 +24,7 @@ class DmsfWorkflowsController < ApplicationController
self.main_menu = false
before_action :find_model_object, except: %i[create new index assign assignment]
- before_action :find_project
+ before_action :find_project, except: %i[assignment]
before_action :authorize_custom
before_action :permissions?, only: %i[new_action assignment start]
before_action :approver_candidates, only: %i[remove_step show reorder_steps add_step]
@@ -216,6 +216,7 @@ class DmsfWorkflowsController < ApplicationController
revision = DmsfFileRevision.find_by(id: params[:dmsf_file_revision_id])
begin
if revision
+ @project = revision.dmsf_file.project
revision.set_workflow(params[:dmsf_workflow_id], params[:action])
revision.assign_workflow(params[:dmsf_workflow_id])
if request.post?
diff --git a/app/helpers/dmsf_workflows_helper.rb b/app/helpers/dmsf_workflows_helper.rb
index 990fe7ed..82ec20e2 100644
--- a/app/helpers/dmsf_workflows_helper.rb
+++ b/app/helpers/dmsf_workflows_helper.rb
@@ -61,7 +61,7 @@ module DmsfWorkflowsHelper
def dmsf_workflows_for_select(project, dmsf_workflow_id)
options = [['', -1]]
- DmsfWorkflow.active.sorted.where(['project_id = ? OR project_id IS NULL', project.id]).find_each do |wf|
+ DmsfWorkflow.active.sorted.where(['project_id = ? OR project_id IS NULL', project&.id]).find_each do |wf|
options << if wf.project_id
[wf.name, wf.id]
else
diff --git a/app/views/dmsf_upload/_form.html.erb b/app/views/dmsf_upload/_form.html.erb
index e4c214af..60eb4de5 100644
--- a/app/views/dmsf_upload/_form.html.erb
+++ b/app/views/dmsf_upload/_form.html.erb
@@ -34,16 +34,17 @@
class: 'filename icon icon-attachment readonly') %>
<%= link_to sprite_icon('del', l(:button_delete), icon_only: true),
dmsf_attachment_path(attachment, attachment_id: "p#{i}", format: 'js'),
- method: 'delete', remote: true, class: 'remove-upload icon-only icon-del' %>
+ method: 'delete', remote: true, title: l(:button_delete),
+ class: 'remove-upload icon-only icon-del' %>
<% wf = container.saved_dmsf_attachments_wfs[attachment.id] %>
<% if wf %>
<%= link_to sprite_icon('checked', l(:title_assigned), icon_only: true), '#', remote: true,
- class: 'modify-upload icon-only icon-ok' %>
+ title: l(:title_assigned), class: 'modify-upload icon-only icon-ok' %>
<%= hidden_field_tag("dmsf_attachments_wfs[p#{i}]", wf.id) %>
<% else %>
<%= link_to sprite_icon('checked', l(:title_assignment), icon_only: true),
- assign_dmsf_workflow_path(id: container.project.id, project_id: container.project.id,
- attachment_id: i + 1), title: l(:label_dmsf_wokflow_action_assign),
+ assign_dmsf_workflow_path(id: i, project_id: container.project&.id,
+ attachment_id: i), title: l(:label_dmsf_wokflow_action_assign),
remote: true, class: 'modify-upload icon-only icon-ok' %>
<% end %>
@@ -88,10 +89,12 @@
end
project_or_folder = folder ? folder : project
files = []
- project_or_folder.dmsf_files.visible.each do |dmsf_file|
- rev = dmsf_file.last_revision
- if rev
- files << [dmsf_file.name, rev.major_version, rev.minor_version, rev.patch_version, dmsf_file.locked_for_user? ]
+ if project_or_folder
+ project_or_folder.dmsf_files.visible.each do |dmsf_file|
+ rev = dmsf_file.last_revision
+ if rev
+ files << [dmsf_file.name, rev.major_version, rev.minor_version, rev.patch_version, dmsf_file.locked_for_user? ]
+ end
end
end
%>
@@ -108,7 +111,7 @@
max_size: number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
max_concurrent_uploads: Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
upload_path: dmsf_uploads_path(format: 'js'),
- project: project.identifier,
+ project: project&.identifier,
awf: awf,
dmsf_file_details_form: controller.send(:render_to_string,
{ partial: 'dmsf_upload/upload_file',
@@ -123,7 +126,7 @@
<% if defined?(container) && container %>
<%= link_to sprite_icon('add', l(:label_link_from)),
- new_dmsf_link_path(project_id: project.id, type: 'link_from', container: container.class.name),
+ new_dmsf_link_path(project_id: project&.id, type: 'link_from', container: container.class.name),
title: l(:title_create_link), class: 'icon icon-add file_selector', remote: true %>
<% end %>
diff --git a/app/views/dmsf_workflows/assignment.js.erb b/app/views/dmsf_workflows/assignment.js.erb
index 8b1205d9..f938e46f 100644
--- a/app/views/dmsf_workflows/assignment.js.erb
+++ b/app/views/dmsf_workflows/assignment.js.erb
@@ -33,7 +33,7 @@ var span = input.parent();
"");
<% end %>
-var a = span.children("a.icon-ok");
+var icon = span.children("a.icon-ok");
-a.attr("href", "#");
-a.attr("title", "<%= l(:title_assigned) %>");
+icon.attr("href", "#");
+icon.attr("title", "<%= l(:title_assigned) %>");
diff --git a/assets/javascripts/dmsf_button.js b/assets/javascripts/dmsf_button.js
index 983253c4..5f4ac527 100644
--- a/assets/javascripts/dmsf_button.js
+++ b/assets/javascripts/dmsf_button.js
@@ -52,10 +52,7 @@ jsToolBar.prototype.dmsfMenu = function(fn){
}
else {
$('
').html('
').appendTo(menu);
- const a = item.split(';');
- let lang = a[0];
- let help = a[1];
- let macroItem = $('').text(help);
+ let macroItem = $('').text(item.split(';')[1]);
$('').html(macroItem).appendTo(menu).mousedown(function () {
window.open('/dmsf/help/wiki_syntax','_blank', 'width=480,height=480');
});
diff --git a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb
index 5290c25f..2082004d 100644
--- a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb
+++ b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb
@@ -23,6 +23,7 @@ module RedmineDmsf
# Issue view hooks
class IssueViewHooks < Redmine::Hook::ViewListener
include DmsfQueriesHelper
+ include DmsfFilesHelper
def view_issues_form_details_bottom(context = {})
return if defined?(EasyExtensions)
@@ -34,10 +35,9 @@ module RedmineDmsf
def view_attachments_form_top(context = {})
html = +''
container = context[:container]
- description = defined?(EasyExtensions) && EasySetting.value('attachment_description')
# Radio buttons
if allowed_to_attach_documents(container) && allowed_to_attach_attachments(container)
- html << (description ? '' : '
')
+ html << '
'
classes = +'inline'
html << "'
- html << (description ? '
' : '
')
+ html << ''
if User.current.pref.dmsf_attachments_upload_choice == 'DMSF'
html << context[:hook_caller].late_javascript_tag(
"$('.attachments-container:not(.dmsf-uploader)').hide();"
@@ -67,7 +67,7 @@ module RedmineDmsf
end
# Upload form
if allowed_to_attach_documents(container)
- html << attach_documents_form(context, label: false, description: description)
+ html << attach_documents_form(context, label: false)
end
unless allowed_to_attach_attachments(container)
html << context[:hook_caller].late_javascript_tag("$('.attachments-container:not(.dmsf-uploader)').hide();")
@@ -113,14 +113,16 @@ module RedmineDmsf
private
def allowed_to_attach_documents(container)
- container.respond_to?(:saved_dmsf_attachments) && container.project &&
- User.current.allowed_to?(:file_manipulation, container.project) &&
- RedmineDmsf.dmsf_act_as_attachable? &&
- (container.project&.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS)
+ return false unless container.respond_to?(:saved_dmsf_attachments) && RedmineDmsf.dmsf_act_as_attachable?
+
+ return false if container.project && (!User.current.allowed_to?(:file_manipulation, container.project) ||
+ (container.project&.dmsf_act_as_attachable != Project::ATTACHABLE_DMS_AND_ATTACHMENTS))
+
+ true
end
def allowed_to_attach_attachments(container)
- return true unless defined?(EasyExtensions)
+ return true unless (defined?(EasyExtensions) && container&.project)
!(allowed_to_attach_documents(container) && !container.project.module_enabled?(:documents))
end
@@ -189,7 +191,7 @@ module RedmineDmsf
return if links.blank?
if defined?(EasyExtensions)
- attachment_rows(links, container, controller)
+ attachment_rows links, container, controller
else
controller.send :render_to_string,
{ partial: 'dmsf_files/links',
@@ -226,7 +228,10 @@ module RedmineDmsf
title: h(dmsf_file.last_revision.try(:tooltip)),
'data-downloadurl' => data)
html << "(#{number_to_human_size(dmsf_file.last_revision.size)})"
- html << " - #{h(dmsf_file.description)}" if dmsf_file.description.present?
+ if dmsf_file.description.present?
+ desc = clean_wiki_text(textilizable(dmsf_file.description))
+ html << " - #{h(desc)}"
+ end
html << ''
# Author, updated at
html << ''
diff --git a/patches/easy_crm_cases_controller_patch.rb b/patches/easy_crm_cases_controller_patch.rb
index 72c187e8..53782d03 100644
--- a/patches/easy_crm_cases_controller_patch.rb
+++ b/patches/easy_crm_cases_controller_patch.rb
@@ -32,7 +32,7 @@ module RedmineDmsf
# Attach DMS documents
uploaded_files = params[:dmsf_attachments]
details = params[:committed_files]
- if uploaded_files && details
+ if uploaded_files
system_folder = easy_crm_case.system_folder(create: true)
uploaded_files.each do |key, uploaded_file|
upload = DmsfUpload.create_from_uploaded_attachment(easy_crm_case.project, system_folder, uploaded_file)
@@ -41,11 +41,16 @@ module RedmineDmsf
uploaded_file[:disk_filename] = upload.disk_filename
uploaded_file[:name] = upload.name
uploaded_file[:title] = upload.title
- uploaded_file[:description] = details[key][:description]
- uploaded_file[:comment] = details[key][:comment]
- uploaded_file[:version_major] = details[key][:version_major]
- uploaded_file[:version_minor] = details[key][:version_minor]
- uploaded_file[:version_patch] = details[key][:version_patch]
+ if details
+ uploaded_file[:description] = details[key][:description]
+ uploaded_file[:comment] = details[key][:comment]
+ uploaded_file[:version_major] = details[key][:version_major]
+ uploaded_file[:version_minor] = details[key][:version_minor]
+ uploaded_file[:version_patch] = details[key][:version_patch]
+ else
+ uploaded_file[:version_major] = 0
+ uploaded_file[:version_minor] = 1
+ end
uploaded_file[:size] = upload.size
uploaded_file[:mime_type] = upload.mime_type
uploaded_file[:tempfile_path] = upload.tempfile_path
@@ -53,7 +58,7 @@ module RedmineDmsf
if params[:dmsf_attachments_wfs].present? && params[:dmsf_attachments_wfs][key].present?
uploaded_file[:workflow_id] = params[:dmsf_attachments_wfs][key].to_i
end
- uploaded_file[:custom_field_values] = details[key][:custom_field_values]
+ uploaded_file[:custom_field_values] = details[key][:custom_field_values] if details
end
DmsfUploadHelper.commit_files_internal uploaded_files, easy_crm_case.project, system_folder, self,
easy_crm_case, new_object: false
|