From e0d9b8295eb876a4b7629ae055b51cf98bd58a90 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Tue, 21 Jan 2025 13:13:41 +0100 Subject: [PATCH] feat: update deleteLink to use link object directly --- src/app/dashboard/dashboard.component.html | 2 +- src/app/dashboard/dashboard.component.ts | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html index 3b93366..4c363ef 100644 --- a/src/app/dashboard/dashboard.component.html +++ b/src/app/dashboard/dashboard.component.html @@ -43,7 +43,7 @@ Actions - + diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 1b0989d..1af3fbf 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -54,10 +54,19 @@ export class DashboardComponent { this.router.navigate(['create-link']); } - deleteLink(id: string) { - this.linkService.deleteLink(id); // TODO Check if something went wrong - this.links = this.links.filter(link => { - return link.id != id; + deleteLink(link: Link) { + this.dialog.open(ConfirmationModalComponent, { + data: { + title: "Are you sure?", + description: "Are you sure that you want to delete " + link.name + "?", + } + }).afterClosed().subscribe((accepted: boolean) => { + if (accepted) { + this.linkService.deleteLink(link.id); // TODO Check if something went wrong + this.links = this.links.filter(givenLink => { + return givenLink.id != link.id; + }); + } }); } }