Ilogeek/redmine_issue_dynamic_edit

Copy paste image in visual editor doesn't work - no attachment saved.

pr-dtakac opened this issue · 0 comments

Hi,
when I paste image in visual editor, image is broken and there is no attachment after issue save.
I found the bug in javascript, where only inputs from dynamic edit field are submitted.
After this change it works. Can you check it and fix it? Thanks a lot.

--- a/assets/javascripts/issue_dynamic_edit.js
+++ b/assets/javascripts/issue_dynamic_edit.js
@@ -235,9 +235,13 @@ document.querySelector('body').addEventListener('click', function(e){
 	if(e.target.matches('.dynamicEditField .action.valid') || e.target.closest('.dynamicEditField .action.valid')){
 		e.preventDefault();
 		let inputs = e.target.closest('.dynamicEditField').querySelectorAll('*[name]');
+		let fileInputs = document.querySelectorAll('#new-attachments .attachments_fields *[name]');
+		let allInputs = [];
+		allInputs.push.apply(allInputs, inputs);
+		allInputs.push.apply(allInputs, fileInputs);
 		let formData = [];
 		let existingIndex = [];
-		inputs.forEach(elt => {
+		allInputs.forEach(elt => {
 			let not_multiple = !elt.matches('input[type="radio"]') && !elt.matches('input[type="checkbox"]');
 			if(elt.matches('input[type="radio"]:checked') || elt.matches('input[type="checkbox"]:checked') || not_multiple){
 				if(!existingIndex.includes(elt.getAttribute('name'))){