- sistemati i filtri per tabella

- corretto le preferenze dell'ospitalità
This commit is contained in:
Surya Paolo
2024-02-19 15:34:47 +01:00
parent 473ea72e80
commit e1bc367418
8 changed files with 115 additions and 88 deletions

View File

@@ -399,7 +399,7 @@ export default defineComponent({
const getNumRecFromQuery = computed(() => () => {
return serverData.value.length
return serverData.value.length
})
const valoriopt = computed(() => (item: any, addall?: boolean, addnone?: boolean) => {
// console.log('valoriopt', item.table)
@@ -508,11 +508,11 @@ export default defineComponent({
const recSector = searchList.value.find((rec) => rec.table === tabsector)
if (recSector)
tools.setCookie(tools.COOK_SEARCH + tabsector, newval)
tools.setCookie(tools.COOK_SEARCH + costanti.FILTER_SEP + mytable.value + costanti.FILTER_SEP + tabsector, newval)
for (const item of searchList.value) {
if (item.table === tablecat) {
const valsaved = tools.getCookie(tools.COOK_SEARCH + tablecat + '_' + newval, costanti.FILTER_TUTTI)
const valsaved = tools.getCookie(tools.COOK_SEARCH + costanti.FILTER_SEP + mytable.value + costanti.FILTER_SEP + item.table + costanti.FILTER_SEP + newval, costanti.FILTER_TUTTI)
const rec = searchList.value.find((myrec) => myrec.table === tablecat) // check if exist
let trovato = false
let arrvalues = []
@@ -539,11 +539,11 @@ export default defineComponent({
const recRegion = searchList.value.find((rec) => rec.table === tabregion)
if (recRegion)
tools.setCookie(tools.COOK_SEARCH + tabregion, newval)
tools.setCookie(tools.COOK_SEARCH + costanti.FILTER_SEP + mytable.value + costanti.FILTER_SEP + tabregion, newval)
for (const item of searchList.value) {
if (item.table === tableprov) {
const valsaved = tools.getCookie(tools.COOK_SEARCH + tableprov + '_' + newval, costanti.FILTER_TUTTI)
const valsaved = tools.getCookie(tools.COOK_SEARCH + costanti.FILTER_SEP + mytable.value + costanti.FILTER_SEP + tableprov + costanti.FILTER_SEP + newval, costanti.FILTER_TUTTI)
const rec = searchList.value.find((myrec) => myrec.table === tableprov) // check if exist
let trovato = false
let arrvalues = []
@@ -561,7 +561,7 @@ export default defineComponent({
}
}
} else if (item.table === toolsext.TABCITIES) {
const valsaved = tools.getCookie(tools.COOK_SEARCH + toolsext.TABCITIES + '_' + newval, costanti.FILTER_TUTTI)
const valsaved = tools.getCookie(tools.COOK_SEARCH + costanti.FILTER_SEP + mytable.value + costanti.FILTER_SEP + item.table + costanti.FILTER_SEP + newval, costanti.FILTER_TUTTI)
const rec = searchList.value.find((myrec) => myrec.table === toolsext.TABCITIES) // check if exist
let trovato = false
let arrvalues = []
@@ -588,9 +588,9 @@ export default defineComponent({
}
function searchval(newval: any, table: any) {
console.log('REFRR searchval', newval, table)
console.log('REFRR searchval', newval, table, 'mytable', mytable.value)
const myrecfilt = searchList.value.find((rec) => rec.table === table)
let keycookie = tools.COOK_SEARCH + table
let keycookie = tools.COOK_SEARCH + costanti.FILTER_SEP + mytable.value + costanti.FILTER_SEP + table
if (myrecfilt && myrecfilt.keycookie)
keycookie += myrecfilt.keycookie
tools.setCookie(keycookie, newval)
@@ -598,7 +598,7 @@ export default defineComponent({
if (table === toolsext.TABSKILLS) {
const recSector = searchList.value.find((rec) => rec.table === 'sectors')
if (recSector) {
tools.setCookie(tools.COOK_SEARCH + table + '_' + recSector.value, newval)
tools.setCookie(tools.COOK_SEARCH + costanti.FILTER_SEP + mytable.value + costanti.FILTER_SEP + recSector.value, newval)
}
} else if (table === toolsext.TABSECTORS) {
setCategBySector(toolsext.TABSKILLS, table, newval)
@@ -609,7 +609,7 @@ export default defineComponent({
} else if (table === toolsext.TABGOODS) {
const recSector = searchList.value.find((rec) => rec.table === toolsext.TABSECTORGOODS)
if (recSector) {
tools.setCookie(tools.COOK_SEARCH + table + '_' + recSector.value, newval)
tools.setCookie(tools.COOK_SEARCH + costanti.FILTER_SEP + mytable.value + costanti.FILTER_SEP + table + costanti.FILTER_SEP + recSector.value, newval)
}
// setCategBySector('sectorgoods', table, newval)
} else if (table === toolsext.TABCITIES) {
@@ -850,7 +850,6 @@ export default defineComponent({
} else if (item.arrvalue.length > 0) {
const myarr = item.arrvalue.filter((value: any) => {
if (typeof value === 'number') {
return value > 0
@@ -861,17 +860,33 @@ export default defineComponent({
const arr2: any = []
if (item.table !== 'provinces') {
myarr.forEach((myval: any) => {
const objitem2: any = {}
objitem2[item.key] = myval
arr2.push(objitem2)
})
if (shared_consts.COL_WITH_ARRFILTER_IN_AND.includes(item.key)) {
myarr.forEach((myval: any) => {
const objitem2: any = {}
objitem2[item.key] = myval
arr2.push(objitem2)
})
const obj2: any = {
$or: arr2
}
if (arr2.length > 0) {
filtersearch.push(obj2)
const obj2: any = {
$and: arr2
}
if (arr2.length > 0) {
filtersearch.push(obj2)
}
} else {
myarr.forEach((myval: any) => {
const objitem2: any = {}
objitem2[item.key] = myval
arr2.push(objitem2)
})
const obj2: any = {
$or: arr2
}
if (arr2.length > 0) {
filtersearch.push(obj2)
}
}
}