Enrich view columns

This commit is contained in:
Adria Navarro 2024-09-06 13:22:50 +02:00
parent 68678235d6
commit 30e31e1254
2 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import {
FieldSchema,
FieldType,
RelationSchemaField,
RenameColumn,
@ -176,7 +177,7 @@ export async function enrichSchema(
}
const relTable = tableCache[tableId]
const result: Record<string, RelationSchemaField> = {}
const result: Record<string, FieldSchema & RelationSchemaField> = {}
for (const relTableFieldName of Object.keys(relTable.schema)) {
const relTableField = relTable.schema[relTableFieldName]
@ -191,6 +192,7 @@ export async function enrichSchema(
const isVisible = !!viewFields[relTableFieldName]?.visible
const isReadonly = !!viewFields[relTableFieldName]?.readonly
result[relTableFieldName] = {
...relTableField,
visible: isVisible,
readonly: isReadonly,
}
@ -211,6 +213,7 @@ export async function enrichSchema(
...tableSchema[key],
...ui,
order: anyViewOrder ? ui?.order ?? undefined : tableSchema[key].order,
columns: undefined,
}
if (schema[key].type === FieldType.LINK) {

View File

@ -3,7 +3,7 @@ import { FieldSchema, RelationSchemaField, ViewV2 } from "../documents"
export interface ViewV2Enriched extends ViewV2 {
schema?: {
[key: string]: FieldSchema & {
columns?: Record<string, RelationSchemaField>
columns?: Record<string, FieldSchema & RelationSchemaField>
}
}
}