More typings
This commit is contained in:
parent
26d1243e68
commit
be1eef2976
|
@ -19,17 +19,12 @@ const columnTypeManyParser = {
|
||||||
field: {
|
field: {
|
||||||
timeOnly?: boolean
|
timeOnly?: boolean
|
||||||
dateOnly?: boolean
|
dateOnly?: boolean
|
||||||
ignoreTimezones?: boolean
|
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
function parseDate(value: any) {
|
function parseDate(value: any) {
|
||||||
const { timeOnly, dateOnly, ignoreTimezones } = field || {}
|
const { timeOnly, dateOnly } = field || {}
|
||||||
const enableTime = !dateOnly
|
const enableTime = !dateOnly
|
||||||
const parsedValue = Helpers.parseDate(value, {
|
const parsedValue = Helpers.parseDate(value, { enableTime })
|
||||||
timeOnly,
|
|
||||||
enableTime,
|
|
||||||
ignoreTimezones,
|
|
||||||
})
|
|
||||||
const parsed = Helpers.getDateDisplayValue(parsedValue, {
|
const parsed = Helpers.getDateDisplayValue(parsedValue, {
|
||||||
enableTime,
|
enableTime,
|
||||||
timeOnly,
|
timeOnly,
|
||||||
|
@ -51,11 +46,12 @@ const columnTypeManyParser = {
|
||||||
|
|
||||||
export function enrichSchemaWithRelColumns(
|
export function enrichSchemaWithRelColumns(
|
||||||
schema: Record<string, UIFieldSchema>
|
schema: Record<string, UIFieldSchema>
|
||||||
) {
|
): Record<string, UIFieldSchema> {
|
||||||
if (!schema) {
|
if (!schema) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const result = Object.keys(schema).reduce((result, fieldName) => {
|
const result = Object.keys(schema).reduce<Record<string, UIFieldSchema>>(
|
||||||
|
(result, fieldName) => {
|
||||||
const field = schema[fieldName]
|
const field = schema[fieldName]
|
||||||
result[fieldName] = field
|
result[fieldName] = field
|
||||||
|
|
||||||
|
@ -75,6 +71,7 @@ export function enrichSchemaWithRelColumns(
|
||||||
const name = `${field.name}.${relColumn}`
|
const name = `${field.name}.${relColumn}`
|
||||||
result[name] = {
|
result[name] = {
|
||||||
...relField,
|
...relField,
|
||||||
|
type: null, // TODO
|
||||||
name,
|
name,
|
||||||
related: { field: fieldName, subField: relColumn },
|
related: { field: fieldName, subField: relColumn },
|
||||||
cellRenderType:
|
cellRenderType:
|
||||||
|
@ -84,7 +81,9 @@ export function enrichSchemaWithRelColumns(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}, {})
|
},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,10 @@ import {
|
||||||
export type UIFieldSchema = FieldSchema &
|
export type UIFieldSchema = FieldSchema &
|
||||||
BasicViewFieldMetadata & {
|
BasicViewFieldMetadata & {
|
||||||
related?: { field: string; subField: string }
|
related?: { field: string; subField: string }
|
||||||
columns?: Record<string, RelationSchemaField & { type?: string }>
|
columns?: Record<string, UIRelationSchemaField & { type?: string }>
|
||||||
|
cellRenderType?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UIRelationSchemaField extends RelationSchemaField {
|
||||||
|
type: string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue