Fixed: le reactions devono stare in una tabella a parte (reactions).

- cambiata la gestione dei seen, fav, book, attend
This commit is contained in:
Surya Paolo
2023-09-27 18:39:05 +02:00
parent f88b753f26
commit 2b359d5260
18 changed files with 4166 additions and 131 deletions

View File

@@ -1,4 +1,4 @@
APP_VERSION="1.0.15"
APP_VERSION="1.0.16"
SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13"
DIRECTORY_LOCAL="newfreeplanet"

View File

@@ -1,4 +1,4 @@
APP_VERSION="1.0.15"
APP_VERSION="1.0.16"
SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13"
DIRECTORY_LOCAL=newfreeplanet

View File

@@ -1,4 +1,4 @@
APP_VERSION="1.0.15"
APP_VERSION="1.0.16"
SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13"
DIRECTORY_LOCAL=newfreeplanet

View File

@@ -1,4 +1,4 @@
APP_VERSION="1.0.15"
APP_VERSION="1.0.16"
SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13"
DIRECTORY_LOCAL="newfreeplanet"

View File

@@ -1,4 +1,4 @@
APP_VERSION="1.0.15"
APP_VERSION="1.0.16"
SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13"
DIRECTORY_LOCAL=newfreeplanet

View File

@@ -1,4 +1,4 @@
APP_VERSION="1.0.15"
APP_VERSION="1.0.16"
SERVICE_WORKER_FILE="service-worker.js"
APP_ID="14"
DIRECTORY_LOCAL="newfreeplanet"

View File

@@ -1144,6 +1144,12 @@
:prop_myrec="myrecdialog"
>
</CMyCardCircuitPopup>
<!--<CMyCardService
v-else-if="shared_consts.TABLES_FAVORITE_BOOKMARK.includes(mytable)"
:table="mytable"
:idRec="myrecdialog._id"
>
</CMyCardService>-->
<CMyCardService
v-else-if="shared_consts.TABLES_FAVORITE_BOOKMARK.includes(mytable)"
:table="mytable"

View File

