Extend view metadata
This commit is contained in:
parent
ee77e08b3c
commit
a0c2843236
|
@ -3,7 +3,7 @@ import {
|
|||
CreateViewRequest,
|
||||
Ctx,
|
||||
RequiredKeys,
|
||||
UIFieldMetadata,
|
||||
ViewUIFieldMetadata,
|
||||
UpdateViewRequest,
|
||||
ViewResponse,
|
||||
ViewResponseEnriched,
|
||||
|
@ -18,20 +18,21 @@ async function parseSchema(view: CreateViewRequest) {
|
|||
const finalViewSchema =
|
||||
view.schema &&
|
||||
Object.entries(view.schema).reduce((p, [fieldName, schemaValue]) => {
|
||||
const fieldSchema: RequiredKeys<UIFieldMetadata> = {
|
||||
const fieldSchema: RequiredKeys<ViewUIFieldMetadata> = {
|
||||
order: schemaValue.order,
|
||||
width: schemaValue.width,
|
||||
visible: schemaValue.visible,
|
||||
readonly: schemaValue.readonly,
|
||||
icon: schemaValue.icon,
|
||||
}
|
||||
Object.entries(fieldSchema)
|
||||
.filter(([, val]) => val === undefined)
|
||||
.forEach(([key]) => {
|
||||
delete fieldSchema[key as keyof UIFieldMetadata]
|
||||
delete fieldSchema[key as keyof ViewUIFieldMetadata]
|
||||
})
|
||||
p[fieldName] = fieldSchema
|
||||
return p
|
||||
}, {} as Record<string, RequiredKeys<UIFieldMetadata>>)
|
||||
}, {} as Record<string, RequiredKeys<ViewUIFieldMetadata>>)
|
||||
for (let [key, column] of Object.entries(finalViewSchema)) {
|
||||
if (!column.visible) {
|
||||
delete finalViewSchema[key]
|
||||
|
|
|
@ -33,6 +33,10 @@ export interface View {
|
|||
groupBy?: string
|
||||
}
|
||||
|
||||
export type ViewUIFieldMetadata = UIFieldMetadata & {
|
||||
readonly?: boolean
|
||||
}
|
||||
|
||||
export interface ViewV2 {
|
||||
version: 2
|
||||
id: string
|
||||
|
@ -45,7 +49,7 @@ export interface ViewV2 {
|
|||
order?: SortOrder
|
||||
type?: SortType
|
||||
}
|
||||
schema?: Record<string, UIFieldMetadata>
|
||||
schema?: Record<string, ViewUIFieldMetadata>
|
||||
}
|
||||
|
||||
export type ViewSchema = ViewCountOrSumSchema | ViewStatisticsSchema
|
||||
|
|
Loading…
Reference in New Issue