From 745dac09a7734a7719355a1abf6b43ef448fbd77 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Tue, 28 Nov 2017 16:48:47 +0100 Subject: [PATCH] Improve clean-up of dropped files [SCI-1747] --- app/assets/javascripts/protocols/steps.js.erb | 6 ++++-- app/assets/javascripts/sitewide/drag_n_drop.js.erb | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/protocols/steps.js.erb b/app/assets/javascripts/protocols/steps.js.erb index 9addb1f07..039610611 100644 --- a/app/assets/javascripts/protocols/steps.js.erb +++ b/app/assets/javascripts/protocols/steps.js.erb @@ -123,6 +123,7 @@ initPreviewModal(); SmartAnnotation.preventPropagation('.atwho-user-popover'); TinyMCE.destroyAll(); + DragNDropSteps.clearFiles(); }, 1000); }) @@ -148,8 +149,8 @@ initializeCheckboxSorting(); animateSpinner(null, false); initPreviewModal(); - - TinyMCE.refresh() + DragNDropSteps.clearFiles(); + TinyMCE.refresh(); $("#new-step-checklists fieldset.nested_step_checklists ul").each(function () { enableCheckboxSorting(this); }); @@ -371,6 +372,7 @@ newStepHandler(); }); toggleButtons(true); + DragNDropSteps.clearFiles(); }); } diff --git a/app/assets/javascripts/sitewide/drag_n_drop.js.erb b/app/assets/javascripts/sitewide/drag_n_drop.js.erb index 4e681b961..1359b3c9e 100644 --- a/app/assets/javascripts/sitewide/drag_n_drop.js.erb +++ b/app/assets/javascripts/sitewide/drag_n_drop.js.erb @@ -19,6 +19,10 @@ return filesValid; } + function clearFiles() { + droppedFiles = []; + } + // loops through a list of files and display each file in a separate panel function listItems() { totalSize = 0; @@ -49,7 +53,6 @@ var name = 'step[assets_attributes][' + index + '][file]'; fd.append(name, droppedFiles[i]); } - droppedFiles = []; filesValid = true; totalSize = 0; _dragNdropAssetsOff(); @@ -144,7 +147,8 @@ init: init, appendFilesToForm: appendFilesToForm, listItems: listItems, - filesStatus: filesStatus + filesStatus: filesStatus, + clearFiles: clearFiles }); })();