++ aggiunta la prenotazione negli eventi. con la lista degli utenti.
This commit is contained in:
@@ -42,9 +42,38 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
}),
|
||||
getters: {
|
||||
|
||||
findEventBooked: (mystate: ICalendarState) => (myevent: IEvents, isconfirmed: boolean) => {
|
||||
updatearrBookingEvent: (mystate: ICalendarState) => (id_bookedevent: any, arrBookings: IBookedEvent[]) => {
|
||||
// Rimuovi quelli precedenti
|
||||
mystate.bookedevent = mystate.bookedevent.filter((rec: IBookedEvent) => rec.id_bookedevent !== id_bookedevent)
|
||||
|
||||
if (arrBookings) {
|
||||
// Aggiorna quelli appena arrivati:
|
||||
mystate.bookedevent = [...mystate.bookedevent, ...arrBookings]
|
||||
}
|
||||
|
||||
console.log('BOOKEDEV: ', mystate.bookedevent)
|
||||
|
||||
},
|
||||
|
||||
findEventBooked: (mystate: ICalendarState) => (id: any, isconfirmed: boolean) => {
|
||||
const userStore = useUserStore()
|
||||
return mystate.bookedevent.find((bookedevent) => (bookedevent.id_bookedevent === myevent._id) && (bookedevent.userId === userStore.my._id) && ((isconfirmed && bookedevent.booked) || (!isconfirmed)))
|
||||
return mystate.bookedevent.find((bookedevent) => (bookedevent.id_bookedevent === id) && (bookedevent.userId === userStore.my._id) && ((isconfirmed && bookedevent.booked) || (!isconfirmed)))
|
||||
},
|
||||
|
||||
findAllBookedByIdEvent: (mystate: ICalendarState) => (id_bookedevent: any) => {
|
||||
const arr = mystate.bookedevent.filter((rec: IBookedEvent) => (rec.id_bookedevent === id_bookedevent) && rec.booked)
|
||||
if (arr)
|
||||
return arr
|
||||
else
|
||||
return []
|
||||
},
|
||||
|
||||
|
||||
isPartecipero: (mystate: ICalendarState) => (id: any, table: string) => {
|
||||
const userStore = useUserStore()
|
||||
const isconfirmed = true
|
||||
const mybooked = mystate.bookedevent.find((bookedevent) => (bookedevent.id_bookedevent === id) && (bookedevent.userId === userStore.my._id) && ((isconfirmed && bookedevent.booked) || (!isconfirmed)))
|
||||
return !!mybooked
|
||||
},
|
||||
|
||||
getNumParticipants: (mystate: ICalendarState) => (myevent: IEvents, showall: boolean, tipo = 0): number => {
|
||||
@@ -103,7 +132,7 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
},
|
||||
actions: {
|
||||
|
||||
getOperatorByUsername (username: string): IOperators | undefined {
|
||||
getOperatorByUsername(username: string): IOperators | undefined {
|
||||
const ctrec = this.operators.find((rec: IOperators) => rec.username === username)
|
||||
return ctrec
|
||||
},
|
||||
@@ -125,6 +154,7 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
return {
|
||||
_id: bookevent._id,
|
||||
id_bookedevent: bookevent.id_bookedevent,
|
||||
username: bookevent.username,
|
||||
infoevent: bookevent.infoevent,
|
||||
numpeople: bookevent.numpeople,
|
||||
numpeopleLunch: bookevent.numpeopleLunch,
|
||||
@@ -170,7 +200,7 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
|
||||
},
|
||||
|
||||
async CancelEvent({ id }: {id: string}) {
|
||||
async CancelEvent({ id }: { id: string }) {
|
||||
const globalStore = useGlobalStore()
|
||||
return globalStore.DeleteRec({ table: costanti.TABEVENTS, id })
|
||||
},
|
||||
@@ -183,7 +213,8 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
return (this.intervalRange.max - this.intervalRange.min) * (1 / this.intervalRangeStep)
|
||||
},
|
||||
|
||||
async CancelBookingEvent({ ideventbook, notify }: {ideventbook: string, notify: string}) {
|
||||
|
||||
async CancelBookingEvent({ ideventbook, notify }: { ideventbook: string, notify: string }) {
|
||||
console.log('CALSTORE: CancelBookingEvent', ideventbook, notify)
|
||||
|
||||
return Api.SendReq('/booking/' + ideventbook + '/' + notify + '/' + process.env.APP_ID, 'DELETE', null)
|
||||
|
||||
@@ -48,17 +48,17 @@ export const useMessageStore = defineStore('MessageStore', {
|
||||
// console.table(users_msg.msgs)
|
||||
|
||||
if (users_msg.msgs) {
|
||||
let userother = users_msg.msgs.slice(-1)[0].dest.username
|
||||
let userother: any = users_msg.msgs.slice(-1)[0].dest
|
||||
if (userother === userStore.my.username)
|
||||
userother = users_msg.msgs.slice(-1)[0].origin.username
|
||||
userother = users_msg.msgs.slice(-1)[0].origin
|
||||
|
||||
let index = this.last_msgs.findIndex((rec: IMessage) => (rec.dest!.username === userother) || (rec.origin!.username === userother))
|
||||
let index = this.last_msgs.findIndex((rec: IMessage) => (rec.dest === userother) || (rec.origin === userother))
|
||||
if (index >= 0) {
|
||||
// Update last message
|
||||
this.last_msgs[index] = users_msg.msgs.slice(-1)[0]
|
||||
} else {
|
||||
this.last_msgs.push(users_msg.msgs.slice(-1)[0])
|
||||
index = this.last_msgs.findIndex((rec: IMessage) => (rec.dest!.username === userother) || (rec.origin!.username === userother))
|
||||
index = this.last_msgs.findIndex((rec: IMessage) => (rec.dest === userother) || (rec.origin === userother))
|
||||
}
|
||||
if (this.last_msgs[index])
|
||||
users_msg.lastdataread = this.last_msgs[index].datemsg
|
||||
@@ -101,8 +101,7 @@ export const useMessageStore = defineStore('MessageStore', {
|
||||
|
||||
data.source!.page = ''
|
||||
data.idapp = process.env.APP_ID
|
||||
data.origin!.idapp = process.env.APP_ID
|
||||
data.origin!.username = userStore.my.username
|
||||
data.origin = userStore.my.username
|
||||
data.datemsg = tools.getDateNow()
|
||||
data.status = StatusMessage.WaitingToSend
|
||||
// Options
|
||||
@@ -122,7 +121,7 @@ export const useMessageStore = defineStore('MessageStore', {
|
||||
const myarr = []
|
||||
myarr.push(data)
|
||||
|
||||
this.setMsg(myarr, data.dest!.username!)
|
||||
this.setMsg(myarr, data.dest)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ export const costanti = {
|
||||
FAVORITE: 1,
|
||||
BOOKMARK: 2,
|
||||
SEEN: 3,
|
||||
ATTEND: 4,
|
||||
},
|
||||
|
||||
ENABLE_FRIENDS: false,
|
||||
@@ -307,6 +308,8 @@ export const costanti = {
|
||||
CMD_MODIFY: 2,
|
||||
CMD_SHOW_PAGE: 3,
|
||||
CMD_OPEN_PAGE: 4,
|
||||
CMD_DUPLICATE: 5,
|
||||
CMD_CLONE: 6,
|
||||
|
||||
SHOW_ALL: 50,
|
||||
|
||||
|
||||
@@ -1359,7 +1359,6 @@ export const colmyHosp = [
|
||||
isadvanced_field: true,
|
||||
sortable: false,
|
||||
}),
|
||||
// **ADDFIELD_MYBACHECAS
|
||||
AddCol({
|
||||
name: 'link_maplocation', label_trans: 'reg.link_maplocation', isadvanced_field: true, fieldtype: costanti.FieldType.link,
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
|
||||
@@ -1394,6 +1393,26 @@ export const colmyBachecas = [
|
||||
isadvanced_field: true,
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'descr',
|
||||
label_trans: 'proj.shortdescr',
|
||||
fieldtype: costanti.FieldType.string,
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
|
||||
noshowlabel: true,
|
||||
maxlength: 120,
|
||||
required: true,
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'photos',
|
||||
label_trans: 'skill.photos',
|
||||
fieldtype: costanti.FieldType.listimages,
|
||||
jointable: '',
|
||||
showpicprofile_ifnotset: true,
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView,
|
||||
isadvanced_field: true,
|
||||
sortable: false,
|
||||
}),
|
||||
|
||||
AddCol({
|
||||
name: 'username',
|
||||
@@ -1407,26 +1426,13 @@ export const colmyBachecas = [
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'idCity',
|
||||
label_trans: 'skill.city',
|
||||
fieldtype: costanti.FieldType.multiselect_by_server,
|
||||
jointable: 'cities',
|
||||
tablesel: 'cities',
|
||||
name: 'groupname',
|
||||
label_trans: 'proj.gruppo',
|
||||
foredit: false,
|
||||
tipovisu: costanti.TipoVisu.LINK,
|
||||
fieldtype: costanti.FieldType.username_chip,
|
||||
link: '/mygrp/groupname',
|
||||
noshowlabel: true,
|
||||
icon: 'fas fa-map-marker-alt',
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
|
||||
remote_table: 'mycities',
|
||||
remote_key: '_id',
|
||||
remote_field: 'comune',
|
||||
sortable: false,
|
||||
required: true,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'pub_to_share',
|
||||
label_trans: 'skill.pub_to_share',
|
||||
fieldtype: costanti.FieldType.select,
|
||||
icon: 'fas fa-users',
|
||||
jointable: 'pub_to_share',
|
||||
}),
|
||||
AddCol(
|
||||
{
|
||||
@@ -1450,16 +1456,47 @@ export const colmyBachecas = [
|
||||
icon: 'fas fa-calendar-day',
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'descr',
|
||||
label_trans: 'proj.shortdescr',
|
||||
fieldtype: costanti.FieldType.string,
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
|
||||
noshowlabel: true,
|
||||
maxlength: 120,
|
||||
required: true,
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'idCity',
|
||||
label_trans: 'skill.city',
|
||||
fieldtype: costanti.FieldType.multiselect_by_server,
|
||||
jointable: 'cities',
|
||||
tablesel: 'cities',
|
||||
noshowlabel: true,
|
||||
icon: 'fas fa-map-marker-alt',
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
|
||||
remote_table: 'mycities',
|
||||
remote_key: '_id',
|
||||
remote_field: 'comune',
|
||||
sortable: false,
|
||||
required: true,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'idSector',
|
||||
label_trans: 'sectors.name',
|
||||
fieldtype: costanti.FieldType.select,
|
||||
required: true,
|
||||
jointable: toolsext.TABSECTORS,
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
|
||||
visible: true,
|
||||
icon: 'category',
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'idSkill',
|
||||
label_trans: 'skill.name',
|
||||
fieldtype: costanti.FieldType.select,
|
||||
jointable: 'skills',
|
||||
addnone: true,
|
||||
filter_table: toolsext.TABSECTORS,
|
||||
filter_field: 'idSector',
|
||||
noshowlabel: true,
|
||||
icon: 'engineering',
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView,
|
||||
allowNewValue: false,
|
||||
required: false,
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'note', label_trans: 'proj.descrapprof', fieldtype: costanti.FieldType.html,
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
|
||||
@@ -1469,31 +1506,41 @@ export const colmyBachecas = [
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'idSector',
|
||||
label_trans: 'sectors.name',
|
||||
fieldtype: costanti.FieldType.select,
|
||||
required: true,
|
||||
jointable: toolsext.TABSECTORS,
|
||||
name: 'address',
|
||||
label_trans: 'event.address',
|
||||
fieldtype: costanti.FieldType.string,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'link_maplocation', label_trans: 'reg.link_maplocation', isadvanced_field: true, fieldtype: costanti.FieldType.link,
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InEdit + costanti.showWhen.InView_OnlyifExist,
|
||||
visible: true,
|
||||
icon: 'category',
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'idSkill',
|
||||
label_trans: 'skill.name',
|
||||
name: 'pub_to_share',
|
||||
label_trans: 'skill.pub_to_share',
|
||||
fieldtype: costanti.FieldType.select,
|
||||
jointable: 'skills',
|
||||
addnone: true,
|
||||
filter_table: toolsext.TABSECTORS,
|
||||
filter_field: 'idSector',
|
||||
noshowlabel: true,
|
||||
icon: 'engineering',
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView,
|
||||
allowNewValue: false,
|
||||
icon: 'fas fa-users',
|
||||
jointable: 'pub_to_share',
|
||||
}),
|
||||
AddCol({
|
||||
name: 'organisedBy',
|
||||
label_trans: 'event.organisedBy_insert',
|
||||
fieldtype: costanti.FieldType.string,
|
||||
required: false,
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'contact_phone',
|
||||
label_trans: 'event.contact_phone',
|
||||
fieldtype: costanti.FieldType.string,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'contact_telegram',
|
||||
label_trans: 'event.contact_telegram',
|
||||
fieldtype: costanti.FieldType.string,
|
||||
}),
|
||||
AddCol({ name: 'min_partecip', label_trans: 'event.min_partecip', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'max_partecip', label_trans: 'event.max_partecip', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({
|
||||
name: 'idContribType',
|
||||
label_trans: 'contribtype.name',
|
||||
@@ -1506,6 +1553,7 @@ export const colmyBachecas = [
|
||||
isadvanced_field: false,
|
||||
sortable: false,
|
||||
}),
|
||||
AddCol({ name: 'contribstr', label_trans: 'event.contribstr', fieldtype: costanti.FieldType.string }),
|
||||
/*AddCol({
|
||||
name: '',
|
||||
fieldtype: costanti.FieldType.separator,
|
||||
@@ -1521,16 +1569,6 @@ export const colmyBachecas = [
|
||||
sortable: true,
|
||||
showWhen: 0
|
||||
}),
|
||||
AddCol({
|
||||
name: 'photos',
|
||||
label_trans: 'skill.photos',
|
||||
fieldtype: costanti.FieldType.listimages,
|
||||
jointable: '',
|
||||
showpicprofile_ifnotset: true,
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView,
|
||||
isadvanced_field: true,
|
||||
sortable: false,
|
||||
}),
|
||||
// **ADDFIELD_MYBACHECAS
|
||||
AddCol({
|
||||
name: 'website', label_trans: 'reg.website', isadvanced_field: true, fieldtype: costanti.FieldType.link,
|
||||
|
||||
@@ -1069,6 +1069,46 @@ export const tools = {
|
||||
label: '10',
|
||||
value: 10,
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
label: '11',
|
||||
value: 11,
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
label: '12',
|
||||
value: 12,
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
label: '13',
|
||||
value: 13,
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
label: '14',
|
||||
value: 14,
|
||||
},
|
||||
{
|
||||
id: 15,
|
||||
label: '15',
|
||||
value: 15,
|
||||
},
|
||||
{
|
||||
id: 20,
|
||||
label: '20',
|
||||
value: 20,
|
||||
},
|
||||
{
|
||||
id: 25,
|
||||
label: '25',
|
||||
value: 25,
|
||||
},
|
||||
{
|
||||
id: 30,
|
||||
label: '30',
|
||||
value: 30,
|
||||
},
|
||||
],
|
||||
|
||||
selectPhase: {
|
||||
@@ -3116,7 +3156,7 @@ export const tools = {
|
||||
}
|
||||
} else {
|
||||
if (withhtml) {
|
||||
mystr = `<span class="cal__where-content">${this.getstrDateLong(myevent.dateTimeStart)}</span>
|
||||
mystr = `<span class="cal__where-content">${this.getstrDateLong(myevent.dateTimeStart)}</span>
|
||||
<span class="cal__hours-content">${$t('cal.starttime')} ${this.getstrTime(myevent.dateTimeStart)} </span>
|
||||
${$t('cal.enddate')} ${this.getstrDateLong(myevent.dateTimeEnd)}
|
||||
<span class="cal__hours-content">${$t('cal.endtime')} ${this.getstrTime(myevent.dateTimeEnd)} </span>`
|
||||
@@ -3766,9 +3806,9 @@ export const tools = {
|
||||
return msg
|
||||
}
|
||||
,
|
||||
gettextevent(myevent: IEvents) {
|
||||
gettextevent(myevent: any) {
|
||||
// return '"' + myevent.title + '" (' + func_tools.getDateStr(myevent.date) + ') - ' + myevent.time
|
||||
return '"' + myevent.title + '" (' + this.getstrDateEmailTime(myevent.dateTimeStart) + ')'
|
||||
return '"' + (myevent.title ? myevent.title : (myevent.descr ? myevent.descr: '')) + '" (' + this.getstrDateEmailTime(myevent.dateTimeStart) + ')'
|
||||
},
|
||||
|
||||
getlangforQuasar(mylang: string) {
|
||||
@@ -6862,7 +6902,7 @@ export const tools = {
|
||||
return ris
|
||||
},
|
||||
|
||||
getdefaultnewrec_MySkill(): any {
|
||||
getdefaultnewrec_MySkill(groupname?: string): any {
|
||||
|
||||
return {
|
||||
idSector: tools.getSelectionByTable('sectors', 0, true),
|
||||
@@ -6878,6 +6918,7 @@ export const tools = {
|
||||
//**ADDFIELD_MYSKILL
|
||||
website: '',
|
||||
descr: '',
|
||||
groupname,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -6944,7 +6985,7 @@ export const tools = {
|
||||
},
|
||||
|
||||
|
||||
getdefaultnewrec_MyBacheca(): any {
|
||||
getdefaultnewrec_MyBacheca(extrarec: any): any {
|
||||
return {
|
||||
idSector: tools.getSelectionByTable('sectors', 0, true),
|
||||
idSkill: tools.getSelectionByTable('skills', 0, true),
|
||||
@@ -6958,6 +6999,13 @@ export const tools = {
|
||||
pub_to_share: tools.getSelectionByTable('pub_to_share', shared_consts.PUBTOSHARE.ALL, true),
|
||||
photos: [],
|
||||
note: '',
|
||||
organisedBy: tools.getSelectionByTable('organisedBy', ''),
|
||||
address: tools.getSelectionByTable('address', ''),
|
||||
min_partecip: tools.getSelectionByTable('min_partecip', 0, true),
|
||||
max_partecip: tools.getSelectionByTable('max_partecip', 0, true),
|
||||
contribstr: tools.getSelectionByTable('contribstr', ''),
|
||||
groupname: extrarec && extrarec.groupname ? extrarec.groupname : '',
|
||||
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
website: '',
|
||||
descr: '',
|
||||
@@ -7811,7 +7859,235 @@ export const tools = {
|
||||
return 0
|
||||
},
|
||||
|
||||
getdefaultnewrec(table: string, extrarec?: any): any {
|
||||
if (table === toolsext.TABMYSKILLS) {
|
||||
return tools.getdefaultnewrec_MySkill()
|
||||
} else if (table === toolsext.TABMYBACHECAS) {
|
||||
return tools.getdefaultnewrec_MyBacheca(extrarec)
|
||||
} else if (table === toolsext.TABMYHOSPS) {
|
||||
return tools.getdefaultnewrec_MyHosp()
|
||||
} else if (table === toolsext.TABMYGOODS) {
|
||||
return tools.getdefaultnewrec_MyGoods()
|
||||
} else if (table === toolsext.TABMYGROUPS) {
|
||||
return tools.getdefaultnewrec_MyGroup()
|
||||
} else if (table === toolsext.TABCIRCUITS) {
|
||||
return tools.getdefaultnewrec_Circuit()
|
||||
}
|
||||
return null
|
||||
},
|
||||
|
||||
extraparams(table: string, extra?: any) {
|
||||
if (table === toolsext.TABMYGROUPS) {
|
||||
|
||||
let lk_tab = 'mygroups'
|
||||
let lk_LF = 'userId'
|
||||
let lk_FF = '_id'
|
||||
let lk_as = 'group'
|
||||
let af_objId_tab = 'myId'
|
||||
|
||||
return {
|
||||
lookup1: {
|
||||
lk_tab,
|
||||
lk_LF,
|
||||
lk_FF,
|
||||
lk_as,
|
||||
af_objId_tab,
|
||||
lk_proj: shared_consts.getProjectByTable(table, {}),
|
||||
},
|
||||
lookup2: {
|
||||
lk_tab: 'catgrps',
|
||||
lk_LF: 'idCatGrp',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'recCatGrp',
|
||||
lk_proj: shared_consts.getProjectByTable(table, {}),
|
||||
},
|
||||
lookup3: {
|
||||
lk_tab: 'cities',
|
||||
lk_LF: 'idCity',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'comune',
|
||||
lk_proj: shared_consts.getProjectByTable(table, {}),
|
||||
},
|
||||
lookup4: {
|
||||
lk_tab: 'cities',
|
||||
lk_LF: 'idCity',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'mycities',
|
||||
af_objId_tab: '',
|
||||
},
|
||||
}
|
||||
|
||||
} else if (table === toolsext.TABCIRCUITS) {
|
||||
|
||||
let lk_tab = 'cities'
|
||||
let lk_LF = 'idCity'
|
||||
let lk_FF = '_id'
|
||||
let lk_as = 'mycities'
|
||||
let af_objId_tab = ''
|
||||
|
||||
return {
|
||||
lookup1: {
|
||||
lk_tab,
|
||||
lk_LF,
|
||||
lk_FF,
|
||||
lk_as,
|
||||
af_objId_tab,
|
||||
lk_proj: shared_consts.getProjectByTable(table, {}),
|
||||
},
|
||||
}
|
||||
|
||||
} else if (table === toolsext.TABMYGOODS) {
|
||||
return {
|
||||
lookup1: {
|
||||
lk_tab: 'users',
|
||||
lk_LF: 'userId',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'user',
|
||||
af_objId_tab: 'myId',
|
||||
},
|
||||
lookup2: {
|
||||
lk_tab: 'goods',
|
||||
lk_LF: 'idGood',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'recGood',
|
||||
af_objId_tab: '',
|
||||
lk_proj: shared_consts.getProjectForAll({}, table),
|
||||
},
|
||||
lookup3: {
|
||||
lk_tab: 'sectorgoods',
|
||||
// lk_LF: 'recGood.idSectorGood',
|
||||
lk_LF: 'idSectorGood',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'sectorGood',
|
||||
af_objId_tab: '',
|
||||
},
|
||||
lookup4: {
|
||||
lk_tab: 'cities',
|
||||
lk_LF: 'idCity',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'mycities',
|
||||
af_objId_tab: '',
|
||||
},
|
||||
}
|
||||
} else if (table === toolsext.TABMYBACHECAS) {
|
||||
return {
|
||||
lookup1: {
|
||||
lk_tab: 'users',
|
||||
lk_LF: 'userId',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'user',
|
||||
af_objId_tab: 'myId',
|
||||
},
|
||||
lookup2: {
|
||||
lk_tab: 'skills',
|
||||
lk_LF: 'idSkill',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'recSkill',
|
||||
af_objId_tab: '',
|
||||
lk_proj: shared_consts.getProjectForAll({}, table),
|
||||
},
|
||||
lookup3: {
|
||||
lk_tab: toolsext.TABSECTORS,
|
||||
// lk_LF: 'recSkill.idSector',
|
||||
lk_LF: 'idSector',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'sector',
|
||||
af_objId_tab: '',
|
||||
},
|
||||
lookup4: {
|
||||
lk_tab: 'cities',
|
||||
lk_LF: 'idCity',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'mycities',
|
||||
af_objId_tab: '',
|
||||
},
|
||||
lookup5: {
|
||||
lk_tab: 'mygroups',
|
||||
lk_LF: 'groupname',
|
||||
lk_FF: 'groupname',
|
||||
lk_as: 'mygrp',
|
||||
lk_proj: shared_consts.getProjectForAll({}, table),
|
||||
unwind: true,
|
||||
noarray: true,
|
||||
},
|
||||
}
|
||||
|
||||
} else if (table === toolsext.TABMYHOSPS) {
|
||||
let obj2: any = {}
|
||||
|
||||
if (extra && extra.myrecfiltertoggle.value === tools.FILTER_ALL) {
|
||||
obj2['visibile'] = true
|
||||
}
|
||||
|
||||
return {
|
||||
filtersearch2: [obj2],
|
||||
lookup1: {
|
||||
lk_tab: 'users',
|
||||
lk_LF: 'userId',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'user',
|
||||
af_objId_tab: 'myId',
|
||||
},
|
||||
lookup2: {
|
||||
lk_tab: 'cities',
|
||||
lk_LF: 'idCity',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'mycities',
|
||||
af_objId_tab: '',
|
||||
lk_proj: shared_consts.getProjectForAll({}, table),
|
||||
},
|
||||
}
|
||||
|
||||
} else {
|
||||
return {
|
||||
// Servizi
|
||||
lookup1: {
|
||||
lk_tab: 'users',
|
||||
lk_LF: 'userId',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'user',
|
||||
af_objId_tab: 'myId',
|
||||
},
|
||||
lookup2: {
|
||||
lk_tab: 'skills',
|
||||
lk_LF: 'idSkill',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'recSkill',
|
||||
af_objId_tab: '',
|
||||
lk_proj: shared_consts.getProjectForAll({}, table),
|
||||
},
|
||||
lookup3: {
|
||||
lk_tab: toolsext.TABSECTORS,
|
||||
lk_LF: 'idSector',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'sector',
|
||||
af_objId_tab: '',
|
||||
},
|
||||
lookup5: {
|
||||
lk_tab: 'cities',
|
||||
lk_LF: 'idCity',
|
||||
lk_FF: '_id',
|
||||
lk_as: 'mycities',
|
||||
af_objId_tab: '',
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getNumPartecipantes(myrec: any) {
|
||||
if (myrec && myrec.mybookings && myrec.mybookings.length > 0) {
|
||||
return myrec.mybookings.reduce((accum: any, currval: any) => accum + (currval.booked ? 0 : currval.numpeople), 0)
|
||||
}
|
||||
return 0
|
||||
},
|
||||
isPartecipero(myrec: any) {
|
||||
const userStore = useUserStore()
|
||||
if (myrec && myrec.mybookings && myrec.mybookings.length > 0) {
|
||||
const isconfirmed = true
|
||||
return myrec.mybookings.find((bookedevent: any) => (bookedevent.id_bookedevent === myrec._id) && (bookedevent.userId === userStore.my._id) && ((isconfirmed && bookedevent.booked) || (!isconfirmed)))
|
||||
}
|
||||
return 0
|
||||
},
|
||||
|
||||
// FINE !
|
||||
|
||||
|
||||
@@ -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