diff --git a/packages/frontend-core/src/utils/relatedColumns.ts b/packages/frontend-core/src/utils/relatedColumns.ts index 5b63e25625..37859e7ca1 100644 --- a/packages/frontend-core/src/utils/relatedColumns.ts +++ b/packages/frontend-core/src/utils/relatedColumns.ts @@ -19,17 +19,12 @@ const columnTypeManyParser = { field: { timeOnly?: boolean dateOnly?: boolean - ignoreTimezones?: boolean } ) => { function parseDate(value: any) { - const { timeOnly, dateOnly, ignoreTimezones } = field || {} + const { timeOnly, dateOnly } = field || {} const enableTime = !dateOnly - const parsedValue = Helpers.parseDate(value, { - timeOnly, - enableTime, - ignoreTimezones, - }) + const parsedValue = Helpers.parseDate(value, { enableTime }) const parsed = Helpers.getDateDisplayValue(parsedValue, { enableTime, timeOnly, @@ -51,40 +46,44 @@ const columnTypeManyParser = { export function enrichSchemaWithRelColumns( schema: Record -) { +): Record { if (!schema) { return } - const result = Object.keys(schema).reduce((result, fieldName) => { - const field = schema[fieldName] - result[fieldName] = field + const result = Object.keys(schema).reduce>( + (result, fieldName) => { + const field = schema[fieldName] + result[fieldName] = field - if ( - field.visible !== false && - isRelationshipField(field) && - field.columns - ) { - const fromSingle = - field?.relationshipType === RelationshipType.ONE_TO_MANY + if ( + field.visible !== false && + isRelationshipField(field) && + field.columns + ) { + const fromSingle = + field?.relationshipType === RelationshipType.ONE_TO_MANY - for (const relColumn of Object.keys(field.columns)) { - const relField = field.columns[relColumn] - if (!relField.visible) { - continue - } - const name = `${field.name}.${relColumn}` - result[name] = { - ...relField, - name, - related: { field: fieldName, subField: relColumn }, - cellRenderType: - (!fromSingle && columnTypeManyTypeOverrides[relField.type]) || - relField.type, + for (const relColumn of Object.keys(field.columns)) { + const relField = field.columns[relColumn] + if (!relField.visible) { + continue + } + const name = `${field.name}.${relColumn}` + result[name] = { + ...relField, + type: null, // TODO + name, + related: { field: fieldName, subField: relColumn }, + cellRenderType: + (!fromSingle && columnTypeManyTypeOverrides[relField.type]) || + relField.type, + } } } - } - return result - }, {}) + return result + }, + {} + ) return result } diff --git a/packages/types/src/ui/stores/grid/table.ts b/packages/types/src/ui/stores/grid/table.ts index f1040a1369..d58bc93f8b 100644 --- a/packages/types/src/ui/stores/grid/table.ts +++ b/packages/types/src/ui/stores/grid/table.ts @@ -7,5 +7,10 @@ import { export type UIFieldSchema = FieldSchema & BasicViewFieldMetadata & { related?: { field: string; subField: string } - columns?: Record + columns?: Record + cellRenderType?: string } + +interface UIRelationSchemaField extends RelationSchemaField { + type: string +}