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
|
||||
// ourselves
|
||||
dispatch("updatedatasource", newDefinition)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
const msg = error?.message || error || "Unknown error"
|
||||
get(notifications).error(`Error saving schema: ${msg}`)
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ export interface DatasourceActions<
|
|||
TSaveDefinitionRequest = UpdateViewRequest | SaveTableRequest
|
||||
> {
|
||||
saveDefinition: (newDefinition: TSaveDefinitionRequest) => Promise<void>
|
||||
addRow: (row: SaveRowRequest) => Promise<Row>
|
||||
updateRow: (row: SaveRowRequest) => Promise<Row>
|
||||
addRow: (row: SaveRowRequest) => Promise<Row | void>
|
||||
updateRow: (row: SaveRowRequest) => Promise<Row | void>
|
||||
deleteRows: (rows: (string | Row)[]) => Promise<void>
|
||||
getRow: (id: string) => Promise<Row>
|
||||
isDatasourceValid: (datasource: UIDatasource) => boolean
|
||||
canUseColumn: (name: string) => boolean
|
||||
getRow: (id: string) => Promise<Row | void>
|
||||
isDatasourceValid: (datasource: UIDatasource) => boolean | void
|
||||
canUseColumn: (name: string) => boolean | void
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
UIFieldSchema,
|
||||
} from "@budibase/types"
|
||||
|
||||
const columnTypeManyTypeOverrides = {
|
||||
const columnTypeManyTypeOverrides: Partial<Record<FieldType, FieldType>> = {
|
||||
[FieldType.DATETIME]: FieldType.STRING,
|
||||
[FieldType.BOOLEAN]: FieldType.STRING,
|
||||
[FieldType.SIGNATURE_SINGLE]: FieldType.ATTACHMENTS,
|
||||
|
@ -46,7 +46,7 @@ const columnTypeManyParser = {
|
|||
|
||||
export function enrichSchemaWithRelColumns(
|
||||
schema: Record<string, UIFieldSchema>
|
||||
): Record<string, UIFieldSchema> {
|
||||
): Record<string, UIFieldSchema> | undefined {
|
||||
if (!schema) {
|
||||
return
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ export function enrichSchemaWithRelColumns(
|
|||
const name = `${field.name}.${relColumn}`
|
||||
result[name] = {
|
||||
...relField,
|
||||
type: null, // TODO
|
||||
type: relField.type as any, // TODO
|
||||
name,
|
||||
related: { field: fieldName, subField: relColumn },
|
||||
cellRenderType:
|
||||
|
@ -102,10 +102,10 @@ export function getRelatedTableValues(
|
|||
if (fromSingle) {
|
||||
result = row[field.related.field]?.[0]?.[field.related.subField]
|
||||
} else {
|
||||
const parser = columnTypeManyParser[field.type] || (value => value)
|
||||
const parser = columnTypeManyParser[field.type] || ((value: any) => value)
|
||||
const value = row[field.related.field]
|
||||
?.flatMap(r => r[field.related.subField])
|
||||
?.filter(i => i !== undefined && i !== null)
|
||||
?.flatMap((r: Row) => r[field.related.subField])
|
||||
?.filter((i: any) => i !== undefined && i !== null)
|
||||
const parsed = parser(value || [], field)
|
||||
result = parsed
|
||||
if (
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
import {
|
||||
BasicViewFieldMetadata,
|
||||
FieldSchema,
|
||||
FieldType,
|
||||
RelationSchemaField,
|
||||
} from "@budibase/types"
|
||||
|
||||
export type UIFieldSchema = FieldSchema &
|
||||
BasicViewFieldMetadata & {
|
||||
related?: { field: string; subField: string }
|
||||
columns?: Record<string, UIRelationSchemaField & { type?: string }>
|
||||
columns?: Record<string, UIRelationSchemaField>
|
||||
cellRenderType?: string
|
||||
}
|
||||
|
||||
interface UIRelationSchemaField extends RelationSchemaField {
|
||||
type: string
|
||||
type: FieldType
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue