Files
myprojplanet_vite/src/views/user/myfriends/myfriends.ts

108 lines
3.0 KiB
TypeScript
Raw Normal View History

import { CMyFriends } from '@/components/CMyFriends'
2022-01-12 00:38:31 +01:00
import { CGridTableRec } from '@/components/CGridTableRec'
2022-01-05 19:11:47 +01:00
import { tools } from '@store/Modules/tools'
import { computed, defineComponent, onMounted, ref, watch } from 'vue'
2022-01-05 19:11:47 +01:00
import { useUserStore } from '@store/UserStore'
import { useRoute, useRouter } from 'vue-router'
import { useGlobalStore } from '@store/globalStore'
2022-01-05 19:11:47 +01:00
import { useI18n } from '@/boot/i18n'
import { colmyUserPeople } from '@store/Modules/fieldsTable'
import { ISearchList } from 'model'
2022-01-05 19:11:47 +01:00
import { costanti } from '@costanti'
import { shared_consts } from '@/common/shared_vuejs'
import { toolsext } from '@store/Modules/toolsext'
2022-01-05 19:11:47 +01:00
export default defineComponent({
name: 'myfriends',
components: { CMyFriends, CGridTableRec },
2022-01-05 19:11:47 +01:00
props: {},
setup() {
const userStore = useUserStore()
const $route = useRoute()
const { t } = useI18n()
2022-01-12 00:38:31 +01:00
const arrfilterand: any = ref([])
const filtercustom: any = ref([])
const searchList = ref(<ISearchList[]>[])
const filter = ref(costanti.FIND_PEOPLE)
2022-01-12 00:38:31 +01:00
function mounted() {
console.log('mounted')
searchList.value = [
{
label: 'Regione',
table: 'regions',
key: 'idReg',
type: costanti.FieldType.select,
value: tools.getCookie(tools.COOK_SEARCH + 'regions', costanti.FILTER_TUTTI),
addall: true,
arrvalue: [],
filter: null,
useinput: false,
icon: 'fas fa-globe-europe'
},
{
label: 'Provincia',
table: 'provinces',
key: 'profile.resid_province',
type: costanti.FieldType.select,
value: tools.getCookie(tools.COOK_SEARCH + 'resid_provinces', costanti.FILTER_TUTTI),
addall: true,
arrvalue: [],
filter: getFilterProvinceByRegion,
useinput: true,
icon: 'flag',
tablesel: 'provinces',
},
]
2022-01-12 00:38:31 +01:00
filtercustom.value = []
arrfilterand.value = []
2022-08-17 00:36:30 +02:00
const filt_loaded = tools.getCookie(tools.COOK_SEARCH + tools.FRIENDS_SEARCH, costanti.FIND_PEOPLE, true)
filter.value = filt_loaded ? filt_loaded : costanti.FIND_PEOPLE
2022-01-12 00:38:31 +01:00
}
watch(() => filter.value, (newval: any, oldval) => {
tools.setCookie(tools.COOK_SEARCH + tools.FRIENDS_SEARCH, newval)
})
2022-01-12 00:38:31 +01:00
function extraparams() {
let lk_tab = 'users'
let lk_LF = 'userId'
let lk_FF = '_id'
let lk_as = 'user'
let af_objId_tab = 'myId'
return {
}
}
function getFilterProvinceByRegion(recProvince: any, index: number, arr: any) {
const recreg: any = searchList.value.find((rec) => rec.table === 'regions')
if (recreg) {
return recProvince.reg === recreg.value
} else {
return true
}
}
2022-01-05 19:11:47 +01:00
onMounted(mounted)
return {
filter,
2022-01-05 19:11:47 +01:00
costanti,
2022-01-12 00:38:31 +01:00
shared_consts,
arrfilterand,
filtercustom,
searchList,
colmyUserPeople,
extraparams,
getFilterProvinceByRegion,
2022-01-05 19:11:47 +01:00
}
}
})