Convert renderer
This commit is contained in:
parent
96052679cb
commit
bb18115585
|
@ -1,4 +1,4 @@
|
||||||
import { FieldType } from "@budibase/types"
|
import { FieldType, UIColumn } from "@budibase/types"
|
||||||
|
|
||||||
import OptionsCell from "../cells/OptionsCell.svelte"
|
import OptionsCell from "../cells/OptionsCell.svelte"
|
||||||
import DateCell from "../cells/DateCell.svelte"
|
import DateCell from "../cells/DateCell.svelte"
|
||||||
|
@ -40,13 +40,23 @@ const TypeComponentMap = {
|
||||||
// Custom types for UI only
|
// Custom types for UI only
|
||||||
role: RoleCell,
|
role: RoleCell,
|
||||||
}
|
}
|
||||||
export const getCellRenderer = column => {
|
|
||||||
|
function getCellRendererByType(type: FieldType | "role" | undefined) {
|
||||||
|
if (!type) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return TypeComponentMap[type as keyof typeof TypeComponentMap]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getCellRenderer = (column: UIColumn) => {
|
||||||
if (column.calculationType) {
|
if (column.calculationType) {
|
||||||
return NumberCell
|
return NumberCell
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
TypeComponentMap[column?.schema?.cellRenderType] ||
|
getCellRendererByType(column.schema?.cellRenderType) ||
|
||||||
TypeComponentMap[column?.schema?.type] ||
|
getCellRendererByType(column.schema?.type) ||
|
||||||
TextCell
|
TextCell
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -14,6 +14,7 @@ export type UIColumn = FieldSchema & {
|
||||||
type: FieldType
|
type: FieldType
|
||||||
readonly: boolean
|
readonly: boolean
|
||||||
autocolumn: boolean
|
autocolumn: boolean
|
||||||
|
cellRenderType?: FieldType | "role"
|
||||||
}
|
}
|
||||||
calculationType: CalculationType
|
calculationType: CalculationType
|
||||||
__idx: number
|
__idx: number
|
||||||
|
|
Loading…
Reference in New Issue