diff --git a/app/config/routes.js b/app/config/routes.js index a60498d7..f262585c 100644 --- a/app/config/routes.js +++ b/app/config/routes.js @@ -1,9 +1,5 @@ app.config(function ($routeProvider) { $routeProvider. - when('/management', { - redirectTo: '/management/services', - access: ["ROLE_ADMIN", "ROLE_WEB_MANAGER", "ROLE_SERVICE_MANAGER"] - }). when('/management/:tab', { templateUrl: 'views/management.html', access: ["ROLE_ADMIN", "ROLE_WEB_MANAGER", "ROLE_SERVICE_MANAGER"] diff --git a/app/controllers/managementController.js b/app/controllers/managementController.js index 6b96b37b..0bff2884 100644 --- a/app/controllers/managementController.js +++ b/app/controllers/managementController.js @@ -1,7 +1,103 @@ -app.controller('ManagementController', function ($controller, $scope) { +app.controller('ManagementController', function ($controller, $scope, UserService) { angular.extend(this, $controller('AbstractController', { $scope: $scope })); -}); \ No newline at end of file + $scope.columns = []; + + $scope.getDefaultManagementTab = function () { + var columns = getColumns(); + return "management/" + columns[0].path; + }; + + var columns = { + "services": { + path: "services", + view: "services", + label: "Services" + }, + "notes": { + path: "notes", + view: "notes", + label: "Notes" + }, + "ideas": { + path: "ideas", + view: "ideas", + label: "Ideas" + }, + "featureProposals": { + path: "feature-proposals", + view: "featureProposals", + label: "Feature Proposals" + }, + "notifications": { + path: "notifications", + view: "notifications", + label: "Notifications" + }, + "users": { + path: "users", + view: "users", + label: "Users" + } + }; + + var getColumns = function () { + var columnDefinitions; + switch (sessionStorage.role) { + case "ROLE_ADMIN": + columnDefinitions = [ + columns.services, + columns.notes, + columns.ideas, + columns.featureProposals, + columns.notifications, + columns.users + ]; + break; + case "ROLE_SERVICE_ADMIN": + columnDefinitions = [ + columns.services, + columns.notes, + columns.ideas, + columns.featureProposals, + columns.notifications + ]; + break; + case "ROLE_SERVICE_MANAGER": + columnDefinitions = [ + columns.services, + columns.notes, + columns.ideas, + columns.featureProposals + ]; + break; + case "ROLE_WEB_MANAGER": + columnDefinitions = [ + columns.notes, + columns.notifications + ]; + break; + case "ROLE_NOTICE_MANAGER": + columnDefinitions = [ + columns.notifications + ]; + break; + default: + columnDefinitions = []; + break; + } + $scope.columns.length = 0; + for (var index = 0 ; index < columnDefinitions.length; index++) { + $scope.columns.push(columnDefinitions[index]); + } + return $scope.columns; + }; + + UserService.userReady().then(function () { + getColumns(); + }); + +}); diff --git a/app/index.html b/app/index.html index e897a1fc..da8a4fc9 100644 --- a/app/index.html +++ b/app/index.html @@ -64,8 +64,8 @@