LP#1976002: Include ancestors in item location filters
authorMike Rylander <mrylander@gmail.com>
Fri, 27 May 2022 15:22:29 +0000 (11:22 -0400)
committerJane Sandberg <sandbergja@gmail.com>
Mon, 5 Sep 2022 16:46:05 +0000 (09:46 -0700)
The item location selector should include locations from ancestor org
units regardless of the specific permission-limiting check it may be
asked to perform.  Item locations at ancestor org units are valid for
use on items in descendant locations.

This commit also makes the org filter list unique.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Andrea Buntz Neiman <abneiman@equinoxOLI.org>
Signed-off-by: Jane Sandberg <sandbergja@gmail.com>
Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts

index 9bbbc7a..82490a2 100644 (file)
@@ -189,23 +189,22 @@ export class ItemLocationSelectComponent
         contextOrgIds.forEach(id => orgIds = orgIds.concat(this.org.ancestors(id, true)));
 
         if (!this.permFilter) {
-            return Promise.resolve(this.filterOrgs = orgIds);
+            return Promise.resolve(this.filterOrgs = [...new Set(orgIds)]);
         }
 
         return this.perm.hasWorkPermAt([this.permFilter], true)
         .then(values => {
-            // Always limit the org units to /at most/ those within
-            // scope of the context org ID.
+            // Include ancestors of perm-approved org units (shared item locations)
 
             const permOrgIds = values[this.permFilter];
-            const trimmedOrgIds = [];
+            let trimmedOrgIds = [];
             permOrgIds.forEach(orgId => {
                 if (orgIds.includes(orgId)) {
-                    trimmedOrgIds.push(orgId);
+                    trimmedOrgIds = trimmedOrgIds.concat(this.org.ancestors(orgId, true));
                 }
             });
 
-            return this.filterOrgs = trimmedOrgIds;
+            return this.filterOrgs = [...new Set(trimmedOrgIds)];
         });
     }