From 1a9fece829b9ad2dfbd49ab99d2c98d1dd68d03c Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Fri, 27 May 2022 11:22:29 -0400 Subject: [PATCH] LP#1976002: Include ancestors in item location filters 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 Signed-off-by: Andrea Buntz Neiman Signed-off-by: Jane Sandberg --- .../item-location-select/item-location-select.component.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts b/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts index 9bbbc7ae7e..82490a249f 100644 --- a/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts @@ -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)]; }); } -- 2.11.0