This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* xeslint-disable */
|
||||
import store from "../store";
|
||||
import roles from "./roles";
|
||||
import lt from "./locale";
|
||||
import locale from "./locale";
|
||||
import api from "./apiutil";
|
||||
|
||||
function addNavItem(title, icon, route) {
|
||||
@@ -18,21 +18,22 @@ function addNavItem(title, icon, route) {
|
||||
export default function initialize() {
|
||||
if (store.state.authenticated) {
|
||||
//GET LOCALIZED TEXT FOR SHELL
|
||||
lt.fetch([
|
||||
"Home",
|
||||
"Service",
|
||||
"Dispatch",
|
||||
"Inventory",
|
||||
"Accounting",
|
||||
"Administration",
|
||||
"Operations",
|
||||
"HelpAboutAyaNova",
|
||||
"Logout"
|
||||
])
|
||||
locale
|
||||
.fetch([
|
||||
"Home",
|
||||
"Service",
|
||||
"Dispatch",
|
||||
"Inventory",
|
||||
"Accounting",
|
||||
"Administration",
|
||||
"Operations",
|
||||
"HelpAboutAyaNova",
|
||||
"Logout"
|
||||
])
|
||||
.then(function() {
|
||||
//put nav items into store
|
||||
//Everyone has a home
|
||||
addNavItem(lt.get("Home"), "home", "/");
|
||||
addNavItem(locale.get("Home"), "home", "/");
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.TechLimited) ||
|
||||
@@ -40,26 +41,26 @@ export default function initialize() {
|
||||
roles.hasRole(roles.AuthorizationRoles.SubContractorLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.SubContractorFull)
|
||||
) {
|
||||
addNavItem(lt.get("Service"), "toolbox", "/service");
|
||||
addNavItem(locale.get("Service"), "toolbox", "/service");
|
||||
}
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.DispatchLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.DispatchFull)
|
||||
) {
|
||||
addNavItem(lt.get("Dispatch"), "shipping-fast", "/dispatch");
|
||||
addNavItem(locale.get("Dispatch"), "shipping-fast", "/dispatch");
|
||||
}
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.InventoryLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.InventoryFull)
|
||||
) {
|
||||
addNavItem(lt.get("Inventory"), "dolly", "/inventory");
|
||||
addNavItem(locale.get("Inventory"), "dolly", "/inventory");
|
||||
}
|
||||
|
||||
if (roles.hasRole(roles.AuthorizationRoles.AccountingFull)) {
|
||||
addNavItem(
|
||||
lt.get("Accounting"),
|
||||
locale.get("Accounting"),
|
||||
"file-invoice-dollar",
|
||||
"/accounting"
|
||||
);
|
||||
@@ -69,19 +70,19 @@ export default function initialize() {
|
||||
roles.hasRole(roles.AuthorizationRoles.BizAdminLimited) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.BizAdminFull)
|
||||
) {
|
||||
addNavItem(lt.get("Administration"), "user-tie", "/admin");
|
||||
addNavItem(locale.get("Administration"), "user-tie", "/admin");
|
||||
}
|
||||
|
||||
if (
|
||||
roles.hasRole(roles.AuthorizationRoles.OpsAdminFull) ||
|
||||
roles.hasRole(roles.AuthorizationRoles.OpsAdminLimited)
|
||||
) {
|
||||
addNavItem(lt.get("Operations"), "cogs", "ops");
|
||||
addNavItem(locale.get("Operations"), "cogs", "ops");
|
||||
}
|
||||
|
||||
//Everyone can see about and logout
|
||||
addNavItem(lt.get("HelpAboutAyaNova"), "info-circle", "/about");
|
||||
addNavItem(lt.get("Logout"), "sign-out-alt", "/login");
|
||||
addNavItem(locale.get("HelpAboutAyaNova"), "info-circle", "/about");
|
||||
addNavItem(locale.get("Logout"), "sign-out-alt", "/login");
|
||||
})
|
||||
.catch(function(error) {
|
||||
store.commit("logItem", "Initialize::() ltfetch -> error" + error);
|
||||
@@ -89,8 +90,6 @@ export default function initialize() {
|
||||
});
|
||||
|
||||
//CACHE LOCALE SETTINGS
|
||||
//check the timezone offset is still valid, offer to change it if not
|
||||
//api.get("UserOptions/" + store.state.userId).then(res => {
|
||||
api
|
||||
.get("UserOptions/" + store.state.userId)
|
||||
.then(res => {
|
||||
@@ -99,6 +98,8 @@ export default function initialize() {
|
||||
//convert error to human readable string for display
|
||||
alert(api.apiErrorToHumanString(res.error));
|
||||
} else {
|
||||
//TODO: also need the other locale settings such as number and date formats etc
|
||||
|
||||
var localOffset = new Date().getTimezoneOffset();
|
||||
if (localOffset != 0) {
|
||||
localOffset = (localOffset / 60) * -1; //time is in minutes and reversed from what we want or expect
|
||||
@@ -114,6 +115,9 @@ export default function initialize() {
|
||||
"."
|
||||
);
|
||||
}
|
||||
|
||||
//Store offset in locale data
|
||||
locale.timeZoneOffset = res.data.timeZoneOffset;
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
|
||||
@@ -76,5 +76,7 @@ export default {
|
||||
shortDate: "YYYY-MM-DD",
|
||||
shortTime: "hh:mm:ss A",
|
||||
shortDateAndTime: "YYYY-MM-DD hh:mm:ss A"
|
||||
}
|
||||
},
|
||||
//timeZoneOffset is in decimal hours
|
||||
timeZoneOffset: -8.0
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user