From: Bill Erickson Date: Fri, 3 Mar 2017 15:34:26 +0000 (-0500) Subject: LP#1522638 Bib holds egProgressDialog API updates X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c96d529a4ead10cade5bc3cde36e59fe50151835;p=evergreen%2Fpines.git LP#1522638 Bib holds egProgressDialog API updates 1. Use the new egProgressDialog name and the new increment() function. 2. Open the dialog before data retrieval starts to better indicate work is happening. 3. Close the dialog in promise.finally() to ensure it always closes. Signed-off-by: Bill Erickson Signed-off-by: Terran McCanna Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js index 4fadbb4e53..54f63960de 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -245,10 +245,10 @@ function($scope , $routeParams , $location , $window , $q , egCore) { }]) .controller('CatalogCtrl', ['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc','egConfirmDialog','ngToast', - 'egGridDataProvider','egHoldGridActions','egProgressModal','$timeout','$uibModal','holdingsSvc','egUser','conjoinedSvc', + 'egGridDataProvider','egHoldGridActions','egProgressDialog','$timeout','$uibModal','holdingsSvc','egUser','conjoinedSvc', '$cookies', function($scope , $routeParams , $location , $window , $q , egCore , egHolds , egCirc , egConfirmDialog , ngToast , - egGridDataProvider , egHoldGridActions ,egProgressModal, $timeout , $uibModal , holdingsSvc , egUser , conjoinedSvc, + egGridDataProvider , egHoldGridActions , egProgressDialog , $timeout , $uibModal , holdingsSvc , egUser , conjoinedSvc, $cookies ) { @@ -1364,6 +1364,10 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e if ($scope.record_tab != 'holds') return $q.when(); var deferred = $q.defer(); hold_ids = []; // no caching ATM + + // open a determinate progress dialog, max value set below. + egProgressDialog.open({max : 1, value : 0}); + // fetch the IDs egCore.net.request( 'open-ils.circ', @@ -1372,15 +1376,25 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e {pickup_lib : egCore.org.descendants($scope.pickup_ou.id(), true)} ).then( function(hold_data) { - if(hold_data.title_holds.length){ - egProgressModal.open().result;}; angular.forEach(hold_data, function(list, type) { hold_ids = hold_ids.concat(list); }); - fetchHolds(offset, count).then( - deferred.resolve, null, deferred.notify).then(function(){ - egProgressModal.close(); - }); + + // Set the max value of the progress bar to the lesser of + // the total number of holds to fetch or the page size + // of the grid. + egProgressDialog.update( + {max : Math.min(hold_ids.length, count)}); + + var holds_fetched = 0; + fetchHolds(offset, count) + .then(deferred.resolve, null, + function(hold_data) { + holds_fetched++; + deferred.notify(hold_data); + egProgressDialog.increment(); + } + )['finally'](egProgressDialog.close); } );