From: Bill Erickson Date: Mon, 28 Mar 2016 19:48:29 +0000 (-0400) Subject: PEdit required fields bug fix -- use org settings when availavble X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9a99e0d006b4a62780fe242a60d173a147fe0da8;p=working%2FEvergreen.git PEdit required fields bug fix -- use org settings when availavble Signed-off-by: Bill Erickson --- 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; }