}
});
- $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;
//check to see if there are multiple barcodes in CSV format
//convert to newline seperated list and send to barcodesFromFile processor
$scope.barcodesFromFile = barcodes.join('\n');
//console.log('Barcodes: ',barcodes);
- }
- else {
+ return $q.when();
+
+ } else {
//Single Barcode
- itemSvc.fetch(args.barcode).then(function(res) {
+ return itemSvc.fetch(args.barcode).then(function(res) {
if (res) {
- copyGrid.refresh();
+ if (!noGridRefresh) {
+ copyGrid.refresh();
+ }
copyGrid.selectItems([res.index]);
$scope.args.barcode = '';
} else {
}
}
- 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;
}
$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 () {
}
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;
});
}