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