LP1904036 Patron ui checkout tab
authorBill Erickson <berickxx@gmail.com>
Fri, 5 Feb 2021 21:44:55 +0000 (16:44 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:23 +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/checkout.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/checkout.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts
Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts

index c856da3..988ea06 100644 (file)
       <eg-grid-column path="index" [index]="true" 
         label="Row Index" i18n-label [hidden]="true"></eg-grid-column>
       <eg-grid-column path="circ.id" label="Circ ID" i18n-label></eg-grid-column>
+
+      <!-- TODO 
+        [datePlusTime]="true" when non-full-day circ 
+      -->
+      <eg-grid-column path="dueDate" label="Due Date" i18n-label
+        datatype="timestamp"></eg-grid-column>
+
+      <eg-grid-column path="copy.barcode" label="Barcode" i18n-label></eg-grid-column>
+
       <eg-grid-column path="title" label="Title" i18n-label 
         [cellTemplate]="titleTemplate"></eg-grid-column>
     </eg-grid>
index 9a278a2..f1f8c69 100644 (file)
@@ -7,19 +7,13 @@ import {IdlObject} from '@eg/core/idl.service';
 import {OrgService} from '@eg/core/org.service';
 import {NetService} from '@eg/core/net.service';
 import {PatronService} from '@eg/staff/share/patron/patron.service';
-import {PatronManagerService} from './patron.service';
+import {PatronManagerService, CircGridEntry} from './patron.service';
 import {CheckoutParams, CheckoutResult, CircService} from '@eg/staff/share/circ/circ.service';
 import {PromptDialogComponent} from '@eg/share/dialog/prompt.component';
 import {GridDataSource, GridColumn, GridCellTextGenerator} from '@eg/share/grid/grid';
 import {GridComponent} from '@eg/share/grid/grid.component';
 import {Pager} from '@eg/share/util/pager';
 
-interface CircGridEntry {
-    title?: string;
-    circ?: IdlObject;
-    copyAlertCount: number;
-}
-
 @Component({
   templateUrl: 'checkout.component.html',
   selector: 'eg-patron-checkout'
@@ -29,7 +23,6 @@ export class CheckoutComponent implements OnInit {
     maxNoncats = 99; // Matches AngJS version
     checkoutNoncat: IdlObject = null;
     checkoutBarcode = '';
-    checkouts: CircGridEntry[] = [];
     gridDataSource: GridDataSource = new GridDataSource();
     cellTextGenerator: GridCellTextGenerator;
 
@@ -48,7 +41,7 @@ export class CheckoutComponent implements OnInit {
         this.circ.getNonCatTypes();
 
         this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
-            return from(this.checkouts);
+            return from(this.context.checkouts);
         };
 
         this.cellTextGenerator = {
@@ -115,17 +108,30 @@ export class CheckoutComponent implements OnInit {
 
     gridifyResult(result: CheckoutResult) {
         const entry: CircGridEntry = {
+            title: '',
+            copy: result.copy,
             circ: result.circ,
+            dueDate: null,
             copyAlertCount: 0 // TODO
         };
 
-        if (this.checkoutNoncat) {
+        if (result.nonCatCirc) {
+
             entry.title = this.checkoutNoncat.name();
-        } else if (result.record) {
-            entry.title = result.record.title();
+            entry.dueDate = result.nonCatCirc.duedate();
+
+        } else {
+
+            if (result.record) {
+                entry.title = result.record.title();
+            }
+
+            if (result.circ) {
+                entry.dueDate = result.circ.due_date();
+            }
         }
 
-        this.checkouts.unshift(entry);
+        this.context.checkouts.unshift(entry);
         this.checkoutsGrid.reload();
     }
 
index 78f25ad..cf653c7 100644 (file)
@@ -5,6 +5,14 @@ import {AuthService} from '@eg/core/auth.service';
 import {PatronService} from '@eg/staff/share/patron/patron.service';
 import {PatronSearch} from '@eg/staff/share/patron/search.component';
 
+export interface CircGridEntry {
+    title?: string;
+    copy?: IdlObject;
+    circ?: IdlObject;
+    dueDate?: string;
+    copyAlertCount: number;
+}
+
 const PATRON_FLESH_FIELDS = [
     'card',
     'cards',
@@ -60,6 +68,9 @@ export class PatronManagerService {
 
     lastPatronSearch: PatronSearch;
 
+    // These should persist tab changes
+    checkouts: CircGridEntry[] = [];
+
     constructor(
         private net: NetService,
         private auth: AuthService,
@@ -69,6 +80,7 @@ export class PatronManagerService {
     loadPatron(id: number): Promise<any> {
         this.loaded = false;
         this.patron = null;
+        this.checkouts = [];
 
         return this.net.request(
             'open-ils.actor',
index 554b77d..1b69e04 100644 (file)
@@ -26,7 +26,9 @@ export interface CheckoutResult {
     index: number;
     params: CheckoutParams,
     success: boolean;
+    copy?: IdlObject;
     circ?: IdlObject;
+    nonCatCirc: IdlObject;
     record?: IdlObject;
 }
 
@@ -89,7 +91,10 @@ export class CircService {
             index: CircService.resultIndex++,
             params: params,
             success: true,
-            circ: payload.circ
+            circ: payload.circ,
+            copy: payload.copy,
+            record: payload.record,
+            nonCatCirc: payload.noncat_circ
         };
 
         return Promise.resolve(result);