Convert renderer

This commit is contained in:
Adria Navarro 2025-01-10 10:26:56 +01:00
parent 96052679cb
commit bb18115585
2 changed files with 15 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { FieldType } from "@budibase/types"
import { FieldType, UIColumn } from "@budibase/types"
import OptionsCell from "../cells/OptionsCell.svelte"
import DateCell from "../cells/DateCell.svelte"
@ -40,13 +40,23 @@ const TypeComponentMap = {
// Custom types for UI only
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) {
return NumberCell
}
return (
TypeComponentMap[column?.schema?.cellRenderType] ||
TypeComponentMap[column?.schema?.type] ||
getCellRendererByType(column.schema?.cellRenderType) ||
getCellRendererByType(column.schema?.type) ||
TextCell
)
}

View File

@ -14,6 +14,7 @@ export type UIColumn = FieldSchema & {
type: FieldType
readonly: boolean
autocolumn: boolean
cellRenderType?: FieldType | "role"
}
calculationType: CalculationType
__idx: number