Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
fix(perm.pipe): Add arguments for pipe: defaultValue: boolean = true,…
Browse files Browse the repository at this point in the history
… trueValue: any = true, falseValue: any = false
  • Loading branch information
EndyKaufman committed May 6, 2018
1 parent 62cd4c6 commit 4189e83
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libs/@rucken/web/src/shared/pipes/perm.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ export class PermPipe implements PipeTransform, OnDestroy {
this._destroyed$.next(true);
this._destroyed$.complete();
}
transform(value: string | string[], args: any): any {
transform(key: string | string[], defaultValue: boolean = true, trueValue: any = true, falseValue: any = false): any {
return new Observable<boolean>(observer =>
this._permissionsService.permissions$.pipe(
takeUntil(this._destroyed$)
).subscribe(permissions => {
if (Object.keys(permissions).length) {
this._permissionsService.hasPermission(value).then(result => {
observer.next(result);
this._permissionsService.hasPermission(key).then(result => {
observer.next(result ? trueValue : falseValue);
});
} else {
observer.next(true);
observer.next(defaultValue ? trueValue : falseValue);
}
})
);
Expand Down

0 comments on commit 4189e83

Please # to comment.