Fix unexpected error on step attachments [SCI-7032]

This commit is contained in:
Anton 2022-08-16 11:20:45 +02:00
parent 39fbb2a9a0
commit 1a13e1bfc6
2 changed files with 10 additions and 1 deletions

View file

@ -432,7 +432,7 @@
.error-container { .error-container {
color: $brand-danger; color: $brand-danger;
margin-top: 1em; margin-top: 1em;
padding: 0 2em; padding: 0 1em;
text-align: center; text-align: center;
} }

View file

@ -55,10 +55,15 @@ export default {
fileObject.isNewUpload = true; fileObject.isNewUpload = true;
this.attachments.push(fileObject); this.attachments.push(fileObject);
const filePosition = this.attachments.length - 1;
upload.create((error, blob) => { upload.create((error, blob) => {
if (error) { if (error) {
fileObject.error = I18n.t('protocols.steps.attachments.new.general_error'); fileObject.error = I18n.t('protocols.steps.attachments.new.general_error');
this.attachments.splice(filePosition, 1);
setTimeout(() => {
this.attachments.push(fileObject);
}, 0);
reject(error); reject(error);
} else { } else {
const signedId = blob.signed_id; const signedId = blob.signed_id;
@ -69,6 +74,10 @@ export default {
fileObject.attributes = result.data.attributes; fileObject.attributes = result.data.attributes;
}).error(() => { }).error(() => {
fileObject.error = I18n.t('protocols.steps.attachments.new.general_error'); fileObject.error = I18n.t('protocols.steps.attachments.new.general_error');
this.attachments.splice(filePosition, 1);
setTimeout(() => {
this.attachments.push(fileObject);
}, 0);
}); });
filesUploadedCntr += 1; filesUploadedCntr += 1;
if (filesUploadedCntr === filesToUploadCntr) { if (filesUploadedCntr === filesToUploadCntr) {