Serialization of attached documents is wrong #1601
This commit is contained in:
parent
138715dba2
commit
aa59d239f2
@ -24,7 +24,7 @@ class DmsfWorkflowsController < ApplicationController
|
|||||||
self.main_menu = false
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :find_model_object, except: %i[create new index assign assignment]
|
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 :authorize_custom
|
||||||
before_action :permissions?, only: %i[new_action assignment start]
|
before_action :permissions?, only: %i[new_action assignment start]
|
||||||
before_action :approver_candidates, only: %i[remove_step show reorder_steps add_step]
|
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])
|
revision = DmsfFileRevision.find_by(id: params[:dmsf_file_revision_id])
|
||||||
begin
|
begin
|
||||||
if revision
|
if revision
|
||||||
|
@project = revision.dmsf_file.project
|
||||||
revision.set_workflow(params[:dmsf_workflow_id], params[:action])
|
revision.set_workflow(params[:dmsf_workflow_id], params[:action])
|
||||||
revision.assign_workflow(params[:dmsf_workflow_id])
|
revision.assign_workflow(params[:dmsf_workflow_id])
|
||||||
if request.post?
|
if request.post?
|
||||||
|
|||||||
@ -61,7 +61,7 @@ module DmsfWorkflowsHelper
|
|||||||
|
|
||||||
def dmsf_workflows_for_select(project, dmsf_workflow_id)
|
def dmsf_workflows_for_select(project, dmsf_workflow_id)
|
||||||
options = [['', -1]]
|
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
|
options << if wf.project_id
|
||||||
[wf.name, wf.id]
|
[wf.name, wf.id]
|
||||||
else
|
else
|
||||||
|
|||||||
@ -34,16 +34,17 @@
|
|||||||
class: 'filename icon icon-attachment readonly') %>
|
class: 'filename icon icon-attachment readonly') %>
|
||||||
<%= link_to sprite_icon('del', l(:button_delete), icon_only: true),
|
<%= link_to sprite_icon('del', l(:button_delete), icon_only: true),
|
||||||
dmsf_attachment_path(attachment, attachment_id: "p#{i}", format: 'js'),
|
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] %>
|
<% wf = container.saved_dmsf_attachments_wfs[attachment.id] %>
|
||||||
<% if wf %>
|
<% if wf %>
|
||||||
<%= link_to sprite_icon('checked', l(:title_assigned), icon_only: true), '#', remote: true,
|
<%= 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) %>
|
<%= hidden_field_tag("dmsf_attachments_wfs[p#{i}]", wf.id) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to sprite_icon('checked', l(:title_assignment), icon_only: true),
|
<%= link_to sprite_icon('checked', l(:title_assignment), icon_only: true),
|
||||||
assign_dmsf_workflow_path(id: container.project.id, project_id: container.project.id,
|
assign_dmsf_workflow_path(id: i, project_id: container.project&.id,
|
||||||
attachment_id: i + 1), title: l(:label_dmsf_wokflow_action_assign),
|
attachment_id: i), title: l(:label_dmsf_wokflow_action_assign),
|
||||||
remote: true, class: 'modify-upload icon-only icon-ok' %>
|
remote: true, class: 'modify-upload icon-only icon-ok' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
@ -88,12 +89,14 @@
|
|||||||
end
|
end
|
||||||
project_or_folder = folder ? folder : project
|
project_or_folder = folder ? folder : project
|
||||||
files = []
|
files = []
|
||||||
|
if project_or_folder
|
||||||
project_or_folder.dmsf_files.visible.each do |dmsf_file|
|
project_or_folder.dmsf_files.visible.each do |dmsf_file|
|
||||||
rev = dmsf_file.last_revision
|
rev = dmsf_file.last_revision
|
||||||
if rev
|
if rev
|
||||||
files << [dmsf_file.name, rev.major_version, rev.minor_version, rev.patch_version, dmsf_file.locked_for_user? ]
|
files << [dmsf_file.name, rev.major_version, rev.minor_version, rev.patch_version, dmsf_file.locked_for_user? ]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
%>
|
%>
|
||||||
<%= file_field_tag 'dmsf_attachments[dummy][file]',
|
<%= file_field_tag 'dmsf_attachments[dummy][file]',
|
||||||
id: nil,
|
id: nil,
|
||||||
@ -108,7 +111,7 @@
|
|||||||
max_size: number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
max_size: number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||||
max_concurrent_uploads: Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
max_concurrent_uploads: Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||||
upload_path: dmsf_uploads_path(format: 'js'),
|
upload_path: dmsf_uploads_path(format: 'js'),
|
||||||
project: project.identifier,
|
project: project&.identifier,
|
||||||
awf: awf,
|
awf: awf,
|
||||||
dmsf_file_details_form: controller.send(:render_to_string,
|
dmsf_file_details_form: controller.send(:render_to_string,
|
||||||
{ partial: 'dmsf_upload/upload_file',
|
{ partial: 'dmsf_upload/upload_file',
|
||||||
@ -123,7 +126,7 @@
|
|||||||
<% if defined?(container) && container %>
|
<% if defined?(container) && container %>
|
||||||
<span class="dmsf-add-link">
|
<span class="dmsf-add-link">
|
||||||
<%= link_to sprite_icon('add', l(:label_link_from)),
|
<%= 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 %>
|
title: l(:title_create_link), class: 'icon icon-add file_selector', remote: true %>
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -33,7 +33,7 @@ var span = input.parent();
|
|||||||
"<input name='dmsf_attachments_wfs[<%= @attachment_id %>]' value='<%= @dmsf_workflow_id %>' type='hidden'>");
|
"<input name='dmsf_attachments_wfs[<%= @attachment_id %>]' value='<%= @dmsf_workflow_id %>' type='hidden'>");
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
var a = span.children("a.icon-ok");
|
var icon = span.children("a.icon-ok");
|
||||||
|
|
||||||
a.attr("href", "#");
|
icon.attr("href", "#");
|
||||||
a.attr("title", "<%= l(:title_assigned) %>");
|
icon.attr("title", "<%= l(:title_assigned) %>");
|
||||||
|
|||||||
@ -52,10 +52,7 @@ jsToolBar.prototype.dmsfMenu = function(fn){
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('<li></li>').html('<hr>').appendTo(menu);
|
$('<li></li>').html('<hr>').appendTo(menu);
|
||||||
const a = item.split(';');
|
let macroItem = $('<div></div>').text(item.split(';')[1]);
|
||||||
let lang = a[0];
|
|
||||||
let help = a[1];
|
|
||||||
let macroItem = $('<div></div>').text(help);
|
|
||||||
$('<li></li>').html(macroItem).appendTo(menu).mousedown(function () {
|
$('<li></li>').html(macroItem).appendTo(menu).mousedown(function () {
|
||||||
window.open('/dmsf/help/wiki_syntax','_blank', 'width=480,height=480');
|
window.open('/dmsf/help/wiki_syntax','_blank', 'width=480,height=480');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -23,6 +23,7 @@ module RedmineDmsf
|
|||||||
# Issue view hooks
|
# Issue view hooks
|
||||||
class IssueViewHooks < Redmine::Hook::ViewListener
|
class IssueViewHooks < Redmine::Hook::ViewListener
|
||||||
include DmsfQueriesHelper
|
include DmsfQueriesHelper
|
||||||
|
include DmsfFilesHelper
|
||||||
|
|
||||||
def view_issues_form_details_bottom(context = {})
|
def view_issues_form_details_bottom(context = {})
|
||||||
return if defined?(EasyExtensions)
|
return if defined?(EasyExtensions)
|
||||||
@ -34,10 +35,9 @@ module RedmineDmsf
|
|||||||
def view_attachments_form_top(context = {})
|
def view_attachments_form_top(context = {})
|
||||||
html = +''
|
html = +''
|
||||||
container = context[:container]
|
container = context[:container]
|
||||||
description = defined?(EasyExtensions) && EasySetting.value('attachment_description')
|
|
||||||
# Radio buttons
|
# Radio buttons
|
||||||
if allowed_to_attach_documents(container) && allowed_to_attach_attachments(container)
|
if allowed_to_attach_documents(container) && allowed_to_attach_attachments(container)
|
||||||
html << (description ? '<p>' : '<div>')
|
html << '<p>'
|
||||||
classes = +'inline'
|
classes = +'inline'
|
||||||
html << "<label class=\"#{classes}\">"
|
html << "<label class=\"#{classes}\">"
|
||||||
onchange = %($(".attachments-container:not(.dmsf-uploader)").show();
|
onchange = %($(".attachments-container:not(.dmsf-uploader)").show();
|
||||||
@ -58,7 +58,7 @@ module RedmineDmsf
|
|||||||
onchange: onchange)
|
onchange: onchange)
|
||||||
html << l(:label_dmsf_attachments)
|
html << l(:label_dmsf_attachments)
|
||||||
html << '</label>'
|
html << '</label>'
|
||||||
html << (description ? '</p>' : '</div>')
|
html << '</p>'
|
||||||
if User.current.pref.dmsf_attachments_upload_choice == 'DMSF'
|
if User.current.pref.dmsf_attachments_upload_choice == 'DMSF'
|
||||||
html << context[:hook_caller].late_javascript_tag(
|
html << context[:hook_caller].late_javascript_tag(
|
||||||
"$('.attachments-container:not(.dmsf-uploader)').hide();"
|
"$('.attachments-container:not(.dmsf-uploader)').hide();"
|
||||||
@ -67,7 +67,7 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
# Upload form
|
# Upload form
|
||||||
if allowed_to_attach_documents(container)
|
if allowed_to_attach_documents(container)
|
||||||
html << attach_documents_form(context, label: false, description: description)
|
html << attach_documents_form(context, label: false)
|
||||||
end
|
end
|
||||||
unless allowed_to_attach_attachments(container)
|
unless allowed_to_attach_attachments(container)
|
||||||
html << context[:hook_caller].late_javascript_tag("$('.attachments-container:not(.dmsf-uploader)').hide();")
|
html << context[:hook_caller].late_javascript_tag("$('.attachments-container:not(.dmsf-uploader)').hide();")
|
||||||
@ -113,14 +113,16 @@ module RedmineDmsf
|
|||||||
private
|
private
|
||||||
|
|
||||||
def allowed_to_attach_documents(container)
|
def allowed_to_attach_documents(container)
|
||||||
container.respond_to?(:saved_dmsf_attachments) && container.project &&
|
return false unless container.respond_to?(:saved_dmsf_attachments) && RedmineDmsf.dmsf_act_as_attachable?
|
||||||
User.current.allowed_to?(:file_manipulation, container.project) &&
|
|
||||||
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)
|
(container.project&.dmsf_act_as_attachable != Project::ATTACHABLE_DMS_AND_ATTACHMENTS))
|
||||||
|
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def allowed_to_attach_attachments(container)
|
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))
|
!(allowed_to_attach_documents(container) && !container.project.module_enabled?(:documents))
|
||||||
end
|
end
|
||||||
@ -189,7 +191,7 @@ module RedmineDmsf
|
|||||||
return if links.blank?
|
return if links.blank?
|
||||||
|
|
||||||
if defined?(EasyExtensions)
|
if defined?(EasyExtensions)
|
||||||
attachment_rows(links, container, controller)
|
attachment_rows links, container, controller
|
||||||
else
|
else
|
||||||
controller.send :render_to_string,
|
controller.send :render_to_string,
|
||||||
{ partial: 'dmsf_files/links',
|
{ partial: 'dmsf_files/links',
|
||||||
@ -226,7 +228,10 @@ module RedmineDmsf
|
|||||||
title: h(dmsf_file.last_revision.try(:tooltip)),
|
title: h(dmsf_file.last_revision.try(:tooltip)),
|
||||||
'data-downloadurl' => data)
|
'data-downloadurl' => data)
|
||||||
html << "<span class=\"size dmsf-size\">(#{number_to_human_size(dmsf_file.last_revision.size)})</span>"
|
html << "<span class=\"size dmsf-size\">(#{number_to_human_size(dmsf_file.last_revision.size)})</span>"
|
||||||
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 << '</td>'
|
html << '</td>'
|
||||||
# Author, updated at
|
# Author, updated at
|
||||||
html << '<td>'
|
html << '<td>'
|
||||||
|
|||||||
@ -32,7 +32,7 @@ module RedmineDmsf
|
|||||||
# Attach DMS documents
|
# Attach DMS documents
|
||||||
uploaded_files = params[:dmsf_attachments]
|
uploaded_files = params[:dmsf_attachments]
|
||||||
details = params[:committed_files]
|
details = params[:committed_files]
|
||||||
if uploaded_files && details
|
if uploaded_files
|
||||||
system_folder = easy_crm_case.system_folder(create: true)
|
system_folder = easy_crm_case.system_folder(create: true)
|
||||||
uploaded_files.each do |key, uploaded_file|
|
uploaded_files.each do |key, uploaded_file|
|
||||||
upload = DmsfUpload.create_from_uploaded_attachment(easy_crm_case.project, system_folder, 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[:disk_filename] = upload.disk_filename
|
||||||
uploaded_file[:name] = upload.name
|
uploaded_file[:name] = upload.name
|
||||||
uploaded_file[:title] = upload.title
|
uploaded_file[:title] = upload.title
|
||||||
|
if details
|
||||||
uploaded_file[:description] = details[key][:description]
|
uploaded_file[:description] = details[key][:description]
|
||||||
uploaded_file[:comment] = details[key][:comment]
|
uploaded_file[:comment] = details[key][:comment]
|
||||||
uploaded_file[:version_major] = details[key][:version_major]
|
uploaded_file[:version_major] = details[key][:version_major]
|
||||||
uploaded_file[:version_minor] = details[key][:version_minor]
|
uploaded_file[:version_minor] = details[key][:version_minor]
|
||||||
uploaded_file[:version_patch] = details[key][:version_patch]
|
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[:size] = upload.size
|
||||||
uploaded_file[:mime_type] = upload.mime_type
|
uploaded_file[:mime_type] = upload.mime_type
|
||||||
uploaded_file[:tempfile_path] = upload.tempfile_path
|
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?
|
if params[:dmsf_attachments_wfs].present? && params[:dmsf_attachments_wfs][key].present?
|
||||||
uploaded_file[:workflow_id] = params[:dmsf_attachments_wfs][key].to_i
|
uploaded_file[:workflow_id] = params[:dmsf_attachments_wfs][key].to_i
|
||||||
end
|
end
|
||||||
uploaded_file[:custom_field_values] = details[key][:custom_field_values]
|
uploaded_file[:custom_field_values] = details[key][:custom_field_values] if details
|
||||||
end
|
end
|
||||||
DmsfUploadHelper.commit_files_internal uploaded_files, easy_crm_case.project, system_folder, self,
|
DmsfUploadHelper.commit_files_internal uploaded_files, easy_crm_case.project, system_folder, self,
|
||||||
easy_crm_case, new_object: false
|
easy_crm_case, new_object: false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user