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 columns
|
||||||
export let fromRelationshipField
|
export let fromRelationshipField
|
||||||
|
|
||||||
const { datasource, dispatch, cache, config } = getContext("grid")
|
const { datasource, dispatch, config } = getContext("grid")
|
||||||
|
|
||||||
$: canSetRelationshipSchemas = $config.canSetRelationshipSchemas
|
$: canSetRelationshipSchemas = $config.canSetRelationshipSchemas
|
||||||
|
|
||||||
|
@ -114,29 +114,19 @@
|
||||||
return { ...c, options }
|
return { ...c, options }
|
||||||
})
|
})
|
||||||
|
|
||||||
let relationshipPanelColumns = []
|
$: relationshipPanelColumns = Object.entries(
|
||||||
async function fetchRelationshipPanelColumns(relationshipField) {
|
relationshipField?.columns || {}
|
||||||
relationshipPanelColumns = []
|
).map(([name, column]) => {
|
||||||
if (!relationshipField) {
|
return {
|
||||||
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) {
|
async function toggleColumn(column, permission) {
|
||||||
const visible = permission !== FieldPermissions.HIDDEN
|
const visible = permission !== FieldPermissions.HIDDEN
|
||||||
|
|
|
@ -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
|
||||||
}, {})
|
}, {})
|
||||||
|
|
|
@ -1278,9 +1278,18 @@ describe.each([
|
||||||
schema: expect.objectContaining({
|
schema: expect.objectContaining({
|
||||||
aux: expect.objectContaining({
|
aux: expect.objectContaining({
|
||||||
columns: {
|
columns: {
|
||||||
id: { visible: false, readonly: false },
|
id: expect.objectContaining({
|
||||||
name: { visible: true, readonly: true },
|
visible: false,
|
||||||
dob: { visible: true, readonly: true },
|
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({
|
schema: expect.objectContaining({
|
||||||
aux: expect.objectContaining({
|
aux: expect.objectContaining({
|
||||||
columns: {
|
columns: {
|
||||||
id: { visible: false, readonly: false },
|
id: expect.objectContaining({
|
||||||
name: { visible: true, readonly: true },
|
visible: false,
|
||||||
dob: { visible: true, readonly: true },
|
readonly: false,
|
||||||
|
}),
|
||||||
|
name: expect.objectContaining({
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
}),
|
||||||
|
dob: expect.objectContaining({
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
aux2: expect.objectContaining({
|
aux2: expect.objectContaining({
|
||||||
columns: {
|
columns: {
|
||||||
id: { visible: false, readonly: false },
|
id: expect.objectContaining({
|
||||||
name: { visible: true, readonly: true },
|
visible: false,
|
||||||
dob: { visible: true, readonly: true },
|
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({
|
schema: expect.objectContaining({
|
||||||
aux: expect.objectContaining({
|
aux: expect.objectContaining({
|
||||||
columns: {
|
columns: {
|
||||||
id: { visible: false, readonly: false },
|
id: expect.objectContaining({
|
||||||
fullName: { visible: true, readonly: true },
|
visible: false,
|
||||||
age: { visible: false, readonly: false },
|
readonly: false,
|
||||||
|
}),
|
||||||
|
fullName: expect.objectContaining({
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
}),
|
||||||
|
age: expect.objectContaining({
|
||||||
|
visible: false,
|
||||||
|
readonly: false,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
aux2: expect.objectContaining({
|
aux2: expect.objectContaining({
|
||||||
columns: {
|
columns: {
|
||||||
id: { visible: false, readonly: false },
|
id: expect.objectContaining({
|
||||||
name: { visible: true, readonly: true },
|
visible: false,
|
||||||
age: { visible: false, readonly: 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({
|
schema: expect.objectContaining({
|
||||||
aux: expect.objectContaining({
|
aux: expect.objectContaining({
|
||||||
columns: {
|
columns: {
|
||||||
id: { visible: false, readonly: false },
|
id: expect.objectContaining({
|
||||||
name: { visible: true, readonly: true },
|
visible: false,
|
||||||
dob: { visible: true, readonly: true },
|
readonly: false,
|
||||||
|
}),
|
||||||
|
name: expect.objectContaining({
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
}),
|
||||||
|
dob: expect.objectContaining({
|
||||||
|
visible: true,
|
||||||
|
readonly: true,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -7,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"
|
||||||
|
@ -176,7 +177,7 @@ export async function enrichSchema(
|
||||||
}
|
}
|
||||||
const relTable = tableCache[tableId]
|
const relTable = tableCache[tableId]
|
||||||
|
|
||||||
const result: Record<string, 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]
|
||||||
|
@ -188,9 +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,
|
||||||
|
name: relTableField.name,
|
||||||
visible: isVisible,
|
visible: isVisible,
|
||||||
readonly: isReadonly,
|
readonly: isReadonly,
|
||||||
}
|
}
|
||||||
|
@ -211,6 +216,7 @@ export async function enrichSchema(
|
||||||
...tableSchema[key],
|
...tableSchema[key],
|
||||||
...ui,
|
...ui,
|
||||||
order: anyViewOrder ? ui?.order ?? undefined : tableSchema[key].order,
|
order: anyViewOrder ? ui?.order ?? undefined : tableSchema[key].order,
|
||||||
|
columns: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schema[key].type === FieldType.LINK) {
|
if (schema[key].type === FieldType.LINK) {
|
||||||
|
|
|
@ -355,10 +355,14 @@ describe("table sdk", () => {
|
||||||
visible: true,
|
visible: true,
|
||||||
columns: {
|
columns: {
|
||||||
title: {
|
title: {
|
||||||
|
name: "title",
|
||||||
|
type: "string",
|
||||||
visible: true,
|
visible: true,
|
||||||
readonly: true,
|
readonly: true,
|
||||||
},
|
},
|
||||||
age: {
|
age: {
|
||||||
|
name: "age",
|
||||||
|
type: "number",
|
||||||
visible: false,
|
visible: false,
|
||||||
readonly: false,
|
readonly: false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,6 +10,11 @@ export enum AutoReason {
|
||||||
FOREIGN_KEY = "foreign_key",
|
FOREIGN_KEY = "foreign_key",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type FieldSubType =
|
||||||
|
| AutoFieldSubType
|
||||||
|
| JsonFieldSubType
|
||||||
|
| BBReferenceFieldSubType
|
||||||
|
|
||||||
export enum AutoFieldSubType {
|
export enum AutoFieldSubType {
|
||||||
CREATED_BY = "createdBy",
|
CREATED_BY = "createdBy",
|
||||||
CREATED_AT = "createdAt",
|
CREATED_AT = "createdAt",
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@ import { FieldSchema, 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, RelationSchemaField>
|
columns?: Record<string, ViewV2ColumnEnriched>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ViewV2ColumnEnriched = RelationSchemaField & FieldSchema
|
||||||
|
|
Loading…
Reference in New Issue