Fix duplicated/missing attachements when bulk upload to result/step [SCI-9920] (#6879)

This commit is contained in:
Soufiane 2024-01-05 14:23:44 +01:00 committed by GitHub
parent 7298042f2a
commit e9d42beec4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 12 deletions

View file

@ -90,6 +90,10 @@
},
computed: {
attachmentsOrdered() {
if (this.attachments.some((attachment) => attachment.attributes.uploading)) {
return this.attachments;
}
return this.attachments.sort((a, b) => {
if (a.attributes.asset_order == b.attributes.asset_order) {
switch(this.parent.attributes.assets_order) {

View file

@ -97,10 +97,7 @@ export default {
upload.create((error, blob) => {
if (error) {
fileObject.error = I18n.t('attachments.new.general_error');
this.attachments.splice(filePosition, 1);
setTimeout(() => {
this.attachments.push(fileObject);
}, 0);
this.attachments = this.attachments.with(filePosition, fileObject);
reject(error);
} else {
const signedId = blob.signed_id;
@ -109,16 +106,10 @@ export default {
}, (result) => {
fileObject.id = result.data.id;
fileObject.attributes = result.data.attributes;
this.attachments.splice(filePosition, 1);
setTimeout(() => {
this.attachments.push(fileObject);
}, 0);
this.attachments = this.attachments.with(filePosition, fileObject);
}).fail(() => {
fileObject.error = I18n.t('attachments.new.general_error');
this.attachments.splice(filePosition, 1);
setTimeout(() => {
this.attachments.push(fileObject);
}, 0);
this.attachments = this.attachments.with(filePosition, fileObject);
});
filesUploadedCntr += 1;
if (filesUploadedCntr === filesToUploadCntr) {