From: Mike Rylander Date: Fri, 27 May 2022 15:22:29 +0000 (-0400) Subject: LP#1976002: Include ancestors in item location filters X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c84898a1faa80c5eb0aa984e24d534c7508a2b06;p=evergreen%2Fjoelewis.git 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 --- 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)]; }); }