RafaelVidaurre / angular-permission

Simple route authorization via roles/permissions
MIT License
1.13k stars 212 forks source link

permissions context #436

Open LaserUnicorns opened 7 years ago

LaserUnicorns commented 7 years ago

It would be nice to have some mechanism for nesting permission options (sref, except, only, authorized/unauthorized methods).

For example

<!-- defines context -->
<div permission-context permission-only="'dashboard.view'"> 
  <h1>Hello!</h1>

  <!-- defines nested context and partially(?) overrides options -->
  <div permission-context permission-only="'dashboard.edit'"> 

    <!-- uses permission from context -->
    <input permission> 
    <button permission><button>

    <!-- partially overrides context options -->
    <input type="password" permission permission-only="'dashboard.editPassword'"> 
  </div>
</div>

That way we can write reusable permissions-aware components without explicitly specifying permissions/roles in them. Also reduces boilerplate when we have many elements with the same permissions.