From b1087e9db11a65c68f97dfa2fb880fe77830131d Mon Sep 17 00:00:00 2001 From: theotheo Date: Sat, 21 Oct 2023 01:47:06 +0300 Subject: [PATCH] refactor: reducing duplication in select/multiselect --- src/views/FormBuilder.svelte | 82 +++---------------- .../components/InputBuilderSelect.svelte | 22 ++++- 2 files changed, 29 insertions(+), 75 deletions(-) diff --git a/src/views/FormBuilder.svelte b/src/views/FormBuilder.svelte index 4ae67565..480f91e2 100644 --- a/src/views/FormBuilder.svelte +++ b/src/views/FormBuilder.svelte @@ -230,80 +230,18 @@ bind:options={field.input.options} bind:folder={field.input.folder} notifyChange={onChange} + is_multi={false} /> {:else if field.input.type === "multiselect"} - {@const source_id = `source_${index}`} -
- - -
- {#if field.input.source === "fixed"} - {@const options_id = `options_btn_${index}`} - - - {#each field.input.multi_select_options || [] as option, idx} - {@const value_id = `${options_id}_option_${idx}`} -
- - - - -
- {/each} -
- {:else if field.input.source === "notes"} - - {/if} + + {:else if field.input.type === "slider"} {@const min_id = `min_${index}`} {@const max_id = `max_${index}`} diff --git a/src/views/components/InputBuilderSelect.svelte b/src/views/components/InputBuilderSelect.svelte index 730fb7ab..3ab5fc4d 100644 --- a/src/views/components/InputBuilderSelect.svelte +++ b/src/views/components/InputBuilderSelect.svelte @@ -14,6 +14,7 @@ export let folder: string | undefined; export let options: EditableInput["options"] = []; export let notifyChange: () => void; + export let is_multi: boolean; $: id = `builder_select_${index}`; $: options_id = `builder_select_options_btn_${index}`; @@ -29,15 +30,29 @@ {#each options || [] as option, idx} {@const value_id = `${options_id}_option_${idx}`} - {@const label_id = `${options_id}_option_label_${idx}`}