From cabd70723be3c29196f5719cbff19acbdc7eb519 Mon Sep 17 00:00:00 2001 From: Martin Maul Date: Thu, 27 Jun 2024 17:13:13 +0200 Subject: [PATCH] chore(policy): 832 layout feedback --- .../policy-management/policies/policies.component.ts | 10 +++++++--- frontend/src/assets/locales/de/page.admin.json | 1 + frontend/src/assets/locales/en/page.admin.json | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/modules/page/admin/presentation/policy-management/policies/policies.component.ts b/frontend/src/app/modules/page/admin/presentation/policy-management/policies/policies.component.ts index f4e5a84374..9bb3de39c3 100644 --- a/frontend/src/app/modules/page/admin/presentation/policy-management/policies/policies.component.ts +++ b/frontend/src/app/modules/page/admin/presentation/policy-management/policies/policies.component.ts @@ -34,6 +34,7 @@ export class PoliciesComponent { ctrlKeyState: boolean = false; deselectPartTrigger$ = new Subject(); selectedPoliciesInfoLabel: string = 'pageAdmin.policyManagement.selectedPolicies'; + isDefaultSelected: boolean; constructor(public readonly policyFacade: PoliciesFacade, private readonly router: Router, private readonly toastService: ToastService, public dialog: MatDialog, private readonly roleService: RoleService) { window.addEventListener('keydown', (event) => { @@ -85,6 +86,8 @@ export class PoliciesComponent { multiSelection(selectedPolicies: Policy[]) { this.selectedPoliciesInfoLabel = selectedPolicies.length === 1 ? 'pageAdmin.policyManagement.selectedPolicy' : 'pageAdmin.policyManagement.selectedPolicies'; this.selectedPolicies = selectedPolicies; + this.isDefaultSelected = this.selectedPolicies.filter(policy => policy?.policyId === 'default-policy').length > 0; + console.log(this.isDefaultSelected); } openDetailedView(selectedPolicy: Record) { @@ -105,21 +108,22 @@ export class PoliciesComponent { dialogRef.afterClosed().subscribe(confirmation => { if (confirmation) { - this.deletePolicies(); + this.deletePolicies(this.isDefaultSelected); this.deselectPartTrigger$.next(this.selectedPolicies); } }); } - deletePolicies() { + deletePolicies(isDefaultSelected?: boolean) { this.policyFacade.deletePolicies(this.selectedPolicies).subscribe({ next: value => { this.toastService.success('pageAdmin.policyManagement.deleteSuccess'); this.policyFacade.setPolicies(); }, error: err => { - this.toastService.error('pageAdmin.policyManagement.deleteError'); + const errorMessage = isDefaultSelected === true ? 'pageAdmin.policyManagement.deleteErrorDefault' : 'pageAdmin.policyManagement.deleteError'; + this.toastService.error(errorMessage); }, }); } diff --git a/frontend/src/assets/locales/de/page.admin.json b/frontend/src/assets/locales/de/page.admin.json index 77c64a0758..5ddc62324a 100644 --- a/frontend/src/assets/locales/de/page.admin.json +++ b/frontend/src/assets/locales/de/page.admin.json @@ -60,6 +60,7 @@ "policyManagement" : "Richtlinienverwaltung", "deleteSuccess" : "Selektierte Richtlinien wurden erfolgreich gelöscht.", "deleteError" : "Fehler bei der Löschung der selektierten Richtlinien.", + "deleteErrorDefault" : "Fehler: Das Löschen der Standardrichtlinie namens 'default-policy' ist nicht erlaubt.", "confirm" : "Bestätigen", "policyDeletion" : "Löschen bestätigen", "deletionText" : "Möchten sie die selektierten Richtlinien löschen?", diff --git a/frontend/src/assets/locales/en/page.admin.json b/frontend/src/assets/locales/en/page.admin.json index adb2c3693f..06dbbc145e 100644 --- a/frontend/src/assets/locales/en/page.admin.json +++ b/frontend/src/assets/locales/en/page.admin.json @@ -60,6 +60,7 @@ "policyManagement" : "Policy management", "deleteSuccess" : "Successfully deleted the selected policies.", "deleteError" : "Error while deleting the selected policies.", + "deleteErrorDefault" : "Error: Deleting the default policy is not permitted.", "confirm" : "Confirm", "policyDeletion" : "Confirm deletion", "deletionText" : "Do you want to delete the selected policies?", @@ -95,7 +96,9 @@ "bpnsHint" : "Please provide a list of BPNs separated by comma", "bpnHint" : "Please provide a BPN", "savePolicy" : "Save policy", - "addConstraint" : "Add constraint" + "addConstraint" : "Add constraint", + "selectedPolicy" : "{{count}} Policy selected for this page.", + "selectedPolicies" : "{{count}} Policies selected for this page." } }