From ab5478b879e9e34a6fe023c188c7a95c11c425ca Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 19 Apr 2022 13:27:17 -0400 Subject: [PATCH] LP1956626 Copy editor loads all needed copy locations The item-location-select component now allows the caller to pass in a set of context org unit IDs (in lieu of just a single id) for loading copy locations across different areas of the org unit tree (without having to load *all* copy locations). Changes applied to the Angular copy location editor to pass the needed context org units to the item location select component. Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- .../item-location-select.component.ts | 30 +++++++++++++++++++--- .../staff/cat/volcopy/copy-attrs.component.html | 1 + .../app/staff/cat/volcopy/copy-attrs.component.ts | 5 ++++ 3 files changed, 32 insertions(+), 4 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 4317500fc4..9bbbc7ae7e 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 @@ -43,6 +43,20 @@ export class ItemLocationSelectComponent this.ngOnInit(); } + get contextOrgId(): number { + return this._contextOrgId; + } + + // Load locations for multiple context org units. + private _contextOrgIds = []; + @Input() set contextOrgIds(value: number[]) { + this._contextOrgIds = value; + } + + get contextOrgIds(): number[] { + return this._contextOrgIds; + } + @Input() orgUnitLabelField = 'shortname'; // Emits an acpl object or null on combobox value change @@ -163,11 +177,19 @@ export class ItemLocationSelectComponent } setFilterOrgs(): Promise { - const org = this._contextOrgId || this.auth.user().ws_ou(); - const contextOrgIds = this.org.ancestors(org, true); + let contextOrgIds: number[] = []; + + if (this.contextOrgIds) { + contextOrgIds = this.contextOrgIds; + } else { + contextOrgIds = [this.contextOrgId || this.auth.user().ws_ou()]; + } + + let orgIds = []; + contextOrgIds.forEach(id => orgIds = orgIds.concat(this.org.ancestors(id, true))); if (!this.permFilter) { - return Promise.resolve(this.filterOrgs = contextOrgIds); + return Promise.resolve(this.filterOrgs = orgIds); } return this.perm.hasWorkPermAt([this.permFilter], true) @@ -178,7 +200,7 @@ export class ItemLocationSelectComponent const permOrgIds = values[this.permFilter]; const trimmedOrgIds = []; permOrgIds.forEach(orgId => { - if (contextOrgIds.includes(orgId)) { + if (orgIds.includes(orgId)) { trimmedOrgIds.push(orgId); } }); diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html index ac1c123a5f..dcee71ddb1 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html @@ -151,6 +151,7 @@
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts index 807d7ca101..8b4c29bc9c 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.ts @@ -658,6 +658,11 @@ export class CopyAttrsComponent implements OnInit, AfterViewInit { // click Apply for every one. this.batchAttrs.filter(attr => attr.editing).forEach(attr => attr.save()); } + + affectedOrgIds(): number[] { + if (!this.context) { return []; } + return this.context.orgNodes().map(n => n.target.id()); + } } -- 2.11.0