This commit is contained in:
2021-07-13 15:15:07 +00:00
parent 5aafca79d9
commit c457a478f7
3 changed files with 49 additions and 23 deletions

View File

@@ -152,7 +152,7 @@
>
</v-toolbar-title>
<v-spacer></v-spacer>
<!-- v-if="$store.state.notifyAvailable" -->
<!-- All users can see this, they may not be able to subscribe to notifications but they may see direct or system notifications for any account so this is always available -->
<template>
<v-btn text icon to="/home-notifications" data-cy="notification">
<v-badge color="deep-purple" :value="newNotificationCount() > 0">

View File

@@ -27,9 +27,6 @@ export default new Vuex.Store({
downloadToken: "-",
tfaEnabled: undefined,
notifyAvailable: true,
isCustomerUser: false,
isSubContractorUser: false,
isScheduleableUser: false,
customerRights: {},
userId: 0,
userName: "NOT AUTHENTICATED",
@@ -56,11 +53,44 @@ export default new Vuex.Store({
knownPassword: false,
newNotificationCount: 0
},
// getters: {
// isOutsideUser: state => {
// return state.userType == 3 || state.userType == 4;
// }
// },
getters: {
/* User types:
Service = 1,
NotService = 2,
Customer = 3,
HeadOffice = 4,
ServiceContractor = 5
*/
isCustomerUser: state => {
return state.userType == 3 || state.userType == 4;
},
isSubContractorUser: state => {
return state.userType == 5;
},
isScheduleableUser: state => {
return state.userType == 1 || state.userType == 5;
},
canSubscribeToNotifications: state => {
switch (state.userType) {
case 1:
case 2:
return true;
case 3:
case 4:
//customer / headoffice and some notifications are enabled for them
return (
state.customerRights.notifyServiceImminent == true ||
state.customerRights.notifyCSRAccepted == true ||
state.customerRights.notifyCSRRejected == true ||
state.customerRights.notifyWOCompleted == true ||
state.customerRights.notifyWOCreated == true
);
case 5: //subcontractor for now no notification subscriptions available
return false;
}
return false;
}
},
mutations: {
setLastClientVersion(state, data) {
state.lastClientVersion = data;
@@ -73,9 +103,6 @@ export default new Vuex.Store({
state.apiToken = data.apiToken;
state.userName = data.userName;
state.userType = data.userType;
state.isSubContractorUser = data.userType == 5;
state.isCustomerUser = data.userType == 3 || data.userType == 4;
state.isScheduleableUser = data.userType == 1 || data.userType == 5;
state.downloadToken = data.dlt;
state.tfaEnabled = data.tfaEnabled;
if (data.customerRights) {
@@ -101,9 +128,6 @@ export default new Vuex.Store({
state.roles = 0;
state.userType = 0;
state.notifyAvailable = true;
state.isCustomerUser = false;
state.isSubContractorUser = false;
state.isScheduleableUser = false;
state.homePage = undefined;
state.navItems = [];
state.translationText = {};