Handle undefineds
This commit is contained in:
parent
398cf99b4f
commit
a3a1e29350
|
@ -49,12 +49,18 @@ async function parseSchemaUI(ctx: Ctx, view: CreateViewRequest) {
|
|||
const schemaUI =
|
||||
view.schema &&
|
||||
Object.entries(view.schema).reduce((p, [fieldName, schemaValue]) => {
|
||||
p[fieldName] = {
|
||||
const fieldSchema: RequiredKeys<UIFieldMetadata> = {
|
||||
order: schemaValue.order,
|
||||
width: schemaValue.width,
|
||||
visible: schemaValue.visible,
|
||||
icon: schemaValue.icon,
|
||||
}
|
||||
Object.entries(fieldSchema)
|
||||
.filter(([_, val]) => val === undefined)
|
||||
.forEach(([key]) => {
|
||||
delete fieldSchema[key as keyof UIFieldMetadata]
|
||||
})
|
||||
p[fieldName] = fieldSchema
|
||||
return p
|
||||
}, {} as Record<string, RequiredKeys<UIFieldMetadata>>)
|
||||
return schemaUI
|
||||
|
|
|
@ -86,6 +86,7 @@ export function enrichSchema(view: View | ViewV2, tableSchema: TableSchema) {
|
|||
: schema[fieldName].order,
|
||||
}
|
||||
}
|
||||
delete view.schemaUI
|
||||
}
|
||||
|
||||
if (view?.columns?.length) {
|
||||
|
@ -97,6 +98,7 @@ export function enrichSchema(view: View | ViewV2, tableSchema: TableSchema) {
|
|||
pickedSchema[fieldName] = { ...schema[fieldName] }
|
||||
}
|
||||
schema = pickedSchema
|
||||
delete view.columns
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue