From 6fd1fef16e5ea7c8ffd21003ecbac17b9ca45915 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 14 Jul 2020 00:13:40 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 7 +- ayanova/src/components/date-control.vue | 1 + ayanova/src/components/duration-control.vue | 176 +++++++++++++------- 3 files changed, 120 insertions(+), 64 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index c02e0045..12d5c8b2 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -45,11 +45,14 @@ todo: Test server down while polling in release mode, does it recover when serve - +todo: all custom controls are fucked (mostly) + wont' start with initial value, WTF???????? + this just started as an issue, def wasn't before + includes custom form date and time etc todo: pick lists in forms should be sortable alphabetically for example the event types and object types in notification subscription - + todo: does Duplicate code really duplicate the tags? i.e. duplicate a widget with tags, do the tags come over? if not then need to modify the copy object code to handle tags as well diff --git a/ayanova/src/components/date-control.vue b/ayanova/src/components/date-control.vue index 69ae500c..a22a4f45 100644 --- a/ayanova/src/components/date-control.vue +++ b/ayanova/src/components/date-control.vue @@ -35,6 +35,7 @@ export default { }, watch: { value(val) { + console.log("date-control watch value is", val); this.internalValue = val; } }, diff --git a/ayanova/src/components/duration-control.vue b/ayanova/src/components/duration-control.vue index 0e8b0469..0e842eeb 100644 --- a/ayanova/src/components/duration-control.vue +++ b/ayanova/src/components/duration-control.vue @@ -7,8 +7,9 @@ /* Xeslint-disable */ -/* +/*https://alligator.io/vuejs/add-v-model-support/ "TimeSpanDays": "days", "TimeSpanHours": "hours", "TimeSpanMinutes": "minutes", @@ -82,47 +86,38 @@ //maybe split by colon first then subsplit first and last elements into days and MS //{"data":{"testTSDaysWMS":"22.10:15:22.0330000","testTSHMS":"05:16:33","testTS_DHMS":"5.10:15:33","testTS_MS":"00:15:33","testTS_S":"00:00:33","testTS_D":"22.00:00:00"}} export default { - data() { - return { - internalValue: null, - days: 0, - hours: 0, - minutes: 0, - seconds: 0 - }; - }, - watch: { - value(val) { - //this.internalValue = val; - if (val == null) { - this.days = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - return; - } - let work = val.split(":"); - //has days? - if (work[0].includes(".")) { - let dh = work[0].split("."); - this.days = Number(dh[0]); - this.hours = Number(dh[1]); - } else { - this.days = 0; - this.hours = Number(work[0]); - } - - this.minutes = Number(work[1]); - - //has milliseconds? (ignore them) - if (work[2].includes(".")) { - let dh = work[2].split("."); - this.seconds = Number(dh[0]); - } else { - this.seconds = Number(work[2]); - } - } - }, + // created() { + // console.log("created, value is:", this.value); + // this.handleUpdate(this.value); + // }, + // beforeMount() { + // console.log("beforeMount, value is:", this.value); + // }, + // mounted() { + // console.log("mounted, value is:", this.value); + // }, + // beforeUpdate() { + // console.log("beforeUpdate, value is:", this.value); + // }, + // updated() { + // console.log("updated, value is:", this.value); + // }, + // data() { + // return { + // internalValue: null, + // days: 0, + // hours: 0, + // minutes: 0, + // seconds: 0 + // }; + // }, + // watch: { + // value(val) { + // console.log("Val is ", val); + // // this.internalValue = val; + // this.handleUpdate(val); + // } + // }, props: { label: String, rules: Array, @@ -138,6 +133,47 @@ export default { showDays: { type: Boolean, default: true }, testId: String }, + computed: { + splitSpan() { + let vm = this; + let theDays = 0; + let theHours = 0; + let theMinutes = 0; + let theSeconds = 0; + + if (vm.value == null) { + theDays = 0; + theHours = 0; + theMinutes = 0; + theSeconds = 0; + } else { + let work = vm.value.split(":"); + //has days? + if (work[0].includes(".")) { + let dh = work[0].split("."); + theDays = Number(dh[0]); + theHours = Number(dh[1]); + } else { + theHours = Number(work[0]); + } + theMinutes = Number(work[1]); + //has milliseconds? (ignore them) + if (work[2].includes(".")) { + let dh = work[2].split("."); + theSeconds = Number(dh[0]); + } else { + theSeconds = Number(work[2]); + } + } + + return { + days: theDays, + hours: theHours, + minutes: theMinutes, + seconds: theSeconds + }; + } + }, methods: { allErrors() { let ret = ""; @@ -157,6 +193,7 @@ export default { this.hour12 ); }, + handleDaysInput(value) { this.days = Number(value); this.handleInput(); @@ -207,21 +244,36 @@ export default { } ret += `${vm.hours}:${vm.minutes}:${vm.seconds}`; this.$emit("input", ret); + }, + handleUpdate(val) { + if (val == null) { + this.days = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + return; + } + let work = val.split(":"); + //has days? + if (work[0].includes(".")) { + let dh = work[0].split("."); + this.days = Number(dh[0]); + this.hours = Number(dh[1]); + } else { + this.days = 0; + this.hours = Number(work[0]); + } + + this.minutes = Number(work[1]); + + //has milliseconds? (ignore them) + if (work[2].includes(".")) { + let dh = work[2].split("."); + this.seconds = Number(dh[0]); + } else { + this.seconds = Number(work[2]); + } } - //combine these into the proper timespan string - // //combine the time and dates into a consolidated value - // let TimePortion = window.$gz.locale.utcDateStringToLocal8601TimeOnlyString( - // this.internalValue, - // this.timeZoneName - // ); - // if (!TimePortion) { - // TimePortion = "00:00:00"; - // } - // let newValue = window.$gz.locale.localTimeDateStringToUTC8601String( - // value + "T" + TimePortion, - // this.timeZoneName - // ); - // this.$emit("input", newValue); } };