From aab2df83096e5f4890e021be2e8cfefc8a49854c Mon Sep 17 00:00:00 2001 From: Mike Risher Date: Wed, 5 Aug 2020 21:34:12 +0000 Subject: [PATCH] lp1890498: Replace Item Barcode now warns about duplicate barcode Modify the Replace Item Barcode page so that it displays an error message when trying to replace a barcode with a barcode already in use. Signed-off-by: Mike Risher Signed-off-by: Elaine Hardy Signed-off-by: Galen Charlton --- .../staff/cat/share/t_replace_barcode.tt2 | 3 +++ .../default/staff/cat/item/replace_barcode/app.js | 23 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 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 f15a831c76..62f9c8b9db 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 @@ -33,6 +33,9 @@
[% l('Item Not Found') %]
+
+ [% l('Duplicate Barcode') %] +
[% l('Item Updated') %] diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/replace_barcode/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/replace_barcode/app.js index 33d1cb6c61..d9d9d3db1a 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/item/replace_barcode/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/replace_barcode/app.js @@ -14,9 +14,10 @@ function($scope , egCore) { $scope.updateBarcode = function() { $scope.copyNotFound = false; + $scope.duplicateBarcode = false; $scope.updateOK = false; - egCore.pcrud.search('acp', + egCore.pcrud.search('acp', {deleted : 'f', barcode : $scope.barcode1}) .then(function(copy) { @@ -26,12 +27,22 @@ function($scope , egCore) { return; } - $scope.copyId = copy.id(); - copy.barcode($scope.barcode2); + egCore.pcrud.search('acp', + {deleted : 'f', barcode : $scope.barcode2}) + .then(function(newBarcodeCopy) { - egCore.pcrud.update(copy).then(function(stat) { - $scope.updateOK = stat; - $scope.focusBarcode = true; + 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; + }); }); }); } -- 2.11.0