LP#1774268: display effective hold notify preference on patron editor user/rogan/lp1774268signoff
authora. bellenir <ab@grpl.org>
Wed, 13 Jun 2018 15:43:47 +0000 (11:43 -0400)
committerRogan Hamby <rogan.hamby@gmail.com>
Tue, 11 Dec 2018 14:23:44 +0000 (09:23 -0500)
fallback on a default hold notify if user does not have a saved preference.
skip saving if the value is unchanged from default.

Signed-off-by: a. bellenir <ab@grpl.org>
Signed-off-by: Rogan Hamby <rogan.hamby@gmail.com>
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index cd8843a..8122e1e 100644 (file)
@@ -1231,6 +1231,8 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
          patronSvc , patronRegSvc , egUnloadPrompt, egAlertDialog ,
          egWorkLog) {
 
+    var default_hold_notify = ':phone:email';
+
     $scope.page_data_loaded = false;
     $scope.hold_notify_type = { phone : null, email : null, sms : null };
     $scope.clone_id = patronRegSvc.clone_id = $routeParams.clone_id;
@@ -1759,7 +1761,14 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
             hold_notify_methods.push('sms');
         }
 
-        $scope.user_settings['opac.hold_notify'] = hold_notify_methods.join(':');
+        // always include a leading ':' to prevent saving an empty string
+        // this allows a user to specify that they do not want any notifications
+        // (otherwise the falsey empty string will fallback to default)
+        var notify_string = ':'+hold_notify_methods.join(':');
+        // save only if there already was a value or the new value is non-default
+        if($scope.user_settings['opac.hold_notify'] || notify_string !== default_hold_notify){
+            $scope.user_settings['opac.hold_notify'] = notify_string;
+        }
     }
 
     // dialog for selecting additional permission groups
@@ -1825,8 +1834,7 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
     }
 
     function extract_hold_notify() {
-        var notify = $scope.user_settings['opac.hold_notify'];
-        if (!notify) return;
+        var notify = $scope.user_settings['opac.hold_notify'] || default_hold_notify;
         $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/));