From: Bill Erickson Date: Thu, 17 Dec 2020 15:19:14 +0000 (-0800) Subject: LP1896285 Post mark-missing serialized item load X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=93a53f57d712355f14a8829fa849bd4686811004;p=evergreen%2Fpines.git LP1896285 Post mark-missing serialized item load Signed-off-by: Bill Erickson Signed-off-by: Chris Sharp --- 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 857e522c0f..fe5bfc49f1 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 @@ -433,25 +433,51 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD } }); - $scope.context.search = function(args) { - if (!args.barcode) return; + $scope.context.search = function(args, noGridRefresh) { + if (!args.barcode) return $q.when(); $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); + return $q.when(); + + } else { + //Single Barcode + return itemSvc.fetch(args.barcode).then(function(res) { + if (res) { + if (!noGridRefresh) { + 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) { - //console.log('listCtrl: add_barcode_to_list',b); - $scope.context.search({barcode:b}); + var add_barcode_to_list = function (b, noGridRefresh) { + // console.log('listCtrl: add_barcode_to_list',b); + return $scope.context.search({barcode:b}, noGridRefresh); } itemSvc.add_barcode_to_list = add_barcode_to_list; @@ -614,7 +640,11 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD } $scope.selectedHoldingsMissing = function () { - itemSvc.selectedHoldingsMissing(copyGrid.selectedItems()); + itemSvc.selectedHoldingsMissing(copyGrid.selectedItems()) + .then(function() { + console.debug('Marking missing complete, refreshing grid'); + copyGrid.refresh(); + }); } $scope.checkin = function () { 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 8e2142882f..0dd074834c 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 @@ -636,8 +636,16 @@ function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast } service.selectedHoldingsMissing = function (items) { - egCirc.mark_missing(items.map(function(el){return {id : el.id, barcode : el.barcode};})).then(function(){ - angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)}); + return egCirc.mark_missing( + items.map(function(el){return {id : el.id, barcode : el.barcode};}) + ).then(function(){ + var promise = $q.when(); + angular.forEach(items, function(cp){ + promise = promise.then(function() { + return service.add_barcode_to_list(cp.barcode, true); + }); + }); + return promise; }); }