From 333e67249d658c9c3dd9b82517ac4dbe33a5188f Mon Sep 17 00:00:00 2001 From: thinkst-marco <51710176+thinkst-marco@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:14:42 +0200 Subject: [PATCH] Fix the BaseFromSelect component (#614) Previously it only accepted a list of strings. It now also will accept a list of SelectOption objects, which must include label and value keys. --- frontend_vue/src/components/base/BaseFormSelect.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend_vue/src/components/base/BaseFormSelect.vue b/frontend_vue/src/components/base/BaseFormSelect.vue index f85d1cda5..aa82f31dd 100644 --- a/frontend_vue/src/components/base/BaseFormSelect.vue +++ b/frontend_vue/src/components/base/BaseFormSelect.vue @@ -14,8 +14,6 @@ :id="id" class="v-select" :options="options" - :value="value" - :label="label" :searchable="false" :placeholder="placeholder" @input="handleSelectOption" @@ -36,10 +34,12 @@ import { toRef, onMounted } from 'vue'; import { useField } from 'vee-validate'; +export type SelectOption = { label: string, value: string }; + const props = defineProps<{ id: string; label: string; - options: string[]; + options: string[] | SelectOption[]; placeholder?: string; }>(); @@ -61,7 +61,10 @@ onMounted(() => { } }); -function handleSelectOption(value: string) { +function handleSelectOption(value: string | SelectOption) { + if (typeof value === 'object') { + value = value.value + }; handleChange(value); emits('selectOption', value); }