Skip to content

Commit

Permalink
Show warning msg before try to delete operator
Browse files Browse the repository at this point in the history
  • Loading branch information
reiterl committed Oct 10, 2023
1 parent aa36d6b commit 5599882
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ <h2 mat-dialog-title>
<li>{{ 'Is manager' | translate }}</li>
</ul>
</ng-container>
<ng-container *ngIf="isOperator(user)">
<p class="padding-left-25">
{{ 'The account is the operator and cannot be deleted' | translate }}
</p>
</ng-container>
</ng-container>
<ng-container *ngIf="user.error">
<p class="padding-left-25">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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];
Expand All @@ -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;
}
}

0 comments on commit 5599882

Please sign in to comment.