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 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)
@ -34,11 +32,8 @@
return row[linkedTable.primaryDisplay || "_id"] return row[linkedTable.primaryDisplay || "_id"]
} }
let oneToManyRow = getPrettyName(linkedRows[0]) || '' $: console.log(rows)
$: console.log(linkedRows)
function oneToManyValueSetter(value) {
linkedRows = [value]
}
</script> </script>
{#if linkedTable.primaryDisplay == null} {#if linkedTable.primaryDisplay == null}
@ -50,10 +45,10 @@
</Label> </Label>
{:else} {:else}
{#if schema.oneToMany} {#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> <option value="">Choose an option</option>
{#each rows as row} {#each rows as row}
<option value={row._id}>{getPrettyName(row)}</option> <option selected={row._id === linkedRows[0]} value={row._id}>{getPrettyName(row)}</option>
{/each} {/each}
</Select> </Select>
{:else} {:else}