From cc4ea131f9e31ac9a81b3fc0ea1f0ca2fee92edb Mon Sep 17 00:00:00 2001 From: andrusyakka Date: Tue, 15 Aug 2023 19:53:50 +0300 Subject: [PATCH] WIP rework search --- src/components/base/BaseInput.vue | 3 +- src/components/base/BaseInputWithSearch.vue | 109 +++++++++++++------- src/components/base/BaseSelect.vue | 19 ++-- 3 files changed, 81 insertions(+), 50 deletions(-) diff --git a/src/components/base/BaseInput.vue b/src/components/base/BaseInput.vue index 6e1abf3..3c9bb6c 100644 --- a/src/components/base/BaseInput.vue +++ b/src/components/base/BaseInput.vue @@ -25,6 +25,7 @@ :autofocus="autofocus", hide-bottom-space :error="error" + @focus="e => $emit('focus', e)" ) template(v-slot:prepend, v-if="iconLeft") slot(name="iconLeft") @@ -85,7 +86,7 @@ export default { height: String, error: Boolean, }, - emits: ["update:modelValue"], + emits: ["update:modelValue", "focus"], computed: { value: { get() { diff --git a/src/components/base/BaseInputWithSearch.vue b/src/components/base/BaseInputWithSearch.vue index 5ed78c6..df5607b 100644 --- a/src/components/base/BaseInputWithSearch.vue +++ b/src/components/base/BaseInputWithSearch.vue @@ -1,33 +1,51 @@ diff --git a/src/components/base/BaseSelect.vue b/src/components/base/BaseSelect.vue index 6abe91a..3300900 100644 --- a/src/components/base/BaseSelect.vue +++ b/src/components/base/BaseSelect.vue @@ -2,6 +2,7 @@ .flex.flex-col.gap-y-2 base-input-container(:label="label", :style="{width: width, ...sizeVariable}") q-select.select( + ref="selectRef" v-model="value", :options="items", :readonly="readonly" @@ -15,17 +16,13 @@ dropdown-icon="app:down-arrow", :menu-offset="[0, 8]", :use-input="useInput", + :input-debounce="inputDebounce", :placeholder="useInput && placeholder ? placeholder : ''", @filter="filterFn", :popup-content-style="popupContentStyle" ) template(v-slot:selected) - span(v-if="!value?.icon", :class="placeholderColor") {{ textSelect }} - q-icon.selected-icon( - v-else, - :name="iconSelect", - size="24px" - ) + slot(name="selected") template(v-slot:option="scope", v-if="!customOption") q-item(v-bind="scope.itemProps", style="justify-content: center", v-if="value?.icon") q-item-section(avatar, style="padding: 0px; min-width: 0px") @@ -37,9 +34,7 @@ slot( name="customOption", :props="itemProps", - :label="opt.label" - :avatar="opt.avatar", - :medcard="opt.medcard" + :data="opt" ) template(v-slot:prepend, v-if="iconLeft") slot(name="iconLeft") @@ -77,6 +72,7 @@ export default { clearable: Boolean, size: String, useInput: Boolean, + inputDebounce: Number, iconLeft: Boolean, iconRight: Boolean, customOption: Boolean, @@ -163,6 +159,11 @@ export default { }; }, }, + methods: { + updateInputValue(value, noFilter) { + this.$refs?.selectRef?.updateInputValue(value, noFilter); + }, + }, };