Patch from Jeff Davis (SITKA) fixing cardless patron updates
authorMike Rylander <mrylander@gmail.com>
Tue, 15 Nov 2011 20:04:08 +0000 (15:04 -0500)
committerMike Rylander <mrylander@gmail.com>
Tue, 15 Nov 2011 20:04:08 +0000 (15:04 -0500)
Quoth the bug report (https://bugs.launchpad.net/evergreen/+bug/851110):

  On our Evergreen 2.0.8 system, it sometimes arises that a patron's card gets deleted. If it was the patron's only card, it becomes impossible to add a new card to the account via the staff client.

  How to reproduce:
  1. Retrieve a patron record for a patron who has no associated card.
  2. Click the Edit button.
  3. Click Replace Barcode and enter a new barcode.
  4. Click Save. This does not work - the process hangs, and if you hit Reload, you will find that your changes were not saved.

  I believe this happens because some code in register.js assumes the patron has at least one card. I have a potential fix that this comment box is too small to contain ... uh, that is to say, I will post it momentarily.

Which he did, and I applied.

Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/web/js/ui/default/actor/user/register.js

index 33fecd7..30359fe 100644 (file)
@@ -346,9 +346,11 @@ function replaceCardHandler() {
     replaceBarcode.attr('disabled', true);
     
     // pull old card off the cards list so we don't have a dupe sitting in there
-    var old = patron.cards().filter(function(c){return (c.id() == patron.card().id())})[0];
-    old.active('f');
-    old.ischanged(1);
+    if (patron.cards().length > 0) {
+        var old = patron.cards().filter(function(c){return (c.id() == patron.card().id())})[0];
+        old.active('f');
+        old.ischanged(1);
+    }
 
     var newc = new fieldmapper.ac();
     newc.id(uEditCardVirtId--);