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 - 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? - or, would the dirty check on nav away cover this anyway?
- Would it be annoying on a small device? - Would it be annoying on a small device?
- Locale settings move to store - 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 - 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 - 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 //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(); resolve();
} }
}) })

View File

@@ -98,29 +98,23 @@ export default {
"Copy" "Copy"
], ],
decimalValidate(required) { decimalValidate(required) {
return { required: required, decimal: [2, this.formats.decimalSeparator] }; return { required: required, decimal: [2, this.format().decimalSeparator] };
}, },
decimalParse(v) { decimalParse(v) {
if (v) { if (v) {
if ( if (
this.decimalSeparator != "." && 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); v = parseFloat(v);
} }
return v; return v;
}, },
formats: { format() {
DecimalSeparator: ".", return store.state.locale;
currencySymbol: "$",
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,
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
// Take in a string that contains one or more // Take in a string that contains one or more
//locale keys between square brackets //locale keys between square brackets

View File

@@ -101,37 +101,37 @@ export default {
return this.value return this.value
? this.$dayjs ? this.$dayjs
.utc(this.value) .utc(this.value)
.add(this.$gzlocale.timeZoneOffset, "hour") .add(this.$gzlocale.format().timeZoneOffset, "hour")
.format(this.$gzlocale.formats.shortDateAndTime) .format(this.$gzlocale.format().shortDateAndTime)
: ""; : "";
}, },
formatDate() { formatDate() {
return this.value return this.value
? this.$dayjs ? this.$dayjs
.utc(this.value) .utc(this.value)
.add(this.$gzlocale.timeZoneOffset, "hour") .add(this.$gzlocale.format().timeZoneOffset, "hour")
.format(this.$gzlocale.formats.shortDate) .format(this.$gzlocale.format().shortDate)
: ""; : "";
}, },
formatTime() { formatTime() {
return this.value return this.value
? this.$dayjs ? this.$dayjs
.utc(this.value) .utc(this.value)
.add(this.$gzlocale.timeZoneOffset, "hour") .add(this.$gzlocale.format().timeZoneOffset, "hour")
.format(this.$gzlocale.formats.shortTime) .format(this.$gzlocale.format().shortTime)
: ""; : "";
}, },
dateOnly: { dateOnly: {
get() { get() {
return this.$dayjs return this.$dayjs
.utc(this.value) .utc(this.value)
.add(this.$gzlocale.timeZoneOffset, "hour") .add(this.$gzlocale.format().timeZoneOffset, "hour")
.format("YYYY-MM-DD"); .format("YYYY-MM-DD");
}, },
set(value) { set(value) {
this.date = this.$dayjs this.date = this.$dayjs
.utc(value + " " + this.timeOnly) .utc(value + " " + this.timeOnly)
.subtract(this.$gzlocale.timeZoneOffset, "hour") .subtract(this.$gzlocale.format().timeZoneOffset, "hour")
.toISOString(); .toISOString();
} }
}, },
@@ -139,13 +139,13 @@ export default {
get() { get() {
return this.$dayjs return this.$dayjs
.utc(this.value) .utc(this.value)
.add(this.$gzlocale.timeZoneOffset, "hour") .add(this.$gzlocale.format().timeZoneOffset, "hour")
.format("HH:mm:ss"); .format("HH:mm:ss");
}, },
set(value) { set(value) {
this.date = this.$dayjs this.date = this.$dayjs
.utc(this.dateOnly + " " + value) .utc(this.dateOnly + " " + value)
.subtract(this.$gzlocale.timeZoneOffset, "hour") .subtract(this.$gzlocale.format().timeZoneOffset, "hour")
.toISOString(); .toISOString();
} }
} }

View File

@@ -18,6 +18,14 @@ export default new Vuex.Store({
userName: "NOT AUTHENTICATED", userName: "NOT AUTHENTICATED",
roles: 0, roles: 0,
localeText: {}, 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: [], navItems: [],
logArray: [] logArray: []
}, },
@@ -39,6 +47,12 @@ export default new Vuex.Store({
state.navItems = []; state.navItems = [];
state.localeText = {}; state.localeText = {};
state.apiUrl = ""; 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) { addNavItem(state, data) {
state.navItems.push(data); state.navItems.push(data);
@@ -46,6 +60,15 @@ export default new Vuex.Store({
addLocaleText(state, data) { addLocaleText(state, data) {
state.localeText[data.key] = data.value; 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) { setAPIURL(state, data) {
state.apiUrl = data; state.apiUrl = data;
}, },

View File

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

View File

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