diff --git a/packages/bbui/src/Form/Core/Select.svelte b/packages/bbui/src/Form/Core/Select.svelte index 3806281438..7d325bb6cc 100644 --- a/packages/bbui/src/Form/Core/Select.svelte +++ b/packages/bbui/src/Form/Core/Select.svelte @@ -102,7 +102,9 @@ {onOptionMouseenter} {onOptionMouseleave} isPlaceholder={value == null || value === ""} - placeholderOption={placeholder === false ? null : placeholder} + placeholderOption={placeholder === false + ? null + : placeholder || "Choose an option"} isOptionSelected={option => compareOptionAndValue(option, value)} onSelectOption={selectOption} {loading} diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte index 85d57e665a..ee9fd12c0c 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte @@ -157,7 +157,7 @@ {:else if schema.type === "link"} onChange({ @@ -169,7 +169,7 @@ /> {:else if schema.type === "bb_reference" || schema.type === "bb_reference_single"} diff --git a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte index b012766171..745f29d56a 100644 --- a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte +++ b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte @@ -146,7 +146,7 @@ {:else if type === "link"} (value = e.detail)} /> diff --git a/packages/builder/src/components/common/LinkedRowSelector.svelte b/packages/builder/src/components/common/LinkedRowSelector.svelte index 8db4a7dc03..009d943456 100644 --- a/packages/builder/src/components/common/LinkedRowSelector.svelte +++ b/packages/builder/src/components/common/LinkedRowSelector.svelte @@ -6,7 +6,7 @@ import { createEventDispatcher } from "svelte" export let schema - export let linkedRows = [] + export let linkedData export let useLabel = true export let linkedTableId export let label @@ -15,14 +15,26 @@ let rows = [] let linkedIds = [] - $: linkedIds = (Array.isArray(linkedRows) ? linkedRows : [])?.map( - row => row?._id || row - ) + $: fieldValue = getFieldValue(linkedData, schema) $: label = label || capitalise(schema.name) $: linkedTableId = linkedTableId || schema.tableId $: linkedTable = $tables.list.find(table => table._id === linkedTableId) $: fetchRows(linkedTableId) + const getFieldValue = val => { + const linkedIds = (Array.isArray(val) ? val : [])?.map( + row => row?._id || row + ) + if ( + schema.relationshipType === "one-to-many" || + schema.type === "bb_reference_single" + ) { + return linkedIds[0] + } else { + return linkedIds + } + } + async function fetchRows(linkedTableId) { try { rows = await API.fetchTableData(linkedTableId) @@ -45,7 +57,7 @@ {:else if schema.relationshipType === "one-to-many" || schema.type === "bb_reference_single"}