LP#1712854: Fetch all hold data for clientsort support
authorMike Rylander <mrylander@gmail.com>
Mon, 4 Dec 2017 15:06:08 +0000 (10:06 -0500)
committerCesar Velez <cesar.velez@equinoxinitiative.org>
Mon, 11 Dec 2017 19:04:27 +0000 (14:04 -0500)
In order for the clientsort feature to work, we must fetch all the
data up front.  So, we do that for the Record / View Holds and the
Hold Shelf interfaces.  The Hold Shelf also gets a progress dialog,
as the dataset may be large.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
Open-ILS/web/js/ui/default/staff/circ/holds/app.js

index cf4da3c..8c94f5b 100644 (file)
@@ -1644,10 +1644,8 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
     var holds = []; // actual hold objs for caching
     var hold_ids = []; // current list of hold ids
 
-    function fetchHolds(offset, count) {
-        var ids = hold_ids.slice(offset, offset + count);
-
-        return egHolds.fetch_holds(ids).then(null, null,
+    function fetchHolds() {
+        return egHolds.fetch_holds(hold_ids).then(null, null,
             function(hold_data) {
                holds.push(hold_data);
                 return hold_data;
@@ -1687,11 +1685,10 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
                 // the total number of holds to fetch or the page size
                 // of the grid.
                 egProgressDialog.update(
-                    {max : Math.min(hold_ids.length, count)});
+                    {max : hold_ids.length});
 
                 var holds_fetched = 0;
-                fetchHolds(offset, count)
-                .then(deferred.resolve, null, 
+                fetchHolds().then(deferred.resolve, null, 
                     function(hold_data) {
                         holds_fetched++;
                         deferred.notify(hold_data);
index 00389fe..75e6e6a 100644 (file)
@@ -37,8 +37,8 @@ angular.module('egHoldsApp',
 
 
 .controller('HoldsShelfCtrl',
-       ['$scope','$q','$routeParams','$window','$location','egCore','egHolds','egHoldGridActions','egCirc','egGridDataProvider',
-function($scope , $q , $routeParams , $window , $location , egCore , egHolds , egHoldGridActions , egCirc , egGridDataProvider)  {
+       ['$scope','$q','$routeParams','$window','$location','egCore','egHolds','egHoldGridActions','egCirc','egGridDataProvider','egProgressDialog',
+function($scope , $q , $routeParams , $window , $location , egCore , egHolds , egHoldGridActions , egCirc , egGridDataProvider , egProgressDialog)  {
     $scope.detail_hold_id = $routeParams.hold_id;
 
     var hold_ids = [];
@@ -47,9 +47,8 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e
     $scope.gridControls = {};
     $scope.grid_actions = egHoldGridActions;
 
-    function fetch_holds(offset, count) {
-        var ids = hold_ids.slice(offset, offset + count);
-        return egHolds.fetch_holds(ids).then(null, null,
+    function fetch_holds() {
+        return egHolds.fetch_holds(hold_ids).then(null, null,
             function(hold_data) { 
                 holds.push(hold_data);
                 return hold_data; // to the grid
@@ -84,6 +83,7 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e
         hold_ids = [];
         holds = [];
 
+        egProgressDialog.open({max : 1, value : 0});
         var method = 'open-ils.circ.captured_holds.id_list.on_shelf.retrieve.authoritative.atomic';
         if (clear_mode) 
             method = 'open-ils.circ.captured_holds.id_list.expired_on_shelf_or_wrong_shelf.retrieve.atomic';
@@ -99,8 +99,15 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e
             }
 
             hold_ids = ids;
-            fetch_holds(offset, count)
-            .then(deferred.resolve, null, deferred.notify);
+            egProgressDialog.update(
+                {max : hold_ids.length});
+
+            fetch_holds().then(deferred.resolve, null,
+                    function(hold_data) {
+                        deferred.notify(hold_data);
+                        egProgressDialog.increment();
+                    }
+                )['finally'](egProgressDialog.close);
         });
 
         return deferred.promise;