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