More types

This commit is contained in:
Adria Navarro 2024-04-03 12:13:33 +02:00
parent 3d45dcea5f
commit edd3ce8f0f
2 changed files with 15 additions and 29 deletions

View File

@ -1,21 +1,7 @@
import { FieldTypeToComponentMap } from "components/design/settings/controls/FieldConfiguration/utils"
import { Component } from "./Component" import { Component } from "./Component"
import { getSchemaForDatasource } from "dataBinding" import { getSchemaForDatasource } from "dataBinding"
const fieldTypeToComponentMap = {
string: "stringfield",
number: "numberfield",
bigint: "bigintfield",
options: "optionsfield",
array: "multifieldselect",
boolean: "booleanfield",
longform: "longformfield",
datetime: "datetimefield",
attachment: "attachmentfield",
link: "relationshipfield",
json: "jsonfield",
barcodeqr: "codescanner",
}
export function makeDatasourceFormComponents(datasource) { export function makeDatasourceFormComponents(datasource) {
const { schema } = getSchemaForDatasource(null, datasource, { const { schema } = getSchemaForDatasource(null, datasource, {
formSchema: true, formSchema: true,
@ -30,7 +16,7 @@ export function makeDatasourceFormComponents(datasource) {
} }
const fieldType = const fieldType =
typeof fieldSchema === "object" ? fieldSchema.type : fieldSchema typeof fieldSchema === "object" ? fieldSchema.type : fieldSchema
const componentType = fieldTypeToComponentMap[fieldType] const componentType = FieldTypeToComponentMap[fieldType]
const fullComponentType = `@budibase/standard-components/${componentType}` const fullComponentType = `@budibase/standard-components/${componentType}`
if (componentType) { if (componentType) {
const component = new Component(fullComponentType) const component = new Component(fullComponentType)

View File

@ -7,19 +7,19 @@
export let order export let order
const FieldTypeToComponentMap = { const FieldTypeToComponentMap = {
string: "stringfield", [FieldType.STRING]: "stringfield",
number: "numberfield", [FieldType.NUMBER]: "numberfield",
bigint: "bigintfield", [FieldType.BIGINT]: "bigintfield",
options: "optionsfield", [FieldType.OPTIONS]: "optionsfield",
array: "multifieldselect", [FieldType.ARRAY]: "multifieldselect",
boolean: "booleanfield", [FieldType.BOOLEAN]: "booleanfield",
longform: "longformfield", [FieldType.LONGFORM]: "longformfield",
datetime: "datetimefield", [FieldType.DATETIME]: "datetimefield",
attachment: "attachmentfield", [FieldType.ATTACHMENT]: "attachmentfield",
link: "relationshipfield", [FieldType.LINK]: "relationshipfield",
json: "jsonfield", [FieldType.JSON]: "jsonfield",
barcodeqr: "codescanner", [FieldType.BARCODEQR]: "codescanner",
bb_reference: "bbreferencefield", [FieldType.BB_REFERENCE]: "bbreferencefield",
} }
const getFieldSchema = field => { const getFieldSchema = field => {