From c02037b35c0b67eaf701a2e96fea80decd60b246 Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Tue, 3 Oct 2023 00:40:54 +0200 Subject: [PATCH] correzione numseen, numfav, ...: ora li ho aggiunti alle tabelle... --- src/common/shared_vuejs.ts | 11 ++++++ .../CMyCardService/CMyCardService.ts | 8 +++- .../CMyCardService/CMyCardService.vue | 38 +++++++++---------- src/components/CMyRecCard/CMyRecCard.vue | 4 +- src/store/UserStore.ts | 34 +++++++---------- 5 files changed, 53 insertions(+), 42 deletions(-) diff --git a/src/common/shared_vuejs.ts b/src/common/shared_vuejs.ts index 12773a20..56cb828d 100755 --- a/src/common/shared_vuejs.ts +++ b/src/common/shared_vuejs.ts @@ -966,6 +966,14 @@ export const shared_consts = { 10, ], + REACTIONS_FIELD: + { + numseen: 1, + numbook: 1, + numfav: 1, + numattend: 1, + }, + OrderStatusStr: [ { label: 'Nessuno', @@ -1755,6 +1763,7 @@ export const shared_consts = { }, getProjectForAll(proj_add: any, table?: string) { + let proj = { idContribType: 1, idCity: 1, @@ -1796,6 +1805,8 @@ export const shared_consts = { if (proj_add) proj = Object.assign({}, proj, proj_add); + proj = {...proj, ...this.REACTIONS_FIELD}; + if (table) { let proj_add3 = this.getProjectByTable(table); proj = Object.assign({}, proj, proj_add3); diff --git a/src/components/CMyCardService/CMyCardService.ts b/src/components/CMyCardService/CMyCardService.ts index b866238a..cfb3ac23 100644 --- a/src/components/CMyCardService/CMyCardService.ts +++ b/src/components/CMyCardService/CMyCardService.ts @@ -180,7 +180,13 @@ export default defineComponent({ }) } else { - myrec.value = props.prop_myrec + // myrec.value = props.prop_myrec + await userStore.loadGeneric(props.table, props.prop_myrec._id, idnotif.value).then((ris) => { + console.log('myrec', myrec) + myrec.value = ris + notifStore.setAsRead(idnotif.value) + }) + } if (myrec.value) diff --git a/src/components/CMyCardService/CMyCardService.vue b/src/components/CMyCardService/CMyCardService.vue index cda4aa40..3363ff26 100644 --- a/src/components/CMyCardService/CMyCardService.vue +++ b/src/components/CMyCardService/CMyCardService.vue @@ -40,9 +40,9 @@
@@ -61,9 +61,9 @@ @click="clicca(costanti.TIPOFAVBOOK.FAVORITE, true, '')" > @@ -82,9 +82,9 @@ @click="clicca(costanti.TIPOFAVBOOK.BOOKMARK, true, '')" > @@ -140,7 +140,7 @@ {{ $t('cmd.favorite', { - num: myrec.myreact.numfav ? myrec.myreact.numfav : 0, + num: myrec.numfav ? myrec.numfav : 0, }) }} @@ -227,7 +227,7 @@ - {{ myrec.myreact.numseen ? myrec.myreact.numseen : 0 }} + {{ myrec.numseen ? myrec.numseen : 0 }}   - {{ myrec.myreact.numfav ? myrec.myreact.numfav : 0 }} + {{ myrec.numfav ? myrec.numfav : 0 }} { if (res && res.data.state === 1) { if (myrec) { - if (!myrec.myreact) { - myrec.myreact = { - numfav: 0, - } + if (!myrec.numfav) { + myrec.numfav = 0 } if (!recreaction) @@ -1717,13 +1715,13 @@ export const useUserStore = defineStore('UserStore', { else recreaction.fav = true; - myrec.myreact.numfav++ + myrec.numfav++ } tools.showPositiveNotif($q, t('cmd.favorite_set')) } else if (res && res.data.state === -1) { // this.my.profile.favorite = tools.removeIObjectOnce(this.my.profile.favorite, { id, tab }) - if (myrec && myrec.myreact.numfav) { - myrec.myreact.numfav-- + if (myrec && myrec.numfav) { + myrec.numfav-- //this.my.profile.reaction = this.my.profile.reaction.filter((rec: IReaction) => !((rec.idrec === id) && (rec.tab === tab) && (rec.username === this.my.username) && (rec.fav === true))) if (recreaction) recreaction.fav = false @@ -1749,10 +1747,8 @@ export const useUserStore = defineStore('UserStore', { return await Api.SendReq('/reactions/cmd', 'POST', { cmd: CMD_REACTION.SET_ATTEND, id, tab, value }) .then((res) => { if (res && res.data.state === 1) { - if (!myrec.myreact) { - myrec.myreact = { - numattend: 0, - } + if (!myrec.numattend) { + myrec.numattend = 0 } if (!myrec.myreact.attend) myrec.myreact.attend = false @@ -1815,10 +1811,8 @@ export const useUserStore = defineStore('UserStore', { return await Api.SendReq('/reactions/cmd', 'POST', { cmd: CMD_REACTION.SET_BOOKMARK, id, tab, value }) .then((res) => { if (res && res.data.state === 1) { - if (!myrec.myreact) { - myrec.myreact = { - numseen: 0, - } + if (!myrec.numbook) { + myrec.numbook = 0 } if (!myrec.mybook) myrec.mybook = [] @@ -1827,13 +1821,13 @@ export const useUserStore = defineStore('UserStore', { else recreaction.book = true - myrec.myreact.numbook++ + myrec.numbook++ tools.showPositiveNotif($q, t('cmd.bookmark_set')) } else if (res && res.data.state === -1) { //++ this.my.profile.reaction = tools.removeIObjectOnce(this.my.profile.reaction, { id, tab, }) if ((myrec && myrec.mybook) && recreaction) recreaction.book = false - myrec.myreact.numbook-- + myrec.numbook-- //myrec.mybook = myrec.mybook.filter((rec: IFavBook) => rec.username !== this.my.username) tools.showNegativeNotif($q, t('cmd.bookmark_unset')) } @@ -1876,12 +1870,12 @@ export const useUserStore = defineStore('UserStore', { .then((res) => { if (res && res.data.state === 1) { if (value) { - if (!myrec.myreact) { - myrec.myreact = { + if (!myrec) { + myrec = { numseen: 0, } } - myrec.myreact.numseen++ + myrec.numseen++ if (!recreaction) this.my.profile.reaction.push({ id: objectId(), idrec: id, tab, username: this.my.username, seen: true }) else