adds functional single select to builder

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

View File

@ -8,8 +8,6 @@
export let schema
export let linkedRows = []
console.log(schema)
console.log(linkedRows)
let rows = []
$: label = capitalise(schema.name)
@ -34,11 +32,8 @@
return row[linkedTable.primaryDisplay || "_id"]
}
let oneToManyRow = getPrettyName(linkedRows[0]) || ''
function oneToManyValueSetter(value) {
linkedRows = [value]
}
$: console.log(rows)
$: console.log(linkedRows)
</script>
{#if linkedTable.primaryDisplay == null}
@ -50,10 +45,10 @@
</Label>
{:else}
{#if schema.oneToMany}
<Select on:change={e => oneToManyValueSetter(e.target.value)} value={getPrettyName(oneToManyRow)} name="Test" label="Flavour">
<Select on:change={e => linkedRows = [e.target.value]} name={label} {label}>
<option value="">Choose an option</option>
{#each rows as row}
<option value={row._id}>{getPrettyName(row)}</option>
<option selected={row._id === linkedRows[0]} value={row._id}>{getPrettyName(row)}</option>
{/each}
</Select>
{:else}