Circuit table...
This commit is contained in:
214
src/views/user/mycircuit/mycircuit.ts
Executable file
214
src/views/user/mycircuit/mycircuit.ts
Executable file
@@ -0,0 +1,214 @@
|
||||
import { CGridTableRec } from '@/components/CGridTableRec'
|
||||
import { CMyFriends } from '@/components/CMyFriends'
|
||||
import { CMyUser } from '@/components/CMyUser'
|
||||
import { CTitleBanner } from '@/components/CTitleBanner'
|
||||
import { CProfile } from '@/components/CProfile'
|
||||
import { CCheckIfIsLogged } from '@/components/CCheckIfIsLogged'
|
||||
import { CMyFieldRec } from '@/components/CMyFieldRec'
|
||||
import { CSkill } from '@/components/CSkill'
|
||||
import { CDateTime } from '@/components/CDateTime'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { computed, defineComponent, onMounted, ref, watch } from 'vue'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { useI18n } from '@/boot/i18n'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { costanti } from '@costanti'
|
||||
import { ICity, IFriends, ICircuit, ISearchList, IUserFields } from 'model'
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
import { colmyUserPeople, colmyUserCircuit } from '@store/Modules/fieldsTable'
|
||||
import { useNotifStore } from '@store/NotifStore'
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: 'mycircuit',
|
||||
components: { CProfile, CTitleBanner, CMyFieldRec, CSkill, CDateTime, CMyFriends, CGridTableRec, CMyUser, CCheckIfIsLogged },
|
||||
props: {},
|
||||
setup() {
|
||||
const userStore = useUserStore()
|
||||
const notifStore = useNotifStore()
|
||||
const $route = useRoute()
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
|
||||
const animation = ref('fade')
|
||||
|
||||
const name = computed(() => $route.params.name ? $route.params.name.toString() : '')
|
||||
const idnotif = computed(() => $route.query.idnotif ? $route.query.idnotif.toString() : '')
|
||||
|
||||
const filtroutente = ref(<any[]>[])
|
||||
const showPic = ref(false)
|
||||
|
||||
const circuit = ref(<ICircuit|null>{})
|
||||
const mystatus = ref(<number>0)
|
||||
const users_in_circuit = ref(<IFriends[]>[])
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const tabgrp = ref('info')
|
||||
const tabmembers = ref('all')
|
||||
const tab = ref('membri')
|
||||
|
||||
const arrfilterand: any = ref([])
|
||||
const filtercustom: any = ref([])
|
||||
const filtercustom_rich: any = ref([])
|
||||
const searchList = ref(<ISearchList[]>[])
|
||||
|
||||
const cities = ref(<ICity[]>[])
|
||||
|
||||
function profile() {
|
||||
return userStore.my.profile
|
||||
}
|
||||
|
||||
function circuitname() {
|
||||
return userStore.my.username
|
||||
}
|
||||
|
||||
async function loadCircuit() {
|
||||
// Carica il profilo di quest'utente
|
||||
if (name.value) {
|
||||
await userStore.loadCIrcuit(name.value, idnotif.value).then(({ data, status }: {data: any, status: number}) => {
|
||||
console.log('data', data)
|
||||
if (data) {
|
||||
circuit.value = data.circuit
|
||||
cities.value = data.cities
|
||||
notifStore.setAsRead(idnotif.value)
|
||||
users_in_circuit.value = data.users_in_circuit
|
||||
} else {
|
||||
circuit.value = null
|
||||
users_in_circuit.value = []
|
||||
}
|
||||
|
||||
mystatus.value = status
|
||||
|
||||
loading.value = false
|
||||
// filtroutente.value = [{ userId: userStore.my._id }]
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => name.value, (to: any, from: any) => {
|
||||
loadCircuit()
|
||||
})
|
||||
|
||||
async function mounted() {
|
||||
loading.value = true
|
||||
await loadCircuit()
|
||||
|
||||
searchList.value = []
|
||||
filtercustom.value = [{ 'profile.mycircuits': { $elemMatch: {name: {$eq: name.value }} } } ]
|
||||
|
||||
arrfilterand.value = []
|
||||
filtercustom_rich.value = []
|
||||
//++TODO: sistemare la filtercustom ... richieste...
|
||||
}
|
||||
|
||||
function getImgGrp() {
|
||||
if (circuit.value)
|
||||
return userStore.getImgByCircuit(circuit.value)
|
||||
else
|
||||
return ''
|
||||
}
|
||||
|
||||
function checkifShow(col: string) {
|
||||
//++Todo: checkifShow Permessi !
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function extraparams() {
|
||||
let lk_tab = 'users'
|
||||
let lk_LF = 'userId'
|
||||
let lk_FF = '_id'
|
||||
let lk_as = 'user'
|
||||
let af_objId_tab = 'myId'
|
||||
|
||||
return {
|
||||
lookup1: {
|
||||
lk_tab,
|
||||
lk_LF,
|
||||
lk_FF,
|
||||
lk_as,
|
||||
af_objId_tab,
|
||||
lk_proj: {
|
||||
'username': 1,
|
||||
'profile.img': 1,
|
||||
'profile.mycircuits': 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function extraparams_rich() {
|
||||
return {
|
||||
querytype: shared_consts.QUERYTYPE_CIRCUIT,
|
||||
myid: circuit.value ? circuit.value._id : '',
|
||||
}
|
||||
}
|
||||
|
||||
function extraparams_refused() {
|
||||
return {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function numUsers() {
|
||||
return users_in_circuit.value ? users_in_circuit.value.length : 0
|
||||
}
|
||||
function numAdmins() {
|
||||
return (circuit.value && circuit.value.admins) ? circuit.value.admins.length : 0
|
||||
}
|
||||
function listaAdmins() {
|
||||
return (circuit.value && circuit.value.admins) ? circuit.value.admins.map((rec) => rec.username).join(', ') : ''
|
||||
}
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
name,
|
||||
profile,
|
||||
tools,
|
||||
costanti,
|
||||
circuit,
|
||||
shared_consts,
|
||||
getImgGrp,
|
||||
checkifShow,
|
||||
|
||||
filtroutente,
|
||||
showPic,
|
||||
circuitname,
|
||||
userStore,
|
||||
t,
|
||||
animation,
|
||||
arrfilterand,
|
||||
filtercustom,
|
||||
filtercustom_rich,
|
||||
searchList,
|
||||
colmyUserPeople,
|
||||
colmyUserCircuit,
|
||||
extraparams,
|
||||
extraparams_rich,
|
||||
extraparams_refused,
|
||||
tab,
|
||||
tabgrp,
|
||||
tabmembers,
|
||||
numUsers,
|
||||
numAdmins,
|
||||
listaAdmins,
|
||||
users_in_circuit,
|
||||
loading,
|
||||
mystatus,
|
||||
cities,
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user