LP#1653001 Hold pull list progress dialog
authorBill Erickson <berickxx@gmail.com>
Thu, 2 Mar 2017 23:05:05 +0000 (18:05 -0500)
committerKathy Lussier <klussier@masslnc.org>
Mon, 6 Mar 2017 20:18:17 +0000 (15:18 -0500)
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 <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/circ/holds/t_pull_list.tt2
Open-ILS/web/js/ui/default/staff/circ/holds/app.js
Open-ILS/web/js/ui/default/staff/services/grid.js

index 91b8571..4016967 100644 (file)
@@ -1,7 +1,3 @@
-<div ng-if="print_list_progress !== null" class="strong-text-2">
-  [% l('Loading... [_1]', '{{print_list_progress}}') %]
-</div>
-
 <eg-grid
   id-field="id"
   idl-class="ahopl"
index 0dccd94..98eee85 100644 (file)
@@ -245,9 +245,9 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e
 
 .controller('HoldsPullListCtrl',
        ['$scope','$q','$routeParams','$window','$location','egCore',
-        'egHolds','egCirc','egHoldGridActions',
+        'egHolds','egCirc','egHoldGridActions','egProgressDialog',
 function($scope , $q , $routeParams , $window , $location , egCore , 
-         egHolds , egCirc , egHoldGridActions) {
+         egHolds , egCirc , egHoldGridActions , egProgressDialog) {
 
     $scope.detail_hold_id = $routeParams.hold_id;
 
@@ -261,12 +261,22 @@ function($scope , $q , $routeParams , $window , $location , egCore ,
         setSort : function() {
             return ['copy_location_order_position','call_number_sort_key']
         },
+        collectStarted : function(offset) {
+            // Launch an indeterminate -> 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);
     }
 
 }])
index ff438f8..f85872b 100644 (file)
@@ -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)