Skip to content

Commit

Permalink
24.06.37: filter-search.vue search opts hint and validation [WTEL-4539]
Browse files Browse the repository at this point in the history
  • Loading branch information
dlohvinov committed May 30, 2024
1 parent 91930ce commit c99293a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webitel/ui-sdk",
"version": "24.6.35",
"version": "24.6.37",
"private": false,
"scripts": {
"dev": "vite",
Expand Down
17 changes: 17 additions & 0 deletions src/modules/Filters/components/filter-search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<wt-search-bar
:search-mode="multisearch && filterName"
:search-mode-options="multisearch && searchModeOpts"
:hint="multisearch && currentSearchMode.hint"
:value="localValue"
:v="multisearch && v$"
class="filter-search"
@input="localValue = $event"
@search="setValue({ name: filterName, value: localValue })"
Expand All @@ -11,6 +13,7 @@
</template>

<script setup>
import { useVuelidate } from '@vuelidate/core';
import { computed, ref, watch } from 'vue';
import { useStore } from 'vuex';
import FilterEvent from '../enums/FilterEvent.enum.js';
Expand Down Expand Up @@ -46,10 +49,24 @@ function setValue(payload) {
const filterName = ref(props.multisearch ? props.searchModeOpts[0].value : props.name);
const currentSearchMode = computed(
() => props.searchModeOpts.find(({ value }) => value === filterName.value),
);
const filterValue = computed(() => getValue(filterName.value));
const localValue = ref(filterValue.value);
const v$ = props.multisearch && useVuelidate(computed(() => {
return {
localValue: {
...currentSearchMode.value.v || {},
},
};
}), { localValue }, { $autoDirty: true });
v$.value.$touch();
async function changeMode({ value }, { clearValue = true } = {}) {
if (clearValue) await setValue({ name: filterName.value, value: '' });
filterName.value = value;
Expand Down

0 comments on commit c99293a

Please sign in to comment.