From: erickson Date: Sun, 24 Sep 2006 15:20:31 +0000 (+0000) Subject: clearing invalid cards from the cards() array when the "mark lost" button is clicked X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5f818ccc9799a9d8fb80a06ead2470993d155e7d;p=Evergreen.git clearing invalid cards from the cards() array when the "mark lost" button is clicked git-svn-id: svn://svn.open-ils.org/ILS/trunk@6201 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Evergreen/xul/staff_client/server/patron/ue.js b/Evergreen/xul/staff_client/server/patron/ue.js index e9b7a9bf49..7c922b80c2 100644 --- a/Evergreen/xul/staff_client/server/patron/ue.js +++ b/Evergreen/xul/staff_client/server/patron/ue.js @@ -627,6 +627,16 @@ function uEditMarkCardLost() { card.ischanged(1); card.active(0); + if( !card.barcode() ) { + /* a card exists in the array with no barcode */ + ueRemoveCard(card.id()); + + } else if( card.isnew() && card.active() == 0 ) { + /* a new card was created, then never used, removing.. */ + _debug("removing new inactive card "+card.barcode()); + ueRemoveCard(card.id()); + } + /* create a new card for the patron */ var newcard = new ac(); newcard.id(uEditCardVirtId--); @@ -647,6 +657,17 @@ function uEditMarkCardLost() { } +function ueRemoveCard(id) { + _debug("removing card from cards() array: " + id); + var cds = grep( patron.cards(), function(c){return (c.id() != id)}); + if(!cds) cds = []; + for( var j = 0; j < cds.length; j++ ) + _debug("patron card array now has : "+cds[j].id()); + patron.cards(cds); +} + + + function compactArray(arr) { var a = []; for( var i = 0; arr && i < arr.length; i++ ) {