This commit is contained in:
@@ -1,119 +1,108 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!-- <v-menu
|
<v-layout row wrap v-if="!readonly">
|
||||||
ref="menu"
|
<v-flex xs6>
|
||||||
v-model="show"
|
<v-dialog v-model="modal" persistent lazy full-width width="290px">
|
||||||
:close-on-content-click="false"
|
<v-text-field
|
||||||
:nudge-right="40"
|
slot="activator"
|
||||||
:return-value.sync="time"
|
v-model="formatDate"
|
||||||
lazy
|
v-bind:label="label"
|
||||||
transition="scale-transition"
|
prepend-icon="fa-calendar-alt"
|
||||||
offset-y
|
readonly
|
||||||
full-width
|
></v-text-field>
|
||||||
max-width="290px"
|
<v-date-picker v-model="dateOnly" @input="modal = false">
|
||||||
min-width="290px"
|
<v-spacer></v-spacer>
|
||||||
>
|
<v-btn flat color="primary" @click="modal = false">Close</v-btn>
|
||||||
<template v-slot:activator="{ on }">
|
</v-date-picker>
|
||||||
<v-text-field
|
</v-dialog>
|
||||||
v-model="value"
|
</v-flex>
|
||||||
prepend-inner-icon="fa-calendar-alt"
|
<v-flex xs6>
|
||||||
@click:prepend-inner="sproing('DATE')"
|
<v-dialog v-model="modal2" persistent lazy full-width width="290px">
|
||||||
append-icon="fa-clock"
|
<v-text-field
|
||||||
@click:append="sproing('TIME')"
|
slot="activator"
|
||||||
readonly
|
v-model="formatTime"
|
||||||
v-on="on"
|
label
|
||||||
></v-text-field>
|
prepend-icon="fa-clock"
|
||||||
|
readonly
|
||||||
-->
|
></v-text-field>
|
||||||
<v-menu
|
<v-time-picker v-model="timeOnly">
|
||||||
ref="menu"
|
<v-spacer></v-spacer>
|
||||||
v-model="show"
|
<v-btn flat color="primary" @click="modal2 = false">OK</v-btn>
|
||||||
:close-on-content-click="false"
|
</v-time-picker>
|
||||||
:nudge-right="40"
|
</v-dialog>
|
||||||
lazy
|
</v-flex>
|
||||||
transition="scale-transition"
|
</v-layout>
|
||||||
offset-y
|
<v-text-field
|
||||||
full-width
|
v-else
|
||||||
min-width="290px"
|
v-model="formatDateTime"
|
||||||
>
|
v-bind:label="label"
|
||||||
<gz-date-picker v-if="show.datePicker" v-bind:value="value" scrollable>
|
prepend-icon="fa-calendar-alt"
|
||||||
<div>WHAAA???</div>
|
disabled
|
||||||
<v-spacer></v-spacer>
|
></v-text-field>
|
||||||
<v-btn flat color="primary" @click="show.datePicker = false">Cancel</v-btn>
|
|
||||||
<v-btn flat color="primary" @click="dateSelected(date)">OK</v-btn>
|
|
||||||
</gz-date-picker>
|
|
||||||
<gz-time-picker v-if="show.timePicker" v-bind:value="value" scrollable>
|
|
||||||
<v-spacer></v-spacer>
|
|
||||||
<div>WHOOOO???</div>
|
|
||||||
<v-btn flat color="primary" @click="show.timePicker = false">Cancel</v-btn>
|
|
||||||
<v-btn flat color="primary" @click="alert('bam!')">OK</v-btn>
|
|
||||||
</gz-time-picker>
|
|
||||||
<v-text-field
|
|
||||||
v-model="value"
|
|
||||||
prepend-inner-icon="fa-calendar-alt"
|
|
||||||
@click:prepend-inner="sproing('DATE')"
|
|
||||||
append-icon="fa-clock"
|
|
||||||
@click:append="sproing('TIME')"
|
|
||||||
readonly
|
|
||||||
></v-text-field>
|
|
||||||
</v-menu>
|
|
||||||
<!-- <v-time-picker
|
|
||||||
v-if="show.timePicker"
|
|
||||||
v-bind:value="value"
|
|
||||||
v-on:input="$emit('input', $event.target.value)"
|
|
||||||
></v-time-picker>
|
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template> <script>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
/* eslint-disable */
|
|
||||||
/*
|
|
||||||
TODO:
|
|
||||||
Add the date picker
|
|
||||||
Make the buttons open the correct picker
|
|
||||||
Make it actually work with the binding and the selections and etc
|
|
||||||
maybe can make it editable by keyboard in the text field and still keep the pickers as a separate option?
|
|
||||||
*/
|
|
||||||
//https://stackoverflow.com/questions/54575541/vuetify-timepicker-return-value-to-model
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
data: () => ({ date: null, modal: false, modal2: false }),
|
||||||
value: String,
|
props: { label: String, value: String, readonly: Boolean },
|
||||||
formatDate: Function
|
watch: {
|
||||||
|
date() {
|
||||||
|
this.$emit("input", this.date);
|
||||||
|
},
|
||||||
|
value() {
|
||||||
|
this.date = this.value;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data() {
|
computed: {
|
||||||
return {
|
formatDateTime() {
|
||||||
show: {
|
return this.value.toString();
|
||||||
timePicker: false,
|
// let momentObj = this.$moment.utc();
|
||||||
datePicker: false
|
// if (this.value) {
|
||||||
|
// momentObj = this.$moment.utc(this.value);
|
||||||
|
// }
|
||||||
|
// return momentObj.local().format("dddd MM/DD/YYYY h:mm a");
|
||||||
|
},
|
||||||
|
formatDate() {
|
||||||
|
return this.value.toString();
|
||||||
|
// let momentObj = this.$moment.utc();
|
||||||
|
// if (this.value) {
|
||||||
|
// momentObj = this.$moment.utc(this.value);
|
||||||
|
// }
|
||||||
|
// return momentObj.local().format("dddd MM/DD/YYYY");
|
||||||
|
},
|
||||||
|
dateOnly: {
|
||||||
|
get() {
|
||||||
|
return this.value ? this.value.substr(0, 10) : null;
|
||||||
|
// let momentObj = this.$moment.utc();
|
||||||
|
// if (this.value) {
|
||||||
|
// momentObj = this.$moment.utc(this.value);
|
||||||
|
// }
|
||||||
|
// return momentObj.local().format("YYYY-MM-DD");
|
||||||
},
|
},
|
||||||
time: null,
|
set(value) {
|
||||||
menu2: false,
|
this.date = value + " " + this.timeOnly;
|
||||||
modal2: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
mounted() {},
|
|
||||||
methods: {
|
|
||||||
sproing: function(sproingUp) {
|
|
||||||
if (sproingUp == "DATE") {
|
|
||||||
this.show.datePicker = true;
|
|
||||||
this.show.timePicker = false;
|
|
||||||
} else {
|
|
||||||
this.show.datePicker = false;
|
|
||||||
this.show.timePicker = true;
|
|
||||||
}
|
}
|
||||||
//debugger;
|
|
||||||
//console.log(this.show);
|
|
||||||
},
|
},
|
||||||
timeSelected(theTime) {
|
timeOnly: {
|
||||||
console.log("time selected: " + theTime);
|
get() {
|
||||||
|
return this.value ? this.value.substr(11, 8) : null;
|
||||||
|
// let momentObj = this.$moment.utc();
|
||||||
|
// if (this.value) {
|
||||||
|
// momentObj = this.$moment.utc(this.value);
|
||||||
|
// }
|
||||||
|
// return momentObj.local().format("HH:mm:ss");
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
this.date = this.dateOnly + " " + value;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
dateSelected(theDate) {
|
formatTime() {
|
||||||
console.log("date selected: " + theDate);
|
return this.value ? this.value.substr(11, 8) : null;
|
||||||
|
// let momentObj = this.$moment.utc();
|
||||||
|
// if (this.value) {
|
||||||
|
// momentObj = this.$moment.utc(this.value);
|
||||||
|
// }
|
||||||
|
// return momentObj.local().format("h:mm a");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style>
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
<script>
|
|
||||||
//////////////////////////////////////////
|
|
||||||
// GZDatePicker
|
|
||||||
// This component was created to wrap the
|
|
||||||
// vuetify date picker to allow using string date
|
|
||||||
// and time in iso format and not lose the time
|
|
||||||
// portion when picking a new date
|
|
||||||
//
|
|
||||||
/* Xeslint-disable */
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
default: ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
render() {
|
|
||||||
var that = this;
|
|
||||||
return this.$createElement("v-date-picker", {
|
|
||||||
props: {
|
|
||||||
...this.$attrs,
|
|
||||||
value: this.value ? this.value.substr(0, 10) : null
|
|
||||||
},
|
|
||||||
on: {
|
|
||||||
...this.$listeners,
|
|
||||||
input: function(date) {
|
|
||||||
//debugger;
|
|
||||||
//Put back the time portion from before
|
|
||||||
var combined = date + that.value.substr(10);
|
|
||||||
that.$emit("input", new Date(combined).toISOString());
|
|
||||||
//Note: I have observed that it converts a date with milliseconds to a date with the final 3 digits stripped and Z put in instead
|
|
||||||
//Not sure if this will be an issue or not but if it is then might need to force to not UTC or whatever
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
<script>
|
|
||||||
//////////////////////////////////////////
|
|
||||||
// GZTimePicker
|
|
||||||
// This component was created to wrap the
|
|
||||||
// vuetify time picker to allow using string date
|
|
||||||
// and time in iso format and not lose the date
|
|
||||||
// portion when picking a new time
|
|
||||||
//2019-02-12T10:12:39.594206
|
|
||||||
/* eslint-disable */
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
default: ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
render() {
|
|
||||||
var that = this;
|
|
||||||
return this.$createElement("v-time-picker", {
|
|
||||||
props: {
|
|
||||||
...this.$attrs,
|
|
||||||
value: this.value ? this.value.substr(11, 8) : null
|
|
||||||
},
|
|
||||||
on: {
|
|
||||||
...this.$listeners,
|
|
||||||
input: function(time) {
|
|
||||||
// debugger;
|
|
||||||
//Put back the time portion from before
|
|
||||||
var combinedDateAndTimeAsString = that.value.substr(0, 11) + time;
|
|
||||||
|
|
||||||
//===========================================
|
|
||||||
//PARSE THE TIME AND DATE
|
|
||||||
//NOTE: FOLLOWING CODE ADAPTED FROM A LIBRARY:
|
|
||||||
//https://github.com/csnover/js-iso8601
|
|
||||||
//Only change is to make it a local function and move "numericKeys" variable into the code block
|
|
||||||
var timestamp,
|
|
||||||
struct,
|
|
||||||
minutesOffset = 0,
|
|
||||||
numericKeys = [1, 4, 5, 6, 7, 10, 11];
|
|
||||||
|
|
||||||
// ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string
|
|
||||||
// before falling back to any implementation-specific date parsing, so that’s what we do, even if native
|
|
||||||
// implementations could be faster
|
|
||||||
// 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
|
|
||||||
if (
|
|
||||||
(struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(
|
|
||||||
combinedDateAndTimeAsString
|
|
||||||
))
|
|
||||||
) {
|
|
||||||
// avoid NaN timestamps caused by “undefined” values being passed to Date.UTC
|
|
||||||
for (var i = 0, k; (k = numericKeys[i]); ++i) {
|
|
||||||
struct[k] = +struct[k] || 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// allow undefined days and months
|
|
||||||
struct[2] = (+struct[2] || 1) - 1;
|
|
||||||
struct[3] = +struct[3] || 1;
|
|
||||||
|
|
||||||
if (struct[8] !== "Z" && struct[9] !== undefined) {
|
|
||||||
minutesOffset = struct[10] * 60 + struct[11];
|
|
||||||
|
|
||||||
if (struct[9] === "+") {
|
|
||||||
minutesOffset = 0 - minutesOffset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
timestamp = Date.UTC(
|
|
||||||
struct[1],
|
|
||||||
struct[2],
|
|
||||||
struct[3],
|
|
||||||
struct[4],
|
|
||||||
struct[5] + minutesOffset,
|
|
||||||
struct[6],
|
|
||||||
struct[7]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
timestamp = Date.parse(combinedDateAndTimeAsString);
|
|
||||||
}
|
|
||||||
//==========================================
|
|
||||||
|
|
||||||
var newDateAsString = new Date(timestamp).toISOString();
|
|
||||||
that.$emit("input", newDateAsString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -11,10 +11,7 @@ import errorHandler from "./api/errorhandler";
|
|||||||
import NProgress from "nprogress";
|
import NProgress from "nprogress";
|
||||||
import "nprogress/nprogress.css";
|
import "nprogress/nprogress.css";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import gzdatepicker from "./components/gzdatepicker.vue";
|
|
||||||
import gztimepicker from "./components/gztimepicker.vue";
|
|
||||||
import gzdateandtimepicker from "./components/gzdateandtimepicker.vue";
|
import gzdateandtimepicker from "./components/gzdateandtimepicker.vue";
|
||||||
import altdateandtimepicker from "./components/altdateandtimepicker.vue";
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// FORM VALIDATION
|
// FORM VALIDATION
|
||||||
@@ -108,10 +105,7 @@ Vue.filter("boolastext", function(value) {
|
|||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
//GZ COMPONENTS
|
//GZ COMPONENTS
|
||||||
//
|
//
|
||||||
Vue.component("gz-date-picker", gzdatepicker);
|
|
||||||
Vue.component("gz-time-picker", gztimepicker);
|
|
||||||
Vue.component("gz-date-time-picker", gzdateandtimepicker);
|
Vue.component("gz-date-time-picker", gzdateandtimepicker);
|
||||||
Vue.component("alt-date-time-picker", altdateandtimepicker);
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// INSTANTIATE
|
// INSTANTIATE
|
||||||
|
|||||||
@@ -74,13 +74,11 @@
|
|||||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||||
<div>{{obj.startDate}}</div>
|
<div>{{obj.startDate}}</div>
|
||||||
<gz-date-time-picker label="TESTBOTHPICKERS" v-model="obj.startDate"></gz-date-time-picker>
|
<gz-date-time-picker label="TESTBOTHPICKERS" v-model="obj.startDate"></gz-date-time-picker>
|
||||||
</v-flex> -->
|
</v-flex>-->
|
||||||
|
|
||||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||||
|
<gz-date-time-picker label="Start" v-model="obj.startDate" readonly="true"></gz-date-time-picker>
|
||||||
<alt-date-time-picker label="TESTBOTHPICKERS" v-model="obj.startDate"></alt-date-time-picker>
|
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<!--
|
<!--
|
||||||
<v-menu
|
<v-menu
|
||||||
ref="menu"
|
ref="menu"
|
||||||
v-model="menu"
|
v-model="menu"
|
||||||
@@ -107,8 +105,7 @@
|
|||||||
<v-btn flat color="primary" @click="menu = false">Cancel</v-btn>
|
<v-btn flat color="primary" @click="menu = false">Cancel</v-btn>
|
||||||
<v-btn flat color="primary" @click="$refs.menu.save(date)">OK</v-btn>
|
<v-btn flat color="primary" @click="$refs.menu.save(date)">OK</v-btn>
|
||||||
</v-date-picker>
|
</v-date-picker>
|
||||||
</v-menu> -->
|
</v-menu>-->
|
||||||
|
|
||||||
</v-layout>
|
</v-layout>
|
||||||
<v-layout align-center justify-space-around row wrap mt-5>
|
<v-layout align-center justify-space-around row wrap mt-5>
|
||||||
<v-flex xs1>
|
<v-flex xs1>
|
||||||
@@ -141,7 +138,7 @@ export default {
|
|||||||
obj: {},
|
obj: {},
|
||||||
lc: locale,
|
lc: locale,
|
||||||
theDate: new Date(),
|
theDate: new Date(),
|
||||||
date: new Date().toISOString().substr(0, 10),
|
date: new Date().toISOString().substr(0, 10),
|
||||||
menu: false,
|
menu: false,
|
||||||
modal: false,
|
modal: false,
|
||||||
menu2: false
|
menu2: false
|
||||||
|
|||||||
Reference in New Issue
Block a user