LP1904036 Bills grid color coding; lint
authorBill Erickson <berickxx@gmail.com>
Mon, 23 Aug 2021 17:16:44 +0000 (13:16 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:36 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.css
Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts

index 390f74d..4a26b2c 100644 (file)
   (onRowActivate)="showStatement($event)"
   [reloadOnColumnChange]="true"
   [showDeclaredFieldsOnly]="true"
+  [rowClassCallback]="rowClassCallback"
+  [rowFlairIsEnabled]="true"
+  [rowFlairCallback]="rowFlairCallback"
   [cellTextGenerator]="cellTextGenerator">
 
   <eg-grid-toolbar-button i18n-label label="Add Billing"
   <eg-grid-column path="xact_start" datatype="timestamp" [datePlusTime]="true"
     label="Start" i18n-label></eg-grid-column>
 
+  <eg-grid-column path="circulation.due_date" label="Due Date" i18n-label                   
+    timezoneContextOrg="circulation.circ_lib" dateOnlyIntervalField="circulation.duration"   
+    datatype="timestamp" [required]="true"></eg-grid-column>  
+
+  <eg-grid-column path="circulation.stop_fines" [required]="true"
+    label="Stop Fines" i18n-label></eg-grid-column>
+
   <eg-grid-column path="summary.xact_type"
     label="Type" i18n-label></eg-grid-column>
 
index d38210f..b4288a1 100644 (file)
@@ -12,7 +12,7 @@ import {AuthService} from '@eg/core/auth.service';
 import {ServerStoreService} from '@eg/core/server-store.service';
 import {PatronService} from '@eg/staff/share/patron/patron.service';
 import {PatronContextService} from './patron.service';
-import {GridDataSource, GridColumn, GridCellTextGenerator} from '@eg/share/grid/grid';
+import {GridDataSource, GridColumn, GridCellTextGenerator, GridRowFlairEntry} from '@eg/share/grid/grid';
 import {GridComponent} from '@eg/share/grid/grid.component';
 import {Pager} from '@eg/share/util/pager';
 import {CircService, CircDisplayInfo} from '@eg/staff/share/circ/circ.service';
@@ -58,6 +58,10 @@ export class BillsComponent implements OnInit, AfterViewInit {
 
     gridDataSource: GridDataSource = new GridDataSource();
     cellTextGenerator: GridCellTextGenerator;
+    rowClassCallback: (row: any) => string;
+    rowFlairCallback: (row: any) => GridRowFlairEntry;
+
+    nowTime: number = new Date().getTime();
 
     @ViewChild('billGrid') private billGrid: GridComponent;
     @ViewChild('annotateDialog') private annotateDialog: PromptDialogComponent;
@@ -98,6 +102,27 @@ export class BillsComponent implements OnInit, AfterViewInit {
             call_number: row => row.call_number_label
         };
 
+        this.rowClassCallback = (row: any): string => {
+            if (row['circulation.stop_fines'] === 'LOST') {
+                return 'lost-row';
+            } else if (row['circulation.stop_fines'] === 'LONGOVERDUE') {
+                return 'longoverdue-row';
+            } else if (this.circIsOverdue(row)) {
+                return 'less-intense-alert';
+            }
+            return '';
+        };
+
+        this.rowFlairCallback = (row: any): GridRowFlairEntry => {
+            if (row['circulation.stop_fines'] === 'LOST') {
+                return {icon: 'help'};
+            } else if (row['circulation.stop_fines'] === 'LONGOVERDUE') {
+                return {icon: 'priority-high'};
+            } else if (this.circIsOverdue(row)) {
+                return {icon: 'schedule'};
+            }
+        };
+
         this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
 
             const query: any = {
@@ -122,6 +147,18 @@ export class BillsComponent implements OnInit, AfterViewInit {
         .then(_ => this.loadSettings());
     }
 
+    circIsOverdue(row: any): boolean {
+        const due = row['circulation.due_date'];
+        if (due && !row['circulation.checkin_time']) {
+            const stopFines = row['circulation.stop_fines'] || '';
+            if (stopFines.match(/LOST|CLAIMSRETURNED|CLAIMSNEVERCHECKEDOUT/)) {
+                return false;
+            }
+
+            return (Date.parse(due) < this.nowTime);
+        }
+    }
+
     loadSettings(): Promise<any> {
         return this.serverStore.getItemBatch([
             'ui.circ.billing.amount_warn',
index d4abd5f..dcf8324 100644 (file)
@@ -3,3 +3,13 @@
   font-size: 1rem; /* defaults to 1.5 */
 }
 
+::ng-deep .lost-row {
+  color: #FFF;
+  background-color: #800000 !important;
+}
+
+::ng-deep .longoverdue-row {
+  color: #000;
+  background-color: #FFE1A8 !important;
+}
+
index 8a3bad3..dd5997a 100644 (file)
@@ -641,7 +641,7 @@ export class HoldsGridComponent implements OnInit {
                     'open-ils.circ',
                     'open-ils.circ.hold.uncancel',
                     this.auth.token(), holdId
-                )
+                );
             })).subscribe(
                 resp => {
                     if (Number(resp) !== 1) {