From d3fd51a48ab2c80d935bd77b1148ee04ccc15dfd Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sat, 6 May 2023 09:26:51 +0200 Subject: [PATCH] Remove id column, add confirmation dialog on delete --- .../platform/platform.component.html | 21 ++--------- .../components/platform/platform.component.ts | 36 ++++++++++++------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/apps/client/src/app/components/platform/platform.component.html b/apps/client/src/app/components/platform/platform.component.html index 5a27c7c80..b4560e0c4 100644 --- a/apps/client/src/app/components/platform/platform.component.html +++ b/apps/client/src/app/components/platform/platform.component.html @@ -5,27 +5,10 @@ class="gf-table w-100" mat-table matSort - matSortActive="id" + matSortActive="name" matSortDirection="asc" [dataSource]="dataSource" > - - - Id - - - {{ element.id }} - {{ - (element.id | slice : 0 : 5) + '...' - }} - - - Edit - + Delete diff --git a/apps/client/src/app/components/platform/platform.component.ts b/apps/client/src/app/components/platform/platform.component.ts index 5d11a632f..66dc1707f 100644 --- a/apps/client/src/app/components/platform/platform.component.ts +++ b/apps/client/src/app/components/platform/platform.component.ts @@ -30,7 +30,7 @@ export class AdminPlatformComponent implements OnInit, OnDestroy { public dataSource: MatTableDataSource = new MatTableDataSource(); public deviceType: string; - public displayedColumns = ['id', 'name', 'url', 'actions']; + public displayedColumns = ['name', 'url', 'actions']; public hasPermissionToCreatePlatform: boolean; public hasPermissionToDeletePlatform: boolean; public platforms: PlatformModel[]; @@ -90,7 +90,28 @@ export class AdminPlatformComponent implements OnInit, OnDestroy { this.fetchPlatforms(); } - public deletePlatform(aId: string) { + public onDeletePlatform(aId: string) { + const confirmation = confirm( + $localize`Do you really want to delete this platform?` + ); + + if (confirmation) { + this.deletePlatform(aId); + } + } + + public onUpdatePlatform(aPlatform: PlatformModel) { + this.router.navigate([], { + queryParams: { platformId: aPlatform.id, editDialog: true } + }); + } + + public ngOnDestroy() { + this.unsubscribeSubject.next(); + this.unsubscribeSubject.complete(); + } + + private deletePlatform(aId: string) { this.adminService .deletePlatform(aId) .pipe(takeUntil(this.unsubscribeSubject)) @@ -106,17 +127,6 @@ export class AdminPlatformComponent implements OnInit, OnDestroy { }); } - public onUpdatePlatform(aPlatform: PlatformModel) { - this.router.navigate([], { - queryParams: { platformId: aPlatform.id, editDialog: true } - }); - } - - public ngOnDestroy() { - this.unsubscribeSubject.next(); - this.unsubscribeSubject.complete(); - } - private fetchPlatforms() { this.adminService .fetchPlatforms()