LP1904036 Patron editor honor reg_default for settings
authorBill Erickson <berickxx@gmail.com>
Mon, 2 May 2022 15:44:19 +0000 (11:44 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:42 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/edit.component.ts

index 983ce0c..9949318 100644 (file)
@@ -701,6 +701,19 @@ export class EditComponent implements OnInit, AfterViewInit {
                 if (!COMMON_USER_SETTING_TYPES.includes(stype.name())) {
                     this.optInSettingTypes[stype.name()] = stype;
                 }
+
+                if (this.patron.isnew()) {
+                    let val = stype.reg_default();
+                    if (val !== null && val !== undefined) {
+                        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));
+                        }
+                        this.userSettings[stype.name()] = val
+                    }
+                }
             });
         });
     }