From 1375d089e41fb80579f3cc485dc82ec0ff7dda47 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 9 Feb 2022 13:09:09 +0900 Subject: [PATCH] Simplify label list page --- frontend/pages/projects/_id/labels/index.vue | 62 ++------------------ 1 file changed, 4 insertions(+), 58 deletions(-) diff --git a/frontend/pages/projects/_id/labels/index.vue b/frontend/pages/projects/_id/labels/index.vue index 95d22dae..3db16231 100644 --- a/frontend/pages/projects/_id/labels/index.vue +++ b/frontend/pages/projects/_id/labels/index.vue @@ -18,15 +18,6 @@ > {{ $t('generic.delete') }} - - - import Vue from 'vue' import ActionMenu from '@/components/label/ActionMenu.vue' -import FormCreate from '@/components/label/FormCreate.vue' import FormDelete from '@/components/label/FormDelete.vue' import FormUpload from '@/components/label/FormUpload.vue' import LabelList from '@/components/label/LabelList.vue' @@ -66,7 +56,6 @@ export default Vue.extend({ components: { ActionMenu, - FormCreate, FormDelete, FormUpload, LabelList @@ -85,24 +74,8 @@ export default Vue.extend({ data() { return { - dialogCreate: false, dialogDelete: false, dialogUpload: false, - editedIndex: -1, - editedItem: { - text: '', - prefixKey: null, - suffixKey: null, - backgroundColor: '#2196F3', - textColor: '#ffffff' - } as LabelDTO, - defaultItem: { - text: '', - prefixKey: null, - suffixKey: null, - backgroundColor: '#2196F3', - textColor: '#ffffff' - } as LabelDTO, items: [] as LabelDTO[], selected: [] as LabelDTO[], isLoading: false, @@ -116,18 +89,11 @@ export default Vue.extend({ canDelete(): boolean { return this.selected.length > 0 }, + projectId(): string { return this.$route.params.id }, - usedNames(): string[] { - const item = this.items[this.editedIndex] // to remove myself - return this.items.filter(_ => _ !== item).map(item => item.text) - }, - usedKeys(): string[] { - const item = this.items[this.editedIndex] // to remove myself - return this.items.filter(_ => _ !== item).map(item => item.suffixKey) - .filter(item => item !==null) as string[] - }, + hasMultiType(): boolean { if ('projectType' in this.project) { return this.project.projectType === 'IntentDetectionAndSlotFilling' @@ -185,25 +151,7 @@ export default Vue.extend({ this.items = await this.service.list(this.projectId) this.isLoading = false }, - - async save() { - if (this.editedIndex > -1) { - await this.service.update(this.projectId, this.editedItem) - } else { - await this.service.create(this.projectId, this.editedItem) - } - await this.list() - this.close() - }, - - close() { - this.dialogCreate = false - this.$nextTick(() => { - this.editedItem = Object.assign({}, this.defaultItem) - this.editedIndex = -1 - }) - }, - + async remove() { await this.service.bulkDelete(this.projectId, this.selected) this.list() @@ -235,9 +183,7 @@ export default Vue.extend({ }, editItem(item: LabelDTO) { - this.editedIndex = this.items.indexOf(item) - this.editedItem = Object.assign({}, item) - this.dialogCreate = true + this.$router.push(`labels/${item.id}/edit?type=${this.labelType}`) } } })