From 182eb514495d105f59bc7631957437e252b26ab2 Mon Sep 17 00:00:00 2001 From: Jason Boyer Date: Wed, 31 May 2017 15:29:46 -0400 Subject: [PATCH] lp1642035: Editing User Hold Preferences The JS for hold notification values was replacing rather than concatenating so only the furthest-right true value would be saved. And because an ng-if directive creates a child scope[1], the hold_notify_sms primitive could never be true. Changed hold_notify_* to an object to avoid this. An ng-model directive was added to enable opac.default_sms_notify but opac.default_sms_carrier will still require some work to enable / replace. [1]:https://github.com/angular/angular.js/wiki/Understanding-Scopes Testing: pre-patch: Try to do anything with default sms number, fail. Try to set more than one of phone + email notification, fail. Try to set sms notification to anything, fail. post-patch: Default sms notify value is populated and can be changed. All 8 possible combinations of hold notify options can be set. Still can't set opac.default_sms_carrier value, needs additional work. Signed-off-by: Jason Boyer Signed-off-by: Kathy Lussier --- .../templates/staff/circ/patron/t_edit.tt2 | 8 +++---- .../js/ui/default/staff/circ/patron/regctl.js | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 index 4f4cc6e43e..b7d9606175 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 @@ -624,19 +624,19 @@ within the "form" by name for validation.
+ type='checkbox' ng-model="hold_notify_type.phone"/> [% l('Phone') %]
+ type='checkbox' ng-model="hold_notify_type.email"/> [% l('Email') %]
+ type='checkbox' ng-model="hold_notify_type.sms"/> [% l('SMS') %]
@@ -648,7 +648,7 @@ within the "form" by name for validation.
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js index f9c20c65f7..9d02459ba6 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js @@ -1097,6 +1097,7 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore , egWorkLog) { $scope.page_data_loaded = false; + $scope.hold_notify_type = { phone : null, email : null, sms : null }; $scope.clone_id = patronRegSvc.clone_id = $routeParams.clone_id; $scope.stage_username = patronRegSvc.stage_username = $routeParams.stage_username; @@ -1130,8 +1131,9 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore , // passsword may originate from staged user. $scope.generate_password(); } - $scope.hold_notify_phone = true; - $scope.hold_notify_email = true; + $scope.hold_notify_type.phone = true; + $scope.hold_notify_type.email = true; + $scope.hold_notify_type.sms = false; // staged users may be loaded w/ a profile. $scope.set_expire_date(); @@ -1500,16 +1502,16 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore , function compress_hold_notify() { var hold_notify = ''; var splitter = ''; - if ($scope.hold_notify_phone) { + if ($scope.hold_notify_type.phone) { hold_notify = 'phone'; splitter = ':'; } - if ($scope.hold_notify_email) { - hold_notify = splitter + 'email'; + if ($scope.hold_notify_type.email) { + hold_notify = hold_notify + splitter + 'email'; splitter = ':'; } - if ($scope.hold_notify_sms) { - hold_notify = splitter + 'sms'; + if ($scope.hold_notify_type.sms) { + hold_notify = hold_notify + splitter + 'sms'; splitter = ':'; } $scope.user_settings['opac.hold_notify'] = hold_notify; @@ -1579,9 +1581,9 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore , function extract_hold_notify() { var notify = $scope.user_settings['opac.hold_notify']; if (!notify) return; - $scope.hold_notify_phone = Boolean(notify.match(/phone/)); - $scope.hold_notify_email = Boolean(notify.match(/email/)); - $scope.hold_notify_sms = Boolean(notify.match(/sms/)); + $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/)); } $scope.invalidate_field = function(field) { -- 2.43.2