From b869f330f754ab830489a1cb8f30ea72aacd3a1b Mon Sep 17 00:00:00 2001 From: paoloar77 Date: Tue, 15 Feb 2022 13:37:33 +0100 Subject: [PATCH] corretto filtro Provincia --- src/components/CFinder/CFinder.ts | 48 ++++++++++++------- src/components/CFinder/CFinder.vue | 14 +++++- src/components/CGridTableRec/CGridTableRec.ts | 29 +++++------ .../CGridTableRec/CGridTableRec.vue | 7 ++- src/components/CMySelect/CMySelect.vue | 4 +- src/store/Modules/tools.ts | 3 ++ 6 files changed, 65 insertions(+), 40 deletions(-) diff --git a/src/components/CFinder/CFinder.ts b/src/components/CFinder/CFinder.ts index 277e11ab..52e8a27a 100755 --- a/src/components/CFinder/CFinder.ts +++ b/src/components/CFinder/CFinder.ts @@ -27,7 +27,7 @@ export default defineComponent({ }, setup(props, { attrs, slots, emit }) { const mytable = 'users' - const { t } = useI18n(); + const { t } = useI18n() const globalStore = useGlobalStore() const userStore = useUserStore() @@ -36,6 +36,7 @@ export default defineComponent({ const searchList = ref([]) const search = ref('') + const myrecfiltertoggle = ref(tools.FILTER_ALL) const idSector = computed(() => { 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() { /*arrfilterand.value = [ { @@ -59,7 +70,7 @@ export default defineComponent({ ]*/ 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) if (recsectors) { return recSkill.idSector.includes(recsectors.value) @@ -69,7 +80,7 @@ export default defineComponent({ } 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) if (recskills) { return recSubSkill.idSkill === recskills.value @@ -79,7 +90,7 @@ export default defineComponent({ } 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) if (recprov) { return recSubSkill.idSkill === recprov.value @@ -164,20 +175,6 @@ export default defineComponent({ useinput: false, 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', table: 'regions', @@ -225,6 +222,20 @@ export default defineComponent({ filteradv: true, //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, search, doSearch, + myrecfiltertoggle, } }, }) diff --git a/src/components/CFinder/CFinder.vue b/src/components/CFinder/CFinder.vue index b6ca5f81..670cbbf5 100755 --- a/src/components/CFinder/CFinder.vue +++ b/src/components/CFinder/CFinder.vue @@ -2,6 +2,18 @@
+
+ +
{ if (!item.notinsearch) { let objitem: any = {} // 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 - filtersearch.push(objitem) + filtersearch.push(objitem) + } else if (item.arrvalue.length > 0) { const myarr = item.arrvalue.filter((value: any) => { if (typeof value === 'number') { @@ -448,20 +458,7 @@ export default defineComponent({ let arr2: any = [] - 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 { + if (item.table !== 'provinces') { myarr.forEach((myval: any) => { let objitem2: any = {} objitem2[item.key] = myval diff --git a/src/components/CGridTableRec/CGridTableRec.vue b/src/components/CGridTableRec/CGridTableRec.vue index 75ade052..24fec33b 100755 --- a/src/components/CGridTableRec/CGridTableRec.vue +++ b/src/components/CGridTableRec/CGridTableRec.vue @@ -106,9 +106,8 @@
-
- - +
+
@@ -131,6 +132,7 @@ emit-value stack-label :options="valori" + options-selected-class="text-deep-blue" :option-value="optval" :option-label="optlab" :dense="dense"> @@ -189,7 +191,7 @@ @new-value="newvaluefuncfirst" emit-value input-debounce="0" - options-selected-class="text-deep-orange" + options-selected-class="text-deep-blue" map-options v-bind="$attrs" class="combowidth"> diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index d5358c72..2f66f2fc 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -53,6 +53,9 @@ export const tools = { TABBED_HOME: 't-home', TABBED_NAVE: 't-nave', + FILTER_ALL: 0, + FILTER_MYREC: 1, + COOK_SEARCH: 'SEARCH_', FRIENDS_SEARCH: 'FR_SE',