diff --git a/packages/builder/src/components/common/LinkedRecordSelector.svelte b/packages/builder/src/components/common/LinkedRecordSelector.svelte index 5bee4eb78f..de0eaba160 100644 --- a/packages/builder/src/components/common/LinkedRecordSelector.svelte +++ b/packages/builder/src/components/common/LinkedRecordSelector.svelte @@ -4,31 +4,30 @@ import api from "builderStore/api" import { Select, Label } from "@budibase/bbui" import { capitalise } from "../../helpers" + import MultiSelect from "components/common/MultiSelect.svelte" export let schema export let linkedRecords = [] - let records = [] $: label = capitalise(schema.name) $: linkedModelId = schema.modelId $: linkedModel = $backendUiStore.models.find( model => model._id === linkedModelId ) + $: promise = fetchRecords(linkedModelId) - async function fetchRecords() { - const FETCH_RECORDS_URL = `/api/${linkedModelId}/records` + async function fetchRecords(linkedModelId) { + const FETCH_RECORDS_URL = `/api/${}/records` const response = await api.get(FETCH_RECORDS_URL) - records = await response.json() + const result = await response.json() + console.log(result) + return result } function getPrettyName(record) { return record[linkedModel.primaryDisplay || "_id"] } - - onMount(() => { - fetchRecords() - }) {#if linkedModel.primaryDisplay == null} @@ -39,10 +38,16 @@ table. {:else} - + {#await promise then records} + + {#each records as record} + + {/each} + + {/await} {/if} diff --git a/packages/builder/src/components/common/MultiSelect.svelte b/packages/builder/src/components/common/MultiSelect.svelte new file mode 100644 index 0000000000..641ca6beaf --- /dev/null +++ b/packages/builder/src/components/common/MultiSelect.svelte @@ -0,0 +1,336 @@ + + +
+ {#if label} + + {/if} +
+
+ {#each Object.values(selected) as s} +
+ {s.name} + {#if !readonly} +
+ + + +
+ {/if} +
+ {/each} +
+ {#if !readonly} + +
+ + + +
+ + + + {/if} +
+
+ + + + {#if showOptions} + + {/if} +
+
+ +