From 30a2dccf05b9eb8fdaa329023773796502861cd6 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 10 Nov 2021 10:06:36 -0500 Subject: [PATCH] LP#1950468: make Replace Barcode from Item Status detect duplicate barcodes This patch makes the Replace Barcode action when invoked from Item Status properly detect and warn if the replacement barcode is a duplicate of one already found in the system. This is a complement to the fix for bug 1890498. To test ------- [1] Enter an item barcode into Item Status. [2] Try 'Replace Barcode' from detail view and set the replacement barcode to one that is already active in Evergreen. Note that the dialog closes without updating the barcode or warning about the duplicate and that a error is logged in the browser console. [3] Repeat step 2, but this time from list view. Note the problem remains the same. [4] Apply the patch and repeat steps 2 and 3. Note that now the dialog will remain open and will display an error message complaining about the duplicate barcode. Signed-off-by: Galen Charlton Signed-off-by: Erica Rohlfs Signed-off-by: Jane Sandberg --- .../staff/cat/share/t_replace_barcode.tt2 | 1 + .../web/js/ui/default/staff/circ/services/item.js | 26 +++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/share/t_replace_barcode.tt2 b/Open-ILS/src/templates/staff/cat/share/t_replace_barcode.tt2 index 7e859faebb..36fbb0265c 100644 --- a/Open-ILS/src/templates/staff/cat/share/t_replace_barcode.tt2 +++ b/Open-ILS/src/templates/staff/cat/share/t_replace_barcode.tt2 @@ -31,6 +31,7 @@
+
[% l('Item Not Found') %] diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/item.js b/Open-ILS/web/js/ui/default/staff/circ/services/item.js index 56d82bfec4..e34cc1a1de 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/services/item.js +++ b/Open-ILS/web/js/ui/default/staff/circ/services/item.js @@ -817,17 +817,27 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast return; } - $scope.copyId = copy.id(); - copy.barcode($scope.barcode2); - - egCore.pcrud.update(copy).then(function(stat) { - $scope.updateOK = stat; - $scope.focusBarcode = true; - if (stat) service.add_barcode_to_list(copy.barcode()); + egCore.pcrud.search('acp', + {deleted : 'f', barcode : $scope.barcode2}) + .then(function(newBarcodeCopy) { + + if (newBarcodeCopy) { + $scope.duplicateBarcode = true; + return; + } + + $scope.copyId = copy.id(); + copy.barcode($scope.barcode2); + + egCore.pcrud.update(copy).then(function(stat) { + $scope.updateOK = stat; + $scope.focusBarcode = true; + if (stat) service.add_barcode_to_list(copy.barcode()); + $uibModalInstance.close(); + }); }); }); - $uibModalInstance.close(); } $scope.cancel = function($event) { -- 2.11.0