From b02222eea000a2b92be055bbc82c8b490293fd8e Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 1 Feb 2022 11:14:24 +0900 Subject: [PATCH 1/3] Fix label creation --- frontend/pages/projects/_id/labels/index.vue | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/frontend/pages/projects/_id/labels/index.vue b/frontend/pages/projects/_id/labels/index.vue index c3ae57a3..c039c34d 100644 --- a/frontend/pages/projects/_id/labels/index.vue +++ b/frontend/pages/projects/_id/labels/index.vue @@ -112,15 +112,6 @@ export default Vue.extend({ } }, - // async fetch() { - // this.items = [] - // this.isLoading = true - // console.log('start fetch') - // this.items = await this.service.list(this.projectId) - // console.log('end fetch') - // this.isLoading = false - // }, - computed: { canDelete(): boolean { return this.selected.length > 0 @@ -171,23 +162,22 @@ export default Vue.extend({ async created() { this.project = await this.$services.project.findById(this.projectId) - this.list() + await this.list() }, methods: { async list() { - this.items = [] this.isLoading = true this.items = await this.service.list(this.projectId) this.isLoading = false }, - async create() { - await this.service.create(this.projectId, this.editedItem) + create(): any { + return this.service.create(this.projectId, this.editedItem) }, - async update() { - await this.service.update(this.projectId, this.editedItem) + update(): any { + return this.service.update(this.projectId, this.editedItem) }, async save() { From 68fa1da8e4e5c4fc2aa65df0511bf677dabf40be Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 1 Feb 2022 11:16:21 +0900 Subject: [PATCH 2/3] Fix LabelItem, resolve #1648 --- frontend/domain/models/label/label.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/domain/models/label/label.ts b/frontend/domain/models/label/label.ts index d028b51c..f7026844 100644 --- a/frontend/domain/models/label/label.ts +++ b/frontend/domain/models/label/label.ts @@ -7,7 +7,7 @@ export class LabelItem { @Expose({ name: 'prefix_key' }) prefixKey: string | null; - @Expose({ name: 'suffixKey' }) + @Expose({ name: 'suffix_key' }) suffixKey: string | null; @Expose({ name: 'background_color' }) From 90d3521bdcad7b282555c2f0f60aa24e990b701b Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 1 Feb 2022 11:24:56 +0900 Subject: [PATCH 3/3] Refactor label page, resolve #1648 --- frontend/pages/projects/_id/labels/index.vue | 12 ++---------- .../application/label/labelApplicationService.ts | 10 ++++++---- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/frontend/pages/projects/_id/labels/index.vue b/frontend/pages/projects/_id/labels/index.vue index c039c34d..4d771308 100644 --- a/frontend/pages/projects/_id/labels/index.vue +++ b/frontend/pages/projects/_id/labels/index.vue @@ -172,19 +172,11 @@ export default Vue.extend({ this.isLoading = false }, - create(): any { - return this.service.create(this.projectId, this.editedItem) - }, - - update(): any { - return this.service.update(this.projectId, this.editedItem) - }, - async save() { if (this.editedIndex > -1) { - await this.update() + await this.service.update(this.projectId, this.editedItem) } else { - await this.create() + await this.service.create(this.projectId, this.editedItem) } await this.list() this.close() diff --git a/frontend/services/application/label/labelApplicationService.ts b/frontend/services/application/label/labelApplicationService.ts index 48deffe1..31a1e263 100644 --- a/frontend/services/application/label/labelApplicationService.ts +++ b/frontend/services/application/label/labelApplicationService.ts @@ -14,7 +14,7 @@ export class LabelApplicationService { return items.map(item => new LabelDTO(item)) } - public create(projectId: string, item: CreateLabelCommand): void { + public async create(projectId: string, item: CreateLabelCommand): Promise { // Todo: use auto mapping. const label = new LabelItem() label.text = item.text @@ -22,10 +22,11 @@ export class LabelApplicationService { label.suffixKey = item.suffixKey label.backgroundColor = item.backgroundColor label.textColor = item.textColor - this.repository.create(projectId, label) + const created = await this.repository.create(projectId, label) + return new LabelDTO(created) } - public update(projectId: string, item: LabelDTO): void { + public async update(projectId: string, item: LabelDTO): Promise { // Todo: use auto mapping. const label = new LabelItem() label.id = item.id @@ -34,7 +35,8 @@ export class LabelApplicationService { label.suffixKey = item.suffixKey label.backgroundColor = item.backgroundColor label.textColor = item.textColor - this.repository.update(projectId, label) + const updated = await this.repository.update(projectId, label) + return new LabelDTO(updated) } public bulkDelete(projectId: string, items: LabelDTO[]): Promise {