LP1699838 - add YOUSes for defaulting hold pickup locs
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Wed, 28 Feb 2018 19:08:08 +0000 (14:08 -0500)
committerKathy Lussier <klussier@masslnc.org>
Fri, 23 Mar 2018 19:34:25 +0000 (15:34 -0400)
Add a YAOUS... err make that two, to control how staff-placed holds
default the pickup library.

Signed-off by: Cesar Velez <cesar.velez@equinoxinitiative.org>

Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/sql/Pg/upgrade/XXXX.data.yaos-circ-holds-default-pickup-lib.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

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.yaos-circ-holds-default-pickup-lib.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.yaos-circ-holds-default-pickup-lib.sql
new file mode 100644 (file)
index 0000000..236dc1b
--- /dev/null
@@ -0,0 +1,14 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version);
+
+INSERT into config.org_unit_setting_type (name, label, grp, description, datatype)
+values ('circ.staff_placed_holds_honor_patron_prefs_first','Honor the patron-preferred Pickup Library as default for staff-placed holds.',
+        'circ', 'Honor the patron-preferred Pickup Library as the default for staff-placed holds.', 'bool');
+
+INSERT into config.org_unit_setting_type (name, label, grp, description, datatype)
+values ('circ.staff_placed_holds_staff_ws_ou_override','During Staff-placed holds, use the patron-preferred location or their home OU instead of the Staff User Workstation Org. unit as default pickup location.',
+    'circ', 'During staff-placed holds, use the patron-preferred location or their home OU instead of the Staff User Workstation Org. unit as default pickup location.', 'bool');
+
+COMMIT;
+
index 37d9a3c..711c995 100644 (file)
@@ -109,14 +109,43 @@ function staff_hold_usr_barcode_changed2(
         return;
     }
     cur_hold_barcode = load_info.barcode;
