Circuit table...
This commit is contained in:
0
src/components/CMyCircuits/CMyCircuits.scss
Executable file
0
src/components/CMyCircuits/CMyCircuits.scss
Executable file
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,
|
||||
}
|
||||
}
|
||||
})
|
||||
55
src/components/CMyCircuits/CMyCircuits.vue
Executable file
55
src/components/CMyCircuits/CMyCircuits.vue
Executable file
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<div v-if="tools.isUserOk()">
|
||||
<div v-if="finder" 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">
|
||||
<slot></slot>
|
||||
</div>
|
||||
<div v-else>
|
||||
<q-list>
|
||||
<span v-for="(circuit, index) in listcircuitsfiltered" :key="index" class="q-my-sm" clickable>
|
||||
<CMyCircuit
|
||||
:mycircuit="circuit"
|
||||
:visu="modelValue">
|
||||
</CMyCircuit>
|
||||
</span>
|
||||
</q-list>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<q-list class="width-container">
|
||||
<span class="q-my-sm" clickable>
|
||||
<CMyCircuit
|
||||
:mycircuit="mycircuit"
|
||||
:visu="visu">
|
||||
</CMyCircuit>
|
||||
</span>
|
||||
</q-list>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<CUserNonVerif></CUserNonVerif>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./CMyCircuits.ts">
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './CMyCircuits';
|
||||
</style>
|
||||
|
||||
1
src/components/CMyCircuits/index.ts
Executable file
1
src/components/CMyCircuits/index.ts
Executable file
@@ -0,0 +1 @@
|
||||
export {default as CMyCircuits} from './CMyCircuits.vue'
|
||||
Reference in New Issue
Block a user