@studiohyperdrive/ngx-auth
Version:
A library of core authentication functionality used with @studiohyperdrive/types-auth.
65 lines (64 loc) • 2.8 kB
TypeScript
import { ChangeDetectorRef, OnDestroy, TemplateRef, ViewContainerRef } from '@angular/core';
import { NgxAuthenticationAbstractService } from '../../abstracts';
import * as i0 from "@angular/core";
/**
* A directive that will render a part of the template based on whether the required permissions(s) are provided.
*
* Based upon `*ngIf`. See https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_if.ts
*/
export declare class NgxHasPermissionDirective<PermissionType extends string> implements OnDestroy {
private viewContainer;
private readonly authenticationService;
private readonly cdRef;
/**
* The destroyed state of the directive
*/
private destroyed$;
/**
* The needed templateRefs
*/
private thenTemplateRef;
private thenViewRef;
private elseTemplateRef;
private elseViewRef;
/**
* The (list of) permission(s) we need to check
*/
private permission;
/**
* Whether the permission should be enabled
*/
private shouldHavePermission;
/**
* Whether all permissions should be enabled
*/
private shouldHaveAllPermissions;
/**
* A permission or list of permissions the item should have
*/
set ngxHasPermission(permission: PermissionType | PermissionType[]);
/**
* The else template in case the permission is not enabled
*/
set ngxHasPermissionElse(ngTemplate: TemplateRef<any>);
/**
* Whether the permission should be enabled, by default this is true
*/
set ngxHasPermissionShouldHavePermission(shouldHavePermissionEnabled: boolean);
/**
* Whether all permissions should be enabled, by default this is true
*/
set ngxHasPermissionShouldHaveAllPermissions(shouldHaveAllPermissions: boolean);
constructor(templateRef: TemplateRef<any>, viewContainer: ViewContainerRef, authenticationService: NgxAuthenticationAbstractService, cdRef: ChangeDetectorRef);
ngOnDestroy(): void;
/**
* Updates the view and hides/renders the template as needed
*/
private updateView;
/**
* Dispose the current subscription
*/
private dispose;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxHasPermissionDirective<any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<NgxHasPermissionDirective<any>, "[ngxHasPermission]", never, { "ngxHasPermission": { "alias": "ngxHasPermission"; "required": false; }; "ngxHasPermissionElse": { "alias": "ngxHasPermissionElse"; "required": false; }; "ngxHasPermissionShouldHavePermission": { "alias": "ngxHasPermissionShouldHavePermission"; "required": false; }; "ngxHasPermissionShouldHaveAllPermissions": { "alias": "ngxHasPermissionShouldHaveAllPermissions"; "required": false; }; }, {}, never, never, true, never>;
}