Merge branch 'master' into devel

This commit is contained in:
Karel Pičman 2024-10-24 08:03:43 +02:00
commit b8e2d5c6eb
3 changed files with 17 additions and 5 deletions

View File

@ -41,25 +41,28 @@ class DmsfUploadController < ApplicationController
def upload_files def upload_files
uploaded_files = params[:dmsf_attachments] uploaded_files = params[:dmsf_attachments]
@uploads = []
# Commit # Commit
if params[:commit] == l(:label_dmsf_upload_commit) if params[:commit] == l(:label_dmsf_upload_commit)
uploaded_files&.each do |key, uploaded_file| uploaded_files&.each do |key, uploaded_file|
upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, uploaded_file) upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, uploaded_file)
next unless upload
@uploads.push upload
params[:committed_files][key][:disk_filename] = upload.disk_filename params[:committed_files][key][:disk_filename] = upload.disk_filename
params[:committed_files][key][:digest] = upload.digest params[:committed_files][key][:digest] = upload.digest
params[:committed_files][key][:tempfile_path] = upload.tempfile_path params[:committed_files][key][:tempfile_path] = upload.tempfile_path
end end
commit_files commit_files if params[:committed_files].present?
# Upload # Upload
else else
@uploads = []
# standard file input uploads # standard file input uploads
uploaded_files&.each do |_, uploaded_file| uploaded_files&.each do |_, uploaded_file|
upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, uploaded_file) upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, uploaded_file)
@uploads.push(upload) if upload @uploads.push(upload) if upload
end end
flash.now[:error] = "#{l(:label_attachment)} #{l('activerecord.errors.messages.invalid')}" if @uploads.empty?
end end
flash.now[:error] = "#{l(:label_attachment)} #{l('activerecord.errors.messages.invalid')}" if @uploads.empty?
end end
# REST API and Redmine attachment form # REST API and Redmine attachment form

View File

@ -306,7 +306,11 @@ dmsfAjaxUpload.uploading = 0;
function dmsfRemoveFileLbl() { function dmsfRemoveFileLbl() {
$(this).parent('span').remove(); let span = $(this).parent('span');
span.next('div').remove();
span.next('br').remove();
span.remove();
return false; return false;
} }

View File

@ -274,8 +274,13 @@ module RedmineDmsf
if issue.attributes_editable? && ((link && User.current.allowed_to?(:file_manipulation, if issue.attributes_editable? && ((link && User.current.allowed_to?(:file_manipulation,
dmsf_file.project)) || (!link && dmsf_file.project)) || (!link &&
User.current.allowed_to?(:file_delete, dmsf_file.project))) User.current.allowed_to?(:file_delete, dmsf_file.project)))
url = if link
dmsf_link_path link, commit: 'yes', back_url: issue_path(issue)
else
dmsf_file_path id: dmsf_file, commit: 'yes', back_url: issue_path(issue)
end
html << link_to('', html << link_to('',
link ? dmsf_link_path(link, commit: 'yes', back_url: issue_path(issue)) : dmsf_file_path(id: dmsf_file, commit: 'yes', back_url: issue_path(issue)), url,
data: { confirm: l(:text_are_you_sure) }, data: { confirm: l(:text_are_you_sure) },
method: :delete, method: :delete,
title: l(:button_delete), title: l(:button_delete),