Circuit go on...
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
ITodo,
|
||||
IUserFields,
|
||||
Privacy,
|
||||
TipoVisu, IGroup, IMySkill, IMyBacheca, IImgGallery, IMsgGlobParam, IUserExport, ISpecialField,
|
||||
TipoVisu, IGroup, IMySkill, IMyBacheca, IImgGallery, IMsgGlobParam, IUserExport, ISpecialField, IAccount,
|
||||
} from '@model'
|
||||
|
||||
import { addToDate } from '@quasar/quasar-ui-qcalendar'
|
||||
@@ -4734,6 +4734,31 @@ export const tools = {
|
||||
},
|
||||
|
||||
|
||||
addToMyCircuits($q: any, username: string, name: string) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const notifStore = useNotifStore()
|
||||
$q.dialog({
|
||||
message: t('db.domanda_addtocircuit', { username, name }),
|
||||
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)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
notifStore.updateNotification = true
|
||||
if (userStore.my.profile.listUserAccounts)
|
||||
userStore.my.profile.listUserAccounts = [...userStore.my.profile.listUserAccounts, res]
|
||||
else
|
||||
userStore.my.profile.listUserAccounts = [res]
|
||||
tools.showPositiveNotif($q, t('db.addedcircuit', { name }))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
addToMyGroups($q: any, username: string, groupnameDest: string) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
@@ -4871,7 +4896,7 @@ export const tools = {
|
||||
const userStore = useUserStore()
|
||||
|
||||
$q.dialog({
|
||||
message: domanda ? domanda : t('db.domanda_remove_group', { username }),
|
||||
message: domanda ? domanda : t('db.domanda_remove_group', { groupname: groupnameDest }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
@@ -5162,6 +5187,103 @@ export const tools = {
|
||||
return risultato
|
||||
|
||||
},
|
||||
setRequestCircuit($q: any, username: string, name: string, value: boolean) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
let msg = ''
|
||||
if (value) {
|
||||
msg = t('circuit.domanda_ask', { name })
|
||||
} else {
|
||||
msg = t('circuit.domanda_revoke', { name })
|
||||
}
|
||||
|
||||
$q.dialog({
|
||||
message: msg,
|
||||
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.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 }))
|
||||
} 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 }))
|
||||
}
|
||||
|
||||
} else {
|
||||
tools.showNegativeNotif($q, t('db.recfailed'))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
removeFromMyCircuits($q: any, username: string, name: string, domanda: any = '') {
|
||||
const userStore = useUserStore()
|
||||
|
||||
$q.dialog({
|
||||
message: domanda ? domanda : t('circuit.domanda_remove', { username }),
|
||||
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.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'))
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
DeleteCircuit($q: any, username: string, name: string, domanda: any = '') {
|
||||
const userStore = useUserStore()
|
||||
|
||||
$q.dialog({
|
||||
message: domanda ? domanda : t('db.domanda_removerecord', { name }),
|
||||
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) => {
|
||||
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 } ))
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
iCanShowCircuitsMember(circuit: ICircuit) {
|
||||
|
||||
/* if (grp && grp.visibility!.includes(shared_consts.Visibility_Group.PRIVATE)) {
|
||||
// Only if I am part of this group
|
||||
return this.iAmPartOfThisGroup(grp)
|
||||
} */
|
||||
|
||||
return true
|
||||
|
||||
},
|
||||
|
||||
iAmAdminCircuit(name: string) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
@@ -5358,6 +5480,12 @@ export const tools = {
|
||||
tools.refuseReqFriends($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND) {
|
||||
tools.cancelReqFriends($q, username, dest)
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SET) {
|
||||
tools.addToMyCircuits($q, username, dest)
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||
tools.setRequestCircuit($q, username, dest, value)
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.DELETE) {
|
||||
tools.DeleteCircuit($q, username, dest)
|
||||
}
|
||||
},
|
||||
isCallable(anything: any) {
|
||||
@@ -5656,29 +5784,32 @@ export const tools = {
|
||||
},
|
||||
|
||||
getToByCol(col: IColGridTable, table: string, rec: any) {
|
||||
if (shared_consts.TABLES_REC_ID.includes(table)) {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + rec['_id']
|
||||
} else if (table === toolsext.TABMYGROUPS) {
|
||||
return '/grp/' + rec.groupname
|
||||
} else if (table === toolsext.TABCIRCUITS) {
|
||||
return '/circuit/' + rec.name
|
||||
}
|
||||
|
||||
return ''
|
||||
return this.getPathByTableAndRec(table, rec)
|
||||
},
|
||||
|
||||
getPathByGroup(grp: any, table: string) {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + grp.groupname
|
||||
},
|
||||
|
||||
getPathByCircuit(grp: any, table: string) {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + grp.name
|
||||
getPathByCircuit(circuit: any, table: string) {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + circuit.path
|
||||
},
|
||||
|
||||
getPathByTable(table: string, pagename: string) {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + pagename
|
||||
},
|
||||
|
||||
getPathByTableAndRec(table: string, rec: any) {
|
||||
if (shared_consts.TABLES_REC_ID.includes(table)) {
|
||||
return '/' + tools.getDirectoryByTable(table) + '/' + rec['_id']
|
||||
} else if (table === toolsext.TABMYGROUPS) {
|
||||
return this.getPathByGroup(rec, table)
|
||||
} else if (table === toolsext.TABCIRCUITS) {
|
||||
return this.getPathByCircuit(rec, table)
|
||||
}
|
||||
return ''
|
||||
},
|
||||
|
||||
getAportadorSolidario() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my ? userStore.my.aportador_solidario : ''
|
||||
|
||||
Reference in New Issue
Block a user