From 177e260bfa1a05066c4d114a5999fbb6f7716803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Mon, 21 Oct 2024 17:11:00 +0200 Subject: [PATCH 1/2] Deleting of uploaded files #1558 --- app/controllers/dmsf_upload_controller.rb | 9 ++++++--- assets/javascripts/attachments_dmsf.js | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index b20965b3..6669ec41 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -41,25 +41,28 @@ def permissions def upload_files uploaded_files = params[:dmsf_attachments] + @uploads = [] # Commit if params[:commit] == l(:label_dmsf_upload_commit) uploaded_files&.each do |key, 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][:digest] = upload.digest params[:committed_files][key][:tempfile_path] = upload.tempfile_path end - commit_files + commit_files if params[:committed_files].present? # Upload else - @uploads = [] # standard file input uploads uploaded_files&.each do |_, uploaded_file| upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, uploaded_file) @uploads.push(upload) if upload end - flash.now[:error] = "#{l(:label_attachment)} #{l('activerecord.errors.messages.invalid')}" if @uploads.empty? end + flash.now[:error] = "#{l(:label_attachment)} #{l('activerecord.errors.messages.invalid')}" if @uploads.empty? end # REST API and Redmine attachment form diff --git a/assets/javascripts/attachments_dmsf.js b/assets/javascripts/attachments_dmsf.js index 9a6b885a..50b6e683 100644 --- a/assets/javascripts/attachments_dmsf.js +++ b/assets/javascripts/attachments_dmsf.js @@ -306,7 +306,11 @@ dmsfAjaxUpload.uploading = 0; function dmsfRemoveFileLbl() { - $(this).parent('span').remove(); + let span = $(this).parent('span'); + + span.next('div').remove(); + span.next('br').remove(); + span.remove(); return false; } From 832ec06ba323f650662d5b9411350f9ba6e4ee1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Thu, 24 Oct 2024 08:03:29 +0200 Subject: [PATCH 2/2] Layout/LineLength: Line is too long --- lib/redmine_dmsf/hooks/views/issue_view_hooks.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb index 67cde1ff..411cbaa7 100644 --- a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb +++ b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb @@ -274,8 +274,13 @@ def attachment_row(dmsf_file, link, issue, controller) if issue.attributes_editable? && ((link && User.current.allowed_to?(:file_manipulation, dmsf_file.project)) || (!link && 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('', - 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) }, method: :delete, title: l(:button_delete),