Browse Source

feat(nc-gui): apply new logic on xcdb base only

pull/5601/head
Wing-Kam Wong 2 years ago
parent
commit
e348c44125
  1. 9
      packages/nc-gui/components/cell/DateTimePicker.vue

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

@ -24,7 +24,7 @@ const { modelValue, isPk } = defineProps<Props>()
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const { isMysql, isSqlite } = useProject() const { isMysql, isSqlite, isXcdbBase } = useProject()
const { showNull } = useGlobal() const { showNull } = useGlobal()
@ -55,7 +55,7 @@ let localState = $computed({
return undefined return undefined
} }
if (isSqlite(column.value.base_id)) { if (isXcdbBase(column.value.base_id) && isSqlite(column.value.base_id)) {
return /^\d+$/.test(modelValue) return /^\d+$/.test(modelValue)
? dayjs(+modelValue) ? dayjs(+modelValue)
.utc(true) .utc(true)
@ -72,6 +72,7 @@ let localState = $computed({
} }
if (val.isValid()) { if (val.isValid()) {
if (isXcdbBase(column.value.base_id)) {
if (isMysql(column.value.base_id)) { if (isMysql(column.value.base_id)) {
emit('update:modelValue', val?.format('YYYY-MM-DD HH:mm:ss')) emit('update:modelValue', val?.format('YYYY-MM-DD HH:mm:ss'))
} else if (isSqlite(column.value.base_id)) { } else if (isSqlite(column.value.base_id)) {
@ -79,6 +80,10 @@ let localState = $computed({
} else { } else {
emit('update:modelValue', dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ')) emit('update:modelValue', dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ'))
} }
} else {
// TODO(timezone): keep ext db as it is
emit('update:modelValue', val?.format(isMysql(column.value.base_id) ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ'))
}
} }
}, },
}) })

Loading…
Cancel
Save