From 28fb3f44a7bc7c5948fe6fb22c5c35eb1a0e094a Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 7 May 2024 18:20:26 -0500 Subject: [PATCH] More data type fixes for traditionally the caller has always dealt with string values only, so the component should never emit events with date values, etc. --- .../static/js/tailbone.buefy.datepicker.js | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/tailbone/static/js/tailbone.buefy.datepicker.js b/tailbone/static/js/tailbone.buefy.datepicker.js index c516b97f..0b861fd6 100644 --- a/tailbone/static/js/tailbone.buefy.datepicker.js +++ b/tailbone/static/js/tailbone.buefy.datepicker.js @@ -27,20 +27,14 @@ const TailboneDatepicker = { }, data() { - let buefyValue = this.value - if (buefyValue && !buefyValue.getDate) { - buefyValue = this.parseDate(this.value) - } return { - buefyValue, + buefyValue: this.parseDate(this.value), } }, watch: { value(to, from) { - if (this.buefyValue != to) { - this.buefyValue = to - } + this.buefyValue = this.parseDate(to) }, }, @@ -61,13 +55,16 @@ const TailboneDatepicker = { }, parseDate(date) { - // note, this assumes classic YYYY-MM-DD (i.e. ISO?) format - var parts = date.split('-') - return new Date(parts[0], parseInt(parts[1]) - 1, parts[2]) + if (typeof(date) == 'string') { + // note, this assumes classic YYYY-MM-DD (i.e. ISO?) format + var parts = date.split('-') + return new Date(parts[0], parseInt(parts[1]) - 1, parts[2]) + } + return date }, dateChanged(date) { - this.$emit('input', date) + this.$emit('input', this.formatDate(date)) }, focus() {