From 982d999ccd391abf811f2cc4fbb0f7108b5f5fc1 Mon Sep 17 00:00:00 2001
From: Bill Erickson <berickxx@gmail.com>
Date: Tue, 23 Jan 2018 17:56:51 -0500
Subject: [PATCH] LP#1743608 Replace barcode discards NULL/accidental entries

When replacing a patron's barcode in the patron editor, discard any
previous replacement attempts done in the current edit session.  This
prevents cases where secondary, etc. replacement cards are accidentally
created or NULL cards that result in ugly error messages.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
---
 Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js | 5 +++++
 1 file changed, 5 insertions(+)

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 b80e307f88..8b389ae6ba 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
@@ -1449,6 +1449,11 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore ,
         new_card.active = true;
         new_card._primary = 'on';
         $scope.patron.card = new_card;
+
+        // Remove any previous attempts to replace the card, since they
+        // may be incomplete or created by accident.
+        $scope.patron.cards =
+            $scope.patron.cards.filter(function(c) {return !c.isnew})
         $scope.patron.cards.push(new_card);
     }
 
-- 
2.11.0