From 7f6170bd1cca9fe41d7f6074e118231dda5e04e3 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 3 Dec 2014 12:48:12 -0500 Subject: [PATCH] LP#1402797 Avoid org tree retrieval race condition on patron app Avoid calling egOrg.ancestors() during startup, because the org unit tree is not guarantee to be available until startup has completed. This was causing an occasional JS excpetion in the patron app pages, which prevented the pages from loading. The error in question: TypeError: Cannot read property 'map' of undefined at Object.service.get (https://host/js/ui/default/staff/services/org.js:21:25) at Object.service.ancestors (https://host/js/ui/default/staff/services/org.js:34:28) at Object.egCore.env.classLoaders.actsc (https://host/js/ui/default/staff/circ/patron/app.js:41:37) at https://host/js/ui/default/staff/services/env.js:77:55 at Object.r [as forEach] (https://host/js/ui/default/staff/build/js/angular.min.js:7:290) at Object.service.load (https://host/js/ui/default/staff/services/env.js:76:17) at https://host/js/ui/default/staff/services/startup.js:64:23 at J (https://host/js/ui/default/staff/build/js/angular.min.js:101:96) at https://host/js/ui/default/staff/build/js/angular.min.js:102:259 at h.$eval (https://host/js/ui/default/staff/build/js/angular.min.js:113:32) Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- .../web/js/ui/default/staff/circ/patron/app.js | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index d1ebcfc9a6..49d1e24343 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -35,19 +35,7 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap', }); } - // local stat cats are displayed in the summary bar on each page. - egCore.env.classLoaders.actsc = function() { - return egCore.pcrud.search('actsc', - {owner : egCore.org.ancestors( - egCore.auth.user().ws_ou(), true)}, - {}, {atomic : true} - ).then(function(cats) { - egCore.env.absorbList(cats, 'actsc'); - }); - } - egCore.env.loadClasses.push('aous'); - egCore.env.loadClasses.push('actsc'); // app-globally modify the default flesh fields for // fleshed user retrieval. @@ -61,7 +49,18 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap', ]); } - return egCore.startup.go() + return egCore.startup.go().then(function() { + + // This call requires orgs to be loaded, because it + // calls egCore.org.ancestors(), so call it after startup + return egCore.pcrud.search('actsc', + {owner : egCore.org.ancestors( + egCore.auth.user().ws_ou(), true)}, + {}, {atomic : true} + ).then(function(cats) { + egCore.env.absorbList(cats, 'actsc'); + }); + }); }]}; $routeProvider.when('/circ/patron/search', { -- 2.11.0