From 50f6df42441175c614c57151202f5309d2aae8a2 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 9 Jun 2017 16:01:14 -0400 Subject: [PATCH] LP#1691237 Date settings retrieval via egEnv Avoid multiple .resolve() calls on the main egStartup promise by asking egEnv to fetch the new date/time org unit settings. Related, make the pathway for adding new universally-loaded data functions more obvious and consistent in egStartup by putting them right up at the top. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- .../js/ui/default/staff/services/startup.js | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/services/startup.js b/Open-ILS/web/js/ui/default/staff/services/startup.js index 682317b77f..f268ddba0c 100644 --- a/Open-ILS/web/js/ui/default/staff/services/startup.js +++ b/Open-ILS/web/js/ui/default/staff/services/startup.js @@ -19,6 +19,25 @@ function($q, $rootScope, $location, $window, egIDL, egAuth, egEnv , egOrg var service = { promise : null } + // Load date/time format settings on all pages. Add more .push(...) + // calls to add more universal data-loading functions. + // egEnv.loaders functions must return a promise. + egEnv.loaders.push( + function() { + return egOrg.settings([ + 'webstaff.format.dates', + 'webstaff.format.date_and_time' + ]).then( + function(set) { + $rootScope.egDateFormat = + set['webstaff.format.dates'] || 'shortDate'; + $rootScope.egDateAndTimeFormat = + set['webstaff.format.date_and_time'] || 'short'; + } + ); + }, + ); + // returns true if we are staying on the current page // false if we are redirecting to login service.expiredAuthHandler = function() { @@ -67,19 +86,6 @@ function($q, $rootScope, $location, $window, egIDL, egAuth, egEnv , egOrg deferred.reject('egEnv did not resolve') } ); - egOrg.settings([ - 'webstaff.format.dates', - 'webstaff.format.date_and_time' - ]).then( - function(set) { - $rootScope.egDateFormat = set['webstaff.format.dates'] || 'shortDate'; - $rootScope.egDateAndTimeFormat = set['webstaff.format.date_and_time'] || 'short'; - deferred.resolve(); - }, - function() { - deferred.reject('egOrg did not resolve'); - } - ); }, // testAuthToken rejected -- 2.43.2