From 6f0bcdcc72d62de47ce0cd66ecef1c9b0a63480a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 1 Oct 2020 11:53:43 +0100 Subject: [PATCH] Add hacked multiselect for testing --- .../common/LinkedRecordSelector.svelte | 33 +- .../src/components/common/MultiSelect.svelte | 336 ++++++++++++++++++ 2 files changed, 355 insertions(+), 14 deletions(-) create mode 100644 packages/builder/src/components/common/MultiSelect.svelte 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} +
    + {#each filtered as option} +
  • + {option.name} +
  • + {/each} +
+ {/if} +
+
+ +