Browse Source

fix: DatePickerCell invalid date handling

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/2254/head
mertmit 3 years ago
parent
commit
a43cab5736
  1. 12
      packages/nc-gui/components/project/spreadsheet/components/editableCell/DatePickerCell.vue

12
packages/nc-gui/components/project/spreadsheet/components/editableCell/DatePickerCell.vue

@ -1,7 +1,7 @@
<template> <template>
<v-menu> <v-menu>
<template #activator="{on}"> <template #activator="{on}">
<input v-model="localState" class="value" v-on="on"> <input :value="date" class="value" v-on="on">
</template> </template>
<v-date-picker <v-date-picker
v-model="localState" v-model="localState"
@ -23,13 +23,21 @@ export default {
computed: { computed: {
localState: { localState: {
get() { get() {
if (!this.value) { return this.value } if (!this.value || !dayjs(this.value).isValid()) { return undefined }
return (/^\d+$/.test(this.value) ? dayjs(+this.value) : dayjs(this.value)).format('YYYY-MM-DD') return (/^\d+$/.test(this.value) ? dayjs(+this.value) : dayjs(this.value)).format('YYYY-MM-DD')
}, },
set(val) { set(val) {
if (dayjs(val).isValid()) {
this.$emit('input', val && dayjs(val).format('YYYY-MM-DD')) this.$emit('input', val && dayjs(val).format('YYYY-MM-DD'))
} }
}
},
date() {
if (!this.value || this.localState) {
return this.localState
}
return 'Invalid Date'
}, },
parentListeners() { parentListeners() {
const $listeners = {} const $listeners = {}

Loading…
Cancel
Save