Browse Source

fix(nc-gui): copy n paste logic

pull/5642/head
Wing-Kam Wong 2 years ago
parent
commit
5abb5d850b
  1. 12
      packages/nc-gui/composables/useMultiSelect/convertCellData.ts
  2. 12
      packages/nc-gui/composables/useMultiSelect/index.ts

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

@ -45,20 +45,14 @@ export default function convertCellData(
throw new Error('Not a valid datetime value')
}
if (isXcdbBase) {
// convert back to utc
// e.g. 2023-05-09T19:41:49+08:00 -> 2023-05-09 11:41:49
if (isMysql) {
// convert back to utc
// e.g. 2023-05-09T19:41:49+08:00 -> 2023-05-09 11:41:49
return `${parsedDateTime.utc().format('YYYY-MM-DD HH:mm:ss')}`
} else if (isMssql) {
return parsedDateTime.utc().format('YYYY-MM-DD HH:mm:ssZ')
} else {
if (!dayjs.isDayjs(value)) {
// e.g. copy the existing cell - 2023-05-06 13:06:51 (UTC)
return parsedDateTime.utc(true).format('YYYY-MM-DD HH:mm:ssZ')
}
// e.g. copy right after setting by datepicker
// value includes timezone
return parsedDateTime
return parsedDateTime.utc().format('YYYY-MM-DD HH:mm:ssZ')
}
}
// External DB - keep it as it is

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

@ -123,15 +123,9 @@ export function useMultiSelect(
// feed custom parse format
d = dayjs(textToCopy, isMysql(columnObj.base_id) ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ')
}
if (isXcdbBase(meta.value?.base_id)) {
if (isMssql(meta.value?.base_id) || isMysql(meta.value?.base_id)) {
textToCopy = d.format(constructDateTimeFormat(columnObj))
} else {
textToCopy = d.utc(true).local().format(constructDateTimeFormat(columnObj))
}
} else {
textToCopy = d.format(constructDateTimeFormat(columnObj))
}
textToCopy = d.format(constructDateTimeFormat(columnObj))
if (!dayjs(textToCopy).isValid()) {
throw new Error('Invalid Date')
}

Loading…
Cancel
Save