Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission pipe #124

Open
Nosfistis opened this issue Dec 22, 2019 · 8 comments
Open

Permission pipe #124

Nosfistis opened this issue Dec 22, 2019 · 8 comments

Comments

@Nosfistis
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x] Feature request
[ ] Documentation issue or request

While the directive usage is fine, sometimes it's useful having attributes based on permissions. For example, disabling a link cannot be done using directives. A better option would be an impure pipe permission,, returning true/false like so:

<button [disabled]="'changeSomethingPermission' | ngxPermission">Change</button>

I understand this might not be the most elegant design, but it would fit easily to any attribute, even component input ones.

@AlexKhymenko
Copy link
Owner

@Nosfistis This is great idea the pipe will only return true or false.. In this case problem with angular material would be fixed. But i actually need to find time for this. Probably after New Year :-)

@Nosfistis
Copy link
Author

Great! If you need any help I can prep a PR.

@AlexKhymenko
Copy link
Owner

@Nosfistis If You have PR please submit it :-)

@AlexKhymenko
Copy link
Owner

@Nosfistis I actually started figuring out. But i have some problems with API. How You want to use it.
For example i can create 2 pipes. ngxPermissionsOnly and ngxPermissionsExcept. But then i can't use them together.

@Nosfistis
Copy link
Author

I don't really see a case where both are needed. In the original directives, I also find the case of both [ngxPermissionsExcept]="['ADMIN', 'JOHNY']" and [ngxPermissionsOnly]="['MANAGER']" weird; doesn't it mean only 'MANAGER' can view that div?

If need be, one can combine the 2 pipes using:

<button [disabled]="('changeSomethingPermission' | ngxPermissionOnly) && ('changeSomethingElsePermission' | ngxPermissionExcept)">Change</button>

Then there is another idea of having the permissions as pipe argument:

<button [disabled]="permissionService.permissions$ | async | ngxPermission:'changeSomethingPermission'">Change</button>

@tplk
Copy link

tplk commented May 27, 2020

@AlexKhymenko hello, can you share your WIP version for now, please?

@AlexKhymenko
Copy link
Owner

@tplk it was on old computer. Now its lost forever :-(

@denes16
Copy link

denes16 commented Apr 6, 2022

Any news on this?.
I can create a pr, but please let me know where i have to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants