From: Bill Erickson Date: Sat, 31 Oct 2015 17:08:02 +0000 (-0400) Subject: LP#1452950 patron reg code cleanup X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2dedeb342e9e84563d345e498b26bb6d22138095;p=evergreen%2Fpines.git LP#1452950 patron reg code cleanup Break up one of the bigger chunks by moving new patron defaults to its own function. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- 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 63ab0c4a38..8b67beedba 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 @@ -558,6 +558,33 @@ function PatronRegCtrl($scope, $routeParams, $scope.edit_passthru.vis_level = 0; // TODO: add save/clone handlers here + // Apply default values for new patrons during initial registration + // prs is shorthand for patronSvc + function set_new_patron_defaults(prs) { + $scope.generate_password(); + $scope.hold_notify_phone = true; + $scope.hold_notify_email = true; + + if (prs.org_settings['ui.patron.default_ident_type']) { + // $scope.patron needs this field to be an object + var id = prs.org_settings['ui.patron.default_ident_type']; + var ident_type = $scope.ident_types.filter( + function(type) { return type.id() == id })[0]; + $scope.patron.ident_type = ident_type; + } + if (prs.org_settings['ui.patron.default_inet_access_level']) { + // $scope.patron needs this field to be an object + var id = prs.org_settings['ui.patron.default_inet_access_level']; + var level = $scope.net_access_levels.filter( + function(lvl) { return lvl.id() == id })[0]; + $scope.patron.net_access_level = level; + } + if (prs.org_settings['ui.patron.default_country']) { + $scope.patron.addresses[0].country = + prs.org_settings['ui.patron.default_country']; + } + } + $q.all([ $scope.initTab ? // initTab comes from patron app @@ -597,31 +624,8 @@ function PatronRegCtrl($scope, $routeParams, if ($scope.org_settings['ui.patron.edit.default_suggested']) $scope.edit_passthru.vis_level = 1; - if ($scope.patron.isnew) { - $scope.generate_password(); - $scope.hold_notify_phone = true; - $scope.hold_notify_email = true; - - if (prs.org_settings['ui.patron.default_ident_type']) { - // $scope.patron needs this field to be an object - var id = prs.org_settings['ui.patron.default_ident_type']; - var ident_type = $scope.ident_types.filter( - function(type) { return type.id() == id })[0]; - $scope.patron.ident_type = ident_type; - } - if (prs.org_settings['ui.patron.default_inet_access_level']) { - // $scope.patron needs this field to be an object - var id = prs.org_settings['ui.patron.default_inet_access_level']; - var level = $scope.net_access_levels.filter( - function(lvl) { return lvl.id() == id })[0]; - $scope.patron.net_access_level = level; - } - if (prs.org_settings['ui.patron.default_country']) { - $scope.patron.addresses[0].country = - prs.org_settings['ui.patron.default_country']; - } - } - + if ($scope.patron.isnew) + set_new_patron_defaults(prs); }); // update the currently displayed field documentation