LP#1879993: use default value for opac.hold_notify when appropriate
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Fri, 22 May 2020 22:40:30 +0000 (15:40 -0700)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 31 Aug 2020 15:24:00 +0000 (11:24 -0400)
Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>

Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index 17c908b..e161105 100644 (file)
@@ -1296,9 +1296,16 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
             // passsword may originate from staged user.
             $scope.generate_password();
         }
-        $scope.hold_notify_type.phone = true;
-        $scope.hold_notify_type.email = true;
-        $scope.hold_notify_type.sms = false;
+
+        var notify = 'phone:email'; // hard-coded default when opac.hold_notify has no reg_default
+        var notify_stype = $scope.user_setting_types['opac.hold_notify'];
+        if (notify_stype && notify_stype.reg_default() !== undefined && notify_stype.reg_default() !== null) {
+            console.log('using default opac.hold_notify');
+            notify = notify_stype.reg_default();
+        }
+        $scope.hold_notify_type.phone = Boolean(notify.match(/phone/));
+        $scope.hold_notify_type.email = Boolean(notify.match(/email/));
+        $scope.hold_notify_type.sms = Boolean(notify.match(/sms/));
 
         // staged users may be loaded w/ a profile.
         $scope.set_expire_date();
@@ -1897,12 +1904,21 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
 
     function extract_hold_notify() {
         var p = $scope.patron;
+
+        // get the user's opac.hold_notify setting
         var notify = $scope.user_settings['opac.hold_notify'];
 
+        // if it's not set, use the default opac.hold_notify value
         if (!notify && !(notify === '')) {
-            $scope.hold_notify_type.phone = true;
-            $scope.hold_notify_type.email = true;
-            return;
+            var notify_stype = $scope.user_setting_types['opac.hold_notify'];
+            if (notify_stype && notify_stype.reg_default() !== undefined && notify_stype.reg_default() !== null) {
+                notify = notify_stype.reg_default();
+            } else {
+                // no setting and no default: set phone and email to true
+                $scope.hold_notify_type.phone = true;
+                $scope.hold_notify_type.email = true;
+                return;
+            }
         }
 
         $scope.hold_notify_type.phone = Boolean(notify.match(/phone/));