11<template lang="pug">
2- q-card.transparent ( style ='min-width: 40vw ; max-width: 80vw ' )
2+ q-card.transparent ( style ='min-width: 45vw ; max-width: 90vw ' )
33 q-toolbar.bg-secondary.text-white ( dense flat style ='height: 32px;' )
44 q-toolbar-title
55 span {{ title }}
@@ -26,7 +26,7 @@ q-card.transparent(style='min-width: 40vw; max-width: 80vw')
2626 .flex.q-col-gutter-md
2727 q-select.col (
2828 ref ='field'
29- style ='min-width: 180px ; max-width: 220px'
29+ style ='min-width: 150px ; max-width: 220px'
3030 v-model ='filter.key'
3131 :readonly ='!!initialFilter?.field'
3232 :use-input ='!initialFilter?.field'
@@ -59,6 +59,16 @@ q-card.transparent(style='min-width: 40vw; max-width: 80vw')
5959 | Ajouter le filtre personnalisé
6060 |
6161 code <{{ inputValue }}>
62+ q-select.col-1 (
63+ style ='min-width: 120px'
64+ v-model ='fieldType'
65+ label ='Type'
66+ :options ='["text", "number", "date", "boolean", "array"]'
67+ :readonly ='!filter.key || !!columnExists(filter.key || "")'
68+ dense
69+ outlined
70+ options-dense
71+ )
6272 q-select.col-1 (
6373 style ='min-width: 130px'
6474 v-model ='filter.operator'
@@ -84,7 +94,7 @@ q-card.transparent(style='min-width: 40vw; max-width: 80vw')
8494 span {{ scope.opt.label }}
8595 q-input.col (
8696 style ='min-width: 300px'
87- v-show ="!comparator?.multiplefields && optionsMapping.length === 0"
97+ v-if ="!comparator?.multiplefields && optionsMapping.length === 0 && comparator?.querySign !== '?' "
8898 v-model ='filter.value'
8999 label ='Valeur'
90100 :prefix ="comparator?.prefix"
@@ -95,9 +105,20 @@ q-card.transparent(style='min-width: 40vw; max-width: 80vw')
95105 dense
96106 outlined
97107 )
108+ q-toggle(
109+ style ='min-width: 140px'
110+ v-if ="!comparator?.multiplefields && comparator?.querySign === '?'"
111+ v-model ="filter.value"
112+ :readonly ='!filter.operator'
113+ :label ="filter.value ? 'Positif' : 'Négatif'"
114+ true-value ="true"
115+ false-value ="false"
116+ color ="gray"
117+ dense
118+ )
98119 q-select.col (
99120 style ='min-width: 300px'
100- v-show ="!comparator?.multiplefields && optionsMapping.length > 0"
121+ v-if ="!comparator?.multiplefields && optionsMapping.length > 0"
101122 v-model ='filter.value'
102123 label ='Valeur'
103124 :prefix ="comparator?.prefix"
@@ -114,7 +135,7 @@ q-card.transparent(style='min-width: 40vw; max-width: 80vw')
114135 )
115136 q-input.col (
116137 style ='min-width: 200px'
117- v-show ="comparator?.multiplefields && comparator?.querySign === '<<'"
138+ v-if ="comparator?.multiplefields && comparator?.querySign === '<<'"
118139 v-model ="filter.min"
119140 :type ='searchInputType'
120141 :readonly ='!filter.operator'
@@ -125,7 +146,7 @@ q-card.transparent(style='min-width: 40vw; max-width: 80vw')
125146 )
126147 q-input.col (
127148 style ='min-width: 200px'
128- v-show ="comparator?.multiplefields && comparator?.querySign === '<<'"
149+ v-if ="comparator?.multiplefields && comparator?.querySign === '<<'"
129150 v-model ="filter.max"
130151 :type ='searchInputType'
131152 :readonly ='!filter.operator'
@@ -136,7 +157,7 @@ q-card.transparent(style='min-width: 40vw; max-width: 80vw')
136157 )
137158 q-select.col (
138159 style ='min-width: 300px'
139- v-show ="comparator?.multiplefields && comparator?.querySign === '@'"
160+ v-if ="comparator?.multiplefields && comparator?.querySign === '@'"
140161 v-model ="filter.items"
141162 label ="Valeur"
142163 :prefix ="comparator?.prefix"
@@ -159,7 +180,7 @@ q-card.transparent(style='min-width: 40vw; max-width: 80vw')
159180 q-space
160181 q-btn(
161182 @click ='writeFilter(filter)'
162- :disabled ='!filter.key || !filter.operator || (! filter.value && !filter.items?.length)'
183+ :disabled ='!filter.key || !filter.operator || (typeof filter.value === "undefined" && !filter.items?.length)'
163184 label ='Valider'
164185 color ='positive'
165186 icon-right ='mdi-check'
@@ -176,7 +197,7 @@ import dayjs from 'dayjs'
176197type Filter = {
177198 operator: string
178199 key: string | undefined
179- value: string | number | undefined
200+ value: string | number | boolean | undefined
180201
181202 min? : string
182203 max? : string
@@ -344,20 +365,21 @@ export default defineNuxtComponent({
344365 }
345366 },
346367 computed: {
347- comparator(): { label: string ; value: string ; prefix? : string ; suffix? : string ; multiplefields? : boolean } | undefined {
368+ comparator(): { label: string ; value: string ; prefix? : string ; suffix? : string ; multiplefields? : boolean ; type ? : string [] } | undefined {
348369 return this .comparatorTypes .find ((comp ) => comp .value === this .filter .operator )
349370 },
350371 searchInputType(): string {
351- if (this .fieldType === undefined || this .fieldType === null ) return ' text'
352- return this .fieldType
372+ if (! this .fieldType ) {
373+ return this .comparator ?.type ? this .comparator .type [0 ] : ' text'
374+ }
375+
376+ return this .fieldType || ' text'
353377 },
354378 availableComparators(): { label: string ; value: string ; prefix? : string ; suffix? : string ; multiplefields? : boolean }[] {
355- if (! this .columnExists (this .filter .key || ' ' )) {
356- return this .comparatorTypes
379+ if (! this .columnExists (this .filter .key || ' ' ) && ! this . fieldType ) {
380+ return this .comparatorTypes || []
357381 }
358382
359- if (this .fieldType === undefined || this .fieldType === null ) return []
360-
361383 return this .comparatorTypes .filter ((comparator ) => {
362384 return comparator .type .includes (this .fieldType ! )
363385 })
0 commit comments