Simplify enriched column

This commit is contained in:
Adria Navarro 2024-10-10 16:14:36 +02:00
parent f0d52f2ea0
commit e191c90385
2 changed files with 22 additions and 6 deletions

View File

@ -1,4 +1,5 @@
import {
BBReferenceFieldSubType,
CalculationType,
canGroupBy,
FeatureFlag,
@ -7,6 +8,7 @@ import {
PermissionLevel,
RelationSchemaField,
RenameColumn,
RequiredKeys,
Table,
TableSchema,
View,
@ -325,13 +327,18 @@ export async function enrichSchema(
const viewFieldSchema = viewFields[relTableFieldName]
const isVisible = !!viewFieldSchema?.visible
const isReadonly = !!viewFieldSchema?.readonly
result[relTableFieldName] = {
...relTableField,
...viewFieldSchema,
name: relTableField.name,
const enrichedFieldSchema: RequiredKeys<ViewV2ColumnEnriched> = {
visible: isVisible,
readonly: isReadonly,
order: viewFieldSchema?.order,
width: viewFieldSchema?.width,
icon: relTableField.icon,
type: relTableField.type,
subtype: relTableField.subtype,
}
}
result[relTableFieldName] = enrichedFieldSchema
}
return result
}

View File

@ -1,4 +1,10 @@
import { FieldSchema, RelationSchemaField, ViewV2 } from "../documents"
import {
FieldSchema,
FieldSubType,
FieldType,
RelationSchemaField,
ViewV2,
} from "../documents"
export interface ViewV2Enriched extends ViewV2 {
schema?: {
@ -8,4 +14,7 @@ export interface ViewV2Enriched extends ViewV2 {
}
}
export type ViewV2ColumnEnriched = RelationSchemaField & FieldSchema
export interface ViewV2ColumnEnriched extends RelationSchemaField {
type: FieldType
subtype?: FieldSubType
}