Skip to content

Commit

Permalink
fix(admin): edit attribute definition
Browse files Browse the repository at this point in the history
- Enable removal of existing attribute policy collections.
  • Loading branch information
sarkapalkovicova authored and HejdaJakub committed Nov 7, 2023
1 parent b561227 commit 248b065
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ export class EditAttributeDefinitionDialogComponent implements OnInit {
});
urn = `${this.attDef.namespace}:${this.attDef.friendlyName}`;
collections$ = new BehaviorSubject<AttributePolicyCollection[]>([]);
emptyCollections: AttributePolicyCollection[] = [
{
id: -1,
attributeId: this.data.attDef.id,
action: AttributeAction.READ,
policies: [],
},
];
services$: Observable<Service[]> = this.serviceService
.getServicesByAttributeDefinition(this.attDef.id)
.pipe(startWith([]));
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 248b065

Please sign in to comment.