Merge pull request #14759 from Budibase/budi-8705-v3-view-joins-required-columns-cant-be-changed-to-read-only

View joins - allow related required columns' visibility to be changed
This commit is contained in:
Adria Navarro 2024-10-11 10:23:24 +02:00 committed by GitHub
commit 0d68a743b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 35 additions and 9 deletions

View File

@ -125,7 +125,7 @@
subtype: column.subtype,
visible: column.visible,
readonly: column.readonly,
constraints: column.constraints, // This is needed to properly display "users" column
icon: column.icon,
},
}
})

View File

@ -19,6 +19,10 @@ export const getCellID = (rowId, fieldName) => {
}
export const getColumnIcon = column => {
if (column.schema.icon) {
return column.schema.icon
}
if (column.schema.autocolumn) {
return "MagicWand"
}

View File

@ -1,4 +1,5 @@
import {
BBReferenceFieldSubType,
CalculationType,
canGroupBy,
FeatureFlag,
@ -7,6 +8,7 @@ import {
PermissionLevel,
RelationSchemaField,
RenameColumn,
RequiredKeys,
Table,
TableSchema,
View,
@ -325,13 +327,26 @@ export async function enrichSchema(
const viewFieldSchema = viewFields[relTableFieldName]
const isVisible = !!viewFieldSchema?.visible
const isReadonly = !!viewFieldSchema?.readonly
result[relTableFieldName] = {
...relTableField,
...viewFieldSchema,
name: relTableField.name,
const enrichedFieldSchema: RequiredKeys<ViewV2ColumnEnriched> = {
visible: isVisible,
readonly: isReadonly,
order: viewFieldSchema?.order,
width: viewFieldSchema?.width,
icon: relTableField.icon,
type: relTableField.type,
subtype: relTableField.subtype,
}
if (
!enrichedFieldSchema.icon &&
relTableField.type === FieldType.BB_REFERENCE &&
relTableField.subtype === BBReferenceFieldSubType.USER &&
!helpers.schema.isDeprecatedSingleUserColumn(relTableField)
) {
// Forcing the icon, otherwise we would need to pass the constraints to show the proper icon
enrichedFieldSchema.icon = "UserGroup"
}
result[relTableFieldName] = enrichedFieldSchema
}
return result
}

View File

@ -355,13 +355,11 @@ describe("table sdk", () => {
visible: true,
columns: {
title: {
name: "title",
type: "string",
visible: true,
readonly: true,
},
age: {
name: "age",
type: "number",
visible: false,
readonly: false,

View File

@ -1,4 +1,10 @@
import { FieldSchema, RelationSchemaField, ViewV2 } from "../documents"
import {
FieldSchema,
FieldSubType,
FieldType,
RelationSchemaField,
ViewV2,
} from "../documents"
export interface ViewV2Enriched extends ViewV2 {
schema?: {
@ -8,4 +14,7 @@ export interface ViewV2Enriched extends ViewV2 {
}
}
export type ViewV2ColumnEnriched = RelationSchemaField & FieldSchema
export interface ViewV2ColumnEnriched extends RelationSchemaField {
type: FieldType
subtype?: FieldSubType
}