LP#1798170 Load grid data after settings are applied
authorBill Erickson <berickxx@gmail.com>
Tue, 16 Oct 2018 18:15:53 +0000 (14:15 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 5 Nov 2018 21:01:03 +0000 (16:01 -0500)
Ensure the initial grid data fetching code does not fire until after the
grid configuration has been retrieved and applied.  This fixes an issue
where custom columns would contain no values on initial grid load.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jason Boyer <jboyer@library.in.gov>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/web/js/ui/default/staff/services/grid.js

index 833c0fc..cf29360 100644 (file)
@@ -110,23 +110,26 @@ angular.module('egGridMod',
         templateUrl : '/eg/staff/share/t_autogrid', 
 
         link : function(scope, element, attrs) {     
-            // link() is called after page compilation, which means our
-            // eg-grid-field's have been parsed and loaded.  Now it's 
-            // safe to perform our initial page load.
 
-            // load auto fields after eg-grid-field's so they are not clobbered
-            scope.handleAutoFields();
-            scope.collect();
+            // Give the grid config loading steps time to fetch the 
+            // workstation setting and apply columns before loading data.
+            var loadPromise = scope.configLoadPromise || $q.when();
+            loadPromise.then(function() {
 
-            scope.grid_element = element;
+                // load auto fields after eg-grid-field's so they are not clobbered
+                scope.handleAutoFields();
+                scope.collect();
 
-            if(!attrs.id){
-                $(element).attr('id', attrs.persistKey);
-            }
+                scope.grid_element = element;
+
+                if(!attrs.id){
+                    $(element).attr('id', attrs.persistKey);
+                }
 
-            $(element)
-                .find('.eg-grid-content-body')
-                .bind('contextmenu', scope.showActionContextMenu);
+                $(element)
+                    .find('.eg-grid-content-body')
+                    .bind('contextmenu', scope.showActionContextMenu);
+            });
         },
 
         controller : [
@@ -249,7 +252,7 @@ angular.module('egGridMod',
 
                 grid.applyControlFunctions();
 
-                grid.loadConfig().then(function() { 
+                $scope.configLoadPromise = grid.loadConfig().then(function() { 
                     // link columns to scope after loadConfig(), since it
                     // replaces the columns array.
                     $scope.columns = grid.columnsProvider.columns;