More types
This commit is contained in:
parent
853ba4e20c
commit
e3a811d1a6
|
@ -18,13 +18,13 @@ import { DatasourceActions } from "./datasources"
|
||||||
|
|
||||||
interface DatasourceStore {
|
interface DatasourceStore {
|
||||||
definition: Writable<UIDatasource>
|
definition: Writable<UIDatasource>
|
||||||
schemaMutations: Writable<Record<string, {}>>
|
schemaMutations: Writable<Record<string, UIFieldMutation>>
|
||||||
subSchemaMutations: Writable<Record<string, {}>>
|
subSchemaMutations: Writable<Record<string, UIFieldMutation>>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DerivedDatasourceStore {
|
interface DerivedDatasourceStore {
|
||||||
schema: Readable<Record<string, FieldSchema>>
|
schema: Readable<Record<string, FieldSchema> | null>
|
||||||
enrichedSchema: Readable<Record<string, UIFieldSchema>>
|
enrichedSchema: Readable<Record<string, UIFieldSchema> | null>
|
||||||
hasBudibaseIdentifiers: Readable<boolean>
|
hasBudibaseIdentifiers: Readable<boolean>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ export const deriveStores = (context: StoreContext): DerivedDatasourceStore => {
|
||||||
const schemaWithRelatedColumns = enrichSchemaWithRelColumns($schema)
|
const schemaWithRelatedColumns = enrichSchemaWithRelColumns($schema)
|
||||||
|
|
||||||
const enrichedSchema: Record<string, UIFieldSchema> = {}
|
const enrichedSchema: Record<string, UIFieldSchema> = {}
|
||||||
Object.keys(schemaWithRelatedColumns).forEach(field => {
|
Object.keys(schemaWithRelatedColumns || {}).forEach(field => {
|
||||||
enrichedSchema[field] = {
|
enrichedSchema[field] = {
|
||||||
...schemaWithRelatedColumns[field],
|
...schemaWithRelatedColumns?.[field],
|
||||||
...$schemaOverrides?.[field],
|
...$schemaOverrides?.[field],
|
||||||
...$schemaMutations[field],
|
...$schemaMutations[field],
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => {
|
||||||
// Update server
|
// Update server
|
||||||
if (get(config).canSaveSchema) {
|
if (get(config).canSaveSchema) {
|
||||||
try {
|
try {
|
||||||
await getAPI()?.actions.saveDefinition(newDefinition as any)
|
await getAPI()?.actions.saveDefinition(newDefinition)
|
||||||
|
|
||||||
// Broadcast change so external state can be updated, as this change
|
// Broadcast change so external state can be updated, as this change
|
||||||
// will not be received by the builder websocket because we caused it
|
// will not be received by the builder websocket because we caused it
|
||||||
|
|
|
@ -102,12 +102,14 @@ export function getRelatedTableValues(
|
||||||
if (fromSingle) {
|
if (fromSingle) {
|
||||||
result = row[field.related.field]?.[0]?.[field.related.subField]
|
result = row[field.related.field]?.[0]?.[field.related.subField]
|
||||||
} else {
|
} else {
|
||||||
const parser = columnTypeManyParser[field.type] || ((value: any) => value)
|
const parser =
|
||||||
|
columnTypeManyParser[field.type as keyof typeof columnTypeManyParser] ||
|
||||||
|
((value: any) => value)
|
||||||
const value = row[field.related.field]
|
const value = row[field.related.field]
|
||||||
?.flatMap((r: Row) => r[field.related.subField])
|
?.flatMap((r: Row) => r[field.related.subField])
|
||||||
?.filter((i: any) => i !== undefined && i !== null)
|
?.filter((i: any) => i !== undefined && i !== null)
|
||||||
const parsed = parser(value || [], field)
|
const parsed = parser(value || [], field as any)
|
||||||
result = parsed
|
result = parsed as any
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
FieldType.STRING,
|
FieldType.STRING,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
|
|
||||||
export type UIFieldSchema = FieldSchema &
|
export type UIFieldSchema = FieldSchema &
|
||||||
BasicViewFieldMetadata & {
|
BasicViewFieldMetadata & {
|
||||||
related?: { field: string; subField: string }
|
related: { field: string; subField: string }
|
||||||
columns?: Record<string, UIRelationSchemaField>
|
columns?: Record<string, UIRelationSchemaField>
|
||||||
cellRenderType?: string
|
cellRenderType?: string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue