From eb0fb72c704eb3c4fd4f3f32371c159fb281093e Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Sat, 11 Oct 2025 18:36:04 +0200 Subject: [PATCH] - Sistemato problema del Circuito ITALIA, quando veniva fatta la richiesta di entrare, ancora non si era entrati nel circuito territoriale. - Ora pertanto viene inviata la richiesta agli admin solo dopo che l'utente viene abilitato al Circuito provinciale. --- src/common/shared_vuejs.ts | 4 +- .../CCheckCircuitsEnabled.ts | 2 +- src/components/CGridTableRec/CGridTableRec.ts | 4 +- .../CGridTableRec/CGridTableRec.vue | 3 - src/components/CMyCircuits/CMyCircuits.ts | 2 +- .../CMyProfileTutorial/CMyProfileTutorial.ts | 2 +- src/model/GlobalStore.ts | 4 +- src/model/UserStore.ts | 1 + .../gestoreordini_old/gestoreordini.scss | 0 .../admin/gestoreordini_old/gestoreordini.ts | 159 ---- .../admin/gestoreordini_old/gestoreordini.vue | 28 - src/statics/lang/it.js | 4 +- src/store/CircuitStore.ts | 16 +- src/store/Modules/fieldsTable.ts | 32 +- src/store/Modules/tools.ts | 3 +- src/store/UserStore.ts | 8 +- src/views/user/mycircuit/mycircuit.ts | 687 +++++++++--------- src/views/user/mycircuit/mycircuit.vue | 2 +- 18 files changed, 417 insertions(+), 544 deletions(-) delete mode 100755 src/rootgen/admin/gestoreordini_old/gestoreordini.scss delete mode 100755 src/rootgen/admin/gestoreordini_old/gestoreordini.ts delete mode 100755 src/rootgen/admin/gestoreordini_old/gestoreordini.vue diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index 031b5a88..7784d4cb 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -2309,7 +2309,9 @@ export const shared_consts = { nome_valuta: 1, fido_scoperto_default: 1, deperimento: 1, - showAlways: 1, + circuitiExtraProv: 1, + isCircItalia: 1, + enableOnlyIf1CircuitExist: 1, ignoreLimits: 1, askManagerToEnter: 1, sendEmailAfterAskingToEnter: 1, diff --git a/src/components/CCheckCircuitsEnabled/CCheckCircuitsEnabled.ts b/src/components/CCheckCircuitsEnabled/CCheckCircuitsEnabled.ts index 6929f410..9e4211c8 100755 --- a/src/components/CCheckCircuitsEnabled/CCheckCircuitsEnabled.ts +++ b/src/components/CCheckCircuitsEnabled/CCheckCircuitsEnabled.ts @@ -44,7 +44,7 @@ export default defineComponent({ function load() { non_hai_circuito_nazionale.value = !circuitStore.sonoDentroAlCircuitoNazionale() if (props.to_user) { - destin_non_ha_circuito_naz.value = !circuitStore.EDentroAlCircuitoNazionale(props.to_user) + destin_non_ha_circuito_naz.value = !circuitStore.EDentroAlCircuitoItalia(props.to_user) if (userStore.getMyCircuitsInCommonByUser(props.to_user).length > 0) { destin_non_ha_circuito_naz.value = false } diff --git a/src/components/CGridTableRec/CGridTableRec.ts b/src/components/CGridTableRec/CGridTableRec.ts index 2225162f..1f19b030 100755 --- a/src/components/CGridTableRec/CGridTableRec.ts +++ b/src/components/CGridTableRec/CGridTableRec.ts @@ -254,9 +254,7 @@ export default defineComponent({ filterextra2: { type: Array, required: false, - default: () => { - return []; - }, + default: () => [] as any[], }, extraparams: { required: false, diff --git a/src/components/CGridTableRec/CGridTableRec.vue b/src/components/CGridTableRec/CGridTableRec.vue index 19c85e25..5db81f30 100755 --- a/src/components/CGridTableRec/CGridTableRec.vue +++ b/src/components/CGridTableRec/CGridTableRec.vue @@ -1472,7 +1472,6 @@
- MODIF_B: {{col.field2}}
- MODIF_C: {{col.field2}} circ.showAlways) + const arrtoinsert: any = circuitStore.listcircuits.filter((circ: any) => circ.isCircItalia) for (const rec of arrtoinsert) { if (arr.findIndex(myrec => myrec._id === rec._id) < 0) { // Se non c'è il circuito Nazionale, glielo aggiungo diff --git a/src/components/CMyProfileTutorial/CMyProfileTutorial.ts b/src/components/CMyProfileTutorial/CMyProfileTutorial.ts index d1921229..8c51244c 100755 --- a/src/components/CMyProfileTutorial/CMyProfileTutorial.ts +++ b/src/components/CMyProfileTutorial/CMyProfileTutorial.ts @@ -280,7 +280,7 @@ export default defineComponent({ checkOk: function () { if (circuititalia.value) { return ((userStore.IsMyCircuitByName(circuititalia.value.name) || - userStore.IsAskedCircuitByName(circuititalia.value.name))) || userStore.my.profile.noCircIta + userStore.IsAskedCircuitByName(circuititalia.value.name))) || userStore.my.profile.noCircIta || userStore.my.profile.insert_circuito_ita } return false }, diff --git a/src/model/GlobalStore.ts b/src/model/GlobalStore.ts index bf6d4e9a..d8b8ee6c 100755 --- a/src/model/GlobalStore.ts +++ b/src/model/GlobalStore.ts @@ -1464,7 +1464,9 @@ export interface ICircuit { qta_max_default_contocom?: number data_costituz?: Date deperimento: boolean - showAlways: boolean + circuitiExtraProv: boolean + isCircItalia?: boolean + enableOnlyIf1CircuitExist?: boolean ignoreLimits: boolean askManagerToEnter?: boolean sendEmailAfterAskingToEnter?: boolean diff --git a/src/model/UserStore.ts b/src/model/UserStore.ts index 1d6d9fc5..e317c1bd 100755 --- a/src/model/UserStore.ts +++ b/src/model/UserStore.ts @@ -164,6 +164,7 @@ export interface IUserProfile { noNameSurname: boolean noCircuit: boolean noCircIta: boolean + insert_circuito_ita?: boolean noFoto: boolean reaction: IReaction[] // bookmark: IBookmark[] diff --git a/src/rootgen/admin/gestoreordini_old/gestoreordini.scss b/src/rootgen/admin/gestoreordini_old/gestoreordini.scss deleted file mode 100755 index e69de29b..00000000 diff --git a/src/rootgen/admin/gestoreordini_old/gestoreordini.ts b/src/rootgen/admin/gestoreordini_old/gestoreordini.ts deleted file mode 100755 index 8e173c27..00000000 --- a/src/rootgen/admin/gestoreordini_old/gestoreordini.ts +++ /dev/null @@ -1,159 +0,0 @@ -import { defineComponent, onMounted, ref } from 'vue' - -import { CImgText } from '../../../components/CImgText/index' -import { CCard } from '@src/components/CCard' -import { CMyPage } from '@src/components/CMyPage' -import { CTitleBanner } from '@src/components/CTitleBanner' -import { CGridTableRec } from '@src/components/CGridTableRec' - -import { colTableGestoreOrdini } from '@src/store/Modules/fieldsTable' -import MixinMetaTags from '@src/mixins/mixin-metatags' - -export default defineComponent({ - name: 'Gestoreordini', - components: { CImgText, CCard, CMyPage, CTitleBanner, CGridTableRec }, - setup() { - - const { setmeta } = MixinMetaTags() - const filtroOrdini = ref([]) - const idGasordine = ref(null) - - function mounted() { - let queryord = [] - - filtroOrdini.value = [] - - if (idGasordine.value) { - const gasordine = { - $match: { - idGasordine: idGasordine.value - }, - } - queryord.push(gasordine) - } - - - const query = [ - { - $lookup: { - from: 'products', - localField: 'idProduct', - foreignField: '_id', - as: 'product', - }, - }, - { - $unwind: { - path: '$product', - preserveNullAndEmptyArrays: true, - }, - }, - { - $unwind: { - path: '$productInfo', - }, - }, - { - $lookup: { - from: 'gasordines', - localField: 'idGasordine', - foreignField: '_id', - as: 'gasordine', - }, - }, - { - $unwind: { - path: '$gasordine', - preserveNullAndEmptyArrays: true, - }, - }, - { - $match: { - $or: [ - { - 'gasordine.active': true, - }, - { - gasordine: { - $exists: false, - }, - }, - ], - }, - }, - { - $match: { - $or: [ - { - quantity: { - $gt: 0, - }, - }, - { - quantitypreordered: { - $gt: 0, - }, - }, - ], - }, - }, - { - $group: { - _id: '$product._id', - name: { - $first: '$product.productInfo.name', - }, - weight: { - $first: '$product.productInfo.weight', - }, - price_acquistato: { - $first: '$product.price_acquistato', - }, - totalQuantity: { - $sum: { - $add: [ - '$quantity', - '$quantitypreordered', - ], - }, - }, - totalPrice_acquistato: { - $sum: { - $multiply: [ - '$product.price_acquistato', - { - $add: [ - '$quantity', - '$quantitypreordered', - ], - }, - ], - }, - }, - count: { - $sum: 1, - }, - }, - }, - { - $sort: { - name: 1, - }, - } - ] - - queryord.push(query) - - filtroOrdini.value = queryord - - } - - onMounted(mounted) - - return { - colTableGestoreOrdini, - setmeta, - filtroOrdini, - } - } -}) diff --git a/src/rootgen/admin/gestoreordini_old/gestoreordini.vue b/src/rootgen/admin/gestoreordini_old/gestoreordini.vue deleted file mode 100755 index 9711c462..00000000 --- a/src/rootgen/admin/gestoreordini_old/gestoreordini.vue +++ /dev/null @@ -1,28 +0,0 @@ - - - diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js index bf6e3e40..f6290279 100755 --- a/src/statics/lang/it.js +++ b/src/statics/lang/it.js @@ -1550,7 +1550,9 @@ const msg_it = { qta_max_default_tips_contocom: 'Rappresenta quanto credito ti è concesso accumulare al Conto Comunitario. Incentiviamo così a frequenti scambi tra i partecipanti', data_costituz: 'Data Costituzione', deperimento: 'Deperimento', - showAlways: 'Mostra Sempre', + circuitiExtraProv: 'Circuito Extra Provinciale (Nazionale o altri)', + isCircItalia: 'Circuito Italia', + enableOnlyIf1CircuitExist: 'Abilita solo se l\'Utente è stato ammesso ad un Circuito Territoriale', freq_deper: 'Frequenza Deperimento', minuto_deper: 'Minuto Dep.', ora_deper: 'Ora Dep.', diff --git a/src/store/CircuitStore.ts b/src/store/CircuitStore.ts index 58944eba..7292a60d 100755 --- a/src/store/CircuitStore.ts +++ b/src/store/CircuitStore.ts @@ -59,7 +59,7 @@ export const useCircuitStore = defineStore('CircuitStore', { sonoDentroAlCircuitoNazionale() { const userStore = useUserStore() - const circNazionali: any = this.listcircuits.filter((circ: any) => circ.showAlways) + const circNazionali: any = this.listcircuits.filter((circ: any) => circ.isCircItalia) for (const circ of circNazionali) { const trovato = userStore.my.profile.mycircuits.findIndex((mycirc: any) => mycirc.circuitname === circ.name) >= 0 @@ -74,7 +74,7 @@ export const useCircuitStore = defineStore('CircuitStore', { getCircuitoNazionale(arrCircuiti: any): any { - const circNazionali: any = this.listcircuits.filter((circ: any) => circ.showAlways) + const circNazionali: any = this.listcircuits.filter((circ: any) => circ.isCircItalia) for (const circ of circNazionali) { const reccirc = arrCircuiti.find((mycirc: any) => mycirc.circuitname === circ.name) @@ -87,9 +87,9 @@ export const useCircuitStore = defineStore('CircuitStore', { }, - EDentroAlCircuitoNazionale(user: IUserFields) { + EDentroAlCircuitoItalia(user: IUserFields) { - const circNazionali: any = this.listcircuits.filter((circ: any) => circ.showAlways) + const circNazionali: any = this.listcircuits.filter((circ: any) => circ.isCircItalia) if (user && user.profile && user.profile.mycircuits && user.profile.mycircuits.length > 0) { for (const circ of circNazionali) { @@ -105,12 +105,12 @@ export const useCircuitStore = defineStore('CircuitStore', { }, isCircuitNational(circuitname: string): boolean { - return this.listcircuits.findIndex((rec: ICircuit) => rec.name === circuitname && rec.showAlways) >= 0 + return this.listcircuits.findIndex((rec: ICircuit) => rec.name === circuitname && rec.isCircItalia) >= 0 }, getCircuitsNational(): any[] { const userStore = useUserStore() - let arrcircnaz = this.listcircuits.filter((rec: ICircuit) => rec.showAlways) + let arrcircnaz = this.listcircuits.filter((rec: ICircuit) => rec.isCircItalia) for (const circ of arrcircnaz) { if (userStore.my.profile.useraccounts) @@ -145,7 +145,7 @@ export const useCircuitStore = defineStore('CircuitStore', { for (const account of accountsConFido) { const mycircuit = this.listcircuits.find((circ: ICircuit) => circ._id === account.circuitId) - if (mycircuit && !mycircuit.showAlways) { + if (mycircuit && !mycircuit.circuitiExtraProv) { return true } } @@ -162,7 +162,7 @@ export const useCircuitStore = defineStore('CircuitStore', { for (const account of accountsConFido) { const mycircuit = this.listcircuits.find((circ: ICircuit) => circ._id === account.circuitId) - if (mycircuit && !mycircuit.showAlways) { + if (mycircuit && !mycircuit.circuitiExtraProv) { return mycircuit } } diff --git a/src/store/Modules/fieldsTable.ts b/src/store/Modules/fieldsTable.ts index dde1042f..7d24d66c 100755 --- a/src/store/Modules/fieldsTable.ts +++ b/src/store/Modules/fieldsTable.ts @@ -6387,8 +6387,20 @@ export const colTableCircuitComplete = [ fieldtype: costanti.FieldType.boolean, }), AddCol({ - name: 'showAlways', - label_trans: 'circuit.showAlways', + name: 'circuitiExtraProv', + label_trans: 'circuit.circuitiExtraProv', + fieldtype: costanti.FieldType.boolean, + onlyforAdmin: true, + }), + AddCol({ + name: 'isCircItalia', + label_trans: 'circuit.isCircItalia', + fieldtype: costanti.FieldType.boolean, + onlyforAdmin: true, + }), + AddCol({ + name: 'enableOnlyIf1CircuitExist', + label_trans: 'circuit.enableOnlyIf1CircuitExist', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true, }), @@ -6688,8 +6700,20 @@ export const colTableCircuit = [ disable: true, }), AddCol({ - name: 'showAlways', - label_trans: 'circuit.showAlways', + name: 'circuitiExtraProv', + label_trans: 'circuit.circuitiExtraProv', + fieldtype: costanti.FieldType.boolean, + onlyforAdmin: true, + }), + AddCol({ + name: 'isCircItalia', + label_trans: 'circuit.isCircItalia', + fieldtype: costanti.FieldType.boolean, + onlyforAdmin: true, + }), + AddCol({ + name: 'enableOnlyIf1CircuitExist', + label_trans: 'circuit.enableOnlyIf1CircuitExist', fieldtype: costanti.FieldType.boolean, onlyforAdmin: true, }), diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index 603ef01c..57253e17 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -8219,7 +8219,8 @@ export const tools = { admins: [], color: '#ff5500', deperimento: false, - showAlways: false, + circuitiExtraProv: false, + isCircItalia: false, transactionsEnabled: false, status: shared_consts.CIRCUIT_STATUS.FASE1_CREAZIONE_GRUPPO, symbol: 'RIS', diff --git a/src/store/UserStore.ts b/src/store/UserStore.ts index fc3e3708..c0f44849 100755 --- a/src/store/UserStore.ts +++ b/src/store/UserStore.ts @@ -113,6 +113,7 @@ export const DefaultUser: IUserFields = { noNameSurname: false, noCircuit: false, noCircIta: false, + insert_circuito_ita: false, noFoto: false, asked_circuits: [], refused_circuits: [], @@ -186,6 +187,7 @@ export const DefaultProfile: IUserProfile = { noNameSurname: false, noCircuit: false, noCircIta: false, + insert_circuito_ita: false, noFoto: false, asked_circuits: [], refused_circuits: [], @@ -612,15 +614,15 @@ export const useUserStore = defineStore('UserStore', { // controlla che il circuito sia Abilitato e Territoriale ! for (const circuitname of arrout) { const circuit = circuitStore.getCircuitByName(circuitname); - if (circuit && circuit.transactionsEnabled && !circuit.showAlways) { + if (circuit && circuit.transactionsEnabled && !circuit.circuitiExtraProv) { arrfinale.push(circuitname); } } - // Poi aggiungi i Circuiti ITALIA + // Poi aggiungi i Circuiti Nazionali for (const circuitname of arrout) { const circuit = circuitStore.getCircuitByName(circuitname); - if (circuit && circuit.transactionsEnabled && circuit.showAlways) { + if (circuit && circuit.transactionsEnabled && circuit.circuitiExtraProv) { arrfinale.push(circuitname); } } diff --git a/src/views/user/mycircuit/mycircuit.ts b/src/views/user/mycircuit/mycircuit.ts index 1daf1ebb..6c26a0d8 100755 --- a/src/views/user/mycircuit/mycircuit.ts +++ b/src/views/user/mycircuit/mycircuit.ts @@ -1,385 +1,412 @@ -import { CGridTableRec } from '@src/components/CGridTableRec' -import { CMyFriends } from '@src/components/CMyFriends' -import { CMyUser } from '@src/components/CMyUser' -import { CTitleBanner } from '@src/components/CTitleBanner' -import { CProfile } from '@src/components/CProfile' -import { CCheckIfIsLogged } from '@src/components/CCheckIfIsLogged' -import { CMyFieldRec } from '@src/components/CMyFieldRec' -import { CCurrencyValue } from '@src/components/CCurrencyValue' -import { CSaldo } from '@src/components/CSaldo' -import { CSendCoins } from '@src/components/CSendCoins' -import { CUserNonVerif } from '@src/components/CUserNonVerif' -import { CTitleSec } from '@src/components/CTitleSec' -import { CSkill } from '@src/components/CSkill' -import { CFinder } from '@src/components/CFinder' -import { CDateTime } from '@src/components/CDateTime' -import { tools } from '@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 'vue-i18n' -import { toolsext } from '@store/Modules/toolsext' -import { useQuasar } from 'quasar' -import { CNotifAtTop } from '@src/components/CNotifAtTop' -import { costanti } from '@costanti' +import { CGridTableRec } from '@src/components/CGridTableRec'; +import { CMyFriends } from '@src/components/CMyFriends'; +import { CMyUser } from '@src/components/CMyUser'; +import { CTitleBanner } from '@src/components/CTitleBanner'; +import { CProfile } from '@src/components/CProfile'; +import { CCheckIfIsLogged } from '@src/components/CCheckIfIsLogged'; +import { CMyFieldRec } from '@src/components/CMyFieldRec'; +import { CCurrencyValue } from '@src/components/CCurrencyValue'; +import { CSaldo } from '@src/components/CSaldo'; +import { CSendCoins } from '@src/components/CSendCoins'; +import { CUserNonVerif } from '@src/components/CUserNonVerif'; +import { CTitleSec } from '@src/components/CTitleSec'; +import { CSkill } from '@src/components/CSkill'; +import { CFinder } from '@src/components/CFinder'; +import { CDateTime } from '@src/components/CDateTime'; +import { tools } from '@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 'vue-i18n'; +import { toolsext } from '@store/Modules/toolsext'; +import { useQuasar } from 'quasar'; +import { CNotifAtTop } from '@src/components/CNotifAtTop'; +import { costanti } from '@costanti'; import type { ICity, IFriends, ICircuit, ISearchList, IAccount, IMyGroup } from 'model'; -import { IUserFields } from 'model' -import { shared_consts } from '@src/common/shared_vuejs' -import { colmyUserPeople, colmyUserPeopleSaldi, colmyUserCircuit, colmyMovement, colmyMovementTable, colmyUserGroup } from '@store/Modules/fieldsTable' -import { useNotifStore } from '@store/NotifStore' -import { useCircuitStore } from '@store/CircuitStore' - +import { IUserFields } from 'model'; +import { shared_consts } from '@src/common/shared_vuejs'; +import { + colmyUserPeople, + colmyUserPeopleSaldi, + colmyUserCircuit, + colmyMovement, + colmyMovementTable, + colmyUserGroup, +} from '@store/Modules/fieldsTable'; +import { useNotifStore } from '@store/NotifStore'; +import { useCircuitStore } from '@store/CircuitStore'; export default defineComponent({ name: 'mycircuit', components: { - CProfile, CTitleBanner, CMyFieldRec, CSkill, CTitleSec, CDateTime, CMyFriends, - CGridTableRec, CMyUser, CCheckIfIsLogged, CCurrencyValue, CSaldo, CNotifAtTop, - CSendCoins, CUserNonVerif, CFinder, + CProfile, + CTitleBanner, + CMyFieldRec, + CSkill, + CTitleSec, + CDateTime, + CMyFriends, + CGridTableRec, + CMyUser, + CCheckIfIsLogged, + CCurrencyValue, + CSaldo, + CNotifAtTop, + CSendCoins, + CUserNonVerif, + CFinder, }, props: {}, setup() { - const userStore = useUserStore() - const globalStore = useGlobalStore() - const notifStore = useNotifStore() - const circuitStore = useCircuitStore() - const $route = useRoute() - const $q = useQuasar() - const { t } = useI18n() + const userStore = useUserStore(); + const globalStore = useGlobalStore(); + const notifStore = useNotifStore(); + const circuitStore = useCircuitStore(); + const $route = useRoute(); + const $q = useQuasar(); + const { t } = useI18n(); - const showwhommov = ref(1) + const showwhommov = ref(1); const optionsmov = [ { label: t('movement.onlymymov'), value: 1 }, { label: t('movement.allmov'), value: 2 }, - ] - const tabellare = ref(false) - const groupsListAdmin = ref([]) - const groupnameSel = ref(null) + ]; + const tabellare = ref(false); + const groupsListAdmin = ref([]); + const groupnameSel = ref(null); - const showsendCoinTo = ref(false) - const showrules = ref(false) - const showMov = ref(false) + const showsendCoinTo = ref(false); + const showrules = ref(false); + const showMov = ref(false); - const animation = ref('fade') + const animation = ref('fade'); - const path = computed(() => $route.params.path ? $route.params.path.toString() : '') - const idnotif = computed(() => $route.query.idnotif ? $route.query.idnotif.toString() : '') + const path = computed(() => + $route.params.path ? $route.params.path.toString() : '' + ); + const idnotif = computed(() => + $route.query.idnotif ? $route.query.idnotif.toString() : '' + ); - const circuitpath_loaded = ref('') + const circuitpath_loaded = ref(''); - const filtroutente = ref([] as any[]) - const showPic = ref(false) - const loadSaldo = ref(false) + const filtroutente = ref([] as any[]); + const showPic = ref(false); + const loadSaldo = ref(false); - const card = ref({}) + const card = ref({}); - const circuit = ref(undefined) - const account = ref(null) - const mystatus = ref(0 as number) - const users_in_circuit = ref([] as IFriends[]) + const circuit = ref(undefined); + const account = ref(null); + const mystatus = ref(0 as number); + const users_in_circuit = ref([] as IFriends[]); - const qtarem = ref(0) - const saldo = ref(0) - const saldo_pend = ref(0) + const qtarem = ref(0); + const saldo = ref(0); + const saldo_pend = ref(0); - const loading = ref(false) - const requestToEnterCircuit = ref(false) + const loading = ref(false); + const requestToEnterCircuit = ref(false); - const tabcircuit = ref('info') - const tabmembers = ref('all') - const showsaldi = ref(false) - const tab = ref('membri') + const tabcircuit = ref('info'); + const tabmembers = ref('all'); + const showsaldi = ref(false); + const tab = ref('membri'); - const arrfilterand: any = ref([]) - const filterextra: any = ref([]) - const filterextra_group: any = ref([]) - const filterextra2: any = ref([]) - const filtercustom: any = ref([]) - const filtercustom_rich: any = ref([]) - const searchList = ref([] as ISearchList[]) + const arrfilterand: any = ref([]); + const filterextra: any = ref([]); + const filterextra_group: any = ref([]); + const filterextra2: any = ref([]); + const filtercustom: any = ref([]); + const filtercustom_rich: any = ref([]); + const searchList = ref([] as ISearchList[]); - const cities = ref([] as ICity[]) + const cities = ref([] as ICity[]); - const fidoConcesso = ref(0) - const qtaMax = ref(0) + const fidoConcesso = ref(0); + const qtaMax = ref(0); const mycards_annunci = computed(() => { - return costanti.MAINCARDS.filter((rec: any) => rec.table && rec.annuncio) - }) + return costanti.MAINCARDS.filter((rec: any) => rec.table && rec.annuncio); + }); - watch(() => path.value, (to: any, from: any) => { - if (circuitpath_loaded.value !== path.value) - loadCircuit() - }) - - watch(() => tabcircuit.value, (to: any, from: any) => { - tools.setCookie(tools.COOK_TAB_CIRCUIT + path.value, tabcircuit.value) - }) - - watch(() => circuit.value, (to: any, from: any) => { - if (to) { - loadAccount() + watch( + () => path.value, + (to: any, from: any) => { + if (circuitpath_loaded.value !== path.value) loadCircuit(); } - }) + ); + + watch( + () => tabcircuit.value, + (to: any, from: any) => { + tools.setCookie(tools.COOK_TAB_CIRCUIT + path.value, tabcircuit.value); + } + ); + + watch( + () => circuit.value, + (to: any, from: any) => { + if (to) { + loadAccount(); + } + } + ); function getParamCircuitsToView() { return { 'circuit.name': 1, 'circuit._id': 1, - } + }; } function loadAccount() { // console.log('loadAccount') - account.value = circuit.value ? userStore.getAccountByCircuitId(circuit.value._id) : null + account.value = circuit.value + ? userStore.getAccountByCircuitId(circuit.value._id) + : null; // console.log('saldo', account.value!.saldo) - fidoConcesso.value = account.value ? account.value.fidoConcesso : (circuit.value ? circuit.value.fido_scoperto_default : 0) - qtaMax.value = account.value ? account.value.qta_maxConcessa : (circuit.value ? circuit.value.qta_max_default : 0) - qtarem.value = account.value ? circuitStore.getRemainingCoinsToSend(account.value) : 0 - saldo.value = account.value ? account.value.saldo : 0 - saldo_pend.value = account.value ? account.value.saldo_pend : 0 + fidoConcesso.value = account.value + ? account.value.fidoConcesso + : circuit.value + ? circuit.value.fido_scoperto_default + : 0; + qtaMax.value = account.value + ? account.value.qta_maxConcessa + : circuit.value + ? circuit.value.qta_max_default + : 0; + qtarem.value = account.value + ? circuitStore.getRemainingCoinsToSend(account.value) + : 0; + saldo.value = account.value ? account.value.saldo : 0; + saldo_pend.value = account.value ? account.value.saldo_pend : 0; } - function profile() { - return userStore.my.profile + return userStore.my.profile; } async function loadCircuit() { - console.log(' *** INIZIO loadCircuit') + console.log(' *** INIZIO loadCircuit'); if (!loading.value) { - loading.value = true + loading.value = true; // Carica il profilo di quest'utente if (path.value) { - circuitpath_loaded.value = path.value - circuit.value = null - users_in_circuit.value = [] - await userStore.loadCircuit(path.value, idnotif.value).then(({ data, status }: { data: any, status: number }) => { - // console.log('data', data) - if (data) { - notifStore.setAsRead(idnotif.value) - users_in_circuit.value = data.users_in_circuit - circuit.value = data.circuit + circuitpath_loaded.value = path.value; + circuit.value = null; + users_in_circuit.value = []; + await userStore + .loadCircuit(path.value, idnotif.value) + .then(({ data, status }: { data: any; status: number }) => { + // console.log('data', data) + if (data) { + notifStore.setAsRead(idnotif.value); + users_in_circuit.value = data.users_in_circuit; + circuit.value = data.circuit; - if (circuit.value!.circuitoIndipendente) { - showrules.value = true + if (circuit.value!.circuitoIndipendente) { + showrules.value = true; + } + } else { + circuit.value = null; + users_in_circuit.value = []; } - } else { - circuit.value = null - users_in_circuit.value = [] - } - loadAccount() + loadAccount(); - mystatus.value = status + mystatus.value = status; - searchList.value = [] - if (circuit.value) { - const addquerysingle = [ + searchList.value = []; + if (circuit.value) { + const addquerysingle = []; - ]; - - filterextra.value = [{ - $match: { - idapp: tools.getEnv('VITE_APP_ID'), - 'profile.mycircuits': { - $elemMatch: { circuitname: { $eq: circuit.value.name } }, + filterextra.value = [ + { + $match: { + idapp: tools.getEnv('VITE_APP_ID'), + 'profile.mycircuits': { + $elemMatch: { circuitname: { $eq: circuit.value.name } }, + }, + }, }, - }, - }, - { - $lookup: { - from: 'circuits', - as: 'circuit', - let: { circuitname: circuit.value.name, idapp: '$idapp' }, - pipeline: [ - { - $match: - { - $expr: + { + $lookup: { + from: 'circuits', + as: 'circuit', + let: { circuitname: circuit.value.name, idapp: '$idapp' }, + pipeline: [ { - $and: - [ - { $eq: ['$name', '$$circuitname'] }, - { $eq: ['$idapp', '$$idapp'] }, - - ], + $match: { + $expr: { + $and: [ + { $eq: ['$name', '$$circuitname'] }, + { $eq: ['$idapp', '$$idapp'] }, + ], + }, + }, }, - }, + ], + }, + }, + { $unwind: '$circuit' }, + { + $project: { + username: 1, + verified_by_aportador: 1, + name: 1, + surname: 1, + date_reg: 1, + profile: 1, + idapp: 1, + ...getParamCircuitsToView(), }, - ], - }, - - }, - { $unwind: '$circuit' }, - { - $project: { - username: 1, - verified_by_aportador: 1, - name: 1, - surname: 1, - date_reg: 1, - profile: 1, - idapp: 1, - ...getParamCircuitsToView(), - } - - }, - - { - $lookup: { - from: 'accounts', - as: 'account', - let: { username: '$username', idapp: '$idapp', circuitId: '$circuit._id' }, - pipeline: [ - { - $match: - { - $expr: - { - $and: - [ - { $eq: ['$$username', '$username'] }, - { $eq: ['$$idapp', '$idapp'] }, - { $eq: ['$$circuitId', '$circuitId'] }, - ], - }, - }, - }, - ], - }, - }, - { $unwind: '$account' }, - ] - - filterextra_group.value = [{ - $match: { - idapp: tools.getEnv('VITE_APP_ID'), - 'mycircuits': { - $elemMatch: { circuitname: { $eq: circuit.value.name } }, }, - }, - }, - { - $lookup: { - from: 'circuits', - as: 'circuit', - let: { circuitname: circuit.value.name, idapp: '$idapp' }, - pipeline: [ - { - $match: - { - $expr: + { + $lookup: { + from: 'accounts', + as: 'account', + let: { + username: '$username', + idapp: '$idapp', + circuitId: '$circuit._id', + }, + pipeline: [ { - $and: - [ - { $eq: ['$name', '$$circuitname'] }, - { $eq: ['$idapp', '$$idapp'] }, - - ], + $match: { + $expr: { + $and: [ + { $eq: ['$$username', '$username'] }, + { $eq: ['$$idapp', '$idapp'] }, + { $eq: ['$$circuitId', '$circuitId'] }, + ], + }, + }, }, + ], + }, + }, + { $unwind: '$account' }, + ]; + + filterextra_group.value = [ + { + $match: { + idapp: tools.getEnv('VITE_APP_ID'), + mycircuits: { + $elemMatch: { circuitname: { $eq: circuit.value.name } }, }, }, - ], - }, + }, - }, - { $unwind: '$circuit' }, - { - $project: { - groupname: 1, - title: 1, - descr: 1, - photos: 1, - surname: 1, - verified_by_aportador: 1, - admins: 1, - idapp: 1, - ...getParamCircuitsToView(), - } - }, - { - $lookup: { - from: 'accounts', - as: 'account', - let: { groupname: '$groupname', idapp: '$idapp', circuitId: '$circuit._id' }, - pipeline: [ - { - $match: - { - $expr: + { + $lookup: { + from: 'circuits', + as: 'circuit', + let: { circuitname: circuit.value.name, idapp: '$idapp' }, + pipeline: [ { - $and: - [ - { $eq: ['$groupname', '$$groupname'] }, - { $eq: ['$idapp', '$$idapp'] }, - { $eq: ['$circuitId', '$$circuitId'] }, - - ], + $match: { + $expr: { + $and: [ + { $eq: ['$name', '$$circuitname'] }, + { $eq: ['$idapp', '$$idapp'] }, + ], + }, + }, }, - }, + ], }, - ], - }, + }, + { $unwind: '$circuit' }, + { + $project: { + groupname: 1, + title: 1, + descr: 1, + photos: 1, + surname: 1, + verified_by_aportador: 1, + admins: 1, + idapp: 1, + ...getParamCircuitsToView(), + }, + }, + { + $lookup: { + from: 'accounts', + as: 'account', + let: { + groupname: '$groupname', + idapp: '$idapp', + circuitId: '$circuit._id', + }, + pipeline: [ + { + $match: { + $expr: { + $and: [ + { $eq: ['$groupname', '$$groupname'] }, + { $eq: ['$idapp', '$$idapp'] }, + { $eq: ['$circuitId', '$$circuitId'] }, + ], + }, + }, + }, + ], + }, + }, + { + $unwind: '$account', + }, + { + $match: { 'account.groupname': { $exists: true, $ne: '' } }, + }, + ]; + } + arrfilterand.value = []; + filtercustom_rich.value = []; - }, - { - $unwind: '$account', - }, - { - $match: { 'account.groupname': { $exists: true, $ne: '' } } - }, - ] - } - arrfilterand.value = [] - filtercustom_rich.value = [] - - if (userStore.my.username && circuit.value) - groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin() - - // filtroutente.value = [{ userId: userStore.my._id }] - }) + if (userStore.my.username && circuit.value) + groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin(); + // filtroutente.value = [{ userId: userStore.my._id }] + }); } - loading.value = false - console.log(' ___ FINE loadCircuit') + loading.value = false; + console.log(' ___ FINE loadCircuit'); } } function mounted() { - tabcircuit.value = tools.getCookie(tools.COOK_TAB_CIRCUIT + path.value, 'info') + tabcircuit.value = tools.getCookie(tools.COOK_TAB_CIRCUIT + path.value, 'info'); - loadCircuit() - - if (mycards_annunci.value) - card.value = mycards_annunci.value[0] + loadCircuit(); + if (mycards_annunci.value) card.value = mycards_annunci.value[0]; } function getImgCircuit() { - if (circuit.value) - return userStore.getImgByCircuit(circuit.value) - else - return '' + if (circuit.value) return userStore.getImgByCircuit(circuit.value); + else return ''; } function checkifShow(col: string) { // ++Todo: checkifShow Permessi ! - return true + return true; } - function extraparams() { - const lk_tab = 'users' - const lk_LF = 'userId' - const lk_FF = '_id' - const lk_as = 'user' - const af_objId_tab = 'myId' + const lk_tab = 'users'; + const lk_LF = 'userId'; + const lk_FF = '_id'; + const lk_as = 'user'; + const af_objId_tab = 'myId'; return { lookup1: { @@ -411,17 +438,17 @@ export default defineComponent({ username_who_report: 1, namecomplete: 1, date_reg: 1, - } + }, }, - } + }; } function extraparams_groups() { - const lk_tab = 'mygroups' - const lk_LF = 'userId' - const lk_FF = '_id' - const lk_as = 'group' - const af_objId_tab = 'myId' + const lk_tab = 'mygroups'; + const lk_LF = 'userId'; + const lk_FF = '_id'; + const lk_as = 'group'; + const af_objId_tab = 'myId'; return { lookup1: { @@ -435,90 +462,93 @@ export default defineComponent({ title: 1, descr: 1, photos: 1, - } + }, }, - } + }; } function extraparams_rich() { return { querytype: shared_consts.QUERYTYPE_CIRCUIT, myid: circuit.value ? circuit.value._id : '', - } + }; } function extraparams_rich_groups() { return { querytype: shared_consts.QUERYTYPE_GROUP_CIRCUIT, myid: circuit.value ? circuit.value._id : '', - } + }; } - const extraparams_movs = (() => { + const extraparams_movs = () => { if (showwhommov.value === 1) { return { querytype: shared_consts.QUERYTYPE_LIST_MOVEMENTS, myid: circuit.value ? circuit.value._id : '', username: userStore.my.username, - } + }; } else { return { querytype: shared_consts.QUERYTYPE_LIST_ALLMOVEMENTS, myid: circuit.value ? circuit.value._id : '', - } - + }; } - }) + }; function extraparams_refused() { return { querytype: shared_consts.QUERYTYPE_REFUSED_USER_CIRCUIT, myid: circuit.value ? circuit.value._id : '', - } + }; } function extraparams_refused_groups() { return { querytype: shared_consts.QUERYTYPE_REFUSED_GROUP_CIRCUIT, myid: circuit.value ? circuit.value._id : '', - } + }; } function numUsers() { - return users_in_circuit.value ? users_in_circuit.value.length : 0 + return users_in_circuit.value ? users_in_circuit.value.length : 0; } function numAdmins() { - let quanti = (circuit.value && circuit.value.admins) ? circuit.value.admins.length : 0 - if (quanti === 0) - quanti = 1 + let quanti = + circuit.value && circuit.value.admins ? circuit.value.admins.length : 0; + if (quanti === 0) quanti = 1; - return quanti + return quanti; } function listaAdmins() { - return (circuit.value && circuit.value.admins) ? circuit.value.admins.map((rec) => rec.username).join(', ') : '' + return circuit.value && circuit.value.admins + ? circuit.value.admins.map((rec) => rec.username).join(', ') + : ''; } function getRegulation(reg: string) { - const strreg = reg + '' + const strreg = reg + ''; if (!reg) { - const mystringa = t('circuit.regolamento', { nomecircuito: circuit.value!.name }) - return mystringa + const mystringa = t('circuit.regolamento', { nomecircuito: circuit.value!.name }); + return mystringa; } else { - return reg + return reg; } - } async function aggiornaSaldo() { - loadSaldo.value = true + loadSaldo.value = true; await circuitStore.aggiornaSaldo(circuit.value!._id, ''); - loadAccount() - loadSaldo.value = false + loadAccount(); + loadSaldo.value = false; } + function myusername() { + return userStore.my.username; + } - onMounted(mounted) + onMounted(mounted); return { profile, @@ -589,6 +619,7 @@ export default defineComponent({ saldo_pend, mycards_annunci, card, - } - } -}) + myusername, + }; + }, +}); diff --git a/src/views/user/mycircuit/mycircuit.vue b/src/views/user/mycircuit/mycircuit.vue index 3462e458..536d71d2 100755 --- a/src/views/user/mycircuit/mycircuit.vue +++ b/src/views/user/mycircuit/mycircuit.vue @@ -647,7 +647,7 @@ shared_consts.GROUPSCMD.REQGROUP, myusername(), true, - grp.groupname + groupnameSel ? groupnameSel.groupname : '' ) " >