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. 14
      packages/nc-gui/components/project/spreadsheet/components/editableCell/DatePickerCell.vue

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

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

Loading…
Cancel
Save