mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-30 05:26:45 +00:00
fix(gui): handle invalid data when copying belongs to cell data
Signed-off-by: Pranav C <pranavxc@gmail.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { UITypes } from 'nocodb-sdk'
|
||||
|
||||
export default
|
||||
function convertCellData(args: { from: UITypes; to: UITypes; value: any }) {
|
||||
const { from, to, value } = args
|
||||
if (from === to) {
|
||||
return value
|
||||
}
|
||||
|
||||
switch (to) {
|
||||
case UITypes.Number:
|
||||
return Number(value)
|
||||
case UITypes.Checkbox:
|
||||
return Boolean(value)
|
||||
case UITypes.Date:
|
||||
return new Date(value)
|
||||
case UITypes.Attachment:
|
||||
try {
|
||||
return typeof value === 'string' ? JSON.parse(value) : value
|
||||
} catch (e) {
|
||||
return []
|
||||
}
|
||||
case UITypes.LinkToAnotherRecord:
|
||||
case UITypes.Lookup:
|
||||
case UITypes.Rollup:
|
||||
case UITypes.Formula:
|
||||
throw new Error(`Unsupported conversion from ${from} to ${to}`)
|
||||
default:
|
||||
return value
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user