Browse Source

fix(nc-gui): incorrect datetime value after saving in expanded form

pull/5601/head
Wing-Kam Wong 1 year ago
parent
commit
c69eaba40b
  1. 12
      packages/nc-gui/components/cell/DateTimePicker.vue

12
packages/nc-gui/components/cell/DateTimePicker.vue

@ -18,10 +18,10 @@ import {
interface Props { interface Props {
modelValue?: string | null modelValue?: string | null
isPk?: boolean isPk?: boolean
isUpdateOutside: Record<string, boolean> isUpdatedFromCopyNPaste: Record<string, boolean>
} }
const { modelValue, isPk, isUpdateOutside } = defineProps<Props>() const { modelValue, isPk, isUpdatedFromCopyNPaste } = defineProps<Props>()
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
@ -78,7 +78,7 @@ let localState = $computed({
// when copying a datetime cell, the copied value would be local time // when copying a datetime cell, the copied value would be local time
// when pasting a datetime cell, UTC (xcdb) will be saved in DB // when pasting a datetime cell, UTC (xcdb) will be saved in DB
// we convert back to local time // we convert back to local time
if (column.value.title! in (isUpdateOutside ?? {})) { if (column.value.title! in (isUpdatedFromCopyNPaste ?? {})) {
localModelValue = dayjs(modelValue).utc().local() localModelValue = dayjs(modelValue).utc().local()
return localModelValue return localModelValue
} }
@ -86,7 +86,11 @@ let localState = $computed({
// if localModelValue is defined, show localModelValue instead // if localModelValue is defined, show localModelValue instead
// localModelValue is set in setter below // localModelValue is set in setter below
if (localModelValue) { if (localModelValue) {
return localModelValue const res = localModelValue
// resetting localModelValue here
// e.g. save in expanded form -> render the correct modelValue
localModelValue = undefined
return res
} }
// empty cell - use modelValue in local time // empty cell - use modelValue in local time

Loading…
Cancel
Save