LP#1452950 patron reg invalidate fields
authorBill Erickson <berickxx@gmail.com>
Tue, 8 Dec 2015 14:39:43 +0000 (09:39 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 25 Feb 2016 22:31:58 +0000 (17:31 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_edit.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index c8bfb8c..980ec0c 100644 (file)
       <!-- invalidate buttons -->
 
       [% IF field.match('phone') OR field.match('email') %]
-        <button ng-show="patron.[% field %] && !patron.isnew" class="btn btn-default"
-          ng-click="">[% l('Invalidate') %]</button>
+        <button ng-show="patron.[% field %] && !patron.isnew" 
+            class="btn btn-default" 
+            ng-click="invalidate_field('[% field %]')">
+            [% l('Invalidate') %]
+        </button>
       [% END %]
 
       <!-- example strings -->
index 8514b09..44f936c 100644 (file)
@@ -355,6 +355,24 @@ angular.module('egCoreMod')
         });
     }
 
+    service.invalidate_field = function(patron, field) {
+        console.log('Invalidating patron field ' + field);
+
+        return egCore.net.request(
+            'open-ils.actor',
+            'open-ils.actor.invalidate.' + field,
+            egCore.auth.token(), patron.id, null, patron.home_ou.id()
+
+        ).then(function(res) {
+            // clear the invalid value from the form
+            patron[field] = '';
+
+            // update last_xact_id so future save operations
+            // on this patron will be allowed
+            patron.last_xact_id = res.payload.last_xact_id[patron.id];
+        });
+    }
+
     service.init_patron = function(current) {
 
         if (!current)
@@ -387,7 +405,8 @@ angular.module('egCoreMod')
 
         patron.home_ou = egCore.org.get(patron.home_ou.id);
         patron.expire_date = new Date(Date.parse(patron.expire_date));
-        patron.dob = new Date(Date.parse(patron.dob));
+        patron.dob = patron.dob ?
+            new Date(Date.parse(patron.dob)) : null;
         patron.profile = current.profile(); // pre-hash version
         patron.net_access_level = current.net_access_level();
         patron.ident_type = current.ident_type();
@@ -1014,6 +1033,10 @@ function PatronRegCtrl($scope, $routeParams,
         $scope.hold_notify_sms = Boolean(notify.match(/sms/));
     }
 
+    $scope.invalidate_field = function(field) {
+        patronRegSvc.invalidate_field($scope.patron, field);
+    }
+
     $scope.edit_passthru.save = function() {
 
         // toss the deleted addresses back into the patron's list of