update permissions paths/directives

This commit is contained in:
Dan Percic 2023-03-19 14:33:40 +02:00
parent 1a4e79529b
commit 39e862b129
4 changed files with 4 additions and 12 deletions

View File

@ -21,10 +21,6 @@ export class IqserAllowDirective extends IqserPermissionsDirective implements On
static ngTemplateGuard_allow: 'binding'; static ngTemplateGuard_allow: 'binding';
#deny?: string | List; #deny?: string | List;
constructor(templateRef: TemplateRef<unknown>) {
super(templateRef);
}
@Input() @Input()
set allow(value: string | List) { set allow(value: string | List) {
this.setPermissions(value); this.setPermissions(value);

View File

@ -20,10 +20,6 @@ export class IqserDenyDirective extends IqserPermissionsDirective implements OnD
*/ */
static ngTemplateGuard_deny: 'binding'; static ngTemplateGuard_deny: 'binding';
constructor(templateRef: TemplateRef<unknown>) {
super(templateRef);
}
@Input() @Input()
set deny(value: string | List) { set deny(value: string | List) {
this.setPermissions(value); this.setPermissions(value);

View File

@ -29,7 +29,7 @@ export abstract class IqserPermissionsDirective implements OnDestroy, OnInit {
protected readonly _viewContainer = inject(ViewContainerRef); protected readonly _viewContainer = inject(ViewContainerRef);
protected readonly _changeDetector = inject(ChangeDetectorRef); protected readonly _changeDetector = inject(ChangeDetectorRef);
protected _permissions?: string | List; protected _permissions?: string | List;
protected _thenTemplateRef: TemplateRef<unknown>; protected _thenTemplateRef = inject(TemplateRef<unknown>);
protected _elseTemplateRef?: TemplateRef<unknown>; protected _elseTemplateRef?: TemplateRef<unknown>;
protected _thenViewRef: EmbeddedViewRef<unknown> | boolean = false; protected _thenViewRef: EmbeddedViewRef<unknown> | boolean = false;
protected _elseViewRef: EmbeddedViewRef<unknown> | boolean = false; protected _elseViewRef: EmbeddedViewRef<unknown> | boolean = false;
@ -37,9 +37,7 @@ export abstract class IqserPermissionsDirective implements OnDestroy, OnInit {
protected readonly _subscription = new Subscription(); protected readonly _subscription = new Subscription();
protected readonly _if = new BehaviorSubject<Promise<boolean> | Observable<boolean>>(of(true)); protected readonly _if = new BehaviorSubject<Promise<boolean> | Observable<boolean>>(of(true));
protected constructor(templateRef: TemplateRef<unknown>) { protected constructor() {
this._thenTemplateRef = templateRef;
const ifCondition$ = this._if.pipe(switchMap(condition => condition)); const ifCondition$ = this._if.pipe(switchMap(condition => condition));
this._subscription = combineLatest([ifCondition$, this._updateView]) this._subscription = combineLatest([ifCondition$, this._updateView])

View File

@ -3,4 +3,6 @@ export * from './services/permissions-guard.service';
export * from './services/permissions.service'; export * from './services/permissions.service';
export * from './services/roles.service'; export * from './services/roles.service';
export * from './directives/permissions.directive'; export * from './directives/permissions.directive';
export * from './directives/allow.directive';
export * from './directives/deny.directive';
export * from './utils'; export * from './utils';