mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-07 16:09:57 +08:00
Merge pull request #2408 from aignatov-bio/ai-sci-4345-file-results-bug
Fix files handling in results [SCI-4345]
This commit is contained in:
commit
b83cbf33a7
1 changed files with 10 additions and 5 deletions
|
@ -352,6 +352,7 @@
|
|||
fileMaxSizeMb = GLOBAL_CONSTANTS.FILE_MAX_SIZE_MB;
|
||||
fileMaxSize = fileMaxSizeMb * 1024 * 1024;
|
||||
for (let i = 0; i < files.length; i += 1) {
|
||||
files[i].uuid = Math.random().toString(36);
|
||||
droppedFiles.push(files[i]);
|
||||
}
|
||||
listItems();
|
||||
|
@ -514,7 +515,7 @@
|
|||
<span class="fas fa-paperclip"></span>
|
||||
${I18n.t('assets.drag_n_drop.file_label')}
|
||||
<div class="pull-right">
|
||||
<a data-item-id="${i}" href="#">
|
||||
<a data-item-id="${asset.uuid}" href="#">
|
||||
<span class="fas fa-times"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
@ -548,13 +549,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
function removeItemHandler(id) {
|
||||
$('[data-item-id="' + id + '"]').off('click').on('click', function(e) {
|
||||
function removeItemHandler(uuid) {
|
||||
$('[data-item-id="' + uuid + '"]').off('click').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
e.stopPropagation();
|
||||
let $el = $(this);
|
||||
let index = $el.data('item-id');
|
||||
let index = droppedFiles.findIndex((file) => {
|
||||
return file.uuid === $el.data('item-id');
|
||||
});
|
||||
totalSize -= parseInt(droppedFiles[index].size, 10);
|
||||
droppedFiles.splice(index, 1);
|
||||
$el.closest('.panel-result-attachment-new').remove();
|
||||
|
@ -575,7 +578,7 @@
|
|||
.after(uploadedAssetPreview(droppedFiles[i], i))
|
||||
.promise()
|
||||
.done(function() {
|
||||
removeItemHandler(i);
|
||||
removeItemHandler(droppedFiles[i].uuid);
|
||||
});
|
||||
}
|
||||
validateTotalSize();
|
||||
|
@ -586,7 +589,9 @@
|
|||
function init(files) {
|
||||
fileMaxSizeMb = GLOBAL_CONSTANTS.FILE_MAX_SIZE_MB;
|
||||
fileMaxSize = fileMaxSizeMb * 1024 * 1024;
|
||||
|
||||
for (let i = 0; i < files.length; i += 1) {
|
||||
files[i].uuid = Math.random().toString(36);
|
||||
droppedFiles.unshift(files[i]);
|
||||
}
|
||||
listItems();
|
||||
|
|
Loading…
Reference in a new issue