LP1891375 Perm Group Editor Indicates Overridden Perms
authorBill Erickson <berickxx@gmail.com>
Thu, 7 Jul 2022 16:29:22 +0000 (12:29 -0400)
committerMichele Morgan <mmorgan@noblenet.org>
Fri, 14 Oct 2022 18:57:09 +0000 (14:57 -0400)
When a permission for the selected group overrides the same permission
applied to a parent group, indicate it in the permission list with an
icon.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Open-ILS/src/eg2/src/app/staff/admin/server/perm-group-tree.component.html
Open-ILS/src/eg2/src/app/staff/admin/server/perm-group-tree.component.ts

index 9164124..fa9fc42 100644 (file)
                 Clear
               </button>
             </div>
+
+            <div class="row font-italic">
+              <span class="label-with-material-icon" i18n>
+                Permissions marked with a 
+                <span class="pl-1 pr-1 font-weight-bold text-danger 
+                  material-icons mat-icon-shrunk-in-button">new_releases</span>
+                override parent group permissions.
+              </span>
+            </div>
             
             <div class="row font-weight-bold">
               <div class="col-lg-5" i18n>Permissions</div>
             <div class="row" *ngFor="let map of groupPermMaps()"
                 [ngClass]="{'bg-warning': map.isdeleted()}">
               <div class="col-lg-5">
-                <span i18n-title 
-                  title="{{map.perm().description() || map.perm().code()}}">
-                  {{map.perm().code()}}
+                <span class="label-with-material-icon">
+                  <span i18n-title title="{{map.perm().description() || map.perm().code()}}">
+                    {{map.perm().code()}}
+                  </span>
+                  <span *ngIf="permOverrides(map)" 
+                    i18n-title title="Permission Overrides a Parent Group Permission"
+                    class="pl-1 font-weight-bold text-danger material-icons mat-icon-shrunk-in-button"
+                    i18n>new_releases</span>
                 </span>
               </div>
               <ng-container *ngIf="permIsInherited(map); else nativeMap">
index c6fd131..5c8b083 100644 (file)
@@ -83,6 +83,7 @@ export class PermGroupTreeComponent implements OnInit {
         this.orgDepths = depths2.sort();
     }
 
+    // Returns maps for this group and ancestors
     groupPermMaps(): IdlObject[] {
         if (!this.selected) { return []; }
 
@@ -204,6 +205,25 @@ export class PermGroupTreeComponent implements OnInit {
         return m.grp().id() !== this.selected.callerData.id();
     }
 
+    // True if the provided mapping applies to the selected group
+    // and a mapping for the same permission exists for an ancestor.
+    permOverrides(m: IdlObject): boolean {
+        const grpId = this.selected.callerData.id();
+
+        if (m.grp().id() === grpId) { // Selected group has the perm.
+
+            // See if at least one of our ancestors also has the perm.
+            return this.groupPermMaps().filter(mp => {
+                return (
+                    mp.perm().id() === m.perm().id() &&
+                    mp.grp().id() !== grpId
+                );
+            }).length > 0;
+        }
+
+        return false;
+    }
+
     // List of perm maps that owned by perm groups which are ancestors
     // of the selected group
     inheritedPermissions(): IdlObject[] {