More and more types
This commit is contained in:
parent
be1eef2976
commit
853ba4e20c
|
@ -203,7 +203,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => {
|
||||||
// will not be received by the builder websocket because we caused it
|
// will not be received by the builder websocket because we caused it
|
||||||
// ourselves
|
// ourselves
|
||||||
dispatch("updatedatasource", newDefinition)
|
dispatch("updatedatasource", newDefinition)
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
const msg = error?.message || error || "Unknown error"
|
const msg = error?.message || error || "Unknown error"
|
||||||
get(notifications).error(`Error saving schema: ${msg}`)
|
get(notifications).error(`Error saving schema: ${msg}`)
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,10 @@ export interface DatasourceActions<
|
||||||
TSaveDefinitionRequest = UpdateViewRequest | SaveTableRequest
|
TSaveDefinitionRequest = UpdateViewRequest | SaveTableRequest
|
||||||
> {
|
> {
|
||||||
saveDefinition: (newDefinition: TSaveDefinitionRequest) => Promise<void>
|
saveDefinition: (newDefinition: TSaveDefinitionRequest) => Promise<void>
|
||||||
addRow: (row: SaveRowRequest) => Promise<Row>
|
addRow: (row: SaveRowRequest) => Promise<Row | void>
|
||||||
updateRow: (row: SaveRowRequest) => Promise<Row>
|
updateRow: (row: SaveRowRequest) => Promise<Row | void>
|
||||||
deleteRows: (rows: (string | Row)[]) => Promise<void>
|
deleteRows: (rows: (string | Row)[]) => Promise<void>
|
||||||
getRow: (id: string) => Promise<Row>
|
getRow: (id: string) => Promise<Row | void>
|
||||||
isDatasourceValid: (datasource: UIDatasource) => boolean
|
isDatasourceValid: (datasource: UIDatasource) => boolean | void
|
||||||
canUseColumn: (name: string) => boolean
|
canUseColumn: (name: string) => boolean | void
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
UIFieldSchema,
|
UIFieldSchema,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
const columnTypeManyTypeOverrides = {
|
const columnTypeManyTypeOverrides: Partial<Record<FieldType, FieldType>> = {
|
||||||
[FieldType.DATETIME]: FieldType.STRING,
|
[FieldType.DATETIME]: FieldType.STRING,
|
||||||
[FieldType.BOOLEAN]: FieldType.STRING,
|
[FieldType.BOOLEAN]: FieldType.STRING,
|
||||||
[FieldType.SIGNATURE_SINGLE]: FieldType.ATTACHMENTS,
|
[FieldType.SIGNATURE_SINGLE]: FieldType.ATTACHMENTS,
|
||||||
|
@ -46,7 +46,7 @@ const columnTypeManyParser = {
|
||||||
|
|
||||||
export function enrichSchemaWithRelColumns(
|
export function enrichSchemaWithRelColumns(
|
||||||
schema: Record<string, UIFieldSchema>
|
schema: Record<string, UIFieldSchema>
|
||||||
): Record<string, UIFieldSchema> {
|
): Record<string, UIFieldSchema> | undefined {
|
||||||
if (!schema) {
|
if (!schema) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ export function enrichSchemaWithRelColumns(
|
||||||
const name = `${field.name}.${relColumn}`
|
const name = `${field.name}.${relColumn}`
|
||||||
result[name] = {
|
result[name] = {
|
||||||
...relField,
|
...relField,
|
||||||
type: null, // TODO
|
type: relField.type as any, // TODO
|
||||||
name,
|
name,
|
||||||
related: { field: fieldName, subField: relColumn },
|
related: { field: fieldName, subField: relColumn },
|
||||||
cellRenderType:
|
cellRenderType:
|
||||||
|
@ -102,10 +102,10 @@ 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 => value)
|
const parser = columnTypeManyParser[field.type] || ((value: any) => value)
|
||||||
const value = row[field.related.field]
|
const value = row[field.related.field]
|
||||||
?.flatMap(r => r[field.related.subField])
|
?.flatMap((r: Row) => r[field.related.subField])
|
||||||
?.filter(i => i !== undefined && i !== null)
|
?.filter((i: any) => i !== undefined && i !== null)
|
||||||
const parsed = parser(value || [], field)
|
const parsed = parser(value || [], field)
|
||||||
result = parsed
|
result = parsed
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
import {
|
import {
|
||||||
BasicViewFieldMetadata,
|
BasicViewFieldMetadata,
|
||||||
FieldSchema,
|
FieldSchema,
|
||||||
|
FieldType,
|
||||||
RelationSchemaField,
|
RelationSchemaField,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
export type UIFieldSchema = FieldSchema &
|
export type UIFieldSchema = FieldSchema &
|
||||||
BasicViewFieldMetadata & {
|
BasicViewFieldMetadata & {
|
||||||
related?: { field: string; subField: string }
|
related?: { field: string; subField: string }
|
||||||
columns?: Record<string, UIRelationSchemaField & { type?: string }>
|
columns?: Record<string, UIRelationSchemaField>
|
||||||
cellRenderType?: string
|
cellRenderType?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UIRelationSchemaField extends RelationSchemaField {
|
interface UIRelationSchemaField extends RelationSchemaField {
|
||||||
type: string
|
type: FieldType
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue