diff --git a/packages/server/src/api/controllers/view/viewsV2.ts b/packages/server/src/api/controllers/view/viewsV2.ts index 90e80fe81d..40afb2e846 100644 --- a/packages/server/src/api/controllers/view/viewsV2.ts +++ b/packages/server/src/api/controllers/view/viewsV2.ts @@ -29,6 +29,9 @@ async function parseSchema(view: CreateViewRequest) { acc[key] = { visible: fieldSchema.visible, readonly: fieldSchema.readonly, + order: fieldSchema.order, + width: fieldSchema.width, + icon: fieldSchema.icon, } return acc }, {}) diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index 4e45fcda87..13d81d6802 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -1,5 +1,4 @@ import { - FieldSchema, FieldType, RelationSchemaField, RenameColumn, @@ -8,6 +7,7 @@ import { View, ViewFieldMetadata, ViewV2, + ViewV2ColumnEnriched, ViewV2Enriched, } from "@budibase/types" import { HTTPError } from "@budibase/backend-core" @@ -177,7 +177,7 @@ export async function enrichSchema( } const relTable = tableCache[tableId] - const result: Record = {} + const result: Record = {} for (const relTableFieldName of Object.keys(relTable.schema)) { const relTableField = relTable.schema[relTableFieldName] @@ -189,10 +189,13 @@ export async function enrichSchema( continue } - const isVisible = !!viewFields[relTableFieldName]?.visible - const isReadonly = !!viewFields[relTableFieldName]?.readonly + const viewFieldSchema = viewFields[relTableFieldName] + const isVisible = !!viewFieldSchema?.visible + const isReadonly = !!viewFieldSchema?.readonly result[relTableFieldName] = { - ...relTableField, + ...viewFieldSchema, + type: relTableField.type, + name: relTableField.name, visible: isVisible, readonly: isReadonly, } diff --git a/packages/types/src/documents/app/view.ts b/packages/types/src/documents/app/view.ts index b5fdcacefe..b847520526 100644 --- a/packages/types/src/documents/app/view.ts +++ b/packages/types/src/documents/app/view.ts @@ -38,8 +38,7 @@ export type ViewFieldMetadata = UIFieldMetadata & { columns?: Record } -export type RelationSchemaField = { - visible?: boolean +export type RelationSchemaField = UIFieldMetadata & { readonly?: boolean } diff --git a/packages/types/src/sdk/view.ts b/packages/types/src/sdk/view.ts index 96a6807b69..7480bf563f 100644 --- a/packages/types/src/sdk/view.ts +++ b/packages/types/src/sdk/view.ts @@ -1,9 +1,19 @@ -import { FieldSchema, RelationSchemaField, ViewV2 } from "../documents" +import { + FieldSchema, + FieldType, + RelationSchemaField, + ViewV2, +} from "../documents" export interface ViewV2Enriched extends ViewV2 { schema?: { [key: string]: FieldSchema & { - columns?: Record + columns?: Record } } } + +export interface ViewV2ColumnEnriched extends RelationSchemaField { + name: string + type: FieldType +}