From abc18bfcdf78d86f3578c1e4e3d90a89aff41eaf Mon Sep 17 00:00:00 2001 From: Josh Stompro Date: Fri, 13 Sep 2019 11:38:33 -0500 Subject: [PATCH] LP1819367 - Allow paste of list of barcodes in csv format Allow the item status scan box to accept a string of barcodes separated with commas. Signed-off-by: Josh Stompro Signed-off-by: Terran McCanna Signed-off-by: Elaine Hardy Signed-off-by: Bill Erickson --- .../src/templates/staff/cat/item/index.tt2 | 1 + .../web/js/ui/default/staff/cat/item/app.js | 45 ++++++++++++++----- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/item/index.tt2 b/Open-ILS/src/templates/staff/cat/item/index.tt2 index 1fb54b354e..f200f6e308 100644 --- a/Open-ILS/src/templates/staff/cat/item/index.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/index.tt2 @@ -71,6 +71,7 @@ aria-label="[% l('Scan Item') %]"> + diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js index c419a72e19..2237d75db9 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js @@ -415,17 +415,40 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD $scope.context.search = function(args) { if (!args.barcode) return; $scope.context.itemNotFound = false; - itemSvc.fetch(args.barcode).then(function(res) { - if (res) { - copyGrid.refresh(); - copyGrid.selectItems([res.index]); - $scope.args.barcode = ''; - } else { - $scope.context.itemNotFound = true; - egCore.audio.play('warning.item_status.itemNotFound'); - } - $scope.context.selectBarcode = true; - }) + + //check to see if there are multiple barcodes in CSV format + var barcodes = []; + //split on commas and clean up barcodes + angular.forEach(args.barcode.split(/,/), function(line) { + //remove all whitespace and commas + line = line.replace(/[\s,]+/g,''); + + //Or remove leading/trailing whitespace + //line = line.replace(/(^[\s,]+|[\s,]+$/g,''); + + if (!line) return; + barcodes.push(line); + }); + + if(barcodes.length > 1){ + //convert to newline seperated list and send to barcodesFromFile processor + $scope.barcodesFromFile = barcodes.join('\n'); + //console.log('Barcodes: ',barcodes); + } + else { + //Single Barcode + itemSvc.fetch(args.barcode).then(function(res) { + if (res) { + copyGrid.refresh(); + copyGrid.selectItems([res.index]); + $scope.args.barcode = ''; + } else { + $scope.context.itemNotFound = true; + egCore.audio.play('warning.item_status.itemNotFound'); + } + $scope.context.selectBarcode = true; + }) + } } var add_barcode_to_list = function (b) { -- 2.43.2