corretto filtro Provincia

This commit is contained in:
paoloar77
2022-02-15 13:37:33 +01:00
parent 10f10d874b
commit b869f330f7
6 changed files with 65 additions and 40 deletions

View File

@@ -27,7 +27,7 @@ export default defineComponent({
}, },
setup(props, { attrs, slots, emit }) { setup(props, { attrs, slots, emit }) {
const mytable = 'users' const mytable = 'users'
const { t } = useI18n(); const { t } = useI18n()
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
const userStore = useUserStore() const userStore = useUserStore()
@@ -36,6 +36,7 @@ export default defineComponent({
const searchList = ref(<ISearchList[]>[]) const searchList = ref(<ISearchList[]>[])
const search = ref('') const search = ref('')
const myrecfiltertoggle = ref(tools.FILTER_ALL)
const idSector = computed(() => { const idSector = computed(() => {
let myval: any = null let myval: any = null
@@ -49,6 +50,16 @@ export default defineComponent({
} }
}) })
watch(() => myrecfiltertoggle.value, (value: any, oldval: any) => {
if (value === tools.FILTER_MYREC) {
filtercustom.value = [{ userId: userStore.my._id }]
} else {
filtercustom.value = []
}
},
)
function mounted() { function mounted() {
/*arrfilterand.value = [ /*arrfilterand.value = [
{ {
@@ -59,7 +70,7 @@ export default defineComponent({
]*/ ]*/
function getFilterSkills(recSkill: any, index: number, arr: any) { function getFilterSkills(recSkill: any, index: number, arr: any) {
const recsectors:any = searchList.value.find((rec) => rec.table === 'sectors') const recsectors: any = searchList.value.find((rec) => rec.table === 'sectors')
// console.log('getFilterSkills', recSkill.idSector, recsectors.value) // console.log('getFilterSkills', recSkill.idSector, recsectors.value)
if (recsectors) { if (recsectors) {
return recSkill.idSector.includes(recsectors.value) return recSkill.idSector.includes(recsectors.value)
@@ -69,7 +80,7 @@ export default defineComponent({
} }
function getFilterSubSkills(recSubSkill: any, index: number, arr: any) { function getFilterSubSkills(recSubSkill: any, index: number, arr: any) {
const recskills:any = searchList.value.find((rec) => rec.table === 'skills') const recskills: any = searchList.value.find((rec) => rec.table === 'skills')
// console.log('recSubSkill', recSubSkill, 'recskills', recskills) // console.log('recSubSkill', recSubSkill, 'recskills', recskills)
if (recskills) { if (recskills) {
return recSubSkill.idSkill === recskills.value return recSubSkill.idSkill === recskills.value
@@ -79,7 +90,7 @@ export default defineComponent({
} }
function getFilterCitiesByProvince(recSubSkill: any, index: number, arr: any) { function getFilterCitiesByProvince(recSubSkill: any, index: number, arr: any) {
const recprov:any = searchList.value.find((rec) => rec.table === 'provinces') const recprov: any = searchList.value.find((rec) => rec.table === 'provinces')
// console.log('recSubSkill', recSubSkill, 'recskills', recskills) // console.log('recSubSkill', recSubSkill, 'recskills', recskills)
if (recprov) { if (recprov) {
return recSubSkill.idSkill === recprov.value return recSubSkill.idSkill === recprov.value
@@ -164,20 +175,6 @@ export default defineComponent({
useinput: false, useinput: false,
icon: 'far fa-id-card', icon: 'far fa-id-card',
}, },
{
label: '',
table: '',
key: '',
value: 0,
type: costanti.FieldType.separator,
arrvalue: [],
addall: true,
filter: null,
showcount: true,
useinput: false,
notinsearch: true,
icon: '',
},
/*{ /*{
label: 'Regione', label: 'Regione',
table: 'regions', table: 'regions',
@@ -225,6 +222,20 @@ export default defineComponent({
filteradv: true, filteradv: true,
//icon: 'swap_horizontal_circle', //icon: 'swap_horizontal_circle',
}, },
{
label: '',
table: '',
key: '',
value: 0,
type: costanti.FieldType.separator,
arrvalue: [],
addall: true,
filter: null,
showcount: true,
useinput: false,
notinsearch: true,
icon: '',
},
] ]
@@ -335,6 +346,7 @@ export default defineComponent({
idSector, idSector,
search, search,
doSearch, doSearch,
myrecfiltertoggle,
} }
}, },
}) })

View File

@@ -2,6 +2,18 @@
<div class="bi-border-all"> <div class="bi-border-all">
<div class="q-ma-xs q-gutter-xs q-pa-xs"> <div class="q-ma-xs q-gutter-xs q-pa-xs">
<div class="text-center">
<q-btn-toggle
v-model="myrecfiltertoggle"
push
glossy
toggle-color="primary"
:options="[
{label: 'Tutti', value: tools.FILTER_ALL},
{label: 'Personali', value: tools.FILTER_MYREC},
]"
/>
</div>
<div v-if="false" class="q-mr-sm"> <div v-if="false" class="q-mr-sm">
<q-input <q-input
v-model="search" filled dense type="search" debounce="500" :hint="t('finder.search_skill')" v-model="search" filled dense type="search" debounce="500" :hint="t('finder.search_skill')"
@@ -26,7 +38,7 @@
:nodataLabel="idSector > 0 ? 'Nessuna Competenza trovata': 'Selezionare un Settore'" :nodataLabel="idSector > 0 ? 'Nessuna Competenza trovata': 'Selezionare un Settore'"
:prop_search="true" :prop_search="true"
:finder="true" :finder="true"
:choose_visutype="true" :choose_visutype="$q.screen.gt.xs"
:butt_modif_new="false" :butt_modif_new="false"
noresultLabel="Il filtro selezionato non ha trovato nessun risultato" noresultLabel="Il filtro selezionato non ha trovato nessun risultato"
:arrfilters="arrfilterand" :arrfilters="arrfilterand"

View File

@@ -431,13 +431,23 @@ export default defineComponent({
if (searchList.value) { if (searchList.value) {
for (const item of searchList.value) { for (const item of searchList.value) {
//searchList.value.forEach((item: ISearchList) => { //searchList.value.forEach((item: ISearchList) => {
if (!item.notinsearch) { if (!item.notinsearch) {
let objitem: any = {} let objitem: any = {}
// console.log(' item ', item) // console.log(' item ', item)
if (item.value > 0) {
if (item.table === 'provinces') {
let obj: any = {}
obj['mycities.prov'] = item.value
if (item.value !== '') {
filtersearch3or.push(obj)
}
} else if (item.value > 0) {
objitem[item.key] = item.value objitem[item.key] = item.value
filtersearch.push(objitem) filtersearch.push(objitem)
} else if (item.arrvalue.length > 0) { } else if (item.arrvalue.length > 0) {
const myarr = item.arrvalue.filter((value: any) => { const myarr = item.arrvalue.filter((value: any) => {
if (typeof value === 'number') { if (typeof value === 'number') {
@@ -448,20 +458,7 @@ export default defineComponent({
let arr2: any = [] let arr2: any = []
if (item.table === 'provinces') { if (item.table !== 'provinces') {
arr2 = []
myarr.forEach((myval: any) => {
let objitem3: any = {}
objitem3['mycities.prov'] = myval
arr2.push(objitem3)
})
let obj2: any = {
$or: arr2
}
if (arr2.length > 0) {
filtersearch3or = arr2
}
} else {
myarr.forEach((myval: any) => { myarr.forEach((myval: any) => {
let objitem2: any = {} let objitem2: any = {}
objitem2[item.key] = myval objitem2[item.key] = myval

View File

@@ -106,9 +106,8 @@
<div v-if="searchList" <div v-if="searchList"
:class="$q.screen.lt.sm ? `` : `row` + ` text-blue `"> :class="$q.screen.lt.sm ? `` : `row` + ` text-blue `">
<span v-for="(item, index) in searchList" :key="index"> <span v-for="(item, index) in searchList" :key="index">
<div class="text-center" v-if="(item.type === costanti.FieldType.separator)"> <div class="text-center q-my-xs" v-if="(item.type === costanti.FieldType.separator)">
<q-btn rounded size="md" dense :icon="!showfilteradv ? 'fas fa-arrow-down' : 'fas fa-arrow-up'" label="Filtri Avanzati" @click="showfilteradv = !showfilteradv"></q-btn> <q-btn rounded flat size="sm" dense :icon="!showfilteradv ? 'fas fa-arrow-down' : 'fas fa-arrow-up'" label="Filtri Avanzati" @click="showfilteradv = !showfilteradv"></q-btn>
<q-separator class="q-my-sm"></q-separator>
</div> </div>
<CMySelect <CMySelect
@@ -235,7 +234,7 @@
<q-space></q-space> <q-space></q-space>
<q-select <q-select
v-if="mytable && pagination.rowsNumber > 0 && (prop_search || canEdit) && showCol" v-if="mytable && pagination.rowsNumber > 0 && (prop_search || canEdit) && showCol && myvertical === 0"
v-model="colVisib" v-model="colVisib"
rounded rounded
outlined outlined

View File

@@ -23,6 +23,7 @@
:input-class="myclass" :input-class="myclass"
:options="valori" :options="valori"
:option-value="optval" :option-value="optval"
options-selected-class="text-deep-blue"
class="combowidth" class="combowidth"
style="min-width: 250px" style="min-width: 250px"
> >
@@ -131,6 +132,7 @@
emit-value emit-value
stack-label stack-label
:options="valori" :options="valori"
options-selected-class="text-deep-blue"
:option-value="optval" :option-value="optval"
:option-label="optlab" :option-label="optlab"
:dense="dense"> :dense="dense">
@@ -189,7 +191,7 @@
@new-value="newvaluefuncfirst" @new-value="newvaluefuncfirst"
emit-value emit-value
input-debounce="0" input-debounce="0"
options-selected-class="text-deep-orange" options-selected-class="text-deep-blue"
map-options map-options
v-bind="$attrs" v-bind="$attrs"
class="combowidth"> class="combowidth">

View File

@@ -53,6 +53,9 @@ export const tools = {
TABBED_HOME: 't-home', TABBED_HOME: 't-home',
TABBED_NAVE: 't-nave', TABBED_NAVE: 't-nave',
FILTER_ALL: 0,
FILTER_MYREC: 1,
COOK_SEARCH: 'SEARCH_', COOK_SEARCH: 'SEARCH_',
FRIENDS_SEARCH: 'FR_SE', FRIENDS_SEARCH: 'FR_SE',