From c0cfe4f2d6f8e250abadabc0c078f66239947e5a Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 25 Mar 2020 18:40:03 +0000 Subject: [PATCH] --- ayanova/src/api/initialize.js | 32 +++++++++++++++++++++++++++++++- ayanova/src/store.js | 6 ++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index b1c9fcde..2347d500 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -735,7 +735,7 @@ export default function initialize() { } }) .then(() => { - //CACHE TRANSLATION SETTINGS + //GET USER OPTIONS window.$gz.api .get("UserOptions/" + window.$gz.store.state.userId) .then(res => { @@ -788,6 +788,36 @@ export default function initialize() { throw error; }); }) + .then(() => { + //GET GLOBAL SETTINGS + window.$gz.api + .get("GlobalBizSettings/client") + .then(res => { + if (res.error != undefined) { + //In a form this would trigger a bunch of validation or error display code but for here and now: + //convert error to human readable string for display and popup a notification to user + var msg = window.$gz.api.apiErrorToHumanString(res.error); + window.$gz.store.commit( + "logItem", + "Initialize::() fetch GlobalBizSettings/client -> error" + msg + ); + window.$gz.eventBus.$emit("notify-error", msg); + } else { + //Check if overrides and use them here + //or else use browser defaults + + window.$gz.store.commit("setGlobalSettings", res.data); + resolve(); + } + }) + .catch(function handleFetchClientGlobalSettingsError(error) { + window.$gz.store.commit( + "logItem", + "Initialize::() fetch GlobalBizSettings/client -> error" + error + ); + throw error; + }); + }) .catch(function handleIntializeError(error) { window.$gz.store.commit( "logItem", diff --git a/ayanova/src/store.js b/ayanova/src/store.js index de169033..9ef88a97 100644 --- a/ayanova/src/store.js +++ b/ayanova/src/store.js @@ -28,6 +28,7 @@ export default new Vuex.Store({ currencyName: "USD", hour12: true }, + globalSettings: {}, navItems: [], logArray: [], formSettings: {}, //this is the settings on forms that survive a refresh like grid number of items to show etc @@ -64,6 +65,7 @@ export default new Vuex.Store({ state.locale.timeZoneOverride = "America/New_York"; state.locale.currencyName = "USD"; state.locale.hour12 = true; + state.globalSettings={}; }, addNavItem(state, data) { state.navItems.push(data); @@ -83,6 +85,10 @@ export default new Vuex.Store({ state.locale.hour12 = data.hour12; state.locale.timeZoneOverride = data.timeZoneOverride; }, + setGlobalSettings(state, data) { + // mutate state + state.globalSettings = data; + }, setEnum(state, data) { state.enums[data.enumKey] = data.items; //{enumKey:"AuthorizationRoles",items:[{0:"no role"},{1:"Limited role"}]} },