Browse Source

Add success event

pull/1242/head
Hironsan 3 years ago
parent
commit
54ed94c552
2 changed files with 23 additions and 27 deletions
  1. 49
      frontend/components/document/FormUpload.vue
  2. 1
      frontend/pages/projects/_id/dataset/index.vue

49
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(', ')
}
})
}
}
}

1
frontend/pages/projects/_id/dataset/index.vue

@ -40,6 +40,7 @@
:formats="project.uploadFormats"
:upload-document="upload"
@cancel="dialogUpload=false"
@success="$fetch();dialogUpload=false"
/>
</v-dialog>
<v-dialog v-model="dialogDownload">

Loading…
Cancel
Save