LP#1564685 Allow delete of all patron addresses
authorBill Erickson <berickxx@gmail.com>
Mon, 28 Mar 2016 19:30:37 +0000 (15:30 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 4 Apr 2016 20:36:27 +0000 (16:36 -0400)
If the org setting ui.patron.registration.require_address is not true,
allow all addresses to be removed from a patron's account.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/register.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index 3eac3ef..0df6f9e 100644 (file)
@@ -14,6 +14,8 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
   s.REG_ADDR_TYPE = "[% l('Mailing') %]";
   s.REG_INVALID_FIELDS = 
     "[% l('Please enter valid values for all required fields.') %]"
+  s.REG_ADDR_REQUIRED = 
+    "[% l('An address is required during registration.') %]"
 }]);
 </script>
 <link rel="stylesheet" href="[% ctx.base_path %]/staff/css/circ.css" />
index 534bda5..37e331a 100644 (file)
@@ -1309,6 +1309,14 @@ function PatronRegCtrl($scope, $routeParams, $q, $modal, $window, egCore,
     // when the patron is updated.
     deleted_addresses = [];
     $scope.delete_address = function(id) {
+
+        if ($scope.patron.isnew &&
+            $scope.patron.addresses.length == 1 &&
+            $scope.org_settings['ui.patron.registration.require_address']) {
+            egAlertDialog.open(egCore.strings.REG_ADDR_REQUIRED);
+            return;
+        }
+
         var addresses = [];
         angular.forEach($scope.patron.addresses, function(addr) {
             if (addr.id == id) {