1
0
Fork 0
mirror of synced 2024-07-20 13:45:56 +12:00

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 3e5c803598
commit 690a2d9c73

View file

@ -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,6 +49,14 @@
table. table.
</Label> </Label>
{:else} {: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 <Multiselect
secondary secondary
bind:value={linkedRows} bind:value={linkedRows}
@ -50,4 +66,5 @@
<option value={row._id}>{getPrettyName(row)}</option> <option value={row._id}>{getPrettyName(row)}</option>
{/each} {/each}
</Multiselect> </Multiselect>
{/if}
{/if} {/if}