From: Bill Erickson Date: Thu, 2 Mar 2017 23:05:05 +0000 (-0500) Subject: LP#1653001 Hold pull list progress dialog X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6fa137e176b4f08f083828fcc454aefbc2e8118b;p=contrib%2FConifer.git LP#1653001 Hold pull list progress dialog Display a progress dialog while loading the holds pull list grid and the when collecting data for printing the holds pull list. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/src/templates/staff/circ/holds/t_pull_list.tt2 b/Open-ILS/src/templates/staff/circ/holds/t_pull_list.tt2 index 91b8571acd..4016967e1f 100644 --- a/Open-ILS/src/templates/staff/circ/holds/t_pull_list.tt2 +++ b/Open-ILS/src/templates/staff/circ/holds/t_pull_list.tt2 @@ -1,7 +1,3 @@ -
- [% l('Loading... [_1]', '{{print_list_progress}}') %] -
- semi-determinate progress + // modal. Using a determinate modal that starts counting + // on the post-grid holds data retrieval results in a modal + // that's stuck at 0% for most of its life, which is aggravating. + egProgressDialog.open(); + }, itemRetrieved : function(item) { + egProgressDialog.increment(); if (!cached_details[item.id]) { details_needed[item.id] = item; } }, - allItemsRetrieved : flesh_holds + allItemsRetrieved : function() { + flesh_holds().finally(egProgressDialog.close); + } } @@ -275,40 +285,36 @@ function($scope , $q , $routeParams , $window , $location , egCore , // and friends have access to holds data they understand. // Only fetch not-yet-cached data. function flesh_holds() { + egProgressDialog.increment(); // Start by fleshing hold details from our cached data. var items = $scope.gridControls.allItems(); angular.forEach(items, function(item) { - if (!cached_details[item.id]) return; + if (!cached_details[item.id]) return $q.when(); angular.forEach(cached_details[item.id], function(val, key) { item[key] = val }) }); // Exit if all needed details were already cached - if (Object.keys(details_needed).length == 0) return; - - $scope.print_list_loading = true; - $scope.print_list_progress = 0; + if (Object.keys(details_needed).length == 0) return $q.when(); - egCore.net.request( + return egCore.net.request( 'open-ils.circ', 'open-ils.circ.hold.details.batch.retrieve.authoritative', egCore.auth.token(), Object.keys(details_needed) - ).then( - function() { - $scope.print_list_loading = false; - $scope.print_list_progress = null; - }, null, - function(hold_info) { - var hold_id = hold_info.hold.id(); - cached_details[hold_id] = hold_info; - var item = details_needed[hold_id]; - delete details_needed[hold_id]; - angular.forEach(hold_info, - function(val, key) { item[key] = val }); - $scope.print_list_progress++; - } - ); + + ).then(null, null, function(hold_info) { + egProgressDialog.increment(); + var hold_id = hold_info.hold.id(); + cached_details[hold_id] = hold_info; + var item = details_needed[hold_id]; + delete details_needed[hold_id]; + + // flesh the grid item from the blob of hold data. + angular.forEach(hold_info, + function(val, key) { item[key] = val }); + + }); } $scope.grid_actions = egHoldGridActions; @@ -343,11 +349,9 @@ function($scope , $q , $routeParams , $window , $location , egCore , win.focus(); } - $scope.print_list_progress = null; $scope.print_full_list = function() { var print_holds = []; - $scope.print_list_loading = true; - $scope.print_list_progress = 0; + egProgressDialog.open({value : 0}); // collect the full list of holds egCore.net.request( @@ -367,7 +371,7 @@ function($scope , $q , $routeParams , $window , $location , egCore , }, null, function(hold_data) { - $scope.print_list_progress++; + egProgressDialog.increment(); egHolds.local_flesh(hold_data); print_holds.push(hold_data); hold_data.title = hold_data.mvr.title(); @@ -377,10 +381,7 @@ function($scope , $q , $routeParams , $window , $location , egCore , hold_data.volume = egCore.idl.toHash(hold_data.volume); hold_data.part = egCore.idl.toHash(hold_data.part); } - ).finally(function() { - $scope.print_list_loading = false; - $scope.print_list_progress = null; - }); + ).finally(egProgressDialog.close); } }]) 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 ff438f875c..f85872b71f 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -68,6 +68,7 @@ angular.module('egGridMod', // These functions are defined by the calling scope and // invoked as-is by the grid w/ the specified parameters. // + // collectStarted : function() {} // itemRetrieved : function(item) {} // allItemsRetrieved : function() {} // @@ -1000,6 +1001,15 @@ angular.module('egGridMod', $scope.items = []; $scope.selected = {}; + + // Inform the caller we've asked the data provider + // for data. This is useful for knowing when collection + // has started (e.g. to display a progress dialg) when + // using the stock (flattener) data provider, where the + // user is not directly defining a get() handler. + if (grid.controls.collectStarted) + grid.controls.collectStarted(grid.offset, grid.limit); + grid.dataProvider.get(grid.offset, grid.limit).then( function() { if (grid.controls.allItemsRetrieved)