@@ -0,0 +1,48 @@
.colmodif {
cursor: pointer;
}
.coldate {
max-width: 250px;
min-width: 200px;
}
.tdclass, .trclass{
min-height: 20px !important;
margin-top: 5px;
}
.q-table td {
padding-left: 1px;
padding-right: 2px;
padding-top: 0;
padding-bottom: 0;
&__title {
font-size: 1rem;
}
}
.q-table {
&__col {
font-size: 1rem;
color: gray;
}
}
.newrec_fields{
display: flex;
padding: 2px;
margin: 2px;
align-items: center;
justify-content: center;
}
.riduci_pad {
min-height: 30px;
padding: 4px 8px !important;
}
.q-table__top{
padding-top: 0 !important;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
export {default as CGridTableUser} from './CGridTableUser.vue'

View File

@@ -24,7 +24,7 @@ import { useI18n } from '@/boot/i18n'
import { toolsext } from '@store/Modules/toolsext'
import { useQuasar } from 'quasar'
import { costanti } from '@costanti'
import { IBookmark, ICircuit, IFavorite, IMyCircuit, IMyGroup, IUserFields } from 'model'
import { IBookmark, IReaction, ICircuit, IFavorite, IMyCircuit, IMyGroup, IUserFields } from 'model'
import { shared_consts } from '@/common/shared_vuejs'
import { static_data } from '@/db/static_data'
import { fieldsTable } from '@store/Modules/fieldsTable'
@@ -183,19 +183,19 @@ export default defineComponent({
function filtrofavorite(table: string) {
const tab = tools.getNumTabByTable(table)
if (myuser.value && myuser.value.profile.favorite) {
let arrfav = myuser.value.profile.favorite.filter((rec: IBookmark) => rec.tab === tab)
if (myuser.value && myuser.value.profile.reaction) {
let arrfav = myuser.value.profile.reaction.filter((rec: IReaction) => rec.tab === tab && (rec.fav! === true))
if (arrfav)
return myuser.value.profile.favorite ? [{ _id: { $in: arrfav.map((rec: any) => rec.id) } }] : []
return myuser.value.profile.reaction ? [{ _id: { $in: arrfav.map((rec: any) => rec.id) } }] : []
}
return []
}
function filtrobookmark(table: string) {
const tab = tools.getNumTabByTable(table)
if (myuser.value && myuser.value.profile.bookmark) {
let arrfav = myuser.value.profile.bookmark.filter((rec: IBookmark) => rec.tab === tab)
if (myuser.value && myuser.value.profile.reaction) {
let arrfav = myuser.value.profile.reaction.filter((rec: IReaction) => rec.tab === tab && rec.book === true);
if (arrfav)
return myuser.value.profile.bookmark ? [{ _id: { $in: arrfav.map((rec: any) => rec.id) } }] : []
return myuser.value.profile.reaction ? [{ _id: { $in: arrfav.map((rec: any) => rec.id) } }] : []
}
return []
}

View File

@@ -7,6 +7,7 @@ import { CDateTime } from '@/components/CDateTime'
import { CMyPage } from '@/components/CMyPage'
import { CMyGroup } from '@/components/CMyGroup'
import { CMyChipList } from '@/components/CMyChipList'
import { CGridTableUser } from '@/components/CGridTableUser'
import { CMyFieldRec } from '@/components/CMyFieldRec'
import { CMyUser } from '@/components/CMyUser'
import { CLabel } from '@/components/CLabel'
@@ -20,7 +21,7 @@ import { useI18n } from '@/boot/i18n'
import { toolsext } from '@store/Modules/toolsext'
import { useQuasar } from 'quasar'
import { costanti } from '@costanti'
import { EState, IBookedEventPage, IColGridTable, IBookedEvent, IEvents, IMessage, IMessagePage, IParamDialog } from '@model'
import { EState, IReaction, IBookedEventPage, IColGridTable, IBookedEvent, IEvents, IMessage, IMessagePage, IParamDialog, ISearchList } from '@model'
import { shared_consts } from '@/common/shared_vuejs'
import { colCitys, fieldsTable } from '@store/Modules/fieldsTable'
import { useRoute, useRouter } from 'vue-router'
@@ -35,7 +36,7 @@ export default defineComponent({
components: {
CProfile, CTitleBanner,
CMyFieldDb, CDateTime, CMyPage, CMyFieldRec, CAccomodation,
CMyUser, CGalleryImages, CMyChipList, CLabel, CMyGroup
CMyUser, CGalleryImages, CMyChipList, CLabel, CMyGroup, CGridTableUser,
},
props: {
table: {
@@ -69,6 +70,10 @@ export default defineComponent({
const $route = useRoute()
const { t } = useI18n()
const arrfilterand: any = ref([])
const searchList = ref(<ISearchList[]>[])
const filter = ref(costanti.FIND_PEOPLE)
const showPic = ref(false)
const loading = ref(false)
@@ -77,8 +82,8 @@ export default defineComponent({
const contextDay = ref(<any>null)
const usersList = ref({ show: false, title: '', list: [] })
const bookedList = ref(<any>{ show: false, title: '', list: [] })
const usersList = ref(<any>{ show: false, title: '', list: [], loadfromDb: false, tipofavbook: 0 })
const bookedList = ref(<any>{ show: false, title: '', list: [], loadfromDb: false, tipofavbook: 0 })
const formbookEventDefault = ref(<IBookedEvent>{
userId: '',
@@ -138,12 +143,35 @@ export default defineComponent({
const idnotif = computed(() => $route.query.idnotif ? $route.query.idnotif.toString() : '')
const arrbookings = computed(() => calendarStore.findAllBookedByIdEvent(myrec.value._id))
const filtercustom: any = computed(() => {
let queryreact = {}
if (usersList.value.tipofavbook === costanti.TIPOFAVBOOK.SEEN) {
queryreact = {seen: true}
} else if (usersList.value.tipofavbook === costanti.TIPOFAVBOOK.FAVORITE) {
queryreact = {fav: true}
} else if (usersList.value.tipofavbook === costanti.TIPOFAVBOOK.BOOKMARK) {
queryreact = {book: true}
} else if (usersList.value.tipofavbook === costanti.TIPOFAVBOOK.ATTEND) {
queryreact = {attend: true}
}
return [{
idapp: process.env.APP_ID,
tab: tools.getNumTabByTable(props.table),
idrec: myrec.value._id,
...queryreact,
}]
})
function profile() {
return userStore.my.profile
}
function load() {
// Carica il profilo di quest'utente
// Carica il record
if (props.idRec) {
userStore.loadGeneric(props.table, props.idRec, idnotif.value).then((ris) => {
myrec.value = ris
@@ -210,29 +238,32 @@ export default defineComponent({
if (myset) {
await userStore.setFavorite($q, t, myrec.value._id, props.table, myrec.value);
}
mylist = myrec.value.myfav
mylist = myrec.value.myreaction ? myrec.value.myreaction.filter((rec: IReaction) => rec.fav) : []
} else if (tipo === costanti.TIPOFAVBOOK.BOOKMARK) {
if (myset) {
await userStore.setBookmark($q, t, myrec.value._id, props.table, myrec.value);
}
mylist = myrec.value.mybook
mylist = myrec.value.myreaction ? myrec.value.myreaction.filter((rec: IReaction) => rec.book) : []
} else if (tipo === costanti.TIPOFAVBOOK.SEEN) {
if (myset) {
loading.value = true
const risrecord = await userStore.setSeen($q, t, myrec.value._id, props.table, myrec.value)
if (risrecord) {
myrec.value = risrecord
calendarStore.updatearrBookingEvent(myrec.value._id, risrecord.mybookings)
if (!userStore.isSeen(myrec.value._id, props.table)) {
loading.value = true
const risrecord = await userStore.setSeen($q, t, myrec.value._id, props.table, myrec.value)
if (risrecord && risrecord.mybookings) {
myrec.value = risrecord
bookEventpage.value.state = EState.None
calendarStore.updatearrBookingEvent(myrec.value._id, risrecord.mybookings)
const findev = calendarStore.findEventBooked(myrec.value._id, false)
EditBookEvent(false)
bookEventpage.value.state = EState.None
const findev = calendarStore.findEventBooked(myrec.value._id, false)
EditBookEvent(false)
}
loading.value = false
}
loading.value = false
}
mylist = myrec.value.myseen
mylist = myrec.value.myreaction ? myrec.value.myreaction.filter((rec: IReaction) => rec.seen) : []
} else if (tipo === costanti.TIPOFAVBOOK.ATTEND) {
if (myset) {
// userStore.setAttend($q, t, myrec.value._id, props.table, bookEventpage.value.bookedevent.numpeople, myrec.value);
@@ -240,17 +271,19 @@ export default defineComponent({
mylist = arrbookings.value
if (!myset && mylist && mylist.length > 0) {
bookedList.value.show = true;
bookedList.value.title = title;
bookedList.value.list = mylist;
bookedList.value.show = true
bookedList.value.title = title
bookedList.value.list = mylist
}
return true;
}
if (!myset && mylist && mylist.length > 0) {
usersList.value.show = true;
usersList.value.title = title;
usersList.value.list = mylist;
if (!myset && mylist) {
usersList.value.show = true
usersList.value.title = title
usersList.value.tipofavbook = tipo
usersList.value.loadfromDb = true
usersList.value.list = mylist
}
}
@@ -442,6 +475,101 @@ export default defineComponent({
arrbookings.value.find((recbook: IBookedEvent) => recbook.userId === userStore.my._id && recbook.booked)
}
function extraparams() {
return {
lookupPipeline1: {
lk_tab: 'users',
lk_LF: 'userId',
lk_FF: '_id',
lk_as: 'user',
lk_proj: {
name: 1,
surname: 1,
username: 1,
'profile.handshake': 1,
'profile.img': 1,
'profile.mygroups': 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
'mycities.reg': 1,
},
},
/*
{
$lookup: {
from: "users",
let: { searchId: { $toObjectId: "$userId" } },
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ["$_id", "$$searchId"] },
],
},
},
},
{
$project: {
name: 1,
surname: 1,
username: 1,
"profile.handshake": 1,
"profile.img": 1,
"profile.mygroups": 1,
"profile.qualifica": 1,
"profile.resid_province": 1,
"mycities.reg": 1,
},
}
],
as: "user",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$mycities",
0,
],
},
{
$arrayElemAt: [
"$user",
0,
],
},
"$$ROOT",
],
},
},
},
lookup1: {
lk_tab: 'provinces',
lk_LF: 'profile.resid_province',
lk_FF: 'prov',
lk_as: 'mycities',
lk_proj: {
username: 1,
name: 1,
surname: 1,
'profile.handshake': 1,
'profile.img': 1,
'profile.mygroups': 1,
'profile.qualifica': 1,
'profile.resid_province': 1,
'mycities.reg': 1,
}
},
*/
}
}
onMounted(mounted)
@@ -485,6 +613,11 @@ export default defineComponent({
isAlreadyBooked,
bookEventForm,
loading,
arrfilterand,
filtercustom,
searchList,
filter,
extraparams,
}
}
})

View File

@@ -2,6 +2,7 @@
<div v-if="myrec && myrec._id" class="fulldiv">
<div class="q-pa-sm row items-start q-gutter-sm full-height fulldiv">
<q-card class="my-card fulldiv" bordered>
idRec: {{ idRec }}
<CGalleryImages
v-if="myrec.photos.length > 0"
:imgGallery="myrec.photos"
@@ -40,9 +41,8 @@
<div class="">
<q-btn flat round color="blue" icon="far fa-eye">
<q-badge
v-if="myrec.myseen"
color="primary"
:label="myrec.myseen.length"
:label="myrec.myreact.numseen ? myrec.myreact.numseen : 0"
floating
transparent
/>
@@ -61,9 +61,8 @@
@click="clicca(costanti.TIPOFAVBOOK.FAVORITE, true, '')"
>
<q-badge
v-if="myrec.myfav"
color="primary"
:label="myrec.myfav.length"
:label="myrec.myreact.numfav ? myrec.myreact.numfav : 0"
floating
transparent
/>
@@ -82,9 +81,8 @@
@click="clicca(costanti.TIPOFAVBOOK.BOOKMARK, true, '')"
>
<q-badge
v-if="myrec.mybook"
color="primary"
:label="myrec.mybook.length"
:label="myrec.myreact.numbook ? myrec.myreact.numbook : 0"
floating
transparent
/>
@@ -104,7 +102,7 @@
<q-menu>
<q-list v-if="true" style="min-width: 200px">
<q-item
v-if="myrec.profile.username_telegram"
v-if="myrec.profile && myrec.profile.username_telegram"
clickable
v-close-popup
>
@@ -113,6 +111,7 @@
</q-item-section>
<q-item-section>
<a
v-if="myrec.profile && myrec.profile.username_telegram"
:href="
tools.getHttpForTelegram(
myrec.profile.username_telegram
@@ -146,7 +145,9 @@
costanti.TIPOFAVBOOK.SEEN,
false,
$t('cmd.seen', {
num: myrec.myseen ? myrec.myseen.length : 0,
num: myrec.myreact.numseen
? myrec.myreact.numseen
: 0,
})
)
"
@@ -157,7 +158,9 @@
<q-item-section>
{{
$t('cmd.seen', {
num: myrec.myseen ? myrec.myseen.length : 0,
num: myrec.myreact.numseen
? myrec.myreact.numseen
: 0,
})
}}
</q-item-section>
@@ -170,7 +173,7 @@
costanti.TIPOFAVBOOK.FAVORITE,
false,
$t('cmd.favorite', {
num: myrec.myfav ? myrec.myfav.length : 0,
num: myrec.myreact.numfav ? myrec.myreact.numfav : 0,
})
)
"
@@ -181,12 +184,13 @@
<q-item-section>
{{
$t('cmd.favorite', {
num: myrec.myfav ? myrec.myfav.length : 0,
num: myrec.myreact.numfav ? myrec.myreact.numfav : 0,
})
}}
</q-item-section>
</q-item>
<q-item
v-if="table === shared_consts.TABLES_MYBACHECAS"
clickable
v-close-popup
@click="
@@ -226,7 +230,9 @@
costanti.TIPOFAVBOOK.BOOKMARK,
false,
$t('cmd.bookmark', {
num: myrec.mybook ? myrec.mybook.length : 0,
num: myrec.myreact.numbook
? myrec.myreact.numbook
: 0,
})
)
"
@@ -237,7 +243,9 @@
<q-item-section>
{{
$t('cmd.bookmark', {
num: myrec.mybook ? myrec.mybook.length : 0,
num: myrec.myreact.numbook
? myrec.myreact.numbook
: 0,
})
}}
</q-item-section>
@@ -695,7 +703,10 @@
class="row absolute-bottom text-shadow custom-caption q-px-md buttons_bottom"
>
<q-btn
v-if="myrec.profile.username_telegram || myrec.contact_telegram"
v-if="
(myrec.profile && myrec.profile.username_telegram) ||
myrec.contact_telegram
"
:label="$t('dialog.contact')"
color="primary"
icon="far fa-comment"
@@ -751,7 +762,7 @@
/>
</div>
</div>
<q-dialog v-model="usersList.show">
<q-dialog v-model="usersList.loadfromDb">
<q-card class="dialog_card">
<q-toolbar class="bg-primary text-white">
<q-toolbar-title>
@@ -761,13 +772,43 @@
</q-toolbar>
<q-card-section class="inset-shadow">
<div v-for="(rec, i) in usersList.list" :key="i">
<CMyUser
:mycontact="rec"
:visu="costanti.FIND_PEOPLE"
@setCmd="tools.setCmd"
<div v-if="usersList.loadfromDb">
<CGridTableUser
prop_mytable="reactions"
prop_mytitle=""
:prop_mycolumns="colmyUserPeople"
prop_colkey="_id"
col_title="username"
:vertical="costanti.VISUTABLE_LISTA"
nodataLabel=" "
:prop_search="false"
:prop_showfilter="false"
hint=""
:finder="false"
:choose_visutype="false"
:finder_noNull="false"
:finder_noNullFilters="false"
:options="shared_consts.OPTIONS_SEARCH_USER_ALL_WORDS"
:butt_modif_new="false"
noresultLabel="Username o nome non trovato"
:arrfilters="arrfilterand"
:filtercustom="filtercustom"
:prop_searchList="searchList"
:showType="costanti.SHOW_USERINFO"
:showCol="false"
:extraparams="extraparams()"
>
</CMyUser>
</CGridTableUser>
</div>
<div v-else>
<div v-for="(rec, i) in usersList.list" :key="i">
<CMyUser
:mycontact="rec"
:visu="costanti.FIND_PEOPLE"
@setCmd="tools.setCmd"
>
</CMyUser>
</div>
</div>
</q-card-section>
</q-card>
@@ -903,7 +944,8 @@
<div class="q-pa-xs">
<q-card class="windowcol" style="display: block">
<q-card-section class="q-pa-xs">
<div>{{ $t('cal.infoprenota') }}</div><br>
<div>{{ $t('cal.infoprenota') }}</div>
<br />
<div style="display: inline-flex" class="q-px-xs centermydiv">
<q-checkbox
style="color: black"

View File

@@ -181,12 +181,12 @@
><q-icon dense color="blue" name="far fa-check-circle" />
</span>
</span>
<span class="q-mx-xxs">{{ myrec.myseen ? myrec.myseen.length : 0 }}</span>
<span class="q-mx-xxs">{{ myrec.myreact.numseen ? myrec.myreact.numseen : 0 }}</span>
<span class="q-mx-xxs"
><q-icon dense color="blue" name="far fa-eye" />
</span>
<span class="q-mx-xxs">&nbsp;</span>
<span class="">{{ myrec.myfav ? myrec.myfav.length : 0 }}</span>
<span class="">{{ myrec.myreact.numfav ? myrec.myreact.numfav : 0 }}</span>
<span class="q-mx-xxs"
><q-icon
dense

View File

@@ -77,6 +77,16 @@ export interface IAttend {
tab: number
num: number
}
export interface IReaction {
id: string
idrec: string
username: string
tab: number
seen?: boolean
fav?: boolean
book?: boolean
attend?: boolean
}
export interface IFavBook {
username: string
@@ -141,16 +151,14 @@ export interface IUserProfile {
noNameSurname: boolean
noCircuit: boolean
noFoto: boolean
bookmark: IBookmark[]
favorite: IFavorite[]
seen: ISeen[]
attend: IAttend[]
reaction: IReaction[]
// bookmark: IBookmark[]
// favorite: IFavorite[]
// seen: ISeen[]
// attend: IAttend[]
// Query
myfav: IFavBook[]
mybook: IFavBook[]
myseen: IFavBook[]
myattend: IFavBook[]
myreaction: IReaction[]
mybookings: IBookedEvent[]
// in memory

View File

@@ -20,6 +20,8 @@ import { tools } from '@store/Modules/tools'
import translate from '@src/globalroutines/util'
import { ICallResult, ILinkReg, IResult, IToken } from '@model/other'
import objectId from '@src/js/objectId'
import * as Types from '@src/store/Api/ApiTypes'
import { useGlobalStore } from '@store/globalStore'
import { serv_constants } from '@store/Modules/serv_constants'
@@ -35,13 +37,13 @@ import { Router } from 'vue-router'
import { useProjectStore } from '@store/Projects'
import { shared_consts } from '@/common/shared_vuejs'
import { costanti } from '@costanti'
import { IBookmark, ISeen, IFavBook, IAttend, IFavorite, IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
import { IReaction, IBookmark, ISeen, IFavBook, IAttend, IFavorite, IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
import globalroutines from '../globalroutines/index'
import { useNotifStore } from '@store/NotifStore'
import { useCircuitStore } from './CircuitStore'
export const CMD_USER = {
export const CMD_REACTION = {
SET_FAVORITE: 1,
SET_BOOKMARK: 2,
SET_SEEN: 3,
@@ -83,14 +85,12 @@ export const DefaultUser: IUserFields = {
asked_groups: [],
refused_groups: [],
notifs: [],
bookmark: [],
favorite: [],
seen: [],
attend: [],
myfav: [],
mybook: [],
myseen: [],
myattend: [],
// bookmark: [],
// favorite: [],
// seen: [],
// attend: [],
reaction: [],
myreaction: [],
mybookings: [],
notif_idCities: [],
notif_provinces: [],
@@ -157,14 +157,8 @@ export const DefaultProfile: IUserProfile = {
asked_groups: [],
refused_groups: [],
notifs: [],
bookmark: [],
favorite: [],
seen: [],
attend: [],
myfav: [],
mybook: [],
myseen: [],
myattend: [],
reaction: [],
myreaction: [],
mybookings: [],
notif_idCities: [],
notif_provinces: [],
@@ -1701,21 +1695,29 @@ export const useUserStore = defineStore('UserStore', {
console.log('table', table)
const tab = tools.getNumTabByTable(table)
const recreaction = this.getRecReaction(id, table)
value = this.isFavorite(id, table) ? false : true
return await Api.SendReq('/users/cmd', 'POST', { cmd: CMD_USER.SET_FAVORITE, id, tab, value })
return await Api.SendReq('/reactions/cmd', 'POST', { cmd: CMD_REACTION.SET_FAVORITE, id, tab, value })
.then((res) => {
if (res && res.data.state === 1) {
if (!myrec.myfav)
myrec.myfav = []
this.my.profile.favorite.push({ id, tab })
if (myrec)
myrec.myfav.push({ username: this.my.username })
if (myrec) {
if (!recreaction)
this.my.profile.reaction.push({ id: objectId(), idrec: id, tab, username: this.my.username, fav: true })
else
recreaction.fav = true;
myrec.myreact.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.myfav)
myrec.myfav = myrec.myfav.filter((rec: IFavBook) => rec.username !== this.my.username)
// this.my.profile.favorite = tools.removeIObjectOnce(this.my.profile.favorite, { id, tab })
if (myrec && myrec.myreact.numfav) {
myrec.myreact.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
}
tools.showNegativeNotif($q, t('cmd.favorite_unset'))
}
}).catch((error) => {
@@ -1731,21 +1733,27 @@ export const useUserStore = defineStore('UserStore', {
console.log('table', table)
const tab = tools.getNumTabByTable(table)
const recreaction = this.getRecReaction(id, table)
value = this.isAttend(id, table) ? false : true
return await Api.SendReq('/users/cmd', 'POST', { cmd: CMD_USER.SET_ATTEND, id, tab, value })
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.myattend)
myrec.myattend = []
this.my.profile.attend.push({ id, tab, num })
if (myrec)
myrec.myattend.push({ username: this.my.username })
if (!myrec.myreact.attend)
myrec.myreact.attend = false
// create a record
//++ this.my.profile.reaction.push({ id, tab, attend: true })
if (myrec) {
if (!recreaction)
this.my.profile.reaction.push({ id: objectId(), idrec: id, tab, username: this.my.username, attend: true })
else
recreaction.attend = true
}
tools.showPositiveNotif($q, t('cmd.attend_set'))
} else if (res && res.data.state === -1) {
this.my.profile.attend = tools.removeIObjectOnce(this.my.profile.attend, { id, tab })
if (myrec && myrec.myattend)
myrec.myattend = myrec.myattend.filter((rec: IFavBook) => rec.username !== this.my.username)
//++ this.my.profile.attend = tools.removeIObjectOnce(this.my.profile.attend, { id, tab })
if (myrec && myrec.myattend && recreaction)
recreaction.attend = false
tools.showNegativeNotif($q, t('cmd.attend_unset'))
}
}).catch((error) => {
@@ -1755,28 +1763,30 @@ export const useUserStore = defineStore('UserStore', {
},
isSeen(id: string, table: string) {
getRecReaction(id: string, table: string) {
const tab = tools.getNumTabByTable(table)
const myseen = this.my.profile.seen.find((rec: ISeen) => ((rec.id === id) && (rec.tab === tab)))
return myseen
const myrec = this.my.profile.reaction.find((rec: IReaction) => ((rec.idrec === id) && (rec.tab === tab)))
return myrec
},
isSeen(id: string, table: string) {
const myrec = this.getRecReaction(id, table)
return myrec ? myrec.seen : false
},
isBookmarked(id: string, table: string) {
const tab = tools.getNumTabByTable(table)
const mybookmark = this.my.profile.bookmark.find((rec: IBookmark) => ((rec.id === id) && (rec.tab === tab)))
return mybookmark
const myrec = this.getRecReaction(id, table)
return myrec ? myrec.book : false
},
isFavorite(id: string, table: string) {
const tab = tools.getNumTabByTable(table)
const myfavorite = this.my.profile.favorite.find((rec: IFavorite) => ((rec.id === id) && (rec.tab === tab)))
return myfavorite
const myrec = this.getRecReaction(id, table)
return myrec ? myrec.fav : false
},
isAttend(id: string, table: string) {
const tab = tools.getNumTabByTable(table)
const myattend = this.my.profile.attend.find((rec: IAttend) => ((rec.id === id) && (rec.tab === tab)))
return myattend
const myrec = this.getRecReaction(id, table)
return myrec ? myrec.attend : false
},
async setBookmark($q: any, t: any, id: any, table: string, myrec: any) {
@@ -1784,21 +1794,27 @@ export const useUserStore = defineStore('UserStore', {
const tab = tools.getNumTabByTable(table)
const recreaction = this.getRecReaction(id, table)
value = this.isBookmarked(id, table) ? false : true
return await Api.SendReq('/users/cmd', 'POST', { cmd: CMD_USER.SET_BOOKMARK, id, tab, value })
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.mybook)
myrec.mybook = []
this.my.profile.bookmark.push({ id, tab })
if (myrec)
myrec.mybook.push({ username: this.my.username })
if (!recreaction)
this.my.profile.reaction.push({ id: objectId(), idrec: id, tab, username: this.my.username, book: true })
else
recreaction.book = true
myrec.myreact.numbook++
tools.showPositiveNotif($q, t('cmd.bookmark_set'))
} else if (res && res.data.state === -1) {
this.my.profile.bookmark = tools.removeIObjectOnce(this.my.profile.bookmark, { id, tab })
if (myrec && myrec.mybook)
myrec.mybook = myrec.mybook.filter((rec: IFavBook) => rec.username !== this.my.username)
//++ this.my.profile.reaction = tools.removeIObjectOnce(this.my.profile.reaction, { id, tab, })
if ((myrec && myrec.mybook) && recreaction)
recreaction.book = false
myrec.myreact.numbook--
//myrec.mybook = myrec.mybook.filter((rec: IFavBook) => rec.username !== this.my.username)
tools.showNegativeNotif($q, t('cmd.bookmark_unset'))
}
}).catch((error) => {
@@ -1833,17 +1849,19 @@ export const useUserStore = defineStore('UserStore', {
const tab = tools.getNumTabByTable(table)
const recreaction = this.getRecReaction(id, table)
value = this.isSeen(id, table) ? false : true
return await Api.SendReq('/users/cmd', 'POST', { cmd: CMD_USER.SET_SEEN, id, tab, value })
return await Api.SendReq('/reactions/cmd', 'POST', { cmd: CMD_REACTION.SET_SEEN, id, tab, value })
.then((res) => {
if (res && res.data.state === 1) {
if (!myrec.myseen)
myrec.myseen = []
this.my.profile.seen.push({ id, tab })
if (myrec)
myrec.myseen.push({ username: this.my.username })
if (value) {
myrec.myreact.numseen++
if (!recreaction)
this.my.profile.reaction.push({ id: objectId(), idrec: id, tab, username: this.my.username, seen: true })
else
recreaction.seen = true
}
}
if (res && res.data) {
if (res.data.record) {

View File

@@ -530,6 +530,14 @@
@click="EseguiFunz('setstrProvByIdCityCircuits')"
></q-btn>
</div>
<div class="row">
<q-btn
label="Aggiorna newRecordsFav - UNA VOLTA SOLA"
color="negative"
@click="EseguiFunz('newRecordsFav')"
></q-btn>
<br />
</div>
</template>
<script lang="ts" src="./dbop.ts">
</script>