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

View File

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