From f47533b004dbcbbae8a575c3438cca873e63d256 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 28 Mar 2016 15:48:29 -0400 Subject: [PATCH] LP#1564685 Required-field org settings overlay defaults An org setting requiring a value for a field in the patron editor means the field is required, even if it's not required by default. IOW, fix the code that was supposed to do that already. Of note, county and state can now both be marked as required by org settings in the patron editor. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier Signed-off-by: Galen Charlton --- .../web/js/ui/default/staff/circ/patron/regctl.js | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) 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 37e331aa9b..106bdb09c0 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 @@ -1199,7 +1199,8 @@ function PatronRegCtrl($scope, $routeParams, $q, $modal, $window, egCore, // 3 == value universally required // 2 == field is visible by default // 1 == field is suggested by default - var field_visibility = { + var field_visibility = {}; + var default_field_visibility = { 'ac.barcode' : 3, 'au.usrname' : 3, 'au.passwd' : 3, @@ -1224,31 +1225,40 @@ function PatronRegCtrl($scope, $routeParams, $q, $modal, $window, egCore, 'surveys' : 1 }; - // returns true if the selected field should be visible + // Returns true if the selected field should be visible // given the current required/suggested/all setting. + // The visibility flag applied to each field as a result of calling + // this function also sets (via the same flag) the requiredness state. $scope.show_field = function(field_key) { + // org settings have not been received yet. + if (!$scope.org_settings) return false; if (field_visibility[field_key] == undefined) { // compile and cache the visibility for the selected field - // org settings have not been received yet. - if (!$scope.org_settings) return false; - var req_set = 'ui.patron.edit.' + field_key + '.require'; var sho_set = 'ui.patron.edit.' + field_key + '.show'; var sug_set = 'ui.patron.edit.' + field_key + '.suggest'; if ($scope.org_settings[req_set]) { field_visibility[field_key] = 3; + } else if ($scope.org_settings[sho_set]) { field_visibility[field_key] = 2; + } else if ($scope.org_settings[sug_set]) { field_visibility[field_key] = 1; - } else { - field_visibility[field_key] = 0; } } + if (field_visibility[field_key] == undefined) { + // No org settings were applied above. Use the default + // settings if present or assume the field has no + // visibility flags applied. + field_visibility[field_key] = + default_field_visibility[field_key] || 0; + } + return field_visibility[field_key] >= $scope.edit_passthru.vis_level; } -- 2.11.0