From 3558dc0cf2e10ee69345c96de75eaf2204fa76f0 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 9 Jul 2014 11:46:22 -0400 Subject: [PATCH] holds shelf. clear shelf Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/circ/holds/index.tt2 | 3 + Open-ILS/web/js/ui/default/staff/circ/holds/app.js | 74 ++++++++++++---------- 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/holds/index.tt2 b/Open-ILS/src/templates/staff/circ/holds/index.tt2 index 5bcac1c49c..b11ae2ec03 100644 --- a/Open-ILS/src/templates/staff/circ/holds/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/holds/index.tt2 @@ -17,6 +17,9 @@ [% END %] diff --git a/Open-ILS/web/js/ui/default/staff/circ/holds/app.js b/Open-ILS/web/js/ui/default/staff/circ/holds/app.js index 09772b92bc..607febff83 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/holds/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/holds/app.js @@ -190,9 +190,29 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e egHolds.retarget(hold_ids).then(refresh_page); } + + // udpate the in-grid hold with the clear-shelf cached response info. + function handle_clear_cache_resp(resp) { + console.debug('clear shelf said: ' + js2JSON(resp)); + if (!angular.isArray(resp)) resp = [resp]; + angular.forEach(resp, function(info) { + if (info.action) { + var grid_item = holds.filter(function(item) { + return item.hold.id() == info.hold_details.id + })[0]; + + // there will be no grid item if the hold is off-page + if (grid_item) { + grid_item.post_clear = + egCore.strings['CLEAR_SHELF_ACTION_' + info.action]; + } + } + }); + } + $scope.clear_holds = function() { clearing = true; - $scope.clear_progress = { max : 0, value : 0 }; + $scope.clear_progress = {max : 0, value : 0}; // we want to see all processed holds, so (effectively) remove // the grid limit. @@ -205,43 +225,29 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e egCore.auth.token(), $scope.pickup_ou.id() // request responses from the clear shelf cache - ).then(function(resp) { - console.debug('clear holds cache key is ' + resp.cache_key); - return egCore.net.request( - 'open-ils.circ', - 'open-ils.circ.hold.clear_shelf.get_cache', - egCore.auth.token(), resp.cache_key - ) - - // with each clear-shelf response, update the progress meter, - // hide it when done. - }).then( - function() { + ).then( + + // clear shelf done; fetch the cached results. + function(resp) { clearing = false; - }, + console.debug('clear holds cache key is ' + resp.cache_key); + egCore.net.request( + 'open-ils.circ', + 'open-ils.circ.hold.clear_shelf.get_cache', + egCore.auth.token(), resp.cache_key + ).then(null, null, handle_clear_cache_resp); + }, + null, + + // handle streamed clear_shelf progress updates function(resp) { - console.debug('clear shelf said: ' + js2JSON(resp)); - if (!angular.isArray(resp)) resp = [resp]; - angular.forEach(resp, function(info) { - if (info.maximum) - $scope.clear_progress.max = info.maximum; - if (info.progress) - $scope.clear_progress.value = info.progress; - - if (info.action) { - var grid_item = holds.filter(function(item) { - return item.hold.id() == info.hold_details.id - })[0]; - - // there will be no grid item if the hold is off-page - if (grid_item) { - grid_item.post_clear = - egCore.strings['CLEAR_SHELF_ACTION_' + info.action]; - } - } - }); + if (resp.maximum) + $scope.clear_progress.max = resp.maximum; + if (resp.progress) + $scope.clear_progress.value = resp.progress; } + ); } -- 2.11.0