From: Bill Erickson Date: Tue, 6 Jul 2021 15:08:37 +0000 (-0400) Subject: LP1913807 Staff catalog shows preferred lib holdings counts X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6d31774625174597a4dd3f0132a03edba5d90f83;p=evergreen%2Ftadl.git LP1913807 Staff catalog shows preferred lib holdings counts Always show holdings counts for the preferred library (when set) even when the library is not directly in the search scope. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts index f7e54d3f3a..c64357d4cb 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts @@ -23,6 +23,15 @@ interface EResourceUrl { label: string; } +export interface HoldingsSummary { + org_unit: number; + depth: number; + unshadow: number; + count: number; + available: number; + transcendant: number; +} + export class BibRecordSummary { id: number; // == record.id() for convenience metabibId: number; // If present, this is a metabib summary @@ -32,7 +41,8 @@ export class BibRecordSummary { record: IdlObject; display: any; attributes: any; - holdingsSummary: any; + holdingsSummary: HoldingsSummary[]; + prefOuHoldingsSummary: HoldingsSummary[]; holdCount: number; bibCallNumber: string; firstCallNumber: string; @@ -117,6 +127,7 @@ export class BibRecordService { summary.eResourceUrls = bibSummary.urls; summary.copies = bibSummary.copies; summary.firstCallNumber = bibSummary.first_call_number; + summary.prefOuHoldingsSummary = bibSummary.pref_ou_copy_counts; return summary; })); @@ -143,6 +154,7 @@ export class BibRecordService { summary.holdingsSummary = metabibSummary.copy_counts; summary.copies = metabibSummary.copies; summary.firstCallNumber = metabibSummary.first_call_number; + summary.prefOuHoldingsSummary = metabibSummary.pref_ou_copy_counts; return summary; })); diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html index 4bd0fe13d6..115d92aef4 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html @@ -147,7 +147,7 @@
+ *ngFor="let copyCount of getHoldingsSummaries(); let copyIdx = index">
{{copyCount.available}} / {{copyCount.count}} items diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts index bd066a72e0..ed75801ae0 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts @@ -4,7 +4,7 @@ import {Router} from '@angular/router'; import {OrgService} from '@eg/core/org.service'; import {IdlObject} from '@eg/core/idl.service'; import {CatalogService} from '@eg/share/catalog/catalog.service'; -import {BibRecordSummary} from '@eg/share/catalog/bib-record.service'; +import {BibRecordSummary, HoldingsSummary} from '@eg/share/catalog/bib-record.service'; import {CatalogSearchContext} from '@eg/share/catalog/search-context'; import {CatalogUrlService} from '@eg/share/catalog/catalog-url.service'; import {StaffCatalogService} from '../catalog.service'; @@ -132,6 +132,28 @@ export class ResultRecordComponent implements OnInit, OnDestroy { return this.basket.removeRecordIds([this.summary.id]); } } + + getHoldingsSummaries(): HoldingsSummary[] { + if (!this.summary.prefOuHoldingsSummary) { + return this.summary.holdingsSummary; + } + + let match = false; + this.summary.holdingsSummary.some(sum => { + if (Number(sum.org_unit) === Number(this.staffCat.prefOrg.id())) { + return match = true; + } + }); + + if (match) { + // Holdings summary for the pref ou is included in the + // record-level holdings summaries. + return this.summary.holdingsSummary; + } + + return this.summary.holdingsSummary + .concat(this.summary.prefOuHoldingsSummary); + } } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 384677e0e6..9fe2500419 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -3071,6 +3071,7 @@ sub catalog_record_summary { my ($self, $client, $org_id, $record_ids, $options) = @_; my $e = new_editor(); $options ||= {}; + my $pref_ou = $options->{pref_ou}; my $is_meta = ($self->api_name =~ /metabib/); my $is_staff = ($self->api_name =~ /staff/); @@ -3098,6 +3099,20 @@ sub catalog_record_summary { $response->{first_call_number} = get_first_call_number( $e, $rec_id, $org_id, $is_staff, $is_meta, $options); + if ($pref_ou) { + + # If we already have the pref ou copy counts, avoid the extra fetch. + my ($match) = + grep {$_->{org_unit} eq $pref_ou} @{$response->{copy_counts}}; + + if (!$match) { + my ($counts) = $copy_method->run($pref_ou, $rec_id); + ($match) = grep {$_->{org_unit} eq $pref_ou} @$counts; + } + + $response->{pref_ou_copy_counts} = $match; + } + $response->{hold_count} = $U->simplereq('open-ils.circ', $holds_method, $rec_id);