LP1913807 Staff catalog shows preferred lib holdings counts
[evergreen-equinox.git] / Open-ILS / src / eg2 / src / app / staff / catalog / result / record.component.ts
index bd066a7..ed75801 100644 (file)
@@ -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);
+    }
 }