From 871a5da022b261264f10374dc1d9d8b84d7b93ba Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 29 May 2019 22:37:01 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 7 +-- ayanova/src/api/initialize.js | 11 ++++- ayanova/src/api/locale.js | 16 +++---- .../src/components/gzdateandtimepicker.vue | 20 ++++----- ayanova/src/store.js | 23 ++++++++++ ayanova/src/views/About.vue | 44 ++++++++++--------- ayanova/src/views/inventory-widget-edit.vue | 5 ++- 7 files changed, 78 insertions(+), 48 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index c79eff22..6b02efb4 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -22,11 +22,12 @@ NEXT TODOS: - Retest on desktop, probably a general date time conversion bug - - On object not found when deleting an item and trying to reload the edit page, shoudl redirect to home or back instead or just not there - - - On save of record should have a brief notification that auto closes that says "SAVED" or something just to handle the case of people not clicking on save?? + - DONE On object not found when deleting an item and trying to reload the edit page, shoudl redirect to home or back instead or just not there + + - DONE NOT DOING THIS AS DIRTY CHECK COVERS IT ANYWAY....On save of record should have a brief notification that auto closes that says "SAVED" or something just to handle the case of people not clicking on save?? - or, would the dirty check on nav away cover this anyway? - Would it be annoying on a small device? + - Locale settings move to store - Right now if you reload a page the locale settings reset back to default as they are not backed by the store - However localized text keys do not because they *are* backed by the store diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index a8151e8f..9394b1ae 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -114,7 +114,16 @@ export default function initialize() { } //Store offset in locale data - locale.timeZoneOffset = res.data.timeZoneOffset; + //TODO: also need the other locale settings such as number and date formats etc to be added at server + store.commit("setLocale", { + decimalSeparator: ".", + currencySymbol: "$", + shortDate: "YYYY-MM-DD", + shortTime: "hh:mm:ss A", + shortDateAndTime: "YYYY-MM-DD hh:mm:ss A", + timeZoneOffset: res.data.timeZoneOffset + }); + resolve(); } }) diff --git a/ayanova/src/api/locale.js b/ayanova/src/api/locale.js index 9adf9fab..c39af539 100644 --- a/ayanova/src/api/locale.js +++ b/ayanova/src/api/locale.js @@ -98,29 +98,23 @@ export default { "Copy" ], decimalValidate(required) { - return { required: required, decimal: [2, this.formats.decimalSeparator] }; + return { required: required, decimal: [2, this.format().decimalSeparator] }; }, decimalParse(v) { if (v) { if ( this.decimalSeparator != "." && - v.includes(this.formats.decimalSeparator) + v.includes(this.format().decimalSeparator) ) { - v = v.replace(this.formats.decimalSeparator, "."); + v = v.replace(this.format().decimalSeparator, "."); } v = parseFloat(v); } return v; }, - formats: { - DecimalSeparator: ".", - currencySymbol: "$", - shortDate: "YYYY-MM-DD", - shortTime: "hh:mm:ss A", - shortDateAndTime: "YYYY-MM-DD hh:mm:ss A" + format() { + return store.state.locale; }, - //timeZoneOffset is in decimal hours - timeZoneOffset: -8.0, //////////////////////////////////////////////////////// // Take in a string that contains one or more //locale keys between square brackets diff --git a/ayanova/src/components/gzdateandtimepicker.vue b/ayanova/src/components/gzdateandtimepicker.vue index 8581746f..aa2ecccb 100644 --- a/ayanova/src/components/gzdateandtimepicker.vue +++ b/ayanova/src/components/gzdateandtimepicker.vue @@ -101,37 +101,37 @@ export default { return this.value ? this.$dayjs .utc(this.value) - .add(this.$gzlocale.timeZoneOffset, "hour") - .format(this.$gzlocale.formats.shortDateAndTime) + .add(this.$gzlocale.format().timeZoneOffset, "hour") + .format(this.$gzlocale.format().shortDateAndTime) : ""; }, formatDate() { return this.value ? this.$dayjs .utc(this.value) - .add(this.$gzlocale.timeZoneOffset, "hour") - .format(this.$gzlocale.formats.shortDate) + .add(this.$gzlocale.format().timeZoneOffset, "hour") + .format(this.$gzlocale.format().shortDate) : ""; }, formatTime() { return this.value ? this.$dayjs .utc(this.value) - .add(this.$gzlocale.timeZoneOffset, "hour") - .format(this.$gzlocale.formats.shortTime) + .add(this.$gzlocale.format().timeZoneOffset, "hour") + .format(this.$gzlocale.format().shortTime) : ""; }, dateOnly: { get() { return this.$dayjs .utc(this.value) - .add(this.$gzlocale.timeZoneOffset, "hour") + .add(this.$gzlocale.format().timeZoneOffset, "hour") .format("YYYY-MM-DD"); }, set(value) { this.date = this.$dayjs .utc(value + " " + this.timeOnly) - .subtract(this.$gzlocale.timeZoneOffset, "hour") + .subtract(this.$gzlocale.format().timeZoneOffset, "hour") .toISOString(); } }, @@ -139,13 +139,13 @@ export default { get() { return this.$dayjs .utc(this.value) - .add(this.$gzlocale.timeZoneOffset, "hour") + .add(this.$gzlocale.format().timeZoneOffset, "hour") .format("HH:mm:ss"); }, set(value) { this.date = this.$dayjs .utc(this.dateOnly + " " + value) - .subtract(this.$gzlocale.timeZoneOffset, "hour") + .subtract(this.$gzlocale.format().timeZoneOffset, "hour") .toISOString(); } } diff --git a/ayanova/src/store.js b/ayanova/src/store.js index 18288d25..75465ab4 100644 --- a/ayanova/src/store.js +++ b/ayanova/src/store.js @@ -18,6 +18,14 @@ export default new Vuex.Store({ userName: "NOT AUTHENTICATED", roles: 0, localeText: {}, + locale: { + decimalSeparator: ".", + currencySymbol: "$", + shortDate: "YYYY-MM-DD", + shortTime: "hh:mm:ss A", + shortDateAndTime: "YYYY-MM-DD hh:mm:ss A", + timeZoneOffset: -7 //timeZoneOffset is in decimal hours + }, navItems: [], logArray: [] }, @@ -39,6 +47,12 @@ export default new Vuex.Store({ state.navItems = []; state.localeText = {}; state.apiUrl = ""; + state.locale.decimalSeparator = "."; + state.locale.currencySymbol = "$"; + state.locale.shortDate = "YYYY-MM-DD"; + state.locale.shortTime = "hh:mm:ss A"; + state.locale.shortDateAndTime = "YYYY-MM-DD hh:mm:ss A"; + state.locale.timeZoneOffset = -7; }, addNavItem(state, data) { state.navItems.push(data); @@ -46,6 +60,15 @@ export default new Vuex.Store({ addLocaleText(state, data) { state.localeText[data.key] = data.value; }, + setLocale(state, data) { + // mutate state + state.locale.decimalSeparator = data.decimalSeparator; + state.locale.currencySymbol = data.currencySymbol; + state.locale.shortDate = data.shortDate; + state.locale.shortTime = data.shortTime; + state.locale.shortDateAndTime = data.shortDateAndTime; + state.locale.timeZoneOffset = data.timeZoneOffset; + }, setAPIURL(state, data) { state.apiUrl = data; }, diff --git a/ayanova/src/views/About.vue b/ayanova/src/views/About.vue index 9b848c42..e39d7df5 100644 --- a/ayanova/src/views/About.vue +++ b/ayanova/src/views/About.vue @@ -29,48 +29,50 @@ {{ this.$gzlocale.get("UserTimeZoneOffset") }}: - {{ this.$gzlocale.timeZoneOffset }} + {{ + this.$gzlocale.format().timeZoneOffset + }}
{{ this.$gzlocale.get("DecimalSeparator") }}: - {{ - this.$gzlocale.formats.DecimalSeparator - }} + + {{ this.$gzlocale.format().decimalSeparator }} +
{{ this.$gzlocale.get("CurrencySymbol") }}: - {{ - this.$gzlocale.formats.currencySymbol - }} + + {{ this.$gzlocale.format().currencySymbol }} +
{{ this.$gzlocale.get("ShortDateFormat") }}: - {{ this.$gzlocale.formats.shortDate }} + {{ this.$gzlocale.format().shortDate }}
{{ this.$gzlocale.get("ShortTimeFormat") }}: - {{ this.$gzlocale.formats.shortTime }} + {{ this.$gzlocale.format().shortTime }}
{{ this.$gzlocale.get("ShortDateAndTimeFormat") }}: - {{ - this.$gzlocale.formats.shortDateAndTime - }} + + {{ this.$gzlocale.format().shortDateAndTime }} +
@@ -115,9 +117,9 @@ {{ this.$gzlocale.get("RegisteredUser") }}: - {{ - serverInfo.license.license.licensedTo - }} + + {{ serverInfo.license.license.licensedTo }} +
{{ this.$gzlocale.get("LicenseExpiration") }}: - {{ - serverInfo.license.license.licenseExpiration - }} + + {{ serverInfo.license.license.licenseExpiration }} +
{{ this.$gzlocale.get("SupportedUntil") }}: - {{ - serverInfo.license.license.maintenanceExpiration - }} + + {{ serverInfo.license.license.maintenanceExpiration }} +
diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index faf719c1..4a7c57f0 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -13,7 +13,8 @@ transition="scale-transition" class="multi-line" outline - >{{ formState.errorBoxMessage }} + >{{ formState.errorBoxMessage }}