From 5599882640798c52239c10eb56c38d69b87fc729 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Tue, 10 Oct 2023 13:27:01 +0200 Subject: [PATCH 1/2] Show warning msg before try to delete operator --- .../get-user-related-models-presenter.service.ts | 1 + .../user-delete-dialog.component.html | 5 +++++ .../user-delete-dialog/user-delete-dialog.component.ts | 10 +++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/client/src/app/gateways/presenter/get-user-related-models-presenter.service.ts b/client/src/app/gateways/presenter/get-user-related-models-presenter.service.ts index b2f974441a..164d224161 100644 --- a/client/src/app/gateways/presenter/get-user-related-models-presenter.service.ts +++ b/client/src/app/gateways/presenter/get-user-related-models-presenter.service.ts @@ -16,6 +16,7 @@ export interface GetUserRelatedModelsUser { motion_submitter_ids: Id[]; }[]; committees?: GetUserRelatedModelsCommittee[]; + name?: string; error?: string; // This is in case the presenter fails in an unpredicted way } diff --git a/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.html b/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.html index 7fe2929cd7..a468d36e0f 100644 --- a/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.html +++ b/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.html @@ -115,6 +115,11 @@

  • {{ 'Is manager' | translate }}
  • + +

    + {{ 'The account is the operator and cannot be deleted' | translate }} +

    +

    diff --git a/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.ts b/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.ts index 054e7083f4..851a6fd0ae 100644 --- a/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.ts +++ b/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.ts @@ -7,6 +7,7 @@ import { GetUserRelatedModelsUser } from 'src/app/gateways/presenter'; import { ViewUser } from 'src/app/site/pages/meetings/view-models/view-user'; +import { OperatorService } from 'src/app/site/services/operator.service'; interface UserDeleteDialogConfig { toRemove: ViewUser[]; @@ -50,7 +51,10 @@ export class UserDeleteDialogComponent implements OnInit { public selectedUser: GetUserRelatedModelsUser | ViewUser = null; - public constructor(@Inject(MAT_DIALOG_DATA) private data: UserDeleteDialogConfig) {} + public constructor( + @Inject(MAT_DIALOG_DATA) private data: UserDeleteDialogConfig, + private operator: OperatorService + ) {} public ngOnInit(): void { this.selectedUser = this.toDeleteUsers[0] || this.toRemoveUsers[0]; @@ -67,4 +71,8 @@ export class UserDeleteDialogComponent implements OnInit { public getManagedCommittees(user: GetUserRelatedModelsUser): GetUserRelatedModelsCommittee[] { return (user.committees || []).filter(committee => committee.cml === CML.can_manage); } + + public isOperator(user: GetUserRelatedModelsUser): boolean { + return user.name == this.operator.user.name; + } } From 26cb3790ce90ad307323cecbf573ab6b90016aa9 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Wed, 11 Oct 2023 10:15:29 +0200 Subject: [PATCH 2/2] Add id to deleteTo data and compare with operatorId --- .../presenter/get-user-related-models-presenter.service.ts | 1 + .../user-delete-dialog/user-delete-dialog.component.ts | 2 +- .../user-components/services/user-delete-dialog.service.ts | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/app/gateways/presenter/get-user-related-models-presenter.service.ts b/client/src/app/gateways/presenter/get-user-related-models-presenter.service.ts index 164d224161..fc751724e6 100644 --- a/client/src/app/gateways/presenter/get-user-related-models-presenter.service.ts +++ b/client/src/app/gateways/presenter/get-user-related-models-presenter.service.ts @@ -17,6 +17,7 @@ export interface GetUserRelatedModelsUser { }[]; committees?: GetUserRelatedModelsCommittee[]; name?: string; + id?: Id; error?: string; // This is in case the presenter fails in an unpredicted way } diff --git a/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.ts b/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.ts index 851a6fd0ae..0d13a93263 100644 --- a/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.ts +++ b/client/src/app/site/modules/user-components/components/user-delete-dialog/user-delete-dialog.component.ts @@ -73,6 +73,6 @@ export class UserDeleteDialogComponent implements OnInit { } public isOperator(user: GetUserRelatedModelsUser): boolean { - return user.name == this.operator.user.name; + return user.id == this.operator.operatorId; } } diff --git a/client/src/app/site/modules/user-components/services/user-delete-dialog.service.ts b/client/src/app/site/modules/user-components/services/user-delete-dialog.service.ts index 4169964964..b47b007619 100644 --- a/client/src/app/site/modules/user-components/services/user-delete-dialog.service.ts +++ b/client/src/app/site/modules/user-components/services/user-delete-dialog.service.ts @@ -52,7 +52,8 @@ export class UserDeleteDialogService extends BaseDialogService< } const toDelete = data.toDelete.map(user => ({ ...result[user.id], - name: user.getTitle() + name: user.getTitle(), + id: user.id })); const module = await import(`../user-components.module`).then(m => m.UserComponentsModule);