From: Adam Bowling Date: Fri, 15 Jan 2021 05:54:48 +0000 (-0500) Subject: Updates the Open-ILS/web/js/ui/default/staff/cat/item/app.js since the previous versi... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6bf37da2c6af81f1b0724f5ee14bf1e20e385733;p=evergreen%2Fpines.git Updates the Open-ILS/web/js/ui/default/staff/cat/item/app.js since the previous version did not take into consideration changes to this file. Signed-off-by: Adam Bowling --- 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 af35f6140c..1cd8f3e7ea 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 @@ -86,8 +86,12 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD itemSvc.add_copies_to_bucket([$scope.args.copyId]); } + $scope.add_records_to_bucket = function() { + itemSvc.add_records_to_bucket([$scope.args.recordId], 'biblio'); + } + $scope.show_in_catalog = function() { - window.open('/eg/staff/cat/catalog/record/' + $scope.args.recordId + '/catalog', '_blank'); + window.open('/eg2/staff/catalog/record/' + $scope.args.recordId, '_blank'); } $scope.print_labels = function() { @@ -145,41 +149,6 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD itemSvc.manage_reservations([$scope.args.copyBarcode]); } - $scope.findAcquisition = function() { - var acqData; - var promises = []; - $scope.openAcquisitionLineItem([$scope.args.copyId]); - } - - $scope.openAcquisitionLineItem = function (cp_list) { - var hasResults = false; - var promises = []; - - angular.forEach(cp_list, function (copyId) { - promises.push( - egNet.request( - 'open-ils.acq', - 'open-ils.acq.lineitem.retrieve.by_copy_id', - egCore.auth.token(), - copyId - ).then(function (acqData) { - if (acqData) { - if (acqData.a) { - acqData = egCore.idl.toHash(acqData); - var url = '/eg/acq/po/view/' + acqData.purchase_order + '/' + acqData.id; - $timeout(function () { $window.open(url, '_blank') }); - hasResults = true; - } - } - }) - ) - }); - - $q.all(promises).then(function () { - !hasResults ? alert('There is no corresponding purchase order for this item.') : false; - }); - } - $scope.requestItems = function() { itemSvc.requestItems([$scope.args.copyId],[$scope.args.recordId]); } @@ -200,7 +169,7 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD } $scope.show_record_holds = function() { - window.open('/eg/staff/cat/catalog/record/' + $scope.args.recordId + '/holds', '_blank'); + window.open('/eg2/staff/catalog/record/' + $scope.args.recordId + '/holds', '_blank'); } $scope.add_item_alerts = function() { @@ -394,6 +363,9 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD }; $scope.$watch('barcodesFromFile', function(newVal, oldVal) { + $scope.context.itemsNotFound = []; + $scope.context.fileDoneLoading = false; + $scope.context.numBarcodesInFile = 0; if (newVal && newVal != oldVal) { $scope.args.barcode = ''; var barcodes = []; @@ -420,13 +392,20 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD if(itemSvc.copies[0]){ // Were any copies actually retrieved copyGrid.selectItems([itemSvc.copies[0].index]); } + $scope.context.fileDoneLoading = true; return; } - itemSvc.fetch(barcode).then(fetch_next_copy); + itemSvc.fetch(barcode).then(function(item) { + if (!item) { + $scope.context.itemsNotFound.push(barcode); + } + fetch_next_copy(); + }) } if (barcodes.length) { + $scope.context.numBarcodesInFile = barcodes.length; egProgressDialog.open({value: 0, max: barcodes.length}); fetch_next_copy(); } @@ -436,17 +415,43 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD $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, noGridRefresh) { @@ -504,6 +509,17 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD return cp_id_list; } + function gatherSelectedHoldingsRecords() { + var record_id_list = []; + angular.forEach( + copyGrid.selectedItems(), + function (item) { + record_id_list.push(item['call_number.record.id']); + } + ) + return record_id_list; + } + $scope.refreshGridData = function() { var chain = $q.when(); var all_items = itemSvc.copies.map(function(item) { @@ -526,6 +542,11 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD itemSvc.add_copies_to_bucket(copy_list); } + $scope.add_records_to_bucket = function() { + var record_list = gatherSelectedHoldingsRecords(); + itemSvc.add_copies_to_bucket(record_list, 'biblio'); + } + $scope.locateAcquisition = function() { if (gatherSelectedHoldingsIds) { var cp_list = gatherSelectedHoldingsIds(); @@ -614,8 +635,10 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD } $scope.selectedHoldingsMissing = function () { + egProgressDialog.open(); itemSvc.selectedHoldingsMissing(copyGrid.selectedItems()) .then(function() { + egProgressDialog.close(); console.debug('Marking missing complete, refreshing grid'); copyGrid.refresh(); }); @@ -665,7 +688,7 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD $scope.showBibHolds = function () { angular.forEach(gatherSelectedRecordIds(), function (r) { - var url = egCore.env.basePath + 'cat/catalog/record/' + r + '/holds'; + var url = '/eg2/staff/catalog/record/' + r + '/holds'; $timeout(function() { $window.open(url, '_blank') }); }); }