initial work on handling single vs multiple values in builder components
This commit is contained in:
parent
b8130183bb
commit
b4cc7c6776
|
@ -8,6 +8,8 @@
|
||||||
export let schema
|
export let schema
|
||||||
export let linkedRows = []
|
export let linkedRows = []
|
||||||
|
|
||||||
|
console.log(schema)
|
||||||
|
console.log(linkedRows)
|
||||||
let rows = []
|
let rows = []
|
||||||
|
|
||||||
$: label = capitalise(schema.name)
|
$: label = capitalise(schema.name)
|
||||||
|
@ -31,6 +33,12 @@
|
||||||
function getPrettyName(row) {
|
function getPrettyName(row) {
|
||||||
return row[linkedTable.primaryDisplay || "_id"]
|
return row[linkedTable.primaryDisplay || "_id"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let oneToManyRow = getPrettyName(linkedRows[0]) || ''
|
||||||
|
|
||||||
|
function oneToManyValueSetter(value) {
|
||||||
|
linkedRows = [value]
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if linkedTable.primaryDisplay == null}
|
{#if linkedTable.primaryDisplay == null}
|
||||||
|
@ -41,13 +49,22 @@
|
||||||
table.
|
table.
|
||||||
</Label>
|
</Label>
|
||||||
{:else}
|
{:else}
|
||||||
<Multiselect
|
{#if schema.oneToMany}
|
||||||
secondary
|
<Select on:change={e => oneToManyValueSetter(e.target.value)} value={getPrettyName(oneToManyRow)} name="Test" label="Flavour">
|
||||||
bind:value={linkedRows}
|
<option value="">Choose an option</option>
|
||||||
{label}
|
{#each rows as row}
|
||||||
placeholder="Choose some options">
|
<option value={row._id}>{getPrettyName(row)}</option>
|
||||||
{#each rows as row}
|
{/each}
|
||||||
<option value={row._id}>{getPrettyName(row)}</option>
|
</Select>
|
||||||
{/each}
|
{:else}
|
||||||
</Multiselect>
|
<Multiselect
|
||||||
|
secondary
|
||||||
|
bind:value={linkedRows}
|
||||||
|
{label}
|
||||||
|
placeholder="Choose some options">
|
||||||
|
{#each rows as row}
|
||||||
|
<option value={row._id}>{getPrettyName(row)}</option>
|
||||||
|
{/each}
|
||||||
|
</Multiselect>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in New Issue