Merge branch 'budi-8579-issue-with-google-sheets' of github.com:budibase/budibase into budi-8579-issue-with-google-sheets
This commit is contained in:
commit
4a5d76b7ea
|
@ -12,7 +12,7 @@
|
|||
export let columns
|
||||
export let fromRelationshipField
|
||||
|
||||
const { datasource, dispatch, cache, config } = getContext("grid")
|
||||
const { datasource, dispatch, config } = getContext("grid")
|
||||
|
||||
$: canSetRelationshipSchemas = $config.canSetRelationshipSchemas
|
||||
|
||||
|
@ -114,29 +114,19 @@
|
|||
return { ...c, options }
|
||||
})
|
||||
|
||||
let relationshipPanelColumns = []
|
||||
async function fetchRelationshipPanelColumns(relationshipField) {
|
||||
relationshipPanelColumns = []
|
||||
if (!relationshipField) {
|
||||
return
|
||||
$: relationshipPanelColumns = Object.entries(
|
||||
relationshipField?.columns || {}
|
||||
).map(([name, column]) => {
|
||||
return {
|
||||
name: name,
|
||||
label: name,
|
||||
schema: {
|
||||
type: column.type,
|
||||
visible: column.visible,
|
||||
readonly: column.readonly,
|
||||
},
|
||||
}
|
||||
|
||||
const table = await cache.actions.getTable(relationshipField.tableId)
|
||||
relationshipPanelColumns = Object.entries(
|
||||
relationshipField?.columns || {}
|
||||
).map(([name, column]) => {
|
||||
return {
|
||||
name: name,
|
||||
label: name,
|
||||
schema: {
|
||||
type: table.schema[name].type,
|
||||
visible: column.visible,
|
||||
readonly: column.readonly,
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
$: fetchRelationshipPanelColumns(relationshipField)
|
||||
})
|
||||
|
||||
async function toggleColumn(column, permission) {
|
||||
const visible = permission !== FieldPermissions.HIDDEN
|
||||
|
|
|
@ -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
|
||||
}, {})
|
||||
|
|
|
@ -1278,9 +1278,18 @@ describe.each([
|
|||
schema: expect.objectContaining({
|
||||
aux: expect.objectContaining({
|
||||
columns: {
|
||||
id: { visible: false, readonly: false },
|
||||
name: { visible: true, readonly: true },
|
||||
dob: { visible: true, readonly: true },
|
||||
id: expect.objectContaining({
|
||||
visible: false,
|
||||
readonly: false,
|
||||
}),
|
||||
name: expect.objectContaining({
|
||||
visible: true,
|
||||
readonly: true,
|
||||
}),
|
||||
dob: expect.objectContaining({
|
||||
visible: true,
|
||||
readonly: true,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
}),
|
||||
|
@ -1323,16 +1332,34 @@ describe.each([
|
|||
schema: expect.objectContaining({
|
||||
aux: expect.objectContaining({
|
||||
columns: {
|
||||
id: { visible: false, readonly: false },
|
||||
name: { visible: true, readonly: true },
|
||||
dob: { visible: true, readonly: true },
|
||||
id: expect.objectContaining({
|
||||
visible: false,
|
||||
readonly: false,
|
||||
}),
|
||||
name: expect.objectContaining({
|
||||
visible: true,
|
||||
readonly: true,
|
||||
}),
|
||||
dob: expect.objectContaining({
|
||||
visible: true,
|
||||
readonly: true,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
aux2: expect.objectContaining({
|
||||
columns: {
|
||||
id: { visible: false, readonly: false },
|
||||
name: { visible: true, readonly: true },
|
||||
dob: { visible: true, readonly: true },
|
||||
id: expect.objectContaining({
|
||||
visible: false,
|
||||
readonly: false,
|
||||
}),
|
||||
name: expect.objectContaining({
|
||||
visible: true,
|
||||
readonly: true,
|
||||
}),
|
||||
dob: expect.objectContaining({
|
||||
visible: true,
|
||||
readonly: true,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
}),
|
||||
|
@ -1375,16 +1402,34 @@ describe.each([
|
|||
schema: expect.objectContaining({
|
||||
aux: expect.objectContaining({
|
||||
columns: {
|
||||
id: { visible: false, readonly: false },
|
||||
fullName: { visible: true, readonly: true },
|
||||
age: { visible: false, readonly: false },
|
||||
id: expect.objectContaining({
|
||||
visible: false,
|
||||
readonly: false,
|
||||
}),
|
||||
fullName: expect.objectContaining({
|
||||
visible: true,
|
||||
readonly: true,
|
||||
}),
|
||||
age: expect.objectContaining({
|
||||
visible: false,
|
||||
readonly: false,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
aux2: expect.objectContaining({
|
||||
columns: {
|
||||
id: { visible: false, readonly: false },
|
||||
name: { visible: true, readonly: true },
|
||||
age: { visible: false, readonly: false },
|
||||
id: expect.objectContaining({
|
||||
visible: false,
|
||||
readonly: false,
|
||||
}),
|
||||
name: expect.objectContaining({
|
||||
visible: true,
|
||||
readonly: true,
|
||||
}),
|
||||
age: expect.objectContaining({
|
||||
visible: false,
|
||||
readonly: false,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
}),
|
||||
|
@ -1427,9 +1472,18 @@ describe.each([
|
|||
schema: expect.objectContaining({
|
||||
aux: expect.objectContaining({
|
||||
columns: {
|
||||
id: { visible: false, readonly: false },
|
||||
name: { visible: true, readonly: true },
|
||||
dob: { visible: true, readonly: true },
|
||||
id: expect.objectContaining({
|
||||
visible: false,
|
||||
readonly: false,
|
||||
}),
|
||||
name: expect.objectContaining({
|
||||
visible: true,
|
||||
readonly: true,
|
||||
}),
|
||||
dob: expect.objectContaining({
|
||||
visible: true,
|
||||
readonly: true,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
}),
|
||||
|
|
|
@ -7,6 +7,7 @@ import {
|
|||
View,
|
||||
ViewFieldMetadata,
|
||||
ViewV2,
|
||||
ViewV2ColumnEnriched,
|
||||
ViewV2Enriched,
|
||||
} from "@budibase/types"
|
||||
import { HTTPError } from "@budibase/backend-core"
|
||||
|
@ -176,7 +177,7 @@ export async function enrichSchema(
|
|||
}
|
||||
const relTable = tableCache[tableId]
|
||||
|
||||
const result: Record<string, RelationSchemaField> = {}
|
||||
const result: Record<string, ViewV2ColumnEnriched> = {}
|
||||
|
||||
for (const relTableFieldName of Object.keys(relTable.schema)) {
|
||||
const relTableField = relTable.schema[relTableFieldName]
|
||||
|
@ -188,9 +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,
|
||||
name: relTableField.name,
|
||||
visible: isVisible,
|
||||
readonly: isReadonly,
|
||||
}
|
||||
|
@ -211,6 +216,7 @@ export async function enrichSchema(
|
|||
...tableSchema[key],
|
||||
...ui,
|
||||
order: anyViewOrder ? ui?.order ?? undefined : tableSchema[key].order,
|
||||
columns: undefined,
|
||||
}
|
||||
|
||||
if (schema[key].type === FieldType.LINK) {
|
||||
|
|
|
@ -355,10 +355,14 @@ describe("table sdk", () => {
|
|||
visible: true,
|
||||
columns: {
|
||||
title: {
|
||||
name: "title",
|
||||
type: "string",
|
||||
visible: true,
|
||||
readonly: true,
|
||||
},
|
||||
age: {
|
||||
name: "age",
|
||||
type: "number",
|
||||
visible: false,
|
||||
readonly: false,
|
||||
},
|
||||
|
|
|
@ -10,6 +10,11 @@ export enum AutoReason {
|
|||
FOREIGN_KEY = "foreign_key",
|
||||
}
|
||||
|
||||
export type FieldSubType =
|
||||
| AutoFieldSubType
|
||||
| JsonFieldSubType
|
||||
| BBReferenceFieldSubType
|
||||
|
||||
export enum AutoFieldSubType {
|
||||
CREATED_BY = "createdBy",
|
||||
CREATED_AT = "createdAt",
|
||||
|
|
|
@ -38,8 +38,7 @@ export type ViewFieldMetadata = UIFieldMetadata & {
|
|||
columns?: Record<string, RelationSchemaField>
|
||||
}
|
||||
|
||||
export type RelationSchemaField = {
|
||||
visible?: boolean
|
||||
export type RelationSchemaField = UIFieldMetadata & {
|
||||
readonly?: boolean
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ import { FieldSchema, RelationSchemaField, ViewV2 } from "../documents"
|
|||
export interface ViewV2Enriched extends ViewV2 {
|
||||
schema?: {
|
||||
[key: string]: FieldSchema & {
|
||||
columns?: Record<string, RelationSchemaField>
|
||||
columns?: Record<string, ViewV2ColumnEnriched>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type ViewV2ColumnEnriched = RelationSchemaField & FieldSchema
|
||||
|
|
Loading…
Reference in New Issue