Skip to content
Snippets Groups Projects
Commit 6fb74802 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

update the implementation for our NavController to simply use our new...

update the implementation for our NavController to simply use our new 'appContext' value from the AppState service.  this keeps the route parsing logic in AppState as well as ensuring a better initialization path.
parent f088be97
No related branches found
No related tags found
No related merge requests found
......@@ -123,8 +123,8 @@ CorvusControllers.controller('Unauthorized', ['$scope', '$location', function($s
}]);
CorvusControllers.controller('Nav', ['$scope', '$routeParams', '$location', function($scope, $routeParams, $location) {
$scope.nav = 'main';
CorvusControllers.controller('Nav', ['$scope', '$routeParams', '$location', 'AppState', function($scope, $routeParams, $location, AppState) {
$scope.activeClass = 'is--selected';
$scope.isActive = function (location) {
......@@ -132,15 +132,23 @@ CorvusControllers.controller('Nav', ['$scope', '$routeParams', '$location', func
return active;
}
$scope.$on('$routeChangeSuccess', function () {
if($routeParams.orgSlug && $location.path().indexOf('admin') > 0) {
var setNavContext = function(context) {
if(context === 'org-admin') {
$scope.nav = 'admin';
} else if ($location.path().indexOf('setup') > 0) {
} else if (context === 'setup') {
$scope.nav = 'setup';
} else if ($location.path().indexOf('superadmin') > 0) {
} else if (context === 'site-admin') {
$scope.nav = 'superadmin';
} else {
// this covers 'org', 'auth', and 'unknown' contexts
$scope.nav = 'main';
}
}
$scope.$on('appstate:context-changed', function (event, newAppContext) {
setNavContext(newAppContext);
});
// initialize our state from the current AppState model, which we expect to have resolved already
setNavContext(AppState.model.appContext);
}]);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment