Trim wrong fields
This commit is contained in:
parent
5715f7e9c1
commit
1391f5d049
|
@ -9,6 +9,7 @@ import {
|
||||||
Database,
|
Database,
|
||||||
FieldType,
|
FieldType,
|
||||||
INTERNAL_TABLE_SOURCE_ID,
|
INTERNAL_TABLE_SOURCE_ID,
|
||||||
|
RelationSchemaField,
|
||||||
RelationshipFieldMetadata,
|
RelationshipFieldMetadata,
|
||||||
Table,
|
Table,
|
||||||
TableResponse,
|
TableResponse,
|
||||||
|
@ -156,6 +157,8 @@ export async function enrichRelationshipSchema(
|
||||||
}
|
}
|
||||||
const relTable = tableCache[field.tableId]
|
const relTable = tableCache[field.tableId]
|
||||||
|
|
||||||
|
const resultSchema: Record<string, 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]
|
||||||
if (relTableField.type === FieldType.LINK) {
|
if (relTableField.type === FieldType.LINK) {
|
||||||
|
@ -166,15 +169,16 @@ export async function enrichRelationshipSchema(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
field.schema ??= {}
|
|
||||||
const isPrimaryDisplay = relTableFieldName === relTable.primaryDisplay
|
const isPrimaryDisplay = relTableFieldName === relTable.primaryDisplay
|
||||||
const isReadonly =
|
const isReadonly =
|
||||||
isPrimaryDisplay || !!field.schema[relTableFieldName]?.readonly
|
isPrimaryDisplay ||
|
||||||
field.schema[relTableFieldName] = {
|
!!(field.schema && field.schema[relTableFieldName]?.readonly)
|
||||||
|
resultSchema[relTableFieldName] = {
|
||||||
visible: isReadonly,
|
visible: isReadonly,
|
||||||
readonly: isReadonly,
|
readonly: isReadonly,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
field.schema = resultSchema
|
||||||
}
|
}
|
||||||
|
|
||||||
const result: TableSchema = {}
|
const result: TableSchema = {}
|
||||||
|
|
Loading…
Reference in New Issue