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 { import {
BBReferenceFieldSubType,
CalculationType, CalculationType,
canGroupBy, canGroupBy,
FeatureFlag, FeatureFlag,
@ -7,6 +8,7 @@ import {
PermissionLevel, PermissionLevel,
RelationSchemaField, RelationSchemaField,
RenameColumn, RenameColumn,
RequiredKeys,
Table, Table,
TableSchema, TableSchema,
View, View,
@ -325,13 +327,18 @@ export async function enrichSchema(
const viewFieldSchema = viewFields[relTableFieldName] const viewFieldSchema = viewFields[relTableFieldName]
const isVisible = !!viewFieldSchema?.visible const isVisible = !!viewFieldSchema?.visible
const isReadonly = !!viewFieldSchema?.readonly const isReadonly = !!viewFieldSchema?.readonly
result[relTableFieldName] = { const enrichedFieldSchema: RequiredKeys<ViewV2ColumnEnriched> = {
...relTableField,
...viewFieldSchema,
name: relTableField.name,
visible: isVisible, visible: isVisible,
readonly: isReadonly, readonly: isReadonly,
order: viewFieldSchema?.order,
width: viewFieldSchema?.width,
icon: relTableField.icon,
type: relTableField.type,
subtype: relTableField.subtype,
} }
}
result[relTableFieldName] = enrichedFieldSchema
} }
return result 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 { export interface ViewV2Enriched extends ViewV2 {
schema?: { schema?: {
@ -8,4 +14,7 @@ export interface ViewV2Enriched extends ViewV2 {
} }
} }
export type ViewV2ColumnEnriched = RelationSchemaField & FieldSchema export interface ViewV2ColumnEnriched extends RelationSchemaField {
type: FieldType
subtype?: FieldSubType
}