Skip to content

Commit 78f03fc

Browse files
authored
Fixes file uploader showing invalid file modal just one time (#5537)
* corrected buggy modal from uploader.vue and corrected linting * added reset in handleFiles
1 parent 7ce4b4c commit 78f03fc

File tree

1 file changed

+35
-28
lines changed
  • contentcuration/contentcuration/frontend/shared/views/files

1 file changed

+35
-28
lines changed

contentcuration/contentcuration/frontend/shared/views/files/Uploader.vue

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -208,36 +208,40 @@
208208
this.$emit('upload');
209209
210210
if (!this.readonly) {
211-
files = this.allowMultiple ? files : [files[0]];
212-
files = await this.validateFiles(files);
211+
try {
212+
files = this.allowMultiple ? files : [files[0]];
213+
files = await this.validateFiles(files);
213214
214-
// Show errors if relevant
215-
if (this.totalUploadSize > this.availableSpace) {
216-
this.showStorageExceededAlert = true;
217-
return;
218-
} else if (this.unsupportedFiles.length) {
219-
this.showUnsupportedFilesAlert = true;
220-
} else if (this.tooLargeFiles.length) {
221-
this.showTooLargeFilesAlert = true;
222-
}
223-
return this.handleUploads(files).then(fileUploads => {
224-
const objects = fileUploads.map(f => f.fileObject).filter(f => !f.error);
225-
if (fileUploads.length) {
226-
for (const fileUpload of fileUploads) {
227-
fileUpload.uploadPromise
228-
.then(fileObject => {
229-
if (isFunction(this.uploadCompleteHandler)) {
230-
this.uploadCompleteHandler(this.getFileUpload(fileObject.id));
231-
}
232-
})
233-
.catch(() => {});
234-
}
235-
if (isFunction(this.uploadingHandler)) {
236-
this.uploadingHandler(this.allowMultiple ? objects : objects[0]);
237-
}
215+
// Show errors if relevant
216+
if (this.totalUploadSize > this.availableSpace) {
217+
this.showStorageExceededAlert = true;
218+
return;
219+
} else if (this.unsupportedFiles.length) {
220+
this.showUnsupportedFilesAlert = true;
221+
} else if (this.tooLargeFiles.length) {
222+
this.showTooLargeFilesAlert = true;
238223
}
239-
return objects;
240-
});
224+
return this.handleUploads(files).then(fileUploads => {
225+
const objects = fileUploads.map(f => f.fileObject).filter(f => !f.error);
226+
if (fileUploads.length) {
227+
for (const fileUpload of fileUploads) {
228+
fileUpload.uploadPromise
229+
.then(fileObject => {
230+
if (isFunction(this.uploadCompleteHandler)) {
231+
this.uploadCompleteHandler(this.getFileUpload(fileObject.id));
232+
}
233+
})
234+
.catch(() => {});
235+
}
236+
if (isFunction(this.uploadingHandler)) {
237+
this.uploadingHandler(this.allowMultiple ? objects : objects[0]);
238+
}
239+
}
240+
return objects;
241+
});
242+
} finally {
243+
this.resetFileInput();
244+
}
241245
}
242246
},
243247
handleUploads(files) {
@@ -255,6 +259,9 @@
255259
return fileUploads.filter(Boolean);
256260
});
257261
},
262+
resetFileInput() {
263+
this.$refs.fileUpload.value = '';
264+
},
258265
},
259266
$trs: {
260267
unsupportedFilesHeader: 'Unsupported files',

0 commit comments

Comments
 (0)