Browse Source

fix(nc-gui): copy n paste logic

pull/5642/head
Wing-Kam Wong 2 years ago
parent
commit
89ce77919c
  1. 24
      packages/nc-gui/components/cell/DateTimePicker.vue

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

@ -58,8 +58,21 @@ let localState = $computed({
return undefined return undefined
} }
const isXcDB = isXcdbBase(column.value.base_id)
// cater copy and paste
// when copying a datetime cell, the copied value would be local time
// when pasting a datetime cell, UTC (xcdb) will be saved in DB
// we convert back to local time
if (column.value.title! in (isUpdatedFromCopyNPaste ?? {})) {
localModelValue = dayjs(modelValue + (isXcDB ? 'Z' : ''))
.utc(isMysql(column.value.base_id))
.local()
return localModelValue
}
// ext db // ext db
if (!isXcdbBase(column.value.base_id)) { if (!isXcDB) {
return /^\d+$/.test(modelValue) ? dayjs(+modelValue) : dayjs(modelValue) return /^\d+$/.test(modelValue) ? dayjs(+modelValue) : dayjs(modelValue)
} }
@ -74,15 +87,6 @@ let localState = $computed({
return dayjs(modelValue).utc(isMysql(column.value.base_id)).local() return dayjs(modelValue).utc(isMysql(column.value.base_id)).local()
} }
// cater copy and paste
// when copying a datetime cell, the copied value would be local time
// when pasting a datetime cell, UTC (xcdb) will be saved in DB
// we convert back to local time
if (column.value.title! in (isUpdatedFromCopyNPaste ?? {})) {
localModelValue = dayjs(modelValue).utc(isMysql(column.value.base_id)).local()
return localModelValue
}
// 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) {

Loading…
Cancel
Save