From 54ed94c552e0fac509961bbcc3ba613a56cfc0c6 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Mon, 8 Mar 2021 12:08:40 +0900 Subject: [PATCH] Add success event --- frontend/components/document/FormUpload.vue | 49 +++++++++---------- frontend/pages/projects/_id/dataset/index.vue | 1 + 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/frontend/components/document/FormUpload.vue b/frontend/components/document/FormUpload.vue index 33393066..7a6caf2a 100644 --- a/frontend/components/document/FormUpload.vue +++ b/frontend/components/document/FormUpload.vue @@ -100,39 +100,34 @@ export default { cancel() { this.$emit('cancel') }, - validate() { - return this.$refs.form.validate() - }, reset() { this.$refs.form.reset() }, create() { - if (this.validate()) { - this.errors = [] - const promises = [] - const type = this.selectedFormat.type - this.file.forEach((item) => { - promises.push({ - format: type, - file: item - }) - }) - let p = Promise.resolve() - promises.forEach((item) => { - p = p.then(() => this.uploadDocument(item.file, item.format)).catch(() => { - this.errors.push(item.file.name) - this.showError = true - }) + this.errors = [] + const promises = [] + const type = this.selectedFormat.type + this.file.forEach((item) => { + promises.push({ + format: type, + file: item }) - p.finally(() => { - if (!this.errors.length) { - this.reset() - this.cancel() - } else { - this.errorMsg = this.errors.join(', ') - } + }) + let p = Promise.resolve() + promises.forEach((item) => { + p = p.then(() => this.uploadDocument(item.file, item.format)).catch(() => { + this.errors.push(item.file.name) + this.showError = true }) - } + }) + p.finally(() => { + if (!this.errors.length) { + this.reset() + this.$emit('success') + } else { + this.errorMsg = this.errors.join(', ') + } + }) } } } diff --git a/frontend/pages/projects/_id/dataset/index.vue b/frontend/pages/projects/_id/dataset/index.vue index eb6a918e..0078e6e3 100644 --- a/frontend/pages/projects/_id/dataset/index.vue +++ b/frontend/pages/projects/_id/dataset/index.vue @@ -40,6 +40,7 @@ :formats="project.uploadFormats" :upload-document="upload" @cancel="dialogUpload=false" + @success="$fetch();dialogUpload=false" />