LP1887429 Properly handle user settings in staffcat holds
authorBill Erickson <berickxx@gmail.com>
Mon, 13 Jul 2020 20:01:38 +0000 (16:01 -0400)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 6 Jan 2021 00:48:27 +0000 (16:48 -0800)
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>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>

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 133480f..65b7e56 100644 (file)
@@ -266,7 +266,7 @@ export class HoldComponent implements OnInit {
         const flesh = {flesh: 1, flesh_fields: {au: ['settings']}};
 
         const promise = id ? this.patron.getById(id, flesh) :
-            this.patron.getByBarcode(this.userBarcode);
+            this.patron.getByBarcode(this.userBarcode, flesh);
 
         promise.then(user => {
             this.user = user;
@@ -294,10 +294,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/));
@@ -306,7 +310,7 @@ export class HoldComponent implements OnInit {
                     break;
 
                 case 'opac.default_pickup_location':
-                    this.pickupLib = value;
+                    this.pickupLib = Number(value);
                     break;
             }
         });
index e50fbb2..9678c4d 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 => {
@@ -35,7 +37,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);
                 }
             }