Add metadata on related columns
This commit is contained in:
parent
30e31e1254
commit
77be1cd869
|
@ -29,6 +29,9 @@ async function parseSchema(view: CreateViewRequest) {
|
||||||
acc[key] = {
|
acc[key] = {
|
||||||
visible: fieldSchema.visible,
|
visible: fieldSchema.visible,
|
||||||
readonly: fieldSchema.readonly,
|
readonly: fieldSchema.readonly,
|
||||||
|
order: fieldSchema.order,
|
||||||
|
width: fieldSchema.width,
|
||||||
|
icon: fieldSchema.icon,
|
||||||
}
|
}
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {
|
import {
|
||||||
FieldSchema,
|
|
||||||
FieldType,
|
FieldType,
|
||||||
RelationSchemaField,
|
RelationSchemaField,
|
||||||
RenameColumn,
|
RenameColumn,
|
||||||
|
@ -8,6 +7,7 @@ import {
|
||||||
View,
|
View,
|
||||||
ViewFieldMetadata,
|
ViewFieldMetadata,
|
||||||
ViewV2,
|
ViewV2,
|
||||||
|
ViewV2ColumnEnriched,
|
||||||
ViewV2Enriched,
|
ViewV2Enriched,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { HTTPError } from "@budibase/backend-core"
|
import { HTTPError } from "@budibase/backend-core"
|
||||||
|
@ -177,7 +177,7 @@ export async function enrichSchema(
|
||||||
}
|
}
|
||||||
const relTable = tableCache[tableId]
|
const relTable = tableCache[tableId]
|
||||||
|
|
||||||
const result: Record<string, FieldSchema & RelationSchemaField> = {}
|
const result: Record<string, ViewV2ColumnEnriched> = {}
|
||||||
|
|
||||||
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]
|
||||||
|
@ -189,10 +189,13 @@ export async function enrichSchema(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const isVisible = !!viewFields[relTableFieldName]?.visible
|
const viewFieldSchema = viewFields[relTableFieldName]
|
||||||
const isReadonly = !!viewFields[relTableFieldName]?.readonly
|
const isVisible = !!viewFieldSchema?.visible
|
||||||
|
const isReadonly = !!viewFieldSchema?.readonly
|
||||||
result[relTableFieldName] = {
|
result[relTableFieldName] = {
|
||||||
...relTableField,
|
...viewFieldSchema,
|
||||||
|
type: relTableField.type,
|
||||||
|
name: relTableField.name,
|
||||||
visible: isVisible,
|
visible: isVisible,
|
||||||
readonly: isReadonly,
|
readonly: isReadonly,
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,7 @@ export type ViewFieldMetadata = UIFieldMetadata & {
|
||||||
columns?: Record<string, RelationSchemaField>
|
columns?: Record<string, RelationSchemaField>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RelationSchemaField = {
|
export type RelationSchemaField = UIFieldMetadata & {
|
||||||
visible?: boolean
|
|
||||||
readonly?: boolean
|
readonly?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
import { FieldSchema, RelationSchemaField, ViewV2 } from "../documents"
|
import {
|
||||||
|
FieldSchema,
|
||||||
|
FieldType,
|
||||||
|
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, FieldSchema & RelationSchemaField>
|
columns?: Record<string, ViewV2ColumnEnriched>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ViewV2ColumnEnriched extends RelationSchemaField {
|
||||||
|
name: string
|
||||||
|
type: FieldType
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue