This commit is contained in:
2021-06-16 17:52:58 +00:00
parent 165d877b69
commit f1da826781
9 changed files with 57 additions and 29 deletions

View File

@@ -389,11 +389,9 @@ Sidetrack, case 3888 customer feature control in global settings required for cu
see case, add to global object at server and also must return login availability and code that too now so it all works see case, add to global object at server and also must return login availability and code that too now so it all works
also customer centric notifications and features need to be filtered through this security at the server now too also customer centric notifications and features need to be filtered through this security at the server now too
STATE: Login returns proper rights for customer type user, now need to update initialize.js to properly present whatever is available TODO: customer access features need to be filtered OUT at the server if they don't have access
meaning the big csr,wo lists but also notifications (none=don't show), notifications in form filter out list of available and User settings filter out or in in case they attempt to circumvent UI somehow
NOTE: is possible user could have no rights to anything at all due to combination of filters and stuff Easiest thing is when code those forms also enable at the back end more security checks
so need to handle that scenario and test for it and maybe clearly display that they have no rights so it's not confusing when it comes up blank
(maybe a norights home page??)

View File

@@ -152,6 +152,7 @@
> >
</v-toolbar-title> </v-toolbar-title>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn text icon to="/home-notifications" data-cy="notification"> <v-btn text icon to="/home-notifications" data-cy="notification">
<v-badge color="deep-purple" :value="newNotificationCount() > 0"> <v-badge color="deep-purple" :value="newNotificationCount() > 0">
<template v-slot:badge> <template v-slot:badge>

View File

@@ -33,13 +33,9 @@ function initNavPanel() {
Customer = 3, Customer = 3,
HeadOffice = 4, HeadOffice = 4,
ServiceContractor = 5 */ ServiceContractor = 5 */
let isCustomerTypeUser =
window.$gz.store.state.userType == 3 ||
window.$gz.store.state.userType == 4;
let isSubcontractorTypeUser = window.$gz.store.state.userType == 5;
//########## OUTSIDE USERS GROUP (CUSTOMER / HEADOFFICE) ### //########## OUTSIDE USERS GROUP (CUSTOMER / HEADOFFICE) ###
if (isCustomerTypeUser) { if (window.$gz.store.state.isCustomerUser == true) {
//clear sublevel array //clear sublevel array
sub = []; sub = [];
@@ -57,6 +53,9 @@ function initNavPanel() {
route: "/home-user-settings", route: "/home-user-settings",
key: key++ key: key++
}); });
window.$gz.store.commit("setHomePage", "/home-user-settings");
CustomerHomePageSet = true;
} }
if ( if (
@@ -71,6 +70,23 @@ function initNavPanel() {
route: "/home-notify-subscriptions", route: "/home-notify-subscriptions",
key: key++ key: key++
}); });
window.$gz.store.commit("setHomePage", "/home-notify-subscriptions");
CustomerHomePageSet = true;
}
//WORKORDERS subitem
if (window.$gz.store.state.customerRights.userSettings == true) {
if (window.$gz.role.canOpen(window.$gz.type.WorkOrder)) {
sub.push({
title: "WorkOrderList",
icon: "$ayiTools",
route: "/customer-workorders",
key: key++
});
window.$gz.store.commit("setHomePage", "/customer-workorders");
CustomerHomePageSet = true;
}
} }
//CSR LIST subitem //CSR LIST subitem
@@ -89,25 +105,12 @@ function initNavPanel() {
CustomerHomePageSet = true; CustomerHomePageSet = true;
} }
//WORKORDERS subitem
if (window.$gz.store.state.customerRights.userSettings == true) {
if (window.$gz.role.canOpen(window.$gz.type.WorkOrder)) {
sub.push({
title: "WorkOrderList",
icon: "$ayiTools",
route: "/customer-workorders",
key: key++
});
}
}
//** CUSTOMER LOGIN HOME (TOP) //** CUSTOMER LOGIN HOME (TOP)
addNavItem("Home", "$ayiHome", undefined, sub, key++, "homecustomer"); addNavItem("Home", "$ayiHome", undefined, sub, key++, "homecustomer");
//last resort home page if user has no roles set //last resort home page if nothing else kicked in
//TODO: Needs to be no rights page, not user settings
if (!CustomerHomePageSet) { if (!CustomerHomePageSet) {
window.$gz.store.commit("setHomePage", "/no-rights"); window.$gz.store.commit("setHomePage", "/no-features-available");
} }
return; return;
@@ -705,7 +708,10 @@ function initNavPanel() {
//*** EVALUATION active trial license should always go to evaluation as home page //*** EVALUATION active trial license should always go to evaluation as home page
//as long as they are a normal User type and not a subcontractor type //as long as they are a normal User type and not a subcontractor type
if ((licenseState == 1) & !isSubcontractorTypeUser) { if (
(licenseState == 1) &
(window.$gz.store.state.isSubContractorUser == false)
) {
addNavItem( addNavItem(
"Evaluate", "Evaluate",
"$ayiRocket", "$ayiRocket",

View File

@@ -26,6 +26,9 @@ export default new Vuex.Store({
apiToken: "-", apiToken: "-",
downloadToken: "-", downloadToken: "-",
tfaEnabled: undefined, tfaEnabled: undefined,
notifyAvailable: true,
isCustomerUser: false,
isSubContractorUser: false,
customerRights: {}, customerRights: {},
userId: 0, userId: 0,
userName: "NOT AUTHENTICATED", userName: "NOT AUTHENTICATED",
@@ -69,10 +72,18 @@ export default new Vuex.Store({
state.apiToken = data.apiToken; state.apiToken = data.apiToken;
state.userName = data.userName; state.userName = data.userName;
state.userType = data.userType; state.userType = data.userType;
state.isSubContractorUser = data.userType == 5;
state.isCustomerUser = data.userType == 3 || data.userType == 4;
state.downloadToken = data.dlt; state.downloadToken = data.dlt;
state.tfaEnabled = data.tfaEnabled; state.tfaEnabled = data.tfaEnabled;
if (data.customerRights) { if (data.customerRights) {
state.customerRights = data.customerRights; state.customerRights = data.customerRights;
//only a customer user could have zero access to notifications
state.notifyAvailable =
data.customerRights.notifyServiceImminent == true ||
data.customerRights.notifyCSRAccepted == true ||
data.customerRights.notifyCSRRejected == true ||
data.customerRights.notifyWOCreated == true;
} }
}, },
logout(state) { logout(state) {
@@ -86,6 +97,9 @@ export default new Vuex.Store({
state.userName = "NOT AUTHENTICATED"; state.userName = "NOT AUTHENTICATED";
state.roles = 0; state.roles = 0;
state.userType = 0; state.userType = 0;
state.notifyAvailable = true;
state.isCustomerUser = false;
state.isSubContractorUser = false;
state.homePage = undefined; state.homePage = undefined;
state.navItems = []; state.navItems = [];
state.translationText = {}; state.translationText = {};

View File

@@ -1,6 +1,7 @@
<template> <template>
<div> <div>
{{ $store.state.customerRights }} {{ $store.state.customerRights }}
todo: backend customer rights checks in conjunction with this form
<UnderConstruction data-cy="underconstruction" /> <UnderConstruction data-cy="underconstruction" />
</div> </div>
</template> </template>

View File

@@ -8,8 +8,9 @@
<h1>UNDER CONSTRUCTION</h1> <h1>UNDER CONSTRUCTION</h1>
<h2> <h2>
Copied from inv part assembly and not implemented as customer work Copied from inv part assembly and not implemented as customer work
order yet order yet. Backend customer rights check in conjunction with this
</h2> </h2>
{{ $store.state.customerRights }}
</v-row> </v-row>
</v-form> </v-form>
</div> </div>

View File

@@ -1,5 +1,9 @@
<template> <template>
<UnderConstruction data-cy="underconstruction" /> <div>
{{ $store.state.customerRights }}
todo: backend customer rights check in addition to here
<UnderConstruction data-cy="underconstruction" />
</div>
</template> </template>
<script> <script>

View File

@@ -77,6 +77,9 @@ export default {
vm.formState.ready = true; vm.formState.ready = true;
} }
}, },
beforeRouteEnter(to, from, next) {
next(window.$gz.store.state.notifyAvailable);
},
beforeDestroy() { beforeDestroy() {
window.$gz.eventBus.$off("menu-click", clickHandler); window.$gz.eventBus.$off("menu-click", clickHandler);
}, },

View File

@@ -2,7 +2,7 @@
<v-row justify-center> <v-row justify-center>
<v-col cols="12"> <v-col cols="12">
<div class="text-center"> <div class="text-center">
<v-icon color="red" size="100">$ayiDragon</v-icon> <v-icon color="primary" size="100">$ayiEgg</v-icon>
<div class="text-h5 mt-8" v-if="ready"> <div class="text-h5 mt-8" v-if="ready">
{{ $ay.t("NoFeaturesAvailable") }} {{ $ay.t("NoFeaturesAvailable") }}
</div> </div>