LP1887429 Properly handle user settings in staffcat holds
authorBill Erickson <berickxx@gmail.com>
Mon, 13 Jul 2020 20:01:38 +0000 (16:01 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Mon, 7 Dec 2020 16:22:08 +0000 (11:22 -0500)
Treat user settings like the raw JSON values that they are
when fetched via fleshing.  Also be sure the value for the
'opac.default_pickup_location' user setting is read as a number in the
staff catalog to ensure it can be linked to the org unit in question.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts
Open-ILS/src/eg2/src/app/staff/share/patron/patron.service.ts

index 3ac3041..e305a46 100644 (file)
@@ -395,10 +395,14 @@ export class HoldComponent implements OnInit {
 
         this.user.settings().forEach(setting => {
             const name = setting.name();
-            const value = setting.value();
+            let value = setting.value();
 
             if (value === '' || value === null) { return; }
 
+            // When fleshing 'settings' on the actor.usr object,
+            // we're grabbing the raw JSON values.
+            value = JSON.parse(value);
+
             switch (name) {
                 case 'opac.hold_notify':
                     this.notifyPhone = Boolean(value.match(/phone/));
@@ -407,7 +411,7 @@ export class HoldComponent implements OnInit {
                     break;
 
                 case 'opac.default_pickup_location':
-                    this.pickupLib = value;
+                    this.pickupLib = Number(value);
                     break;
 
                 case 'opac.default_phone':
index e658a79..32aa678 100644 (file)
@@ -24,6 +24,8 @@ export class PatronService {
            'actor', barcode.trim());
     }
 
+    // Note pcrudOps should be constructed from the perspective
+    // of a user ('au') retrieval, not a barcode ('ac') retrieval.
     getByBarcode(barcode: string, pcrudOps?: any): Promise<IdlObject> {
         return this.bcSearch(barcode).toPromise()
         .then(barcodes => {
@@ -36,7 +38,7 @@ export class PatronService {
             for (let i = 0; i < barcodes.length; i++) {
                 const bc = barcodes[i];
                 if (!this.evt.parse(bc)) {
-                    return this.getById(bc.id);
+                    return this.getById(bc.id, pcrudOps);
                 }
             }