From 4ce8b8e90a1c90fe432488670cb92ac20a7932c8 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 25 Jun 2018 09:40:57 -0500 Subject: [PATCH 1/3] Item b03526: Present tabs based on roles, using ng-show Perform access control in the controller and present a list of columns for renderring such than an ng-repeat can be used: `{{column.label}}` This is not working as expected, possibly due to the current weaver tabs implementation. This includes a not so great work-around using ng-show with a preset number of columns. This should be improved to use ng-repeat or something similar instead of using ng-show with a preset column list. --- app/controllers/managementController.js | 80 ++++++++++++++++++++++++- app/views/management.html | 14 ++--- 2 files changed, 84 insertions(+), 10 deletions(-) diff --git a/app/controllers/managementController.js b/app/controllers/managementController.js index 6b96b37b..98493ef3 100644 --- a/app/controllers/managementController.js +++ b/app/controllers/managementController.js @@ -1,7 +1,81 @@ -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 + 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" + } + }; + + $scope.user = UserService.getCurrentUser(); + + $scope.columns = []; + + if ($scope.user.role == "ROLE_ADMIN") { + $scope.columns = [ + columns.services, + columns.notes, + columns.ideas, + columns.featureProposals, + columns.notifications, + columns.users + ]; + } + else if ($scope.user.role == "ROLE_SERVICE_ADMIN") { + $scope.columns = [ + columns.services, + columns.notes, + columns.ideas, + columns.featureProposals, + columns.notifications + ]; + } + else if ($scope.user.role == "ROLE_SERVICE_MANAGER") { + $scope.columns = [ + columns.services, + columns.notes, + columns.ideas, + columns.featureProposals, + ]; + } + else if ($scope.user.role == "ROLE_WEB_MANAGER") { + $scope.columns = [ + columns.notes, + columns.notifications + ]; + } + else if ($scope.user.role == "ROLE_NOTICE_MANAGER") { + $scope.columns = [ + columns.notifications + ]; + } +}); diff --git a/app/views/management.html b/app/views/management.html index 7e77d80b..05ca9cfa 100644 --- a/app/views/management.html +++ b/app/views/management.html @@ -3,16 +3,16 @@
- Services - Ideas - Feature Proposals - Notes - Notifications - Users + {{columns[0].label}} + {{columns[1].label}} + {{columns[2].label}} + {{columns[3].label}} + {{columns[4].label}} + {{columns[5].label}}
- \ No newline at end of file + From ec7e5072c2ef8180bd6d97515cd7f104975f0c4e Mon Sep 17 00:00:00 2001 From: William Welling Date: Mon, 25 Jun 2018 11:10:45 -0500 Subject: [PATCH 2/3] minor cleanup, update routing to management --- app/config/routes.js | 4 - app/controllers/managementController.js | 164 ++++++++++++++---------- app/index.html | 4 +- app/views/management.html | 10 +- 4 files changed, 101 insertions(+), 81 deletions(-) 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 98493ef3..48c5cca0 100644 --- a/app/controllers/managementController.js +++ b/app/controllers/managementController.js @@ -1,81 +1,103 @@ app.controller('ManagementController', function ($controller, $scope, UserService) { + angular.extend(this, $controller('AbstractController', { $scope: $scope })); + $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" - } + "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" + } }; - $scope.user = UserService.getCurrentUser(); + 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 col of columnDefinitions) { + $scope.columns.push(col); + } + return $scope.columns; + }; - $scope.columns = []; + UserService.userReady().then(function () { + getColumns(); + }); - if ($scope.user.role == "ROLE_ADMIN") { - $scope.columns = [ - columns.services, - columns.notes, - columns.ideas, - columns.featureProposals, - columns.notifications, - columns.users - ]; - } - else if ($scope.user.role == "ROLE_SERVICE_ADMIN") { - $scope.columns = [ - columns.services, - columns.notes, - columns.ideas, - columns.featureProposals, - columns.notifications - ]; - } - else if ($scope.user.role == "ROLE_SERVICE_MANAGER") { - $scope.columns = [ - columns.services, - columns.notes, - columns.ideas, - columns.featureProposals, - ]; - } - else if ($scope.user.role == "ROLE_WEB_MANAGER") { - $scope.columns = [ - columns.notes, - columns.notifications - ]; - } - else if ($scope.user.role == "ROLE_NOTICE_MANAGER") { - $scope.columns = [ - columns.notifications - ]; - } -}); +}); \ No newline at end of file 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 @@