From: Galen Charlton Date: Wed, 5 Sep 2018 14:56:43 +0000 (-0400) Subject: LP#1781235: fix changing primary user barcode in web client X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=90c716e3bd4be9c449a9e5d71849abd8d4f07e4f;p=Evergreen.git LP#1781235: fix changing primary user barcode in web client This patch fixes a bug where the patron card dialog would not allow the user to change the primary barcode under certain circumstances. The fix is to ensure that the radio buttons controlling the selection of the primary card are bound to exactly one scope variable; otherwise, the /last/ barcode in the list that had a primary value set after user interaction would be the winner. To test ------- [1] Use the 'replace barcode' feature in the patron editor to create a test patron with 3 barcodes: - barcode A - barcode B - barcode C (which as last created, would be primary) [2] Attempt to make barcode A the primary barcode again using the 'See All' patron card dialog in the patron editor. [3] Note that the change of primary barcode doesn't stick upon saving the patron record. [4] Apply the patch and repeat steps 1-3. This time, the primary barcode should be changed as expected. [5] Verify that other patron edit actions and registering a new patron record continue to work as expected. Signed-off-by: Galen Charlton Signed-off-by: John Amundson Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/templates/staff/circ/patron/t_patron_cards_dialog.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_patron_cards_dialog.tt2 index 5ba4652e26..b171d71c77 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_patron_cards_dialog.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_patron_cards_dialog.tt2 @@ -23,8 +23,9 @@ ng-disabled="!perms.UPDATE_PATRON_ACTIVE_CARD"/>
-
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 9f6dbeb355..30f2a63d60 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 @@ -754,7 +754,7 @@ angular.module('egCoreMod') card.active = card.active == 't'; if (card.id == patron.card.id) { patron.card = card; - card._primary = 'on'; + card._primary = true; } }); @@ -802,7 +802,7 @@ angular.module('egCoreMod') id : service.virt_id--, isnew : true, active : true, - _primary : 'on' + _primary : true }; var user = { @@ -910,7 +910,7 @@ angular.module('egCoreMod') barcode : cuser.cards[0].barcode(), isnew : true, active : true, - _primary : 'on' + _primary : true }; user.cards.push(user.card); @@ -1625,10 +1625,15 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore , templateUrl: './circ/patron/t_patron_cards_dialog', backdrop: 'static', controller: - ['$scope','$uibModalInstance','cards','perms', - function($scope , $uibModalInstance , cards , perms) { + ['$scope','$uibModalInstance','cards','perms','patron', + function($scope , $uibModalInstance , cards , perms , patron) { // scope here is the modal-level scope - $scope.args = {cards : cards}; + $scope.args = {cards : cards, primary_barcode : null}; + angular.forEach(cards, function(card) { + if (card.id == patron.card.id) { + $scope.args.primary_barcode = card.id; + } + }); $scope.perms = perms; $scope.ok = function() { $uibModalInstance.close($scope.args) } $scope.cancel = function () { $uibModalInstance.dismiss() } @@ -1640,15 +1645,20 @@ function($scope , $routeParams , $q , $uibModal , $window , egCore , }, perms : function() { return $scope.perms; + }, + patron : function() { + return $scope.patron; } } }).result.then( function(args) { angular.forEach(args.cards, function(card) { card.ischanged = true; // assume cards need updating, OK? - if (card._primary == 'on' && - card.id != $scope.patron.card.id) { + if (card.id == args.primary_barcode) { $scope.patron.card = card; + card._primary = true; + } else { + card._primary = false; } }); }