UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

49 lines 1.95 kB
import { TemplateRef, ViewContainerRef } from '@angular/core'; import { Permissions } from './permissions.service'; import * as i0 from "@angular/core"; /** * A structural directive that conditionally includes a template only if the user has * all or any of the roles passed as an input. By default the directive checks all roles: * * ```html * <button *c8yIfAllowed="['ROLE_RECORD_DELETE', 'ROLE_ENTRY_DELETE']" (click)="delete()" title="Delete"> * Delete * </button> * ``` * * To check if the user has any of the required roles to view the element you need to use the `allowAny` input: * * ```html * <button *c8yIfAllowed="['ROLE_RECORD_DELETE', 'ROLE_ENTRY_DELETE']; allowAny: true" (click)="delete()" title="Delete"> * Delete * </button> * ``` * * or use the shorter version * * ```html * <button *c8yIfAllowed="['ROLE_RECORD_DELETE', 'ROLE_ENTRY_DELETE']; allowAny" (click)="delete()" title="Delete"> * Delete * </button> * ``` */ export declare class IfAllowedDirective { private template; private container; private permissions; /** * One or many roles required for the element to be rendered */ set c8yIfAllowed(roleIds: string | string[]); /** * Switches to the mode where at least one of the provided roles is sufficient for the element to be rendered */ set c8yIfAllowedAllowAny(allowAny: boolean); private rolesIds; private allowAny; constructor(template: TemplateRef<any>, container: ViewContainerRef, permissions: Permissions); ngOnInit(): void; static ɵfac: i0.ɵɵFactoryDeclaration<IfAllowedDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<IfAllowedDirective, "[c8yIfAllowed]", never, { "c8yIfAllowed": { "alias": "c8yIfAllowed"; "required": false; }; "c8yIfAllowedAllowAny": { "alias": "c8yIfAllowedAllowAny"; "required": false; }; }, {}, never, never, true, never>; } //# sourceMappingURL=if-allowed.directive.d.ts.map