diff --git a/contentcuration/contentcuration/frontend/shared/views/files/Uploader.vue b/contentcuration/contentcuration/frontend/shared/views/files/Uploader.vue index 1a3acb3abc..d304473087 100644 --- a/contentcuration/contentcuration/frontend/shared/views/files/Uploader.vue +++ b/contentcuration/contentcuration/frontend/shared/views/files/Uploader.vue @@ -208,36 +208,40 @@ this.$emit('upload'); if (!this.readonly) { - files = this.allowMultiple ? files : [files[0]]; - files = await this.validateFiles(files); + try { + files = this.allowMultiple ? files : [files[0]]; + files = await this.validateFiles(files); - // Show errors if relevant - if (this.totalUploadSize > this.availableSpace) { - this.showStorageExceededAlert = true; - return; - } else if (this.unsupportedFiles.length) { - this.showUnsupportedFilesAlert = true; - } else if (this.tooLargeFiles.length) { - this.showTooLargeFilesAlert = true; - } - return this.handleUploads(files).then(fileUploads => { - const objects = fileUploads.map(f => f.fileObject).filter(f => !f.error); - if (fileUploads.length) { - for (const fileUpload of fileUploads) { - fileUpload.uploadPromise - .then(fileObject => { - if (isFunction(this.uploadCompleteHandler)) { - this.uploadCompleteHandler(this.getFileUpload(fileObject.id)); - } - }) - .catch(() => {}); - } - if (isFunction(this.uploadingHandler)) { - this.uploadingHandler(this.allowMultiple ? objects : objects[0]); - } + // Show errors if relevant + if (this.totalUploadSize > this.availableSpace) { + this.showStorageExceededAlert = true; + return; + } else if (this.unsupportedFiles.length) { + this.showUnsupportedFilesAlert = true; + } else if (this.tooLargeFiles.length) { + this.showTooLargeFilesAlert = true; } - return objects; - }); + return this.handleUploads(files).then(fileUploads => { + const objects = fileUploads.map(f => f.fileObject).filter(f => !f.error); + if (fileUploads.length) { + for (const fileUpload of fileUploads) { + fileUpload.uploadPromise + .then(fileObject => { + if (isFunction(this.uploadCompleteHandler)) { + this.uploadCompleteHandler(this.getFileUpload(fileObject.id)); + } + }) + .catch(() => {}); + } + if (isFunction(this.uploadingHandler)) { + this.uploadingHandler(this.allowMultiple ? objects : objects[0]); + } + } + return objects; + }); + } finally { + this.resetFileInput(); + } } }, handleUploads(files) { @@ -255,6 +259,9 @@ return fileUploads.filter(Boolean); }); }, + resetFileInput() { + this.$refs.fileUpload.value = ''; + }, }, $trs: { unsupportedFilesHeader: 'Unsupported files',