-    if(!only_settings || (isload && isload !== true)) document.getElementById('hold_usr_input').value = load_info.barcode; // Safe at this point as we already set cur_hold_barcode
-    if(!only_settings || (isload && isload !== true) && load_info.pickup_lib) document.getElementById('pickup_lib').value = load_info.pickup_lib; // Safe at this point as we already set cur_hold_barcode
-    if(load_info.settings['opac.default_pickup_location'])
-        document.getElementById('pickup_lib').value = load_info.settings['opac.default_pickup_location'];
-    if(!load_info.settings['opac.default_phone']) load_info.settings['opac.default_phone'] = '';
-    if(!load_info.settings['opac.default_sms_notify']) load_info.settings['opac.default_sms_notify'] = '';
-    if(!load_info.settings['opac.default_sms_carrier']) load_info.settings['opac.default_sms_carrier'] = '';
-    if(load_info.settings['opac.hold_notify'] || load_info.settings['opac.hold_notify'] === '') {
+    if (!only_settings || (isload && isload !== true)) {
+        document.getElementById('hold_usr_input').value = load_info.barcode;
+        // Safe at this point as we already set cur_hold_barcode
+    }
+
+    var patronDefaultPickupOU;
+    if (!only_settings || (isload && isload !== true) && load_info.pickup_lib) {
+
+        // Patron default is either their preferred pickup loc or their home OU
+        patronDefaultPickupOU = load_info.settings['opac.default_pickup_location']
+            ? load_info.settings['opac.default_pickup_location'] : load_info.pickup_lib;
+
+        document.getElementById('pickup_lib').value = patronDefaultPickupOU;
+        // Safe at this point as we already set cur_hold_barcode
+    }
+
+    if (load_info.settings['staff_WS_OU']){ // this is staff-placed hold!
+
+        // check wether we want to default to staff's WS OU or just the patron's Home OU
+        document.getElementById('pickup_lib').value = load_info.settings['overrideStaff_WS_OU']
+            ? patronDefaultPickupOU : load_info.settings['staff_WS_OU'];
+
+        // use staff WS OU as default pickup_lib unless YAOUS says otherwise
+        document.getElementById('pickup_lib').value = load_info.settings['honorPatronPrefPickupOU']
+            ?  patronDefaultPickupOU : load_info.settings['staff_WS_OU'];
+
+    }
+
+    if (!load_info.settings['opac.default_sms_notify']){
+        load_info.settings['opac.default_sms_notify'] = '';
+    }
+
+    if (!load_info.settings['opac.default_sms_carrier']){
+        load_info.settings['opac.default_sms_carrier'] = '';
+    }
+
+    if (load_info.settings['opac.hold_notify'] || load_info.settings['opac.hold_notify'] === '') {
         var email = load_info.settings['opac.hold_notify'].indexOf('email') > -1;
         var phone = load_info.settings['opac.hold_notify'].indexOf('phone') > -1;
         var sms = load_info.settings['opac.hold_notify'].indexOf('sms') > -1;
@@ -127,8 +156,10 @@ function staff_hold_usr_barcode_changed2(
         update_elements = document.getElementsByName('sms_notify_checkbox');
         for(var i in update_elements) update_elements[i].checked = (sms ? 'checked' : '');
     }
+
     update_elements = document.getElementsByName('phone_notify');
-    for(var i in update_elements) update_elements[i].value = load_info.settings['opac.default_phone'];
+    for(var i in update_elements) update_elements[i].value = load_info.settings['opac.default_phone']
+        ? load_info.settings['opac.default_phone'] : '';
     update_elements = document.getElementsByName('sms_notify');
     for(var i in update_elements) update_elements[i].value = load_info.settings['opac.default_sms_notify'];
     update_elements = document.getElementsByName('sms_carrier');
index ae26e7f..1b423b2 100644 (file)
@@ -239,34 +239,56 @@ angular.module('egCoreMod')
                                 return null;
                             }
 
-                            // copied more or less directly from XUL menu.js
-                            var settings = {};
-                            for(var i = 0; i < user.settings().length; i++) {
-                                settings[user.settings()[i].name()] = 
-                                    JSON2js(user.settings()[i].value());
-                            }
-
-                            if(!settings['opac.default_phone'] && user.day_phone()) 
-                                settings['opac.default_phone'] = user.day_phone();
-                            if(!settings['opac.hold_notify'] && settings['opac.hold_notify'] !== '') 
-                                settings['opac.hold_notify'] = 'email:phone';
-
-                            // Taken from patron/util.js format_name
-                            // FIXME: I18n
-                            var patron_name = 
-                                ( user.prefix() ? user.prefix() + ' ' : '') +
-                                user.family_name() + ', ' +
-                                user.first_given_name() + ' ' +
-                                ( user.second_given_name() ? user.second_given_name() + ' ' : '' ) +
-                                ( user.suffix() ? user.suffix() : '');
-
-                            deferred.resolve({
-                                "barcode": barcode, 
-                                "pickup_lib": user.home_ou(), 
-                                "settings" : settings, 
-                                "user_email" : user.email(), 
-                                "patron_name" : patron_name
-                            });
+                            egCore.org.settings(['circ.staff_placed_holds_honor_patron_prefs_first',
+                                'circ.staff_placed_holds_staff_ws_ou_override'])
+                                .then(function(auth_usr_aous){
+
+                                    // copied more or less directly from XUL menu.js
+                                    var settings = {};
+                                    for(var i = 0; i < user.settings().length; i++) {
+                                        settings[user.settings()[i].name()] = 
+                                            JSON2js(user.settings()[i].value());
+                                    }
+
+                                    // find applicable YAOUSes for staff-placed holds
+                                    var honorPatronPrefPickupOU;
+                                    var overrideStaff_WS_OU;
+                                    var requestor = egCore.auth.user();
+                                    if (requestor.id() !== user.id()){
+                                        // this is a staff-placed hold
+
+                                        settings["staff_WS_OU"] = requestor.ws_ou();
+                                        if (auth_usr_aous['circ.staff_placed_holds_honor_patron_prefs_first']){
+                                            settings['honorPatronPrefPickupOU'] = true;
+                                        }
+
+                                        if (auth_usr_aous['circ.staff_placed_holds_staff_ws_ou_override']){
+                                            settings['overrideStaff_WS_OU'] = true;
+                                        }
+                                    }
+
+                                    if(!settings['opac.default_phone'] && user.day_phone()) 
+                                        settings['opac.default_phone'] = user.day_phone();
+                                    if(!settings['opac.hold_notify'] && settings['opac.hold_notify'] !== '') 
+                                        settings['opac.hold_notify'] = 'email:phone';
+
+                                    // Taken from patron/util.js format_name
+                                    // FIXME: I18n
+                                    var patron_name = 
+                                        ( user.prefix() ? user.prefix() + ' ' : '') +
+                                        user.family_name() + ', ' +
+                                        user.first_given_name() + ' ' +
+                                        ( user.second_given_name() ? user.second_given_name() + ' ' : '' ) +
+                                        ( user.suffix() ? user.suffix() : '');
+
+                                    deferred.resolve({
+                                        "barcode": barcode, 
+                                        "pickup_lib": user.home_ou(), 
+                                        "settings" : settings, 
+                                        "user_email" : user.email(), 
+                                        "patron_name" : patron_name
+                                    });
+                                });
                         });
 
                         return deferred.promise;