Add to the Circuit
Remove to the Circuit Revoke request Users Admins
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
ITodo,
|
||||
IUserFields,
|
||||
Privacy,
|
||||
TipoVisu, IGroup, IMySkill, IMyBacheca, IImgGallery, IMsgGlobParam, IUserExport, ISpecialField, IAccount,
|
||||
TipoVisu, IGroup, IMySkill, IMyBacheca, IImgGallery, IMsgGlobParam, IUserExport, ISpecialField, IAccount, IMyCircuit,
|
||||
} from '@model'
|
||||
|
||||
import { addToDate } from '@quasar/quasar-ui-qcalendar'
|
||||
@@ -4734,26 +4734,26 @@ export const tools = {
|
||||
},
|
||||
|
||||
|
||||
addToMyCircuits($q: any, username: string, name: string) {
|
||||
addToMyCircuits($q: any, username: string, circuitname: string) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const notifStore = useNotifStore()
|
||||
$q.dialog({
|
||||
message: t('db.domanda_addtocircuit', { username, name }),
|
||||
message: t('db.domanda_addtocircuit', { username, circuitname }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, name, shared_consts.CIRCUITCMD.SET, true)
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.SET, true)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
notifStore.updateNotification = true
|
||||
if (userStore.my.profile.listUserAccounts)
|
||||
userStore.my.profile.listUserAccounts = [...userStore.my.profile.listUserAccounts, res]
|
||||
if (userStore.my.profile.mycircuits)
|
||||
userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res]
|
||||
else
|
||||
userStore.my.profile.listUserAccounts = [res]
|
||||
tools.showPositiveNotif($q, t('db.addedcircuit', { name }))
|
||||
userStore.my.profile.mycircuits = [res]
|
||||
tools.showPositiveNotif($q, t('db.addedcircuit', { circuitname }))
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -4798,7 +4798,9 @@ export const tools = {
|
||||
userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REFUSE_REQ_GROUP, null).then((res) => {
|
||||
if (res) {
|
||||
notifStore.updateNotification = true
|
||||
userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
|
||||
if (username === userStore.my.username) {
|
||||
userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
|
||||
}
|
||||
tools.showPositiveNotif($q, t('db.refusedgroup', { username }))
|
||||
}
|
||||
})
|
||||
@@ -4836,9 +4838,11 @@ export const tools = {
|
||||
userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP, null).then((res) => {
|
||||
if (res) {
|
||||
if (userStore.my.profile.mygroups) {
|
||||
userStore.my.profile.mygroups = userStore.my.profile.mygroups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
|
||||
tools.showPositiveNotif($q, t('db.removedgroup'))
|
||||
if (username === userStore.my.username) {
|
||||
userStore.my.profile.mygroups = userStore.my.profile.mygroups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
|
||||
}
|
||||
}
|
||||
tools.showPositiveNotif($q, t('db.removedgroup'))
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -5025,7 +5029,9 @@ export const tools = {
|
||||
|
||||
userStore.setGroupsCmd($q, t, username, groupnameDest, shared_consts.GROUPSCMD.CANCEL_REQ_GROUP, null).then((res) => {
|
||||
if (res) {
|
||||
userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
|
||||
if (username === userStore.my.username) {
|
||||
userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
|
||||
}
|
||||
tools.showPositiveNotif($q, t('db.cancel_req_group'))
|
||||
}
|
||||
})
|
||||
@@ -5187,15 +5193,15 @@ export const tools = {
|
||||
return risultato
|
||||
|
||||
},
|
||||
setRequestCircuit($q: any, username: string, name: string, value: boolean) {
|
||||
setRequestCircuit($q: any, username: string, circuitname: string, value: boolean) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
let msg = ''
|
||||
if (value) {
|
||||
msg = t('circuit.domanda_ask', { name })
|
||||
msg = t('circuit.domanda_ask', { circuitname })
|
||||
} else {
|
||||
msg = t('circuit.domanda_revoke', { name })
|
||||
msg = t('circuit.domanda_revoke', { circuitname })
|
||||
}
|
||||
|
||||
$q.dialog({
|
||||
@@ -5210,17 +5216,17 @@ export const tools = {
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, name, shared_consts.CIRCUITCMD.REQ, value)
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REQ, value)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
if (value) {
|
||||
// ADD to req
|
||||
userStore.my.profile.asked_circuits.push(res)
|
||||
tools.showPositiveNotif($q, t('circuit.askedto', { name }))
|
||||
tools.showPositiveNotif($q, t('circuit.askedto', { circuitname }))
|
||||
} else {
|
||||
// REMOVE to req
|
||||
userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== name)
|
||||
tools.showPositiveNotif($q, t('circuit.revoketo', { name }))
|
||||
userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname)
|
||||
tools.showPositiveNotif($q, t('circuit.revoketo', { circuitname }))
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -5230,7 +5236,50 @@ export const tools = {
|
||||
})
|
||||
},
|
||||
|
||||
removeFromMyCircuits($q: any, username: string, name: string, domanda: any = '') {
|
||||
cancelReqCircuit($q: any, username: string, circuitname: string) {
|
||||
const userStore = useUserStore()
|
||||
$q.dialog({
|
||||
message: t('circuit.domanda_cancel_req', { username, circuitname }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.CANCEL_REQ, null).then((res) => {
|
||||
if (res) {
|
||||
if (username === userStore.my.username) {
|
||||
userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname)
|
||||
}
|
||||
tools.showPositiveNotif($q, t('db.cancel_req_group'))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
refuseReqCircuit($q: any, username: string, circuitname: string) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const notifStore = useNotifStore()
|
||||
$q.dialog({
|
||||
message: t('circuit.domanda_refuse_circuit', { username, circuitname }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REFUSE_REQ, null).then((res) => {
|
||||
if (res) {
|
||||
notifStore.updateNotification = true
|
||||
if (username === userStore.my.username) {
|
||||
userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname)
|
||||
}
|
||||
tools.showPositiveNotif($q, t('db.refusedcircuit', { username }))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
removeFromMyCircuits($q: any, username: string, circuitname: string, domanda: any = '') {
|
||||
const userStore = useUserStore()
|
||||
|
||||
$q.dialog({
|
||||
@@ -5240,32 +5289,80 @@ export const tools = {
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, name, shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST, null).then((res) => {
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST, null).then((res) => {
|
||||
if (res) {
|
||||
if (userStore.my.profile.listUserAccounts) {
|
||||
userStore.my.profile.listUserAccounts = userStore.my.profile.listUserAccounts.filter((rec: IAccount) => rec.name !== name)
|
||||
tools.showPositiveNotif($q, t('circuit.removed'))
|
||||
if (userStore.my.profile.mycircuits && username === userStore.my.username) {
|
||||
userStore.my.profile.mycircuits = userStore.my.profile.mycircuits.filter((rec: IMyCircuit) => rec.circuitname !== circuitname)
|
||||
}
|
||||
tools.showPositiveNotif($q, t('circuit.removed'))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
addtoAdminOfCircuit($q: any, username: string, circuitname: string, domanda: any = '') {
|
||||
const userStore = useUserStore()
|
||||
|
||||
$q.dialog({
|
||||
message: domanda ? domanda : t('db.domanda_addadminofcircuit', { username, circuitname }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.ADDADMIN, null).then((res) => {
|
||||
if (res) {
|
||||
const mycircuit = userStore.my.profile.manage_mycircuits.find((rec: ICircuit) => rec.name === circuitname)
|
||||
console.log('mycircuit', mycircuit)
|
||||
if (mycircuit && mycircuit.admins) {
|
||||
mycircuit.admins = [...mycircuit.admins, {username, date: new Date}]
|
||||
console.log('mycircuit.admins', mycircuit.admins)
|
||||
tools.showPositiveNotif($q, t('db.addedtoadmin', { username }))
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
DeleteCircuit($q: any, username: string, name: string, domanda: any = '') {
|
||||
removeAdminOfCircuit($q: any, username: string, circuitname: string, domanda: any = '') {
|
||||
const userStore = useUserStore()
|
||||
|
||||
$q.dialog({
|
||||
message: domanda ? domanda : t('db.domanda_removerecord', { name }),
|
||||
message: domanda ? domanda : t('db.domanda_removeadminofcircuit', { username, circuitname }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, name, shared_consts.CIRCUITCMD.DELETE, null).then((res) => {
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REMOVEADMIN, null).then((res) => {
|
||||
if (res) {
|
||||
const mygrp = userStore.my.profile.manage_mycircuits.find((rec: ICircuit) => rec.name === circuitname)
|
||||
console.log('mygrp', mygrp)
|
||||
if (mygrp && mygrp.admins) {
|
||||
mygrp.admins = mygrp.admins.filter((rec: any) => rec.username !== username)
|
||||
console.log('mygrp.admins', mygrp.admins)
|
||||
tools.showPositiveNotif($q, t('db.removedtoadmin', { username }))
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
DeleteCircuit($q: any, username: string, circuitname: string, domanda: any = '') {
|
||||
const userStore = useUserStore()
|
||||
|
||||
$q.dialog({
|
||||
message: domanda ? domanda : t('db.domanda_removerecord', { circuitname }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.DELETE, null).then((res) => {
|
||||
if (res) {
|
||||
if (userStore.my.profile.manage_mycircuits) {
|
||||
userStore.my.profile.manage_mycircuits = userStore.my.profile.manage_mycircuits.filter((rec: ICircuit) => rec.name !== name)
|
||||
tools.showPositiveNotif($q, t('circuit.deleted', { name } ))
|
||||
userStore.my.profile.manage_mycircuits = userStore.my.profile.manage_mycircuits.filter((rec: ICircuit) => rec.name !== circuitname)
|
||||
tools.showPositiveNotif($q, t('circuit.deleted', { circuitname } ))
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -5274,6 +5371,7 @@ export const tools = {
|
||||
|
||||
|
||||
iCanShowCircuitsMember(circuit: ICircuit) {
|
||||
// ++Todo: Posso vedere i membri dei Circuiti ???
|
||||
|
||||
/* if (grp && grp.visibility!.includes(shared_consts.Visibility_Group.PRIVATE)) {
|
||||
// Only if I am part of this group
|
||||
@@ -5284,14 +5382,14 @@ export const tools = {
|
||||
|
||||
},
|
||||
|
||||
iAmAdminCircuit(name: string) {
|
||||
iAmAdminCircuit(circuitname: string) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
let risultato = false
|
||||
|
||||
if (userStore.my.profile.manage_mycircuits) {
|
||||
const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => {
|
||||
if (circuit.name === name) {
|
||||
if (circuit.name === circuitname) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
@@ -5405,7 +5503,7 @@ export const tools = {
|
||||
|
||||
},
|
||||
|
||||
isUserTheCreatorOfThCircuit(name: string, username: string) {
|
||||
isUserTheCreatorOfTheCircuit(name: string, username: string) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
let risultato = false
|
||||
@@ -5941,11 +6039,12 @@ export const tools = {
|
||||
circuitStore.listcircuits = ris.listcircuits ? ris.listcircuits : []
|
||||
|
||||
// to Refresh Data User Accounts:
|
||||
userStore.my.profile.listUserAccounts = ris.listUserAccounts ? ris.listUserAccounts : []
|
||||
userStore.my.profile.mycircuits = ris.mycircuits ? ris.mycircuits : []
|
||||
|
||||
// Others not loaded at the beginning:
|
||||
userStore.my.profile.asked_circuits = ris.listSentRequestCircuits ? ris.listSentRequestCircuits : []
|
||||
userStore.my.profile.refused_circuits = ris.listRefusedCircuits ? ris.listRefusedCircuits : []
|
||||
|
||||
userStore.my.profile.asked_circuits = ris.asked_circuits ? ris.asked_circuits : []
|
||||
userStore.my.profile.refused_circuits = ris.refused_circuits ? ris.refused_circuits : []
|
||||
return [{ userId: userStore.my._id }]
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user