From df88759b55b140cff101043e49256e19a2adc016 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 16 May 2014 15:18:45 -0400 Subject: [PATCH] item status UI continued; upload Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/cat/item/index.tt2 | 47 +++++++-------- Open-ILS/web/js/ui/default/staff/cat/item/app.js | 69 ++++++++++++++++------- Open-ILS/web/js/ui/default/staff/services/grid.js | 4 +- 3 files changed, 77 insertions(+), 43 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/item/index.tt2 b/Open-ILS/src/templates/staff/cat/item/index.tt2 index 4557afc706..a79661f229 100644 --- a/Open-ILS/src/templates/staff/cat/item/index.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/index.tt2 @@ -8,7 +8,7 @@ [% BLOCK APP_JS %] - + [% END %] @@ -26,29 +26,32 @@

[% l('Scan Item') %]

-
-
-
- - - - - - - - - - -
-
-
+
+
+ + +
+
+
+
[% l('OR') %]
+
+ +
+
+
+
+ +
+
+
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 690d01a4f0..b6b8cdaba8 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 @@ -57,6 +57,7 @@ function(egCore) { } } + // resolved with the last received copy service.fetch = function(barcode, id, noListDupes) { var promise; @@ -67,27 +68,33 @@ function(egCore) { promise = egCore.pcrud.retrieve('acp', id, service.flesh); } - return promise.then(function(copy) { - if (!copy) return null; + var lastRes; + return promise.then( + function() {return lastRes}, + null, // error - var flatCopy; - if (noListDupes) { - // use the existing copy if possible - flatCopy = service.copies.filter( - function(c) {return c.id == copy.id()})[0]; - } + // notify reads the stream of copies, one at a time. + function(copy) { - if (!flatCopy) { - flatCopy = egCore.idl.toHash(copy, true); - flatCopy.index = service.index++; - service.copies.unshift(flatCopy); - } + var flatCopy; + if (noListDupes) { + // use the existing copy if possible + flatCopy = service.copies.filter( + function(c) {return c.id == copy.id()})[0]; + } - return { - copy : copy, - index : flatCopy.index - }; - }); + if (!flatCopy) { + flatCopy = egCore.idl.toHash(copy, true); + flatCopy.index = service.index++; + service.copies.unshift(flatCopy); + } + + return lastRes = { + copy : copy, + index : flatCopy.index + } + } + ); } return service; @@ -119,8 +126,8 @@ function($scope , $location , egCore , egGridDataProvider , itemSvc) { * List view - grid stuff */ .controller('ListCtrl', - ['$scope','$location','$timeout','egCore','egGridDataProvider','itemSvc', -function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc) { + ['$scope','$q','$location','$timeout','egCore','egGridDataProvider','itemSvc', +function($scope , $q , $location , $timeout , egCore , egGridDataProvider , itemSvc) { $scope.context.page = 'list'; var provider = egGridDataProvider.instance(); @@ -131,7 +138,29 @@ function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc) provider.itemFieldValue = provider.flatItemFieldValue; $scope.gridDataProvider = provider; + $scope.$watch('barcodesFromFile', function(newVal, oldVal) { + if (newVal && newVal != oldVal) { + $scope.args.barcode = ''; + var barcodes = []; + + angular.forEach(newVal.split(/\n/), function(line) { + if (!line) return; + // scrub any trailing spaces or commas from the barcode + line = line.replace(/(.*?)($|\s.*|,.*)/,'$1'); + barcodes.push(line); + }); + + itemSvc.fetch(barcodes).then( + function() { + provider.increment() + provider.selectOneItem(itemSvc.copies[0].index); + } + ); + } + }); + $scope.context.search = function(args) { + if (!args.barcode) return; $scope.context.itemNotFound = false; itemSvc.fetch(args.barcode).then(function(res) { if (res) { diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index d3be787dfc..dcb48809af 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -666,8 +666,10 @@ angular.module('egGridMod', // asks the dataProvider for a page of data grid.collect = function() { + if (grid.collecting) return; // avoid parallel collects() $scope.items = []; $scope.selected = {}; + grid.collecting = true; grid.dataProvider.get(grid.offset, grid.limit) .then(null, null, function(item) { if (item) { @@ -675,7 +677,7 @@ angular.module('egGridMod', if (grid.onItemRetrieved) grid.onItemRetrieved(item); } - }); + })['finally'](function() { grid.collecting = false }) } grid.init(); -- 2.11.0