LP1819367 - Allow paste of list of barcodes in csv format
authorJosh Stompro <stompro@stompro.org>
Fri, 13 Sep 2019 16:38:33 +0000 (11:38 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 21 Aug 2020 18:27:46 +0000 (14:27 -0400)
Allow the item status scan box to accept a string of barcodes
separated with commas.

Signed-off-by: Josh Stompro <stompro@stompro.org>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Elaine Hardy <ehardy@georgialibraries.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/cat/item/index.tt2
Open-ILS/web/js/ui/default/staff/cat/item/app.js

index 1fb54b3..f200f6e 100644 (file)
@@ -71,6 +71,7 @@
         aria-label="[% l('Scan Item') %]">
       <input class="btn btn-default" 
         type="submit" value="[% l('Submit') %]"/>
+      <eg-help-popover help-text="[% l('Single barcode or list of barcodes separated with commas.') %]">
     </div>
     <!-- give the upload container div some padding to prevent force the
         upload widget into the vertical middle of the row -->
index c419a72..2237d75 100644 (file)
@@ -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) {