LP1913807 Staff catalog shows preferred lib holdings counts
[evergreen-equinox.git] / Open-ILS / src / eg2 / src / app / share / catalog / bib-record.service.ts
index ce352c7..c64357d 100644 (file)
@@ -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,12 +41,15 @@ export class BibRecordSummary {
     record: IdlObject;
     display: any;
     attributes: any;
-    holdingsSummary: any;
+    holdingsSummary: HoldingsSummary[];
+    prefOuHoldingsSummary: HoldingsSummary[];
     holdCount: number;
     bibCallNumber: string;
+    firstCallNumber: string;
     net: NetService;
     displayHighlights: {[name: string]: string | string[]} = {};
     eResourceUrls: EResourceUrl[] = [];
+    copies: any[];
 
     constructor(record: IdlObject, orgId: number, orgDepth?: number) {
         this.id = Number(record.id());
@@ -95,8 +107,8 @@ export class BibRecordService {
         return this.getBibSummaries([id], orgId, isStaff);
     }
 
-    getBibSummaries(bibIds: number[],
-        orgId?: number, isStaff?: boolean): Observable<BibRecordSummary> {
+    getBibSummaries(bibIds: number[], orgId?: number,
+        isStaff?: boolean, options?: any): Observable<BibRecordSummary> {
 
         if (bibIds.length === 0) { return from([]); }
         if (!orgId) { orgId = this.org.root().id(); }
@@ -104,7 +116,7 @@ export class BibRecordService {
         let method = 'open-ils.search.biblio.record.catalog_summary';
         if (isStaff) { method += '.staff'; }
 
-        return this.net.request('open-ils.search', method, orgId, bibIds)
+        return this.net.request('open-ils.search', method, orgId, bibIds, options)
         .pipe(map(bibSummary => {
             const summary = new BibRecordSummary(bibSummary.record, orgId);
             summary.net = this.net; // inject
@@ -113,12 +125,16 @@ export class BibRecordService {
             summary.holdCount = bibSummary.hold_count;
             summary.holdingsSummary = bibSummary.copy_counts;
             summary.eResourceUrls = bibSummary.urls;
+            summary.copies = bibSummary.copies;
+            summary.firstCallNumber = bibSummary.first_call_number;
+            summary.prefOuHoldingsSummary = bibSummary.pref_ou_copy_counts;
+
             return summary;
         }));
     }
 
     getMetabibSummaries(metabibIds: number[],
-        orgId?: number, isStaff?: boolean): Observable<BibRecordSummary> {
+        orgId?: number, isStaff?: boolean, options?: any): Observable<BibRecordSummary> {
 
         if (metabibIds.length === 0) { return from([]); }
         if (!orgId) { orgId = this.org.root().id(); }
@@ -126,7 +142,7 @@ export class BibRecordService {
         let method = 'open-ils.search.biblio.metabib.catalog_summary';
         if (isStaff) { method += '.staff'; }
 
-        return this.net.request('open-ils.search', method, orgId, metabibIds)
+        return this.net.request('open-ils.search', method, orgId, metabibIds, options)
         .pipe(map(metabibSummary => {
             const summary = new BibRecordSummary(metabibSummary.record, orgId);
             summary.net = this.net; // inject
@@ -136,6 +152,10 @@ export class BibRecordService {
             summary.attributes = metabibSummary.attributes;
             summary.holdCount = metabibSummary.hold_count;
             summary.holdingsSummary = metabibSummary.copy_counts;
+            summary.copies = metabibSummary.copies;
+            summary.firstCallNumber = metabibSummary.first_call_number;
+            summary.prefOuHoldingsSummary = metabibSummary.pref_ou_copy_counts;
+
             return summary;
         }));
     }