From 248b065e9bc9383a71f80b2b6ef5e95331542250 Mon Sep 17 00:00:00 2001 From: sarkapalkovicova Date: Sat, 4 Nov 2023 00:23:22 +0100 Subject: [PATCH] fix(admin): edit attribute definition - Enable removal of existing attribute policy collections. --- .../edit-attribute-definition-dialog.component.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/admin-gui/src/app/shared/components/dialogs/edit-attribute-definition-dialog/edit-attribute-definition-dialog.component.ts b/apps/admin-gui/src/app/shared/components/dialogs/edit-attribute-definition-dialog/edit-attribute-definition-dialog.component.ts index 9fc7fbfb4..c9cb78d55 100644 --- a/apps/admin-gui/src/app/shared/components/dialogs/edit-attribute-definition-dialog/edit-attribute-definition-dialog.component.ts +++ b/apps/admin-gui/src/app/shared/components/dialogs/edit-attribute-definition-dialog/edit-attribute-definition-dialog.component.ts @@ -47,6 +47,14 @@ export class EditAttributeDefinitionDialogComponent implements OnInit { }); urn = `${this.attDef.namespace}:${this.attDef.friendlyName}`; collections$ = new BehaviorSubject([]); + emptyCollections: AttributePolicyCollection[] = [ + { + id: -1, + attributeId: this.data.attDef.id, + action: AttributeAction.READ, + policies: [], + }, + ]; services$: Observable = this.serviceService .getServicesByAttributeDefinition(this.attDef.id) .pipe(startWith([])); @@ -85,7 +93,12 @@ export class EditAttributeDefinitionDialogComponent implements OnInit { switchMap(() => of(this.collections$.getValue())), this.attributeRightsService.filterNullInPolicy(), switchMap((collections) => - this.attributesManager.setAttributePolicyCollections({ policyCollections: collections }), + // If list of collections is empty then pass empty collection with attribute definition ID for which all existing policies should be removed. + this.attributesManager.setAttributePolicyCollections( + collections.length > 0 + ? { policyCollections: collections } + : { policyCollections: this.emptyCollections }, + ), ), switchMap(() => this.attributeRightsService.updateAttributeAction(