From 239081237a1622301e157dc770aa183214da60e2 Mon Sep 17 00:00:00 2001 From: Llewellyn Marshall Date: Tue, 15 Nov 2022 13:29:33 -0500 Subject: [PATCH] on the holdings edit page grab all call number prefixes and suffixes from the database, filter them down in volcopy edit based on owning library of the copy. add documentation & use fullpath instead of ancestors/descendants --- .../app/staff/cat/volcopy/vol-edit.component.html | 8 +++--- .../app/staff/cat/volcopy/vol-edit.component.ts | 32 ++++++++++++++++++++++ .../src/app/staff/cat/volcopy/volcopy.service.ts | 26 ++++++++++++++++-- .../src/perlmods/lib/OpenILS/Application/Cat.pm | 4 +-- 4 files changed, 62 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html index 2e295282a7..f41d33b762 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html @@ -46,7 +46,7 @@
- @@ -73,7 +73,7 @@
- @@ -294,7 +294,7 @@ - @@ -322,7 +322,7 @@ - diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts index 9370a0773a..1d2860c8ca 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts @@ -588,5 +588,37 @@ export class VolEditComponent implements OnInit { !this.volcopy.defaults.visible.batch_actions; this.volcopy.saveDefaults(); } + + // Retrieve call number prefixes for the work station OU + batchPrefixes(): IdlObject[]{ + return this.orgPrefixes(this.auth.user().ws_ou()); + } + + // Retrieve call number suffixes for the work station OU + batchSuffixes(): IdlObject[]{ + return this.orgSuffixes(this.auth.user().ws_ou()); + } + + // Given an org unit ID, find all call number prefixes belonging to + // the org unit, its ancestors, and its descendants + orgPrefixes(orgId: number): IdlObject[] { + let r = []; + this.org.fullPath(orgId,true).forEach( org => { + if(this.volcopy.callNumberPrefixMap[org]) + this.volcopy.callNumberPrefixMap[org].forEach(prefix => r.push(prefix)); + }); + return r; + } + + // Given an org unit ID, find all call number suffixes belonging to + // the org unit, its ancestors, and its descendants + orgSuffixes(orgId: number): IdlObject[] { + let r = []; + this.org.fullPath(orgId,true).forEach( org => { + if(this.volcopy.callNumberSuffixMap[org]) + this.volcopy.callNumberSuffixMap[org].forEach(suffix => r.push(suffix)); + }); + return r; + } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts index ed023eeddd..960641e5ad 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.service.ts @@ -42,6 +42,8 @@ export class VolCopyService { currentContext: VolCopyContext; statCatEntryMap: {[id: number]: IdlObject} = {}; // entry id => entry + callNumberPrefixMap: {[key: string]: IdlObject[]} = {}; + callNumberSuffixMap: {[key: string]: IdlObject[]} = {}; templateNames: ComboboxEntry[] = []; templates: any = {}; @@ -107,10 +109,30 @@ export class VolCopyService { // specially in the markup. this.commonData.acn_prefix = this.commonData.acn_prefix.filter(pfx => pfx.id() !== -1); - + // Map the call number prefixes by their owning libraries + this.commonData.acn_prefix.forEach( + pfx => { + let ol = pfx.owning_lib(); + if (!this.callNumberPrefixMap[ol]) { + this.callNumberPrefixMap[ol] = []; + } + this.callNumberPrefixMap[ol].push(pfx); + } + ); + this.commonData.acn_suffix = this.commonData.acn_suffix.filter(sfx => sfx.id() !== -1); - + // Map the call number suffixes by their owning libraries + this.commonData.acn_suffix.forEach( + sfx => { + let ol = sfx.owning_lib(); + if (!this.callNumberSuffixMap[ol]) { + this.callNumberSuffixMap[ol] = []; + } + this.callNumberSuffixMap[ol].push(sfx); + } + ); + this.commonData.acp_status.forEach( stat => this.copyStatuses[stat.id()] = stat); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm index deb7ad4036..de49876437 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm @@ -2039,14 +2039,14 @@ sub volcopy_data { $client->respond({ acn_prefix => $e->search_asset_call_number_prefix([ - {owning_lib => $org_ids}, + {id => {'!=' => undef}}, {order_by => {acnp => 'label_sortkey'}} ]) }); $client->respond({ acn_suffix => $e->search_asset_call_number_suffix([ - {owning_lib => $org_ids}, + {id => {'!=' => undef}}, {order_by => {acns => 'label_sortkey'}} ]) }); -- 2.11.0