LP#1695029 Patron reg. supports bool opt-in defaults
authorBill Erickson <berickxx@gmail.com>
Fri, 21 Jul 2017 18:50:17 +0000 (14:50 -0400)
committerJason Etheridge <jason@EquinoxInitiative.org>
Thu, 31 Aug 2017 03:57:16 +0000 (23:57 -0400)
Support default values for boolean user opt-in settings during patron
registration.  A default value of True, true, T, or t (or really
anything starting with a 't') is treated as true.  Any other value
(including null) means false.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Josh Stompro <stomproj@larl.org>
Signed-off-by: Jason Etheridge <jason@EquinoxInitiative.org>
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index 0ec59df..92c4a5f 100644 (file)
@@ -516,8 +516,14 @@ angular.module('egCoreMod')
                 // apply default user setting values
                 angular.forEach(setting_types, function(stype, index) {
                     if (stype.reg_default() != undefined) {
                 // apply default user setting values
                 angular.forEach(setting_types, function(stype, index) {
                     if (stype.reg_default() != undefined) {
-                        service.user_settings[stype.name()] =
-                            Boolean(stype.reg_default());
+                        var val = stype.reg_default();
+                        if (stype.datatype() == 'bool') {
+                            // A boolean user setting type whose default 
+                            // value starts with t/T is considered 'true',
+                            // false otherwise.
+                            val = Boolean((val+'').match(/^t/i));
+                        }
+                        service.user_settings[stype.name()] = val;
                     }
                 });
             }
                     }
                 });
             }