Improve clean-up of dropped files [SCI-1747]

This commit is contained in:
Oleksii Kriuchykhin 2017-11-28 16:48:47 +01:00
parent e35031dd9a
commit 745dac09a7
2 changed files with 10 additions and 4 deletions

View file

@ -123,6 +123,7 @@
initPreviewModal(); initPreviewModal();
SmartAnnotation.preventPropagation('.atwho-user-popover'); SmartAnnotation.preventPropagation('.atwho-user-popover');
TinyMCE.destroyAll(); TinyMCE.destroyAll();
DragNDropSteps.clearFiles();
}, 1000); }, 1000);
}) })
@ -148,8 +149,8 @@
initializeCheckboxSorting(); initializeCheckboxSorting();
animateSpinner(null, false); animateSpinner(null, false);
initPreviewModal(); initPreviewModal();
DragNDropSteps.clearFiles();
TinyMCE.refresh() TinyMCE.refresh();
$("#new-step-checklists fieldset.nested_step_checklists ul").each(function () { $("#new-step-checklists fieldset.nested_step_checklists ul").each(function () {
enableCheckboxSorting(this); enableCheckboxSorting(this);
}); });
@ -371,6 +372,7 @@
newStepHandler(); newStepHandler();
}); });
toggleButtons(true); toggleButtons(true);
DragNDropSteps.clearFiles();
}); });
} }

View file

@ -19,6 +19,10 @@
return filesValid; return filesValid;
} }
function clearFiles() {
droppedFiles = [];
}
// loops through a list of files and display each file in a separate panel // loops through a list of files and display each file in a separate panel
function listItems() { function listItems() {
totalSize = 0; totalSize = 0;
@ -49,7 +53,6 @@
var name = 'step[assets_attributes][' + index + '][file]'; var name = 'step[assets_attributes][' + index + '][file]';
fd.append(name, droppedFiles[i]); fd.append(name, droppedFiles[i]);
} }
droppedFiles = [];
filesValid = true; filesValid = true;
totalSize = 0; totalSize = 0;
_dragNdropAssetsOff(); _dragNdropAssetsOff();
@ -144,7 +147,8 @@
init: init, init: init,
appendFilesToForm: appendFilesToForm, appendFilesToForm: appendFilesToForm,
listItems: listItems, listItems: listItems,
filesStatus: filesStatus filesStatus: filesStatus,
clearFiles: clearFiles
}); });
})(); })();