|
1 | 1 | <template lang="pug"> |
2 | 2 | .row.q-gutter-sm.items-center.q-mt-sm |
3 | | - //- .col.col-md-2 |
4 | | - //- q-select(:options="fieldTypes" label="Type de champ" v-model="fieldType" clearable @update:model-value="clearFields(['field', 'comparator'])") |
5 | | - .col.col-md-2 |
6 | | - q-select(:options="fields" label="Champs" v-model="field" clearable @update:model-value="onFieldChange($event)") |
7 | | - .col.col-md-2 |
8 | | - q-select(:options="comparatorFilteredByType" label="Comparateurs" v-model="comparator" clearable @update:model-value="clearFields([])" :disable="isFieldDisabled.comparator") |
9 | | - template(v-slot:selected-item="scope") |
10 | | - q-icon(:name="scope.opt.icon" size="xs") |
11 | | - template(v-slot:option="scope") |
12 | | - q-item(v-bind="scope.itemProps") |
13 | | - q-item-section(avatar) |
14 | | - q-icon(:name="scope.opt.icon") |
15 | | - q-item-section |
16 | | - q-item-label |
17 | | - span {{ scope.opt.label }} |
18 | | - |
19 | | - .col-12.col-md-2(v-show="!comparator?.multiplefields") |
20 | | - q-input(v-model="search" label="Rechercher" clearable :type="searchInputType" :disable="isFieldDisabled.search" :prefix="comparator?.prefix" :suffix="comparator?.suffix") |
21 | | - .col-6.col-md-2(v-show="comparator?.multiplefields") |
22 | | - q-input(v-model="searchMin" label="Min" clearable :type="searchInputType" :disable="isFieldDisabled.search" ) |
23 | | - .col-6.col-md-2(v-show="comparator?.multiplefields") |
24 | | - q-input(v-model="searchMax" label="Max" clearable :type="searchInputType" :disable="isFieldDisabled.search" ) |
25 | | - .col-12.col-md-1 |
26 | | - q-btn(color="primary" @click="addFilter" :disable="isFieldDisabled.addButton") Ajouter |
27 | | - q-space |
28 | | - .col-12.col-md-2 |
29 | | - tk-SearchfiltersRightSelect(ref="rightSelect") |
| 3 | + //- .col.col-md-2 |
| 4 | + //- q-select(:options="fieldTypes" label="Type de champ" v-model="fieldType" clearable @update:model-value="clearFields(['field', 'comparator'])") |
| 5 | + .col.col-md-2 |
| 6 | + q-select(:options="fields" label="Champs" v-model="field" clearable @update:model-value="onFieldChange($event)") |
| 7 | + .col.col-md-2 |
| 8 | + q-select(:options="comparatorFilteredByType" label="Comparateurs" v-model="comparator" clearable @update:model-value="clearFields([])" :disable="isFieldDisabled.comparator") |
| 9 | + template(v-slot:selected-item="scope") |
| 10 | + q-icon(:name="scope.opt.icon" size="xs") |
| 11 | + template(v-slot:option="scope") |
| 12 | + q-item(v-bind="scope.itemProps") |
| 13 | + q-item-section(avatar) |
| 14 | + q-icon(:name="scope.opt.icon") |
| 15 | + q-item-section |
| 16 | + q-item-label |
| 17 | + span {{ scope.opt.label }} |
| 18 | + |
| 19 | + .col-12.col-md-2(v-show="!comparator?.multiplefields") |
| 20 | + q-input(v-model="search" label="Rechercher" clearable :type="searchInputType" :disable="isFieldDisabled.search" :prefix="comparator?.prefix" :suffix="comparator?.suffix") |
| 21 | + .col-6.col-md-2(v-show="comparator?.multiplefields") |
| 22 | + q-input(v-model="searchMin" label="Min" clearable :type="searchInputType" :disable="isFieldDisabled.search" ) |
| 23 | + .col-6.col-md-2(v-show="comparator?.multiplefields") |
| 24 | + q-input(v-model="searchMax" label="Max" clearable :type="searchInputType" :disable="isFieldDisabled.search" ) |
| 25 | + .col-12.col-md-1 |
| 26 | + q-btn(color="primary" @click="addFilter" :disable="isFieldDisabled.addButton") Ajouter |
| 27 | + q-space |
| 28 | + .col-12.col-md-2 |
| 29 | + tk-SearchfiltersRightSelect(ref="rightSelect") |
30 | 30 | </template> |
31 | 31 |
|
32 | 32 | <script lang="ts" setup> |
33 | 33 | import { ref, computed, inject } from 'vue' |
34 | 34 | import { useRouter, useRoute } from 'nuxt/app' |
35 | 35 | import { useDayjs } from '#imports'; |
| 36 | +import { pushQuery } from '~/composables' |
36 | 37 | import type { Filter, Field, Comparator, SearchFilter } from '~/types' |
37 | 38 | const dayjs = useDayjs() |
38 | 39 |
|
@@ -95,11 +96,11 @@ const addFilter = async () => { |
95 | 96 | if (!searchFilter) return |
96 | 97 | if (searchFilter.comparator.multiplefields) { |
97 | 98 | for (const { key, value } of parseMultipleFilter(searchFilter)) { |
98 | | - await pushQuery(key, value) |
| 99 | + await pushQuery({ key, value }) |
99 | 100 | } |
100 | 101 | } else { |
101 | 102 | const { key, value } = parseSimpleFilter(searchFilter) |
102 | | - await pushQuery(key, value) |
| 103 | + await pushQuery({ key, value }) |
103 | 104 | } |
104 | 105 | } |
105 | 106 |
|
@@ -130,15 +131,15 @@ const parseMultipleFilter = (searchFilter: SearchFilter) => { |
130 | 131 | return [min, max] |
131 | 132 | } |
132 | 133 |
|
133 | | -const pushQuery = async (key: string, value: string) => { |
134 | | - const query = { |
135 | | - ...route.query, |
136 | | - } |
137 | | - query[key] = value |
138 | | - await router.push({ |
139 | | - query |
140 | | - }) |
141 | | -} |
| 134 | +// const pushQuery = async (key: string, value: string) => { |
| 135 | +// const query = { |
| 136 | +// ...route.query, |
| 137 | +// } |
| 138 | +// query[key] = value |
| 139 | +// await router.push({ |
| 140 | +// query |
| 141 | +// }) |
| 142 | +// } |
142 | 143 |
|
143 | 144 | const getSearchFilter = computed(() => { |
144 | 145 | if (field.value === undefined || field.value === null) return null |
|
0 commit comments