Hide some fields and fix datetime issue

Closes #168

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-10-09 12:54:09 +02:00
parent f756c1bc37
commit c47546bb1a
2 changed files with 55 additions and 44 deletions

View File

@@ -40,8 +40,12 @@ export default class DateTimePicker extends Vue {
date: Date = this.value;
time: string = '00:00';
created() {
let minutes = this.value.getHours() * 60 + this.value.getMinutes();
mounted() {
this.convertTime();
}
convertTime() {
let minutes = this.date.getHours() * 60 + this.date.getMinutes();
minutes = Math.ceil(minutes / this.step) * this.step;
this.time = [Math.floor(minutes / 60), minutes % 60].map((v) => { return v < 10 ? `0${v}` : v; }).join(':');
@@ -57,15 +61,22 @@ export default class DateTimePicker extends Vue {
@Watch('date')
updateDate() {
this.updateDateTime();
this.updateTime(this.time);
}
@Watch('value')
updateValue() {
this.date = this.value;
this.convertTime();
}
updateDateTime() {
/**
* Returns the updated date
*
* @type {DateTime}
* @type {Date}
*/
console.log('updated this.date with', this.date);
this.$emit('input', this.date);
}
}