Browse Source

Merge pull request #2254 from nocodb/fix/2251-invalid-date

fix: DatePickerCell invalid date handling
pull/2258/merge
Raju Udava 3 years ago committed by GitHub
parent
commit
f5464e7ef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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> <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,14 +23,22 @@ 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) {
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() { parentListeners() {
const $listeners = {} const $listeners = {}

Loading…
Cancel
Save