Merge pull request #11829 from Budibase/BUDI-7403/design-bb-refs
Display design BB refs
This commit is contained in:
commit
1b2170d1a4
|
@ -25,6 +25,7 @@
|
||||||
longform: StringRenderer,
|
longform: StringRenderer,
|
||||||
array: ArrayRenderer,
|
array: ArrayRenderer,
|
||||||
internal: InternalRenderer,
|
internal: InternalRenderer,
|
||||||
|
bb_reference: RelationshipRenderer,
|
||||||
}
|
}
|
||||||
$: type = getType(schema)
|
$: type = getType(schema)
|
||||||
$: customRenderer = customRenderers?.find(x => x.column === schema?.name)
|
$: customRenderer = customRenderers?.find(x => x.column === schema?.name)
|
||||||
|
|
|
@ -65,6 +65,7 @@ const componentMap = {
|
||||||
"field/array": FormFieldSelect,
|
"field/array": FormFieldSelect,
|
||||||
"field/json": FormFieldSelect,
|
"field/json": FormFieldSelect,
|
||||||
"field/barcodeqr": FormFieldSelect,
|
"field/barcodeqr": FormFieldSelect,
|
||||||
|
"field/bb_reference": FormFieldSelect,
|
||||||
// Some validation types are the same as others, so not all types are
|
// Some validation types are the same as others, so not all types are
|
||||||
// explicitly listed here. e.g. options uses string validation
|
// explicitly listed here. e.g. options uses string validation
|
||||||
"validation/string": ValidationEditor,
|
"validation/string": ValidationEditor,
|
||||||
|
@ -74,6 +75,7 @@ const componentMap = {
|
||||||
"validation/datetime": ValidationEditor,
|
"validation/datetime": ValidationEditor,
|
||||||
"validation/attachment": ValidationEditor,
|
"validation/attachment": ValidationEditor,
|
||||||
"validation/link": ValidationEditor,
|
"validation/link": ValidationEditor,
|
||||||
|
"validation/bb_reference": ValidationEditor,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getComponentForSetting = setting => {
|
export const getComponentForSetting = setting => {
|
||||||
|
|
|
@ -43,4 +43,5 @@ export const FieldTypeToComponentMap = {
|
||||||
link: "relationshipfield",
|
link: "relationshipfield",
|
||||||
json: "jsonfield",
|
json: "jsonfield",
|
||||||
barcodeqr: "codescanner",
|
barcodeqr: "codescanner",
|
||||||
|
bb_reference: "bbreferencefield",
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,8 @@
|
||||||
"datetimefield",
|
"datetimefield",
|
||||||
"multifieldselect",
|
"multifieldselect",
|
||||||
"s3upload",
|
"s3upload",
|
||||||
"codescanner"
|
"codescanner",
|
||||||
|
"bbreferencefield"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -5623,5 +5623,73 @@
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"bbreferencefield": {
|
||||||
|
"devComment": "As bb reference is only used for user subtype for now, we are using user for icon and labels",
|
||||||
|
"name": "User Field",
|
||||||
|
"icon": "User",
|
||||||
|
"styles": ["size"],
|
||||||
|
"requiredAncestors": ["form"],
|
||||||
|
"editable": true,
|
||||||
|
"size": {
|
||||||
|
"width": 400,
|
||||||
|
"height": 50
|
||||||
|
},
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
"type": "field/bb_reference",
|
||||||
|
"label": "Field",
|
||||||
|
"key": "field",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"label": "Label",
|
||||||
|
"key": "label"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"label": "Placeholder",
|
||||||
|
"key": "placeholder"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"label": "Default value",
|
||||||
|
"key": "defaultValue"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "validation/link",
|
||||||
|
"label": "Validation",
|
||||||
|
"key": "validation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "filter/relationship",
|
||||||
|
"label": "Filtering",
|
||||||
|
"key": "filter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"label": "Search",
|
||||||
|
"key": "autocomplete",
|
||||||
|
"defaultValue": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"label": "Disabled",
|
||||||
|
"key": "disabled",
|
||||||
|
"defaultValue": false
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
link: "relationshipfield",
|
link: "relationshipfield",
|
||||||
json: "jsonfield",
|
json: "jsonfield",
|
||||||
barcodeqr: "codescanner",
|
barcodeqr: "codescanner",
|
||||||
|
bb_reference: "bbreferencefield",
|
||||||
}
|
}
|
||||||
|
|
||||||
let formId
|
let formId
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<script>
|
||||||
|
import RelationshipField from "./RelationshipField.svelte"
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<RelationshipField
|
||||||
|
{...$$props}
|
||||||
|
datasourceType={"user"}
|
||||||
|
primaryDisplay={"email"}
|
||||||
|
/>
|
|
@ -16,6 +16,8 @@
|
||||||
export let defaultValue
|
export let defaultValue
|
||||||
export let onChange
|
export let onChange
|
||||||
export let filter
|
export let filter
|
||||||
|
export let datasourceType = "table"
|
||||||
|
export let primaryDisplay
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
@ -24,12 +26,15 @@
|
||||||
let searchTerm
|
let searchTerm
|
||||||
let open
|
let open
|
||||||
|
|
||||||
|
$: type =
|
||||||
|
datasourceType === "table" ? FieldTypes.LINK : FieldTypes.BB_REFERENCE
|
||||||
|
|
||||||
$: multiselect = fieldSchema?.relationshipType !== "one-to-many"
|
$: multiselect = fieldSchema?.relationshipType !== "one-to-many"
|
||||||
$: linkedTableId = fieldSchema?.tableId
|
$: linkedTableId = fieldSchema?.tableId
|
||||||
$: fetch = fetchData({
|
$: fetch = fetchData({
|
||||||
API,
|
API,
|
||||||
datasource: {
|
datasource: {
|
||||||
type: "table",
|
type: datasourceType,
|
||||||
tableId: linkedTableId,
|
tableId: linkedTableId,
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
@ -44,7 +49,7 @@
|
||||||
: flatten(fieldState?.value)?.[0]
|
: flatten(fieldState?.value)?.[0]
|
||||||
$: component = multiselect ? CoreMultiselect : CoreSelect
|
$: component = multiselect ? CoreMultiselect : CoreSelect
|
||||||
$: expandedDefaultValue = expand(defaultValue)
|
$: expandedDefaultValue = expand(defaultValue)
|
||||||
$: primaryDisplay = tableDefinition?.primaryDisplay
|
$: primaryDisplay = primaryDisplay || tableDefinition?.primaryDisplay
|
||||||
|
|
||||||
let optionsObj = {}
|
let optionsObj = {}
|
||||||
let initialValuesProcessed
|
let initialValuesProcessed
|
||||||
|
@ -54,7 +59,7 @@
|
||||||
// Persist the initial values as options, allowing them to be present in the dropdown,
|
// Persist the initial values as options, allowing them to be present in the dropdown,
|
||||||
// even if they are not in the inital fetch results
|
// even if they are not in the inital fetch results
|
||||||
initialValuesProcessed = true
|
initialValuesProcessed = true
|
||||||
optionsObj = fieldState?.value?.reduce((accumulator, value) => {
|
optionsObj = (fieldState?.value || []).reduce((accumulator, value) => {
|
||||||
accumulator[value._id] = {
|
accumulator[value._id] = {
|
||||||
_id: value._id,
|
_id: value._id,
|
||||||
[primaryDisplay]: value.primaryDisplay,
|
[primaryDisplay]: value.primaryDisplay,
|
||||||
|
@ -161,7 +166,7 @@
|
||||||
{disabled}
|
{disabled}
|
||||||
{validation}
|
{validation}
|
||||||
defaultValue={expandedDefaultValue}
|
defaultValue={expandedDefaultValue}
|
||||||
type={FieldTypes.LINK}
|
{type}
|
||||||
bind:fieldState
|
bind:fieldState
|
||||||
bind:fieldApi
|
bind:fieldApi
|
||||||
bind:fieldSchema
|
bind:fieldSchema
|
||||||
|
|
|
@ -15,3 +15,4 @@ export { default as formstep } from "./FormStep.svelte"
|
||||||
export { default as jsonfield } from "./JSONField.svelte"
|
export { default as jsonfield } from "./JSONField.svelte"
|
||||||
export { default as s3upload } from "./S3Upload.svelte"
|
export { default as s3upload } from "./S3Upload.svelte"
|
||||||
export { default as codescanner } from "./CodeScannerField.svelte"
|
export { default as codescanner } from "./CodeScannerField.svelte"
|
||||||
|
export { default as bbreferencefield } from "./BBReferenceField.svelte"
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
export const FieldTypes = {
|
import { FieldType as FieldTypes } from "@budibase/types"
|
||||||
STRING: "string",
|
export { FieldType as FieldTypes } from "@budibase/types"
|
||||||
BARCODEQR: "barcodeqr",
|
|
||||||
LONGFORM: "longform",
|
|
||||||
OPTIONS: "options",
|
|
||||||
NUMBER: "number",
|
|
||||||
BOOLEAN: "boolean",
|
|
||||||
ARRAY: "array",
|
|
||||||
DATETIME: "datetime",
|
|
||||||
ATTACHMENT: "attachment",
|
|
||||||
LINK: "link",
|
|
||||||
FORMULA: "formula",
|
|
||||||
JSON: "json",
|
|
||||||
}
|
|
||||||
|
|
||||||
export const UnsortableTypes = [
|
export const UnsortableTypes = [
|
||||||
FieldTypes.FORMULA,
|
FieldTypes.FORMULA,
|
||||||
|
|
Loading…
Reference in New Issue