Skip to content

Commit

Permalink
Add in application test on strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Khymenko authored and Oleksandr Khymenko committed Mar 8, 2018
1 parent fb3974a commit 094329c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@
</ng-template>


<button *ngxPermissionsOnly="'NEVER EXIST'"> SHOULD BE DISABLES</button>
<button *ngxPermissionsOnly="'ADMIN'"> SHOULD NOt BE DISABLES</button>


<div> ENd on lazy ISOLATE Module</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { NgxRolesService } from 'ngx-permissions';
import { Component, OnInit, Renderer2, TemplateRef } from '@angular/core';
import { NgxRolesService, NgxPermissionsConfigurationService, NgxPermissionsService } from 'ngx-permissions';

@Component({
selector: 'app-lazy-role-isolate-test',
Expand All @@ -8,9 +8,18 @@ import { NgxRolesService } from 'ngx-permissions';
})
export class LazyRoleIsolateTestComponent implements OnInit {

constructor(private rolesService: NgxRolesService) { }
constructor(private rolesService: NgxRolesService,
private permissionsService: NgxPermissionsService,
private renderer: Renderer2,
private configService: NgxPermissionsConfigurationService) { }

ngOnInit() {
this.configService.addPermissionStrategy('lol', (tf: TemplateRef<any>) => {
this.renderer.setAttribute(tf.elementRef.nativeElement.nextSibling, 'disabled', 'true');
});

this.configService.setDefaultOnUnauthorizedStrategy('lol');
this.permissionsService.addPermission('ADMIN')
this.rolesService.addRole('ADMIN', ['NICE']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { LazyRoleIsolateTestComponent } from './lazy-role-isolate-test/lazy-role
LazyIsolateRolesRoutingModule,
NgxPermissionsModule.forChild({
permissionsIsolate: true,
rolesIsolate: true
rolesIsolate: true,
configurationIsolate: true
})
],
declarations: [
Expand Down

0 comments on commit 094329c

Please sign in to comment.