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. 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>
<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,13 +23,21 @@ 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) {
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