Circuit table...
This commit is contained in:
131
src/components/CMyCircuits/CMyCircuits.ts
Executable file
131
src/components/CMyCircuits/CMyCircuits.ts
Executable file
@@ -0,0 +1,131 @@
|
||||
import { CMyCircuit } from '@/components/CMyCircuit'
|
||||
import { computed, defineComponent, onMounted, PropType, ref, toRef } from 'vue'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useCircuitStore } from '@store/CircuitStore'
|
||||
import { useI18n } from '@/boot/i18n'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { costanti } from '@costanti'
|
||||
import { ICircuit, ISearchList, IUserFields } from 'model'
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { CUserNonVerif } from '@/components/CUserNonVerif'
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMyCircuits',
|
||||
components: { CMyCircuit, CUserNonVerif },
|
||||
emits: ['update:modelValue'],
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
finder: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
},
|
||||
circuit: {
|
||||
type: Object as PropType<ICircuit | null>,
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
circuitname: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
visu: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const userStore = useUserStore()
|
||||
const circuitStore = useCircuitStore()
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
|
||||
const username = ref('')
|
||||
|
||||
const filtroutente = ref(<any[]>[])
|
||||
|
||||
const listcircuitsfiltered = computed(() => {
|
||||
let arr: any[] = []
|
||||
try {
|
||||
if (props.modelValue === costanti.CIRCUITS) {
|
||||
arr = circuitStore.listcircuits
|
||||
} else if (props.modelValue === costanti.MY_USERACCOUNTS ) {
|
||||
arr = userStore.my.profile.listUserAccounts
|
||||
} else if (props.modelValue === costanti.MANAGE_CIRCUITS) {
|
||||
// arr = userStore.my.profile.manage_mycircuits
|
||||
} else if (props.modelValue === costanti.ASK_SENT_CIRCUIT) {
|
||||
arr = userStore.my.profile.asked_circuits
|
||||
}
|
||||
} catch (e) {
|
||||
arr = []
|
||||
}
|
||||
|
||||
return arr
|
||||
})
|
||||
|
||||
const myoptions = computed(() => {
|
||||
const mybutt = []
|
||||
mybutt.push({ label: t('mypages.find_circuit'), value: costanti.FIND_CIRCUIT })
|
||||
mybutt.push({ label: t('mypages.follow_circuits') + ' (' + numMyCircuits.value + ')', value: costanti.MY_USERACCOUNTS })
|
||||
// mybutt.push({ label: t('mypages.manage_my_circuits') + ' (' + numManageCircuits.value + ')', value: costanti.MANAGE_CIRCUITS })
|
||||
|
||||
|
||||
if (numAskSentCircuits.value > 0 || props.modelValue === costanti.ASK_SENT_CIRCUIT)
|
||||
mybutt.push({
|
||||
label: t('mypages.request_sent_circuits') + ' (' + numAskSentCircuits.value + ')',
|
||||
value: costanti.ASK_SENT_CIRCUIT
|
||||
})
|
||||
|
||||
|
||||
return mybutt
|
||||
})
|
||||
|
||||
|
||||
const numMyCircuits = computed(() => {
|
||||
const arr = userStore.my.profile.listUserAccounts
|
||||
return (arr) ? arr.length : 0
|
||||
})
|
||||
|
||||
const numAskSentCircuits = computed(() => {
|
||||
const arr = userStore.my.profile.asked_circuits
|
||||
return (arr) ? arr.length : 0
|
||||
})
|
||||
|
||||
async function loadCircuits() {
|
||||
// Carica il profilo di quest'utente
|
||||
if (username.value) {
|
||||
filtroutente.value = await tools.loadCircuits()
|
||||
}
|
||||
}
|
||||
|
||||
function mounted() {
|
||||
username.value = userStore.my.username
|
||||
loadCircuits()
|
||||
|
||||
}
|
||||
|
||||
function updateValue(val: number) {
|
||||
emit('update:modelValue', val)
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
tools,
|
||||
costanti,
|
||||
shared_consts,
|
||||
filtroutente,
|
||||
listcircuitsfiltered,
|
||||
updateValue,
|
||||
myoptions,
|
||||
userStore,
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user