This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
@@ -73,17 +73,22 @@ function decodeError(e, vm) {
|
||||
// console.log(typeof e === "object");
|
||||
|
||||
//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 (
|
||||
e == null ||
|
||||
e == "" ||
|
||||
(typeof e === "object" && Object.keys(e).length === 0)
|
||||
) {
|
||||
return "errorHandler::decodeError - Error is unknown / empty";
|
||||
}
|
||||
|
||||
//an Error object?
|
||||
if (e instanceof Error) {
|
||||
return `Error - Name:${e.name}, Message:${e.message}`;
|
||||
return `errorHandler::decodeError - Error is unknown / empty (e:${e})`;
|
||||
}
|
||||
|
||||
//API error object?
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
v-on="on"
|
||||
prepend-icon="$ayiCalendarAlt"
|
||||
@click:prepend="dlgdate = true"
|
||||
v-model="formatDate"
|
||||
:value="dateValue"
|
||||
v-bind:label="label"
|
||||
v-bind:rules="rules"
|
||||
readonly
|
||||
@@ -22,8 +22,9 @@
|
||||
></v-text-field>
|
||||
</template>
|
||||
<v-date-picker
|
||||
v-model="dateOnly"
|
||||
@input="dlgdate = false"
|
||||
:value="dateValue"
|
||||
ref="dateField"
|
||||
@input="updateDateValue"
|
||||
:locale="defaultLocale"
|
||||
:data-cy="'dpick:' + testId"
|
||||
>
|
||||
@@ -44,7 +45,7 @@
|
||||
<template v-slot:activator="{ on }">
|
||||
<v-text-field
|
||||
v-on="on"
|
||||
v-model="formatTime"
|
||||
:value="timeValue"
|
||||
label
|
||||
prepend-icon="$ayiClock"
|
||||
@click:prepend="dlgtime = true"
|
||||
@@ -57,7 +58,9 @@
|
||||
scrollable
|
||||
ampm-in-title
|
||||
:format="hour12 ? 'ampm' : '24hr'"
|
||||
v-model="timeOnly"
|
||||
:value="timeValue"
|
||||
@input="updateTimeValue"
|
||||
ref="timeField"
|
||||
:data-cy="'tpick:' + testId"
|
||||
>
|
||||
<v-spacer></v-spacer>
|
||||
@@ -84,8 +87,6 @@
|
||||
/* Xeslint-disable */
|
||||
export default {
|
||||
data: () => ({
|
||||
date: null,
|
||||
oldDate: null,
|
||||
dlgdate: false,
|
||||
dlgtime: false,
|
||||
//cache display format stuff
|
||||
@@ -97,33 +98,43 @@ export default {
|
||||
props: {
|
||||
label: String,
|
||||
rules: Array,
|
||||
"error-messages": { type: Array, default: null },
|
||||
value: String,
|
||||
readonly: { type: Boolean, default: false },
|
||||
disabled: { type: Boolean, default: false },
|
||||
error: {
|
||||
type: String,
|
||||
required: false
|
||||
},
|
||||
testId: String
|
||||
},
|
||||
watch: {
|
||||
date() {
|
||||
//this tortuous fuckery is required so that the input and change events only fire on a real change, not initial page load
|
||||
//also it shouldn't signal a change if the values are the same and nothing was effectively changed
|
||||
let hasChanged = false;
|
||||
if (this.date != this.oldDate) {
|
||||
hasChanged = true;
|
||||
}
|
||||
this.oldDate = this.date;
|
||||
if (hasChanged) {
|
||||
this.$emit("input", this.date); //always in UTC
|
||||
}
|
||||
|
||||
computed: {
|
||||
timeValue() {
|
||||
return window.$gz.locale.utcDateStringToLocal8601TimeOnlyString(
|
||||
this.value,
|
||||
this.timeZoneName
|
||||
);
|
||||
},
|
||||
value() {
|
||||
this.date = this.value; //always in UTC
|
||||
dateValue() {
|
||||
return window.$gz.locale.utcDateStringToLocal8601DateOnlyString(
|
||||
this.value,
|
||||
this.timeZoneName
|
||||
);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
formatDateTime() {
|
||||
methods: {
|
||||
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(
|
||||
this.value,
|
||||
this.timeZoneName,
|
||||
@@ -131,72 +142,48 @@ export default {
|
||||
this.hour12
|
||||
);
|
||||
},
|
||||
formatDate() {
|
||||
return window.$gz.locale.utcDateToShortDateLocalized(
|
||||
this.value,
|
||||
this.timeZoneName,
|
||||
this.languageName
|
||||
);
|
||||
updateTimeValue(v) {
|
||||
// console.log("updatedTimevalue", v);
|
||||
// console.log("currentDateValue", this.dateValue);
|
||||
this.updateValue(this.dateValue, v);
|
||||
},
|
||||
formatTime() {
|
||||
return window.$gz.locale.utcDateToShortTimeLocalized(
|
||||
this.value,
|
||||
this.timeZoneName,
|
||||
this.languageName,
|
||||
this.hour12
|
||||
);
|
||||
updateDateValue(v) {
|
||||
// console.log("updatedDatevalue", v);
|
||||
// console.log("currentTimeValue", this.timeValue);
|
||||
this.updateValue(v, this.timeValue);
|
||||
this.dlgdate = false;
|
||||
},
|
||||
dateOnly: {
|
||||
get() {
|
||||
//return date only portion converted to local working time zone: YYYY-MM-DD
|
||||
return window.$gz.locale.utcDateStringToLocal8601DateOnlyString(
|
||||
this.value,
|
||||
this.timeZoneName
|
||||
);
|
||||
},
|
||||
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();
|
||||
}
|
||||
updateValue(theDate, theTime) {
|
||||
// console.log("updatevalue", v);
|
||||
//@input="dlgdate = false"
|
||||
let vm = this;
|
||||
//console.log(vm.$refs.dateField.value);
|
||||
// let dateValue = vm.$refs.dateField.$refs.input.value;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
this.date = window.$gz.locale.localTimeDateStringToUTC8601String(
|
||||
DatePortion + "T" + value,
|
||||
this.timeZoneName
|
||||
);
|
||||
let fullDay = v.getDate();
|
||||
if (fullDay < 10) {
|
||||
fullDay = "0" + fullDay.toString();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user