Browse Source

refactor(nc-gui): move the logic to backend

pull/5601/head
Wing-Kam Wong 2 years ago
parent
commit
1f1d3bf374
  1. 14
      packages/nc-gui/composables/useMultiSelect/convertCellData.ts
  2. 6
      packages/nc-gui/composables/useMultiSelect/index.ts

14
packages/nc-gui/composables/useMultiSelect/convertCellData.ts

@ -7,8 +7,6 @@ import { parseProp } from '#imports'
export default function convertCellData( export default function convertCellData(
args: { from: UITypes; to: UITypes; value: any; column: ColumnType; appInfo: AppInfo }, args: { from: UITypes; to: UITypes; value: any; column: ColumnType; appInfo: AppInfo },
isMysql = false, isMysql = false,
isSqlite = false,
isXcdbBase = false,
) { ) {
const { from, to, value } = args const { from, to, value } = args
if (from === to && ![UITypes.Attachment, UITypes.Date, UITypes.DateTime, UITypes.Time, UITypes.Year].includes(to)) { if (from === to && ![UITypes.Attachment, UITypes.Date, UITypes.DateTime, UITypes.Time, UITypes.Year].includes(to)) {
@ -44,17 +42,7 @@ export default function convertCellData(
if (!parsedDateTime.isValid()) { if (!parsedDateTime.isValid()) {
throw new Error('Not a valid datetime value') throw new Error('Not a valid datetime value')
} }
if (isXcdbBase) { return parsedDateTime.format(dateFormat)
if (isMysql) {
return parsedDateTime?.format('YYYY-MM-DD HH:mm:ss')
} else if (isSqlite) {
return parsedDateTime.utc().format('YYYY-MM-DD HH:mm:ss')
} else {
return parsedDateTime.utc().format('YYYY-MM-DD HH:mm:ssZ')
}
}
// TODO(timezone): keep ext db as it is
return parsedDateTime.format(isMysql ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ')
} }
case UITypes.Time: { case UITypes.Time: {
let parsedTime = dayjs(value) let parsedTime = dayjs(value)

6
packages/nc-gui/composables/useMultiSelect/index.ts

@ -52,7 +52,7 @@ export function useMultiSelect(
const { appInfo } = useGlobal() const { appInfo } = useGlobal()
const { isMysql, isSqlite, isXcdbBase } = useProject() const { isMysql } = useProject()
let clipboardContext = $ref<{ value: any; uidt: UITypes } | null>(null) let clipboardContext = $ref<{ value: any; uidt: UITypes } | null>(null)
@ -305,8 +305,6 @@ export function useMultiSelect(
appInfo: unref(appInfo), appInfo: unref(appInfo),
}, },
isMysql(meta.value?.base_id), isMysql(meta.value?.base_id),
isSqlite(meta.value?.base_id),
isXcdbBase(meta.value?.base_id),
) )
e.preventDefault() e.preventDefault()
@ -341,8 +339,6 @@ export function useMultiSelect(
appInfo: unref(appInfo), appInfo: unref(appInfo),
}, },
isMysql(meta.value?.base_id), isMysql(meta.value?.base_id),
isSqlite(meta.value?.base_id),
isXcdbBase(meta.value?.base_id),
) )
e.preventDefault() e.preventDefault()
syncCellData?.(activeCell) syncCellData?.(activeCell)

Loading…
Cancel
Save