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 8593dfb767a9444fadf7f0f4a2ac15587d93fa26..2936174ed18150a78536b7e4206ac86c9303a4fb 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 0c0914c1eff4cbd5e97610418874fbeb6df6cc9a..8abcfc330e115e9d3a31f4e8529c373cfbc113a4 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 7af9be234616ea95a925e57fb4c2807bdbcf5ebc..792432ac82938139388a8871307359196620478f 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); + } + }) } }