LP#1759382 Setting: staff placed holds default to workstation
authorDan Briem <dbriem@wlsmail.org>
Wed, 25 Aug 2021 14:24:12 +0000 (10:24 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 23 Sep 2021 15:05:54 +0000 (11:05 -0400)
New org unit setting to always default the pickup location to
the workstation when placing holds as staff, regardless of the
patron's preferred pickup location.

The setting applies to staff placed holds in the Angular and
traditional catalogs.

Priority for determining the default pickup location when
placing holds as staff:

1. workstation if circ.staff_placed_holds_default_to_ws_ou
2. user preferred location if opac.default_pickup_location
3. workstation if circ.staff_placed_holds_fallback_to_ws_ou
4. user home org unit

Signed-off-by: Dan Briem <dbriem@wlsmail.org>
Signed-off-by: Gina Monti <gmonti@biblio.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/xxxx.data.staff_placed_holds_default_to_ws_ou.sql [new file with mode: 0644]
Open-ILS/web/js/ui/default/opac/staff.js
Open-ILS/web/js/ui/default/staff/services/eframe.js

index 25943b9..b4d2443 100644 (file)
@@ -88,6 +88,7 @@ export class HoldComponent implements OnInit {
     badBarcode: string = null;
 
     puLibWsFallback = false;
+    puLibWsDefault = false;
 
     // Orgs which are not valid pickup locations
     disableOrgs: number[] = [];
@@ -137,8 +138,15 @@ export class HoldComponent implements OnInit {
             this.userBarcode = this.staffCat.holdForBarcode;
         }
 
-        this.store.getItem('circ.staff_placed_holds_fallback_to_ws_ou')
-        .then(setting => this.puLibWsFallback = setting === true);
+        this.store.getItemBatch([
+            'circ.staff_placed_holds_fallback_to_ws_ou',
+            'circ.staff_placed_holds_default_to_ws_ou'
+        ]).then(settings => {
+            this.puLibWsFallback =
+                settings['circ.staff_placed_holds_fallback_to_ws_ou'] === true;
+            this.puLibWsDefault =
+                settings['circ.staff_placed_holds_default_to_ws_ou'] === true;
+        });
 
         this.org.list().forEach(org => {
             if (org.ou_type().can_have_vols() === 'f') {
@@ -429,9 +437,13 @@ export class HoldComponent implements OnInit {
         this.phoneValue = this.user.day_phone() || this.user.evening_phone();
 
         // Default to work org if placing holds for staff.
-        if (this.user.id() !== this.requestor.id() && !this.puLibWsFallback) {
-            // This value may be superseded below by user settings.
-            this.pickupLib = this.user.home_ou();
+        // Default to home org if placing holds for patrons unless
+        // settings default or fallback to the workstation.
+        if (this.user.id() !== this.requestor.id()) {
+            if (!this.puLibWsFallback && !this.puLibWsDefault) {
+                // This value may be superseded below by user settings.
+                this.pickupLib = this.user.home_ou();
+            }
         }
 
         if (!this.user.settings()) { return; }
@@ -454,7 +466,7 @@ export class HoldComponent implements OnInit {
                     break;
 
                 case 'opac.default_pickup_location':
-                    if (value) {
+                    if (!this.puLibWsDefault && value) {
                         this.pickupLib = Number(value);
                     }
                     break;
index 6780c2d..b8e38b3 100644 (file)
@@ -60,6 +60,7 @@ export class CatalogResolver implements Resolve<Promise<any[]>> {
             'eg.catalog.search.form.open',
             'eg.staff.catalog.results.show_more',
             'circ.staff_placed_holds_fallback_to_ws_ou',
+            'circ.staff_placed_holds_default_to_ws_ou',
             'opac.staff.jump_to_details_on_single_hit',
             'eg.staffcat.search_filters'
         ]).then(settings => {
index f7fc686..143584f 100644 (file)
@@ -21937,3 +21937,22 @@ VALUES (
     )
 );
 
+INSERT INTO config.org_unit_setting_type (
+    name, grp, label, description, datatype
+) VALUES (
+    'circ.staff_placed_holds_default_to_ws_ou',
+    'circ',
+    oils_i18n_gettext(
+        'circ.staff_placed_holds_default_to_ws_ou',
+        'Workstation OU is the default for staff-placed holds',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.staff_placed_holds_default_to_ws_ou',
+        'For staff-placed holds, regardless of the patron preferred pickup location, the staff workstation OU is the default pickup location',
+        'coust',
+        'description'
+    ),
+    'bool'
+);
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.data.staff_placed_holds_default_to_ws_ou.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.data.staff_placed_holds_default_to_ws_ou.sql
new file mode 100644 (file)
index 0000000..86196f8
--- /dev/null
@@ -0,0 +1,25 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version);
+
+INSERT INTO config.org_unit_setting_type (
+    name, grp, label, description, datatype
+) VALUES (
+    'circ.staff_placed_holds_default_to_ws_ou',
+    'circ',
+    oils_i18n_gettext(
+        'circ.staff_placed_holds_default_to_ws_ou',
+        'Workstation OU is the default for staff-placed holds',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.staff_placed_holds_default_to_ws_ou',
+        'For staff-placed holds, regardless of the patron preferred pickup location, the staff workstation OU is the default pickup location',
+        'coust',
+        'description'
+    ),
+    'bool'
+);
+
+COMMIT;
index 525b8d5..f0679df 100644 (file)
@@ -177,8 +177,10 @@ function staff_hold_usr_barcode_changed2(
         // Safe at this point as we already set cur_hold_barcode
         document.getElementById('hold_usr_input').value = load_info.barcode;
 
-        // Patron preferred pickup loc always overrides the default pickup lib
+        // Patron preferred pickup loc overrides the default pickup lib 
+        // unless the default to workstation setting is enabled
         document.getElementById('pickup_lib').value = 
+            !load_info.settings['circ.staff_placed_holds_default_to_ws_ou'] &&
             load_info.settings['opac.default_pickup_location'] ?
             load_info.settings['opac.default_pickup_location'] : load_info.pickup_lib;
     }
index bf27b88..c4defe5 100644 (file)
@@ -259,7 +259,10 @@ angular.module('egCoreMod')
                                 return null;
                             }
 
-                            egCore.org.settings(['circ.staff_placed_holds_fallback_to_ws_ou'])
+                            var wsFallback = 'circ.staff_placed_holds_fallback_to_ws_ou';
+                            var wsDefault = 'circ.staff_placed_holds_default_to_ws_ou';
+
+                            egCore.org.settings([wsFallback, wsDefault])
                                 .then(function(auth_usr_aous){
 
                                     // copied more or less directly from XUL menu.js
@@ -268,13 +271,14 @@ angular.module('egCoreMod')
                                         settings[user.settings()[i].name()] = 
                                             JSON2js(user.settings()[i].value());
                                     }
+                                    settings[wsDefault] = auth_usr_aous[wsDefault];
 
                                     // find applicable YAOUSes for staff-placed holds
                                     var requestor = egCore.auth.user();
                                     var pickup_lib = user.home_ou(); // default to home ou
                                     if (requestor.id() !== user.id()){
                                         // this is a staff-placed hold, optionally default to ws ou
-                                        if (auth_usr_aous['circ.staff_placed_holds_fallback_to_ws_ou']){
+                                        if (auth_usr_aous[wsFallback] || auth_usr_aous[wsDefault]) {
                                             pickup_lib = requestor.ws_ou();
                                         }
                                     }