LP#1835982: add cell value print handlers to holdings grid
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 30 Jul 2019 16:02:26 +0000 (12:02 -0400)
committerJane Sandberg <sandbej@linnbenton.edu>
Sat, 18 Jan 2020 18:12:57 +0000 (10:12 -0800)
This patch adds cell value print handlers for the barcode
and holdable columns of the Angular staff catalog holdings
view.

To test
-------
[1] After applying the patches for this bug, perform a "Download
    Full CSV" or "Print Full Grid" action on the Holdings View
    grid in the Angular staff catalog.
[2] Verify that the Location/Barcode and Holdable? columns in the
    output contain appropriate values.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html
Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts

index bcd980e..ac5bcc9 100644 (file)
     </eg-grid-column>
     <eg-grid-column name="owner_label" [flex]="4"
       [cellTemplate]="locationTemplate" [cellContext]="gridTemplateContext" 
+      [cellPrintValue]="cellPrintValues"
       label="Location/Barcode" [disableTooltip]="true" i18n-label>
     </eg-grid-column>
     <eg-grid-column path="callNumCount" datatype="number" label="Call Numbers" i18n-label>
     <eg-grid-column i18n-label label="Deposit Amount" path="copy.deposit_amount" 
       name="deposit_amount" datatype="money" [hidden]="true"></eg-grid-column>
     <eg-grid-column i18n-label label="Holdable?" name="holdable" 
-      [cellTemplate]="holdableTemplate" [cellContext]="gridTemplateContext">
+      [cellTemplate]="holdableTemplate" [cellContext]="gridTemplateContext"
+      [cellPrintValue]="cellPrintValues">
     </eg-grid-column>
     <eg-grid-column i18n-label label="Reference?" path="copy.ref" 
       name="ref" datatype="bool" [hidden]="true"></eg-grid-column>
index 1c78e59..973f31a 100644 (file)
@@ -9,7 +9,7 @@ import {StaffCatalogService} from '../catalog.service';
 import {OrgService} from '@eg/core/org.service';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {AuthService} from '@eg/core/auth.service';
-import {GridDataSource} from '@eg/share/grid/grid';
+import {GridDataSource, GridColumn} from '@eg/share/grid/grid';
 import {GridComponent} from '@eg/share/grid/grid.component';
 import {GridToolbarCheckboxComponent
     } from '@eg/share/grid/grid-toolbar-checkbox.component';
@@ -131,6 +131,7 @@ export class HoldingsMaintenanceComponent implements OnInit {
     renderFromPrefs: boolean;
 
     rowClassCallback: (row: any) => string;
+    cellPrintValues: (row: any, cell: GridColumn) => string;
 
     private _recId: number;
     @Input() set recordId(id: number) {
@@ -182,6 +183,18 @@ export class HoldingsMaintenanceComponent implements OnInit {
             }
         };
 
+        // Text-ify function for cells that use display templates.
+        this.cellPrintValues = (row: any, cell: GridColumn): string => {
+            switch (cell.name) {
+                case 'owner_label':
+                    return row.locationLabel;
+                case 'holdable':
+                    return row.copy ?
+                        this.gridTemplateContext.copyIsHoldable(row.copy) :
+                        '';
+            }
+        };
+
         this.gridTemplateContext = {
             toggleExpandRow: (row: HoldingsEntry) => {
                 row.treeNode.expanded = !row.treeNode.expanded;