From b2860e8a5378bf777acd46fc10bb292adc6ab85e Mon Sep 17 00:00:00 2001 From: Juanfran Date: Thu, 11 Aug 2016 10:39:27 +0200 Subject: [PATCH] load project in the routerProvider resolve --- app/coffee/app.coffee | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 7827d1a7..ad15383f 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -57,6 +57,19 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven $translate().then () -> deferred.resolve() + return deferred.promise + ], + projectLoaded: ["$q", "tgProjectService", "$route", ($q, projectService, $route) -> + deferred = $q.defer() + + projectService.setSection($route.current.$$route.section) + + if $route.current.params.pslug + projectService.setProjectBySlug($route.current.params.pslug).then(deferred.resolve) + else + projectService.cleanProject() + deferred.resolve() + return deferred.promise ] }) @@ -659,7 +672,7 @@ i18nInit = (lang, $translate) -> checksley.updateMessages('default', messages) -init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $navUrls, appMetaService, projectService, loaderService, navigationBarService, errorHandlingService) -> +init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $navUrls, appMetaService, loaderService, navigationBarService, errorHandlingService) -> $log.debug("Initialize application") $rootscope.$on '$translatePartialLoaderStructureChanged', () -> @@ -722,13 +735,6 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na if !$auth.isAuthenticated() $location.path($navUrls.resolve("login")) - projectService.setSection(next.section) - - if next.params.pslug - projectService.setProjectBySlug(next.params.pslug) - else - projectService.cleanProject() - if next.title or next.description title = $translate.instant(next.title or "") description = $translate.instant(next.description or "") @@ -826,7 +832,6 @@ module.run([ "$tgLocation", "$tgNavUrls", "tgAppMetaService", - "tgProjectService", "tgLoader", "tgNavigationBarService", "tgErrorHandlingService",