initial work on handling single vs multiple values in builder components

This commit is contained in:
Keviin Åberg Kultalahti 2021-02-09 15:35:09 +01:00
parent b8130183bb
commit b4cc7c6776
1 changed files with 26 additions and 9 deletions

View File

@ -8,6 +8,8 @@
export let schema
export let linkedRows = []
console.log(schema)
console.log(linkedRows)
let rows = []
$: label = capitalise(schema.name)
@ -31,6 +33,12 @@
function getPrettyName(row) {
return row[linkedTable.primaryDisplay || "_id"]
}
let oneToManyRow = getPrettyName(linkedRows[0]) || ''
function oneToManyValueSetter(value) {
linkedRows = [value]
}
</script>
{#if linkedTable.primaryDisplay == null}
@ -40,6 +48,14 @@
<b>{linkedTable.name}</b>
table.
</Label>
{:else}
{#if schema.oneToMany}
<Select on:change={e => oneToManyValueSetter(e.target.value)} value={getPrettyName(oneToManyRow)} name="Test" label="Flavour">
<option value="">Choose an option</option>
{#each rows as row}
<option value={row._id}>{getPrettyName(row)}</option>
{/each}
</Select>
{:else}
<Multiselect
secondary
@ -51,3 +67,4 @@
{/each}
</Multiselect>
{/if}
{/if}