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 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
) )
} }

View File

@ -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