Fixes for Single select and Single user pickers. Now displaying binding status correctly
This commit is contained in:
parent
8279a0b31c
commit
853e891664
|
@ -157,7 +157,7 @@
|
||||||
</span>
|
</span>
|
||||||
{:else if schema.type === "link"}
|
{:else if schema.type === "link"}
|
||||||
<LinkedRowSelector
|
<LinkedRowSelector
|
||||||
linkedRows={fieldData}
|
linkedData={fieldData}
|
||||||
{schema}
|
{schema}
|
||||||
on:change={e =>
|
on:change={e =>
|
||||||
onChange({
|
onChange({
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
/>
|
/>
|
||||||
{:else if schema.type === "bb_reference" || schema.type === "bb_reference_single"}
|
{:else if schema.type === "bb_reference" || schema.type === "bb_reference_single"}
|
||||||
<LinkedRowSelector
|
<LinkedRowSelector
|
||||||
linkedRows={fieldData}
|
linkedData={fieldData}
|
||||||
{schema}
|
{schema}
|
||||||
linkedTableId={"ta_users"}
|
linkedTableId={"ta_users"}
|
||||||
on:change={e =>
|
on:change={e =>
|
||||||
|
|
|
@ -146,7 +146,7 @@
|
||||||
{:else if type === "link"}
|
{:else if type === "link"}
|
||||||
<LinkedRowSelector
|
<LinkedRowSelector
|
||||||
{error}
|
{error}
|
||||||
linkedRows={value}
|
linkedData={value}
|
||||||
schema={meta}
|
schema={meta}
|
||||||
on:change={e => (value = e.detail)}
|
on:change={e => (value = e.detail)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
import { createEventDispatcher } from "svelte"
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
export let schema
|
export let schema
|
||||||
export let linkedRows = []
|
export let linkedData
|
||||||
export let useLabel = true
|
export let useLabel = true
|
||||||
export let linkedTableId
|
export let linkedTableId
|
||||||
export let label
|
export let label
|
||||||
|
@ -15,14 +15,25 @@
|
||||||
let rows = []
|
let rows = []
|
||||||
let linkedIds = []
|
let linkedIds = []
|
||||||
|
|
||||||
$: linkedIds = (Array.isArray(linkedRows) ? linkedRows : [])?.map(
|
$: fieldValue = getFieldValue(linkedData)
|
||||||
row => row?._id || row
|
|
||||||
)
|
|
||||||
$: label = label || capitalise(schema.name)
|
$: label = label || capitalise(schema.name)
|
||||||
$: linkedTableId = linkedTableId || schema.tableId
|
$: linkedTableId = linkedTableId || schema.tableId
|
||||||
$: linkedTable = $tables.list.find(table => table._id === linkedTableId)
|
$: linkedTable = $tables.list.find(table => table._id === linkedTableId)
|
||||||
$: fetchRows(linkedTableId)
|
$: fetchRows(linkedTableId)
|
||||||
|
|
||||||
|
const getFieldValue = val => {
|
||||||
|
const linkedIds = (Array.isArray(val) ? val : [])?.map(
|
||||||
|
row => row?._id || row
|
||||||
|
)
|
||||||
|
if (schema.relationshipType === "one-to-many") {
|
||||||
|
return linkedIds?.[0]
|
||||||
|
} else if (schema.type === "bb_reference_single") {
|
||||||
|
return val
|
||||||
|
} else {
|
||||||
|
return linkedIds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchRows(linkedTableId) {
|
async function fetchRows(linkedTableId) {
|
||||||
try {
|
try {
|
||||||
rows = await API.fetchTableData(linkedTableId)
|
rows = await API.fetchTableData(linkedTableId)
|
||||||
|
@ -45,7 +56,7 @@
|
||||||
</Label>
|
</Label>
|
||||||
{:else if schema.relationshipType === "one-to-many" || schema.type === "bb_reference_single"}
|
{:else if schema.relationshipType === "one-to-many" || schema.type === "bb_reference_single"}
|
||||||
<Select
|
<Select
|
||||||
value={linkedIds?.[0]}
|
value={fieldValue}
|
||||||
options={rows}
|
options={rows}
|
||||||
getOptionLabel={getPrettyName}
|
getOptionLabel={getPrettyName}
|
||||||
getOptionValue={row => row._id}
|
getOptionValue={row => row._id}
|
||||||
|
@ -58,7 +69,7 @@
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<Multiselect
|
<Multiselect
|
||||||
value={linkedIds}
|
value={fieldValue}
|
||||||
label={useLabel ? label : null}
|
label={useLabel ? label : null}
|
||||||
options={rows}
|
options={rows}
|
||||||
getOptionLabel={getPrettyName}
|
getOptionLabel={getPrettyName}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import ClientBindingPanel from "components/common/bindings/ClientBindingPanel.svelte"
|
import ClientBindingPanel from "components/common/bindings/ClientBindingPanel.svelte"
|
||||||
import { createEventDispatcher, setContext } from "svelte"
|
import { createEventDispatcher, setContext } from "svelte"
|
||||||
import { isJSBinding } from "@budibase/string-templates"
|
import { isJSBinding, findHBSBlocks } from "@budibase/string-templates"
|
||||||
|
|
||||||
export let panel = ClientBindingPanel
|
export let panel = ClientBindingPanel
|
||||||
export let value = ""
|
export let value = ""
|
||||||
|
@ -109,6 +109,7 @@
|
||||||
array: hasValidOptions,
|
array: hasValidOptions,
|
||||||
longform: value => !isJSBinding(value),
|
longform: value => !isJSBinding(value),
|
||||||
json: value => !isJSBinding(value),
|
json: value => !isJSBinding(value),
|
||||||
|
options: value => !isJSBinding(value) && !findHBSBlocks(value)?.length,
|
||||||
boolean: isValidBoolean,
|
boolean: isValidBoolean,
|
||||||
attachment: false,
|
attachment: false,
|
||||||
attachment_single: false,
|
attachment_single: false,
|
||||||
|
|
Loading…
Reference in New Issue