From fb99a1f18067e828b319122750d0f815ca2a8606 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 16 Oct 2018 14:15:53 -0400 Subject: [PATCH] LP#1798170 Load grid data after settings are applied 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 Signed-off-by: Jason Boyer Signed-off-by: Galen Charlton --- .../web/js/ui/default/staff/services/grid.js | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) 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 833c0fc39e..cf29360291 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -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; -- 2.43.2