Skip to content

Commit 248b065

Browse files
sarkapalkovicovaHejdaJakub
authored andcommitted
fix(admin): edit attribute definition
- Enable removal of existing attribute policy collections.
1 parent b561227 commit 248b065

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

apps/admin-gui/src/app/shared/components/dialogs/edit-attribute-definition-dialog/edit-attribute-definition-dialog.component.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ export class EditAttributeDefinitionDialogComponent implements OnInit {
4747
});
4848
urn = `${this.attDef.namespace}:${this.attDef.friendlyName}`;
4949
collections$ = new BehaviorSubject<AttributePolicyCollection[]>([]);
50+
emptyCollections: AttributePolicyCollection[] = [
51+
{
52+
id: -1,
53+
attributeId: this.data.attDef.id,
54+
action: AttributeAction.READ,
55+
policies: [],
56+
},
57+
];
5058
services$: Observable<Service[]> = this.serviceService
5159
.getServicesByAttributeDefinition(this.attDef.id)
5260
.pipe(startWith([]));
@@ -85,7 +93,12 @@ export class EditAttributeDefinitionDialogComponent implements OnInit {
8593
switchMap(() => of(this.collections$.getValue())),
8694
this.attributeRightsService.filterNullInPolicy(),
8795
switchMap((collections) =>
88-
this.attributesManager.setAttributePolicyCollections({ policyCollections: collections }),
96+
// If list of collections is empty then pass empty collection with attribute definition ID for which all existing policies should be removed.
97+
this.attributesManager.setAttributePolicyCollections(
98+
collections.length > 0
99+
? { policyCollections: collections }
100+
: { policyCollections: this.emptyCollections },
101+
),
89102
),
90103
switchMap(() =>
91104
this.attributeRightsService.updateAttributeAction(

0 commit comments

Comments
 (0)