LP1904036 patron UI noncat/holds summary
authorBill Erickson <berickxx@gmail.com>
Fri, 21 Aug 2020 21:02:10 +0000 (17:02 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:22 +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/patron.service.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/summary.component.html

index 0f1a8bb..684ec84 100644 (file)
@@ -31,8 +31,13 @@ interface PatronStats {
         lost: number,
         out: number,
         total_out: number,
-        long_overdue: number
+        long_overdue: number,
+        noncat: number
     };
+    holds: {
+        ready: number;
+        total: number;
+    }
 }
 
 @Injectable()
@@ -76,6 +81,12 @@ export class PatronManagerService {
         this.accountExpired = false;
         this.accountExpiresSoon = false;
 
+        // When quickly navigating patron search results it's possible
+        // for this.patron to be cleared right before this function
+        // is called.  Exit early instead of making an unneeded call.
+        // For this func. in particular a nasty JS error is thrown.
+        if (!this.patron) { return Promise.resolve(); }
+
         return this.patronService.testExpire(this.patron)
         .then(value => {
             if (value === 'expired') {
@@ -88,6 +99,11 @@ export class PatronManagerService {
 
     getPatronStats(id: number): Promise<any> {
 
+        // When quickly navigating patron search results it's possible
+        // for this.patron to be cleared right before this function
+        // is called.  Exit early instead of making an unneeded call.
+        if (!this.patron) { return Promise.resolve(); }
+
         return this.net.request(
             'open-ils.actor',
             'open-ils.actor.user.opac.vital_stats.authoritative',
@@ -112,7 +128,21 @@ export class PatronManagerService {
                 stats.checkouts.total_out += stats.checkouts.lost
             }
 
-            return this.patronStats = stats;
+            this.patronStats = stats;
+
+        }).then(_ => {
+
+            if (!this.patron) { return; }
+
+            return this.net.request(
+                'open-ils.circ',
+                'open-ils.circ.open_non_cataloged_circulation.user.authoritative',
+                this.auth.token(), id).toPromise()
+
+        }).then(noncats => {
+            if (noncats && this.patronStats) {
+                this.patronStats.checkouts.noncat = noncats.length;
+            }
         });
     }
 }
index a7e7cf8..cdeaf97 100644 (file)
     </div>
     <div class="row mb-1">
       <div class="col-lg-5" i18n>Non-Cataloged</div>
-      <div class="col-lg-7">XXXX</div>
+      <div class="col-lg-7">{{context.patronStats.checkouts.noncat}}</div>
     </div>
     <div class="row">
       <div class="col-lg-5" i18n>Holds</div>
-      <div class="col-lg-7">XX / YY</div>
+      <div class="col-lg-7">
+        {{context.patronStats.holds.ready}} / {{context.patronStats.holds.total}}
+      </div>
     </div>
 
     <hr class="m-1"/>