This commit is contained in:
2020-11-30 17:23:35 +00:00
parent 66b7de3f24
commit 759c664e48
3 changed files with 83 additions and 90 deletions

View File

@@ -29,6 +29,7 @@ todo: DATE / TIME / DATE_TIME controls switch back to vuetify ones
Better solution: one clear button that clears all and emits properly and disable the built in if possible Better solution: one clear button that clears all and emits properly and disable the built in if possible
todo: datetime testing make sure locale, am/pm etc are all honoured
todo: gz-data-table make sure unbounded notes column is bounded by some length restriction todo: gz-data-table make sure unbounded notes column is bounded by some length restriction
mobile format is ok, it cuts off at one line, but for desktop we should have a sane limit as right now it's completely unbounded mobile format is ok, it cuts off at one line, but for desktop we should have a sane limit as right now it's completely unbounded

View File

@@ -73,17 +73,22 @@ function decodeError(e, vm) {
// console.log(typeof e === "object"); // console.log(typeof e === "object");
//empty? //empty?
// console.log("e instanceof Error ", e instanceof Error);
// console.log(e);
//console.log("Object.keys(e)", Object.keys(e));
//an Error object?
if (e instanceof Error) {
return `Error - Name:${e.name}, Message:${e.message}`;
}
if ( if (
e == null || e == null ||
e == "" || e == "" ||
(typeof e === "object" && Object.keys(e).length === 0) (typeof e === "object" && Object.keys(e).length === 0)
) { ) {
return "errorHandler::decodeError - Error is unknown / empty"; return `errorHandler::decodeError - Error is unknown / empty (e:${e})`;
}
//an Error object?
if (e instanceof Error) {
return `Error - Name:${e.name}, Message:${e.message}`;
} }
//API error object? //API error object?

View File

@@ -13,7 +13,7 @@
v-on="on" v-on="on"
prepend-icon="$ayiCalendarAlt" prepend-icon="$ayiCalendarAlt"
@click:prepend="dlgdate = true" @click:prepend="dlgdate = true"
v-model="formatDate" :value="dateValue"
v-bind:label="label" v-bind:label="label"
v-bind:rules="rules" v-bind:rules="rules"
readonly readonly
@@ -22,8 +22,9 @@
></v-text-field> ></v-text-field>
</template> </template>
<v-date-picker <v-date-picker
v-model="dateOnly" :value="dateValue"
@input="dlgdate = false" ref="dateField"
@input="updateDateValue"
:locale="defaultLocale" :locale="defaultLocale"
:data-cy="'dpick:' + testId" :data-cy="'dpick:' + testId"
> >
@@ -44,7 +45,7 @@
<template v-slot:activator="{ on }"> <template v-slot:activator="{ on }">
<v-text-field <v-text-field
v-on="on" v-on="on"
v-model="formatTime" :value="timeValue"
label label
prepend-icon="$ayiClock" prepend-icon="$ayiClock"
@click:prepend="dlgtime = true" @click:prepend="dlgtime = true"
@@ -57,7 +58,9 @@
scrollable scrollable
ampm-in-title ampm-in-title
:format="hour12 ? 'ampm' : '24hr'" :format="hour12 ? 'ampm' : '24hr'"
v-model="timeOnly" :value="timeValue"
@input="updateTimeValue"
ref="timeField"
:data-cy="'tpick:' + testId" :data-cy="'tpick:' + testId"
> >
<v-spacer></v-spacer> <v-spacer></v-spacer>
@@ -84,8 +87,6 @@
/* Xeslint-disable */ /* Xeslint-disable */
export default { export default {
data: () => ({ data: () => ({
date: null,
oldDate: null,
dlgdate: false, dlgdate: false,
dlgtime: false, dlgtime: false,
//cache display format stuff //cache display format stuff
@@ -97,33 +98,43 @@ export default {
props: { props: {
label: String, label: String,
rules: Array, rules: Array,
"error-messages": { type: Array, default: null },
value: String, value: String,
readonly: { type: Boolean, default: false }, readonly: { type: Boolean, default: false },
disabled: { type: Boolean, default: false },
error: { error: {
type: String, type: String,
required: false required: false
}, },
testId: String testId: String
}, },
watch: {
date() { computed: {
//this tortuous fuckery is required so that the input and change events only fire on a real change, not initial page load timeValue() {
//also it shouldn't signal a change if the values are the same and nothing was effectively changed return window.$gz.locale.utcDateStringToLocal8601TimeOnlyString(
let hasChanged = false; this.value,
if (this.date != this.oldDate) { this.timeZoneName
hasChanged = true; );
}
this.oldDate = this.date;
if (hasChanged) {
this.$emit("input", this.date); //always in UTC
}
}, },
value() { dateValue() {
this.date = this.value; //always in UTC return window.$gz.locale.utcDateStringToLocal8601DateOnlyString(
this.value,
this.timeZoneName
);
} }
}, },
computed: { methods: {
formatDateTime() { allErrors() {
let ret = "";
if (this.error != null) {
ret = this.error;
}
if (this.errorMessages != null && this.errorMessages.length > 0) {
ret += this.errorMessages.toString();
}
return ret;
},
readonlyFormat() {
return window.$gz.locale.utcDateToShortDateAndTimeLocalized( return window.$gz.locale.utcDateToShortDateAndTimeLocalized(
this.value, this.value,
this.timeZoneName, this.timeZoneName,
@@ -131,72 +142,48 @@ export default {
this.hour12 this.hour12
); );
}, },
formatDate() { updateTimeValue(v) {
return window.$gz.locale.utcDateToShortDateLocalized( // console.log("updatedTimevalue", v);
this.value, // console.log("currentDateValue", this.dateValue);
this.timeZoneName, this.updateValue(this.dateValue, v);
this.languageName
);
}, },
formatTime() { updateDateValue(v) {
return window.$gz.locale.utcDateToShortTimeLocalized( // console.log("updatedDatevalue", v);
this.value, // console.log("currentTimeValue", this.timeValue);
this.timeZoneName, this.updateValue(v, this.timeValue);
this.languageName, this.dlgdate = false;
this.hour12
);
}, },
dateOnly: { updateValue(theDate, theTime) {
get() { // console.log("updatevalue", v);
//return date only portion converted to local working time zone: YYYY-MM-DD //@input="dlgdate = false"
return window.$gz.locale.utcDateStringToLocal8601DateOnlyString( let vm = this;
this.value, //console.log(vm.$refs.dateField.value);
this.timeZoneName // let dateValue = vm.$refs.dateField.$refs.input.value;
);
},
set(value) {
//2017-08-15T12:10:34.4443084+03:00
let TimePortion = this.timeOnly;
if (!TimePortion) {
TimePortion = "00:00:00";
}
this.date = window.$gz.locale.localTimeDateStringToUTC8601String(
value + "T" + TimePortion,
this.timeZoneName
);
}
},
timeOnly: {
//expects just the hours minutes seconds portion: 18:18:49
//Needs to convert into and out of the desired time zone or the control will show the UTC time instead
get() {
return window.$gz.locale.utcDateStringToLocal8601TimeOnlyString(
this.value,
this.timeZoneName
);
},
set(value) {
let DatePortion = this.dateOnly;
if (!DatePortion) {
let v = new Date();
let fullYear = v.getFullYear();
let fullMonth = v.getMonth() + 1;
if (fullMonth < 10) {
fullMonth = "0" + fullMonth.toString();
}
let fullDay = v.getDate();
if (fullDay < 10) {
fullDay = "0" + fullDay.toString();
}
DatePortion = fullYear + "-" + fullMonth + "-" + fullDay; if (!theDate) {
let v = new Date();
let fullYear = v.getFullYear();
let fullMonth = v.getMonth() + 1;
if (fullMonth < 10) {
fullMonth = "0" + fullMonth.toString();
} }
let fullDay = v.getDate();
this.date = window.$gz.locale.localTimeDateStringToUTC8601String( if (fullDay < 10) {
DatePortion + "T" + value, fullDay = "0" + fullDay.toString();
this.timeZoneName }
); theDate = fullYear + "-" + fullMonth + "-" + fullDay;
} }
// let timeValue = vm.$refs.timeField.$refs.input.value;
if (!theTime) {
theTime = "00:00:00";
}
let ret = window.$gz.locale.localTimeDateStringToUTC8601String(
theDate + "T" + theTime,
vm.timeZoneName
);
vm.$emit("input", ret);
} }
} }
}; };