Update backend linked row selector to support new relationship object

This commit is contained in:
Andrew Kingston 2021-02-25 11:34:35 +00:00
parent c3a74c5006
commit 8d496a49b4
1 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,4 @@
<script> <script>
import { onMount } from "svelte"
import { backendUiStore } from "builderStore" import { backendUiStore } from "builderStore"
import api from "builderStore/api" import api from "builderStore/api"
import { Select, Label, Multiselect } from "@budibase/bbui" import { Select, Label, Multiselect } from "@budibase/bbui"
@ -9,7 +8,9 @@
export let linkedRows = [] export let linkedRows = []
let rows = [] let rows = []
let linkedIds = (linkedRows || [])?.map(row => row?._id || row)
$: linkedRows = linkedIds
$: label = capitalise(schema.name) $: label = capitalise(schema.name)
$: linkedTableId = schema.tableId $: linkedTableId = schema.tableId
$: linkedTable = $backendUiStore.tables.find( $: linkedTable = $backendUiStore.tables.find(
@ -45,12 +46,12 @@
<Select <Select
thin thin
secondary secondary
on:change={e => (linkedRows = [e.target.value])} on:change={e => (linkedIds = e.target.value ? [e.target.value] : [])}
name={label} name={label}
{label}> {label}>
<option value="">Choose an option</option> <option value="">Choose an option</option>
{#each rows as row} {#each rows as row}
<option selected={row._id === linkedRows[0]} value={row._id}> <option selected={row._id === linkedIds[0]} value={row._id}>
{getPrettyName(row)} {getPrettyName(row)}
</option> </option>
{/each} {/each}
@ -58,7 +59,7 @@
{:else} {:else}
<Multiselect <Multiselect
secondary secondary
bind:value={linkedRows} bind:value={linkedIds}
{label} {label}
placeholder="Choose some options"> placeholder="Choose some options">
{#each rows as row} {#each rows as row}