- Fare LISTA MOVIMENTI più comprensibile
- Grafica Circuiti
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { CMyCircuit } from '@/components/CMyCircuit'
|
||||
import { computed, defineComponent, onMounted, PropType, ref, toRef } from 'vue'
|
||||
import { computed, defineComponent, onMounted, PropType, ref, toRef, watch } from 'vue'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { useCircuitStore } from '@store/CircuitStore'
|
||||
import { useI18n } from '@/boot/i18n'
|
||||
import { useQuasar } from 'quasar'
|
||||
@@ -9,12 +10,14 @@ import { ICircuit, ISearchList, IUserFields } from 'model'
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { CUserNonVerif } from '@/components/CUserNonVerif'
|
||||
import { CMyCircuits } from '@/components/CMyCircuits'
|
||||
import { CTitleBanner } from '@/components/CTitleBanner'
|
||||
import { CMovements } from '@/components/CMovements'
|
||||
import { CSendRISTo } from '@/components/CSendRISTo'
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CMyCircuits',
|
||||
components: { CMyCircuit, CUserNonVerif },
|
||||
components: { CMyCircuit, CUserNonVerif, CTitleBanner, CMovements, CSendRISTo },
|
||||
emits: ['update:modelValue'],
|
||||
props: {
|
||||
modelValue: {
|
||||
@@ -59,12 +62,32 @@ export default defineComponent({
|
||||
const { t } = useI18n()
|
||||
|
||||
const username = ref('')
|
||||
const visu = ref(0)
|
||||
const numtransaz = ref(0)
|
||||
const finishloading = ref(false)
|
||||
const loadingvalues = ref(false)
|
||||
|
||||
const init = ref(false)
|
||||
|
||||
const globalStore = useGlobalStore()
|
||||
const isfinishLoadingSite = computed(() => globalStore.finishLoading)
|
||||
|
||||
const filtroutente = ref(<any[]>[])
|
||||
|
||||
const nummovTodownload = ref(5)
|
||||
|
||||
const listcircuitsfind = computed(() => {
|
||||
// console.log('list modif')
|
||||
return updateListCircuit(costanti.FIND_CIRCUIT)
|
||||
})
|
||||
const listcircuitsmy = computed(() => {
|
||||
// console.log('list modif')
|
||||
return updateListCircuit(costanti.MY_CIRCUITS)
|
||||
})
|
||||
|
||||
const listcircuitsfiltered = computed(() => {
|
||||
// console.log('list modif')
|
||||
return updateListCircuit()
|
||||
return updateListCircuit(visu.value)
|
||||
})
|
||||
|
||||
const myoptions = computed(() => {
|
||||
@@ -73,7 +96,7 @@ export default defineComponent({
|
||||
mybutt.push({ label: t('mypages.find_circuit'), value: costanti.FIND_CIRCUIT })
|
||||
|
||||
|
||||
if (numAskSentCircuits.value > 0 || props.modelValue === costanti.ASK_SENT_CIRCUIT)
|
||||
if (numAskSentCircuits.value > 0 || visu.value === costanti.ASK_SENT_CIRCUIT)
|
||||
mybutt.push({
|
||||
label: t('mypages.request_sent') + ' (' + numAskSentCircuits.value + ')',
|
||||
value: costanti.ASK_SENT_CIRCUIT
|
||||
@@ -94,28 +117,32 @@ export default defineComponent({
|
||||
return (arr) ? arr.length : 0
|
||||
})
|
||||
|
||||
async function loadCircuits() {
|
||||
watch(() => globalStore.finishLoading, async (to: any, from: any) => {
|
||||
load()
|
||||
})
|
||||
|
||||
async function loadCircuits(nummovTodownload: number) {
|
||||
// Carica il profilo di quest'utente
|
||||
if (username.value) {
|
||||
filtroutente.value = await tools.loadCircuits()
|
||||
filtroutente.value = await tools.loadCircuits(nummovTodownload)
|
||||
}
|
||||
}
|
||||
|
||||
function updateListCircuit() {
|
||||
function updateListCircuit(visu: number) {
|
||||
let arr: any[] = []
|
||||
try {
|
||||
if (props.modelValue === costanti.CIRCUITS) {
|
||||
if (visu === costanti.CIRCUITS) {
|
||||
arr = circuitStore.listcircuits
|
||||
} else if (props.modelValue === costanti.MY_CIRCUITS) {
|
||||
} else if (visu === costanti.MY_CIRCUITS) {
|
||||
arr = circuitStore.listcircuits.filter((circ: any) => userStore.my.profile.mycircuits.findIndex((rec: any) => circ.name === rec.circuitname) >= 0)
|
||||
} else if (props.modelValue === costanti.ASK_SENT_CIRCUIT) {
|
||||
} else if (visu === costanti.ASK_SENT_CIRCUIT) {
|
||||
arr = userStore.my.profile.asked_circuits
|
||||
}
|
||||
} catch (e) {
|
||||
arr = []
|
||||
}
|
||||
|
||||
if (props.modelValue === costanti.MY_CIRCUITS) {
|
||||
if (visu === costanti.MY_CIRCUITS) {
|
||||
const arrtoinsert: any = circuitStore.listcircuits.filter((circ: any) => circ.showAlways)
|
||||
for (const rec of arrtoinsert) {
|
||||
if (arr.findIndex(myrec => myrec._id === rec._id) < 0) {
|
||||
@@ -129,10 +156,18 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
|
||||
async function mounted() {
|
||||
async function load() {
|
||||
if (init.value)
|
||||
return // Gia inizializzato
|
||||
|
||||
// console.log(' ## INIZIO MOUNT ')
|
||||
username.value = userStore.my.username
|
||||
await loadCircuits()
|
||||
visu.value = props.modelValue
|
||||
|
||||
await loadCircuits(nummovTodownload.value)
|
||||
|
||||
finishloading.value = true
|
||||
init.value = true
|
||||
// console.log(' -- FINE MOUNT ')
|
||||
}
|
||||
|
||||
@@ -140,6 +175,35 @@ export default defineComponent({
|
||||
emit('update:modelValue', val)
|
||||
}
|
||||
|
||||
function togglevisu() {
|
||||
if (visu.value !== costanti.FIND_CIRCUIT) {
|
||||
visu.value = costanti.FIND_CIRCUIT
|
||||
} else {
|
||||
visu.value = costanti.MY_CIRCUITS
|
||||
}
|
||||
}
|
||||
function movcaricati(params: any) {
|
||||
if (params.numtransaz) {
|
||||
numtransaz.value = params.numtransaz
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function mounted() {
|
||||
if (globalStore.finishLoading) {
|
||||
load()
|
||||
}
|
||||
}
|
||||
|
||||
async function addlastmov() {
|
||||
nummovTodownload.value += 5
|
||||
|
||||
loadingvalues.value = true
|
||||
await loadCircuits(nummovTodownload.value)
|
||||
loadingvalues.value = false
|
||||
}
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -153,6 +217,16 @@ export default defineComponent({
|
||||
userStore,
|
||||
circuitStore,
|
||||
username,
|
||||
t,
|
||||
visu,
|
||||
listcircuitsfind,
|
||||
listcircuitsmy,
|
||||
togglevisu,
|
||||
movcaricati,
|
||||
numtransaz,
|
||||
finishloading,
|
||||
addlastmov,
|
||||
loadingvalues,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,54 +1,116 @@
|
||||
<template>
|
||||
<div v-if="tools.isUserOk()">
|
||||
<q-inner-loading id="spinner" :showing="!finishloading">
|
||||
<q-spinner-tail size="3em" color="primary" />
|
||||
</q-inner-loading>
|
||||
<div v-if="tools.isUserOk() && finishloading">
|
||||
<div v-if="finder && showfinder" class="q-gutter-sm q-pa-sm q-pb-sm">
|
||||
<q-btn-toggle
|
||||
:model-value="modelValue"
|
||||
@update:model-value="updateValue"
|
||||
class="my-custom-toggle"
|
||||
no-caps
|
||||
rounded
|
||||
unelevated
|
||||
push
|
||||
toggle-color="primary"
|
||||
color="white"
|
||||
text-color="primary"
|
||||
:options="myoptions"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="finder" class="">
|
||||
<div
|
||||
v-if="
|
||||
modelValue === costanti.FIND_CIRCUIT ||
|
||||
listcircuitsfiltered.length === 0
|
||||
"
|
||||
>
|
||||
<slot></slot>
|
||||
</div>
|
||||
<div v-else>
|
||||
<!--
|
||||
mycircuits: {{userStore.my.profile.mycircuits}}<br><br>
|
||||
listcircuitsfiltered: {{listcircuitsfiltered}}
|
||||
<div class="q-mt-md">
|
||||
<CSendRISTo></CSendRISTo>
|
||||
|
||||
<q-btn label="test" @click="userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, {circuitname: 'prova'}]; circuitStore.listcircuits = [...circuitStore.listcircuits, {name: 'prova', path: 'prova'}]"></q-btn>
|
||||
-->
|
||||
|
||||
<q-list>
|
||||
<CTitleBanner
|
||||
:class="`q-pa-xs `"
|
||||
:title="myoptions[0].label"
|
||||
bgcolor="white"
|
||||
bgcolor2="lightblue"
|
||||
:clcolor="`text-indigo`"
|
||||
:canopen="true"
|
||||
:small="true"
|
||||
>
|
||||
<div v-if="listcircuitsmy.length === 0" class="q-ma-sm q-pa-sm">
|
||||
{{ t('circuit.nessun_circuito_attivo') }}
|
||||
</div>
|
||||
<div v-else style="max-height: 250px; overflow-y: auto">
|
||||
<span
|
||||
v-for="(circuit, index) in listcircuitsfiltered"
|
||||
v-for="(circuit, index) in listcircuitsmy"
|
||||
:key="index"
|
||||
class="q-my-sm"
|
||||
clickable
|
||||
>
|
||||
<CMyCircuit :mycircuit="circuit" :visu="modelValue"
|
||||
:username="username"> </CMyCircuit>
|
||||
<CMyCircuit
|
||||
:mycircuit="circuit"
|
||||
:visu="visu"
|
||||
:username="username"
|
||||
>
|
||||
</CMyCircuit>
|
||||
</span>
|
||||
</q-list>
|
||||
</div>
|
||||
</CTitleBanner>
|
||||
|
||||
<CTitleBanner
|
||||
:class="`q-pa-xs `"
|
||||
:title="t('circuit.tuoi_ultimi_movimenti', { num: numtransaz })"
|
||||
bgcolor="white"
|
||||
bgcolor2="lightblue"
|
||||
:clcolor="`text-indigo`"
|
||||
:canopen="true"
|
||||
:small="true"
|
||||
:open="false"
|
||||
>
|
||||
<CMovements @loaded="movcaricati" :username="username">
|
||||
<div class="row justify-center"><q-btn
|
||||
rounded
|
||||
dense
|
||||
class="text-center"
|
||||
color="primary"
|
||||
:label="t('circuit.show_next_mov')"
|
||||
@click="addlastmov()"
|
||||
/>
|
||||
</div>
|
||||
</CMovements>
|
||||
|
||||
<q-inner-loading id="spinner" :showing="loadingvalues">
|
||||
<q-spinner-tail size="3em" color="primary" />
|
||||
</q-inner-loading>
|
||||
|
||||
<br />
|
||||
</CTitleBanner>
|
||||
<div class="row justify-center">
|
||||
<q-btn
|
||||
rounded
|
||||
toggle-color="primary"
|
||||
:label="
|
||||
visu === costanti.MY_CIRCUITS
|
||||
? t('circuit.find_others_circuit')
|
||||
: t('circuit.hide_others_circuit')
|
||||
"
|
||||
@click="togglevisu()"
|
||||
/>
|
||||
</div>
|
||||
<CTitleBanner
|
||||
v-if="visu === costanti.FIND_CIRCUIT"
|
||||
:class="`q-pa-xs `"
|
||||
:title="t('circuit.circuiti_territoriali')"
|
||||
bgcolor="bg-primary"
|
||||
:clcolor="`text-white`"
|
||||
:canopen="true"
|
||||
:small="true"
|
||||
>
|
||||
<div>
|
||||
<span
|
||||
v-for="(circuit, index) in listcircuitsfind"
|
||||
:key="index"
|
||||
class="q-my-sm"
|
||||
clickable
|
||||
>
|
||||
<CMyCircuit
|
||||
:mycircuit="circuit"
|
||||
:visu="visu"
|
||||
:username="username"
|
||||
>
|
||||
</CMyCircuit>
|
||||
</span>
|
||||
</div>
|
||||
</CTitleBanner>
|
||||
</div>
|
||||
<div v-if="visu === costanti.FIND_CIRCUIT">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<q-list class="width-container">
|
||||
<span class="q-my-sm" clickable>
|
||||
<CMyCircuit :mycircuit="mycircuit" :visu="visu" :username="username"> </CMyCircuit>
|
||||
<CMyCircuit :mycircuit="mycircuit" :visu="visu" :username="username">
|
||||
</CMyCircuit>
|
||||
</span>
|
||||
</q-list>
|
||||
</div>
|
||||
@@ -56,6 +118,17 @@
|
||||
<div v-else>
|
||||
<CUserNonVerif></CUserNonVerif>
|
||||
</div>
|
||||
|
||||
<CTitleBanner
|
||||
v-if="visu === costanti.FIND_CIRCUIT"
|
||||
:class="`q-pa-xs `"
|
||||
:title="myoptions[0].label"
|
||||
bgcolor="bg-primary"
|
||||
:clcolor="`text-white`"
|
||||
:canopen="true"
|
||||
:small="true"
|
||||
>
|
||||
</CTitleBanner>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./CMyCircuits.ts">
|
||||
|
||||
Reference in New Issue
Block a user