LP1904036 Checkin grid shows circ user; routeTo updates
authorBill Erickson <berickxx@gmail.com>
Wed, 12 Jan 2022 16:27:02 +0000 (11:27 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:39 +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/checkin/checkin.component.html
Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts
Open-ILS/src/eg2/src/app/staff/share/circ/route-dialog.component.ts

index 7489dbc..b756aeb 100644 (file)
       <eg-grid-column path="circ.checkin_time" label="Checkin Date" i18n-label
         datatype="timestamp" [datePlusTime]="true"></eg-grid-column>
 
-      <eg-grid-column path="patron.family_name" label="Family Name" i18n-label>
-      </eg-grid-column>
-
       <eg-grid-column path="circ.xact_finish" label="Finish" i18n-label
         datatype="timestamp" [datePlusTime]="true"></eg-grid-column>
+      <eg-grid-column path="circ_patron.family_name" label="Last Name" i18n-label>
+      </eg-grid-column>
+
+      <eg-grid-column path="circ_patron.first_given_name" label="First Name" i18n-label>
+      </eg-grid-column>
 
-      <eg-grid-column path="copy.location.name" label="Location" i18n-label>
+      <eg-grid-column path="copy.location.name" label="Location" i18n-label [hidden]="true">
       </eg-grid-column>
 
       <eg-grid-column name="routeTo" label="Route To" i18n-label>
index d3de2f9..38c1762 100644 (file)
@@ -146,11 +146,22 @@ export interface CircResultCommon {
     circ?: IdlObject;
     parent_circ?: IdlObject;
     hold?: IdlObject;
+
+    // Set to one of circ_patron or hold_patron depending on the context.
     patron?: IdlObject;
+
+    // Set to the patron linked to the relevant circulation.
+    circ_patron?: IdlObject;
+
+    // Set to the patron linked to the relevant hold.
+    hold_patron?: IdlObject;
+
     transit?: IdlObject;
     copyAlerts?: IdlObject[];
     mbts?: IdlObject;
 
+    routeTo?: string; // org name or in-branch destination
+
     // Calculated values
     title?: string;
     author?: string;
@@ -190,7 +201,6 @@ export interface CheckinParams {
 
 export interface CheckinResult extends CircResultCommon {
     params: CheckinParams;
-    routeTo?: string; // org name or in-branch destination
     destOrg?: IdlObject;
     destAddress?: IdlObject;
     destCourierCode?: string;
@@ -746,35 +756,55 @@ export class CircService {
         });
     }
 
+    fetchPatron(userId: number): Promise<IdlObject> {
+        return this.pcrud.retrieve('au', userId, {
+            flesh: 1,
+            flesh_fields : {'au' : ['card', 'stat_cat_entries']}
+        })
+        .toPromise();
+    }
+
     fleshCommonData(result: CircResultCommon): Promise<CircResultCommon> {
 
+        console.warn('fleshCommonData()');
+
         const copy = result.copy;
         const volume = result.volume;
         const circ = result.circ;
         const hold = result.hold;
         const nonCatCirc = (result as CheckoutResult).nonCatCirc;
 
-        let promise = Promise.resolve();
+        let promise: Promise<any> = Promise.resolve();
 
-        if (!result.patron) {
-            let patronId;
-            if (hold) {
-                patronId = hold.usr();
-            } else if (circ) {
-                patronId = circ.usr();
-            } else if (nonCatCirc) {
-                patronId = nonCatCirc.patron();
-            }
+        if (hold) {
+            console.debug('fleshCommonData() hold ', hold.usr());
+            promise = promise.then(_ => {
+                return this.fetchPatron(hold.usr())
+                .then(usr => {
+                    result.hold_patron = usr;
+                    console.debug('Setting hold patron to ' + usr.id());
+                });
+            });
+        }
+
+        const circPatronId = circ ? circ.usr() :
+            (nonCatCirc ? nonCatCirc.patron() : null);
 
-            if (patronId) {
-                promise = promise.then(_ => {
-                    return this.pcrud.retrieve('au', patronId,
-                      {flesh: 1, flesh_fields : {'au' : ['card']}})
-                    .toPromise().then(p => result.patron = p);
+        if (circPatronId) {
+            console.debug('fleshCommonData() circ ', circPatronId);
+            promise = promise.then(_ => {
+                return this.fetchPatron(circPatronId)
+                .then(usr => {
+                    result.circ_patron = usr;
+                    console.debug('Setting circ patron to ' + usr.id());
                 });
-            }
+            });
         }
 
+        // Set a default patron value which is used in most cases.
+        promise = promise.then(_ => {
+            result.patron = result.hold_patron || result.circ_patron;
+        });
 
         if (result.record) {
             result.title = result.record.title();
@@ -808,6 +838,14 @@ export class CircService {
             }
         }
 
+        promise = promise.then(_ => {
+            // By default, all items route-to their location.
+            // Value replaced later on as needed.
+            if (copy && typeof copy.location() === 'object') {
+                result.routeTo = copy.location().name();
+            }
+        });
+
         if (volume) {
             // Flesh volume prefixes and suffixes
 
index 490e065..c39ced3 100644 (file)
@@ -44,11 +44,13 @@ export class RouteDialogComponent extends DialogComponent {
         return from(this.applySettings())
 
         .pipe(concatMap(exit => {
-            if (exit) {
-                return of(exit);
-            } else {
-                return from(this.collectData());
-            }
+            return from(
+                this.collectData().then(exit2 => {
+                    // If either applySettings or collectData() tell us
+                    // to exit, make it so.
+                    return exit || exit2;
+                })
+            );
         }))
 
         .pipe(concatMap(exit => {
@@ -64,6 +66,8 @@ export class RouteDialogComponent extends DialogComponent {
         let promise = Promise.resolve(null);
         const hold = this.checkin.hold;
 
+        console.debug('Route Dialog collecting data');
+
         if (this.slip !== 'hold_shelf_slip') {
 
             // Always fetch the most recent transit for the copy,
@@ -102,6 +106,7 @@ export class RouteDialogComponent extends DialogComponent {
     }
 
     applySettings(): Promise<boolean> {
+        console.debug('Route Dialog applying print settings');
 
         if (this.checkin.transit) {
             if (this.checkin.patron && this.checkin.hold &&