++ aggiunta la prenotazione negli eventi. con la lista degli utenti.
This commit is contained in:
@@ -35,7 +35,7 @@ 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, IFavorite, IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
|
||||
import { IBookmark, ISeen, IFavBook, IAttend, IFavorite, IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
|
||||
|
||||
import globalroutines from '../globalroutines/index'
|
||||
import { useNotifStore } from '@store/NotifStore'
|
||||
@@ -45,6 +45,7 @@ export const CMD_USER = {
|
||||
SET_FAVORITE: 1,
|
||||
SET_BOOKMARK: 2,
|
||||
SET_SEEN: 3,
|
||||
SET_ATTEND: 4,
|
||||
}
|
||||
|
||||
export const DefaultUser: IUserFields = {
|
||||
@@ -85,9 +86,12 @@ export const DefaultUser: IUserFields = {
|
||||
bookmark: [],
|
||||
favorite: [],
|
||||
seen: [],
|
||||
attend: [],
|
||||
myfav: [],
|
||||
mybook: [],
|
||||
myseen: [],
|
||||
myattend: [],
|
||||
mybookings: [],
|
||||
notif_idCities: [],
|
||||
notif_provinces: [],
|
||||
notif_regions: [],
|
||||
@@ -156,9 +160,12 @@ export const DefaultProfile: IUserProfile = {
|
||||
bookmark: [],
|
||||
favorite: [],
|
||||
seen: [],
|
||||
attend: [],
|
||||
myfav: [],
|
||||
mybook: [],
|
||||
myseen: [],
|
||||
myattend: [],
|
||||
mybookings: [],
|
||||
notif_idCities: [],
|
||||
notif_provinces: [],
|
||||
notif_regions: [],
|
||||
@@ -254,7 +261,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return { sortBy: 'namecomplete', descending: false, page: 1, rowsNumber: 0, rowsPerPage: 15 }
|
||||
},
|
||||
getSortFieldsAvailable(): any[] {
|
||||
return [{ label: 'Name e User', value: { 'namecomplete': 1 } }, { label: 'Ultimi entrati', value: { 'date_reg': -1} }]
|
||||
return [{ label: 'Name e User', value: { 'namecomplete': 1 } }, { label: 'Ultimi entrati', value: { 'date_reg': -1 } }]
|
||||
},
|
||||
|
||||
IsMyFriendByUsername(username: string): boolean {
|
||||
@@ -1672,7 +1679,37 @@ export const useUserStore = defineStore('UserStore', {
|
||||
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)
|
||||
tools.showPositiveNotif($q, t('cmd.favorite_unset'))
|
||||
tools.showNegativeNotif($q, t('cmd.favorite_unset'))
|
||||
}
|
||||
}).catch((error) => {
|
||||
tools.showNegativeNotif($q, t('db.recfailed'))
|
||||
return {}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
async setAttend($q: any, t: any, id: any, table: string, num: number, myrec: any) {
|
||||
let value = false
|
||||
|
||||
console.log('table', table)
|
||||
const tab = tools.getNumTabByTable(table)
|
||||
|
||||
value = this.isAttend(id, table) ? false : true
|
||||
|
||||
return await Api.SendReq('/users/cmd', 'POST', { cmd: CMD_USER.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 })
|
||||
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)
|
||||
tools.showNegativeNotif($q, t('cmd.attend_unset'))
|
||||
}
|
||||
}).catch((error) => {
|
||||
tools.showNegativeNotif($q, t('db.recfailed'))
|
||||
@@ -1699,6 +1736,12 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return myfavorite
|
||||
},
|
||||
|
||||
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
|
||||
},
|
||||
|
||||
async setBookmark($q: any, t: any, id: any, table: string, myrec: any) {
|
||||
let value = false
|
||||
|
||||
@@ -1719,7 +1762,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
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)
|
||||
tools.showPositiveNotif($q, t('cmd.bookmark_unset'))
|
||||
tools.showNegativeNotif($q, t('cmd.bookmark_unset'))
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('error', error)
|
||||
@@ -1744,10 +1787,17 @@ export const useUserStore = defineStore('UserStore', {
|
||||
this.my.profile.seen.push({ id, tab })
|
||||
if (myrec)
|
||||
myrec.myseen.push({ username: this.my.username })
|
||||
|
||||
}
|
||||
if (res && res.data) {
|
||||
if (res.data.record) {
|
||||
return res.data.record
|
||||
}
|
||||
}
|
||||
return null
|
||||
}).catch((error) => {
|
||||
console.error('error', error)
|
||||
return {}
|
||||
return null
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user