From 9e1bf2d5f87dc85b37c4b71c3b9b89547030d071 Mon Sep 17 00:00:00 2001 From: Stefan Plociennik <stefan.plociennik@mni.thm.de> Date: Sun, 2 May 2021 12:44:18 +0200 Subject: [PATCH] implemented delete confirm dialog; fixed a bug with editing keyword --- .../topic-cloud-confirm-dialog.component.html | 6 ++--- .../topic-cloud-dialog.component.html | 2 +- .../topic-cloud-dialog.component.ts | 22 +++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/app/components/shared/_dialogs/topic-cloud-confirm-dialog/topic-cloud-confirm-dialog.component.html b/src/app/components/shared/_dialogs/topic-cloud-confirm-dialog/topic-cloud-confirm-dialog.component.html index 8593dfb76..2936174ed 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-confirm-dialog/topic-cloud-confirm-dialog.component.html +++ b/src/app/components/shared/_dialogs/topic-cloud-confirm-dialog/topic-cloud-confirm-dialog.component.html @@ -1,6 +1,6 @@ -<h1 mat-dialog-title>Do you really want to delete {{data.topic}}</h1> +<h1 mat-dialog-title>Do you really want to delete the topic "{{data.topic}}"?</h1> <div mat-dialog-actions> - <button mat-button (click)="onNoClick()">No</button> - <button mat-button [mat-dialog-close]="data.topic" cdkFocusInitial>Yes</button> + <button mat-button [mat-dialog-close]="false">No</button> + <button mat-button [mat-dialog-close]="true" cdkFocusInitial>Yes</button> </div> diff --git a/src/app/components/shared/_dialogs/topic-cloud-dialog/topic-cloud-dialog.component.html b/src/app/components/shared/_dialogs/topic-cloud-dialog/topic-cloud-dialog.component.html index 0c0914c1e..8abcfc330 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-dialog/topic-cloud-dialog.component.html +++ b/src/app/components/shared/_dialogs/topic-cloud-dialog/topic-cloud-dialog.component.html @@ -23,7 +23,7 @@ <mat-icon class="primary">edit</mat-icon> </button> <button mat-icon-button style="align-self:flex-end;" - (click)="openConfirmDialog(keyword.keywordID)"> + (click)="openConfirmDialog(keyword)"> <mat-icon class="warn">delete</mat-icon> </button> </div> diff --git a/src/app/components/shared/_dialogs/topic-cloud-dialog/topic-cloud-dialog.component.ts b/src/app/components/shared/_dialogs/topic-cloud-dialog/topic-cloud-dialog.component.ts index 7af9be234..792432ac8 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-dialog/topic-cloud-dialog.component.ts +++ b/src/app/components/shared/_dialogs/topic-cloud-dialog/topic-cloud-dialog.component.ts @@ -62,12 +62,11 @@ export class TopicCloudDialogComponent implements OnInit { } cancelEdit(): void { - console.log("edit canceled"); this.edit = false; + this.newKeyword = ''; } confirmEdit(id: number): void { - console.log("edit confirmed "+id); this.keywords.map(keyword => { if (keyword.keywordID == id) keyword.keyword = this.newKeyword; @@ -76,18 +75,17 @@ export class TopicCloudDialogComponent implements OnInit { this.newKeyword = ''; } - openConfirmDialog(id: number): void { - let keyword = ""; - - this.keywords.map(k => { - if (k.keywordID == id) { - keyword = k.keyword; - } - }); - + openConfirmDialog(keyword: Keyword): void { const confirmDialogRef = this.confirmDialog.open(TopicCloudConfirmDialogComponent, { - data: {topic: keyword} + data: {topic: keyword.keyword} }); + + confirmDialogRef.afterClosed().subscribe(result => { + console.log(`dialog result: ${result}`); + if (result == true) { + this.deleteKeyword(keyword.keywordID); + } + }) } } -- GitLab