lp1739277 OrgSelect Class Callback Holdings Implementation
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / catalog / record / holdings.component.ts
index 07fb393..8ba8583 100644 (file)
@@ -7,6 +7,7 @@ import {Pager} from '@eg/share/util/pager';
 import {IdlObject, IdlService} from '@eg/core/idl.service';
 import {StaffCatalogService} from '../catalog.service';
 import {OrgService} from '@eg/core/org.service';
+import {NetService} from '@eg/core/net.service';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {AuthService} from '@eg/core/auth.service';
 import {GridDataSource, GridColumn, GridCellTextGenerator} from '@eg/share/grid/grid';
@@ -152,7 +153,10 @@ export class HoldingsMaintenanceComponent implements OnInit {
     renderFromPrefs: boolean;
 
     rowClassCallback: (row: any) => string;
+
     cellTextGenerator: GridCellTextGenerator;
+    orgClassCallback: (orgId: number) => string;
+    marked_orgs: number[] = [];
 
     private _recId: number;
     @Input() set recordId(id: number) {
@@ -179,6 +183,7 @@ export class HoldingsMaintenanceComponent implements OnInit {
         private org: OrgService,
         private idl: IdlService,
         private pcrud: PcrudService,
+        private net: NetService,
         private auth: AuthService,
         private staffCat: StaffCatalogService,
         private store: ServerStoreService,
@@ -210,6 +215,7 @@ export class HoldingsMaintenanceComponent implements OnInit {
             }
         };
 
+
         // Text-ify function for cells that use display templates.
         this.cellTextGenerator = {
             owner_label: row => row.locationLabel,
@@ -217,6 +223,11 @@ export class HoldingsMaintenanceComponent implements OnInit {
                 this.gridTemplateContext.copyIsHoldable(row.copy) : ''
         };
 
+        this.orgClassCallback = (orgId: number): string => {
+            if (this.marked_orgs.includes(orgId)) { return 'font-weight-bold'; }
+            return '';
+        };
+
         this.gridTemplateContext = {
             toggleExpandRow: (row: HoldingsEntry) => {
                 row.treeNode.expanded = !row.treeNode.expanded;
@@ -279,6 +290,16 @@ export class HoldingsMaintenanceComponent implements OnInit {
             if (!this.contextOrgLoaded) { return empty(); }
             return this.fetchHoldings(pager);
         };
+
+        this.net.request(
+            'open-ils.search',
+            'open-ils.search.biblio.copy_counts.retrieve.staff',
+            this.recordId
+        ).toPromise().then(result => {
+            result.forEach(copy_count => {
+                this.marked_orgs.push(copy_count[0]);
+            });
+        });
     }
 
     // No data is loaded until the first occurrence of the org change handler