This commit is contained in:
2019-05-29 22:37:01 +00:00
parent 4f4252a947
commit 871a5da022
7 changed files with 78 additions and 48 deletions

View File

@@ -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
- 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
- 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 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

View File

@@ -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();
}
})

View File

@@ -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

View File

@@ -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();
}
}

View File

@@ -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;
},

View File

@@ -29,48 +29,50 @@
<span class="ml-4 body-1"
>{{ this.$gzlocale.get("UserTimeZoneOffset") }}:</span
>
<span class="body-2">{{ this.$gzlocale.timeZoneOffset }}</span>
<span class="body-2">{{
this.$gzlocale.format().timeZoneOffset
}}</span>
</div>
<div>
<span class="ml-4 body-1"
>{{ this.$gzlocale.get("DecimalSeparator") }}:</span
>
<span class="body-2">{{
this.$gzlocale.formats.DecimalSeparator
}}</span>
<span class="body-2">
{{ this.$gzlocale.format().decimalSeparator }}
</span>
</div>
<div>
<span class="ml-4 body-1"
>{{ this.$gzlocale.get("CurrencySymbol") }}:</span
>
<span class="body-2">{{
this.$gzlocale.formats.currencySymbol
}}</span>
<span class="body-2">
{{ this.$gzlocale.format().currencySymbol }}
</span>
</div>
<div>
<span class="ml-4 body-1"
>{{ this.$gzlocale.get("ShortDateFormat") }}:</span
>
<span class="body-2">{{ this.$gzlocale.formats.shortDate }}</span>
<span class="body-2">{{ this.$gzlocale.format().shortDate }}</span>
</div>
<div>
<span class="ml-4 body-1"
>{{ this.$gzlocale.get("ShortTimeFormat") }}:</span
>
<span class="body-2">{{ this.$gzlocale.formats.shortTime }}</span>
<span class="body-2">{{ this.$gzlocale.format().shortTime }}</span>
</div>
<div>
<span class="ml-4 body-1"
>{{ this.$gzlocale.get("ShortDateAndTimeFormat") }}:</span
>
<span class="body-2">{{
this.$gzlocale.formats.shortDateAndTime
}}</span>
<span class="body-2">
{{ this.$gzlocale.format().shortDateAndTime }}
</span>
</div>
<v-divider class="mt-4"></v-divider>
@@ -115,9 +117,9 @@
<span class="ml-4 body-1"
>{{ this.$gzlocale.get("RegisteredUser") }}:</span
>
<span class="body-2">{{
serverInfo.license.license.licensedTo
}}</span>
<span class="body-2">
{{ serverInfo.license.license.licensedTo }}
</span>
</div>
<div>
<span class="ml-4 body-1"
@@ -135,17 +137,17 @@
<span class="ml-4 body-1"
>{{ this.$gzlocale.get("LicenseExpiration") }}:</span
>
<span class="body-2">{{
serverInfo.license.license.licenseExpiration
}}</span>
<span class="body-2">
{{ serverInfo.license.license.licenseExpiration }}
</span>
</div>
<div>
<span class="ml-4 body-1"
>{{ this.$gzlocale.get("SupportedUntil") }}:</span
>
<span class="body-2">{{
serverInfo.license.license.maintenanceExpiration
}}</span>
<span class="body-2">
{{ serverInfo.license.license.maintenanceExpiration }}
</span>
</div>
<v-divider class="mt-4"></v-divider>

View File

@@ -13,7 +13,8 @@
transition="scale-transition"
class="multi-line"
outline
>{{ formState.errorBoxMessage }}</v-alert>
>{{ formState.errorBoxMessage }}</v-alert
>
</v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2>
<v-text-field
@@ -70,7 +71,7 @@
<v-text-field
v-model="obj.dollarAmount"
:readonly="this.formState.readOnly"
:prefix="this.$gzlocale.formats.currencySymbol"
:prefix="this.$gzlocale.format().currencySymbol"
:label="this.$gzlocale.get('WidgetDollarAmount')"
ref="dollarAmount"
required