1.2 #11
2 changed files with 14 additions and 5 deletions
|
@ -43,7 +43,7 @@
|
||||||
<ng-container matColumnDef="actions">
|
<ng-container matColumnDef="actions">
|
||||||
<th mat-header-cell *matHeaderCellDef> Actions </th>
|
<th mat-header-cell *matHeaderCellDef> Actions </th>
|
||||||
<td mat-cell *matCellDef="let element">
|
<td mat-cell *matCellDef="let element">
|
||||||
<button mat-flat-button color="warn" (click)="deleteLink(element.id)">Delete</button>
|
<button mat-flat-button color="warn" (click)="deleteLink(element)">Delete</button>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|
|
@ -54,10 +54,19 @@ export class DashboardComponent {
|
||||||
this.router.navigate(['create-link']);
|
this.router.navigate(['create-link']);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteLink(id: string) {
|
deleteLink(link: Link) {
|
||||||
this.linkService.deleteLink(id); // TODO Check if something went wrong
|
this.dialog.open(ConfirmationModalComponent, {
|
||||||
this.links = this.links.filter(link => {
|
data: {
|
||||||
return link.id != id;
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue