- L'utente entra direttamente sul circuito, con fido a zero.

++Abilitazione Fido utente (per admin).
This commit is contained in:
Surya Paolo
2023-06-01 11:40:26 +02:00
parent 616a6c4218
commit e805088da7
32 changed files with 481 additions and 187 deletions

View File

@@ -630,7 +630,7 @@ export const colmyMovement = [
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/circuits/contocomfrom.path',
link: '/circuit/contocomfrom.path',
noshowlabel: true,
extrafield: 'movement.fromCCom',
tipoconto: costanti.AccountType.COMMUNITY_ACCOUNT,
@@ -670,7 +670,7 @@ export const colmyMovement = [
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/circuits/contocomto.path',
link: '/circuit/contocomto.path',
noshowlabel: true,
extrafield: 'movement.toCCom',
tipoconto: costanti.AccountType.COMMUNITY_ACCOUNT,
@@ -718,7 +718,7 @@ export const colmyMovementTable = [
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/circuits/contocomfrom.path',
link: '/circuit/contocomfrom.path',
tipoconto: costanti.AccountType.COMMUNITY_ACCOUNT,
required: true,
}),
@@ -755,7 +755,7 @@ export const colmyMovementTable = [
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/circuits/contocomto.path',
link: '/circuit/contocomto.path',
tipoconto: costanti.AccountType.COMMUNITY_ACCOUNT,
required: true,
}),
@@ -3181,7 +3181,7 @@ export const colmyUserCircuit = [
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/circuits/contocom',
link: '/circuit/contocom',
noshowlabel: true,
tipoconto: costanti.AccountType.COMMUNITY_ACCOUNT,
}),
@@ -3192,7 +3192,7 @@ export const colmyUserCircuit = [
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/circuits/groupname',
link: '/circuit/groupname',
noshowlabel: true,
tipoconto: costanti.AccountType.COLLECTIVE_ACCOUNT,
}),
@@ -3212,16 +3212,40 @@ export const colTableNotifCoins = [
AddCol({ name: 'datenotif', label_trans: 'sendnotifs.datenotif', fieldtype: costanti.FieldType.date }),
AddCol({
name: 'extrarec.dest',
label_trans: 'reg.username',
field: 'extrarec',
subfield: 'dest',
label_trans: 'reg.username',
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/my/extrarec.dest',
noshowlabel: true,
extrafield: 'movement.to',
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit + costanti.showWhen.InView,
tipoconto: costanti.AccountType.USER,
}),
AddCol({
name: 'extrarec.groupdest',
label_trans: 'extrarec.groupname',
field: 'extrarec',
subfield: 'groupdest',
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/grp/extrarec.groupdest',
noshowlabel: true,
tipoconto: costanti.AccountType.COLLECTIVE_ACCOUNT,
}),
AddCol({
name: 'extrarec.contoComDest',
label_trans: 'groups.groupname',
field: 'extrarec',
subfield: 'contoComDest',
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/circuit/extrarec.contoComDest',
noshowlabel: true,
tipoconto: costanti.AccountType.COMMUNITY_ACCOUNT,
}),
AddCol({ name: 'extrarec.qty', field: 'extrarec', subfield: 'qty', label_trans: 'movement.amount', fieldtype: costanti.FieldType.currency }),
AddCol({ name: 'extrarec.causal', field: 'extrarec', subfield: 'causal', label_trans: 'movement.causal', tipovisu: costanti.TipoVisu.TESTO_BORDATO }),

View File

@@ -3818,7 +3818,7 @@ export const tools = {
,
gettextevent(myevent: any) {
// return '"' + myevent.title + '" (' + func_tools.getDateStr(myevent.date) + ') - ' + myevent.time
return '"' + (myevent.title ? myevent.title : (myevent.descr ? myevent.descr: '')) + '" (' + this.getstrDateEmailTime(myevent.dateTimeStart) + ')'
return '"' + (myevent.title ? myevent.title : (myevent.descr ? myevent.descr : '')) + '" (' + this.getstrDateEmailTime(myevent.dateTimeStart) + ')'
},
getlangforQuasar(mylang: string) {
@@ -5756,6 +5756,66 @@ export const tools = {
})
},
addFidoToMyCircuits($q: any, username: string, circuitname: string) {
const userStore = useUserStore()
const notifStore = useNotifStore()
$q.dialog({
message: t('db.domanda_addfidotocircuit', { 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.SETFIDO, true)
.then((res: any) => {
if (res && res.result) {
this.updateMyData(res)
notifStore.updateNotification = true
if (res.circuit) {
if (userStore.my.profile.mycircuits)
userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit]
else
userStore.my.profile.mycircuits = [res]
}
tools.showPositiveNotif($q, t('db.addedfidocircuit', { circuitname }))
}
})
})
},
addFidoGroupToMyCircuits($q: any, groupname: string, circuitname: string) {
const userStore = useUserStore()
const notifStore = useNotifStore()
$q.dialog({
message: t('db.domanda_addgrouptocircuit', { groupname, circuitname }),
ok: { label: t('dialog.yes'), push: true },
cancel: { label: t('dialog.cancel') },
title: t('db.domanda')
}).onOk(() => {
let extrarec = {
groupname,
}
userStore.setCircuitCmd($q, t, userStore.my.username, circuitname, shared_consts.CIRCUITCMD.SETFIDO, true, extrarec)
.then((res: any) => {
if (res && res.result) {
this.updateMyData(res)
notifStore.updateNotification = true
if (res.circuit) {
if (userStore.my.profile.mycircuits)
userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit]
else
userStore.my.profile.mycircuits = [res]
}
tools.showPositiveNotif($q, t('db.addedfidocircuit', { circuitname }))
}
})
})
},
addToMyGroups($q: any, username: string, groupnameDest: string) {
const userStore = useUserStore()
@@ -6276,44 +6336,32 @@ export const tools = {
const userStore = useUserStore()
let msg = ''
if (value) {
msg = t('circuit.domanda_ask', { circuitname })
} else {
msg = t('circuit.domanda_revoke', { circuitname })
}
$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, circuitname, shared_consts.CIRCUITCMD.REQ, value, { groupname })
.then((res: any) => {
if (res) {
if (value) {
// ADD to req
userStore.my.profile.asked_circuits.push(res.circuit)
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 !== circuitname)
tools.showPositiveNotif($q, t('circuit.revoketo', { circuitname }))
}
this.updateMyData(res)
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REQ, value, { groupname })
.then((res: any) => {
if (res) {
if (value) {
// ADD to req
userStore.my.profile.asked_circuits.push(res.circuit)
tools.showPositiveNotif($q, t('circuit.askedto', { circuitname }))
} else {
tools.showNegativeNotif($q, t('db.recfailed'))
// REMOVE to req
userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname)
tools.showPositiveNotif($q, t('circuit.revoketo', { circuitname }))
}
})
})
this.updateMyData(res)
} else {
tools.showNegativeNotif($q, t('db.recfailed'))
}
})
},
getDestStrByExtraRec(extrarec: any) {
return extrarec.groupdest ? extrarec.groupdest : (extrarec.contoComDest ? extrarec.contoComDest : extrarec.dest)
},
getOrigStrBySendNotif(extrarec: any) {
return extrarec.grouporig ? extrarec.grouporig : (extrarec.contoComOrig ? extrarec.contoComOrig : extrarec.sender)
},
async sendCoinsByCircuit($q: any, circuit: ICircuit, sendcoinrec: ISendCoin) {
@@ -6523,6 +6571,10 @@ export const tools = {
let risultato = false
if (userStore.isAdmin) {
return true
}
if (userStore.my.profile.manage_mycircuits) {
const ris = userStore.my.profile.manage_mycircuits.find((circuit: ICircuit) => {
if (circuit.name === circuitname) {
@@ -6622,6 +6674,9 @@ export const tools = {
isUserAdminGroup(groupname: string, username: string) {
const userStore = useUserStore()
if (userStore.my.username === username && userStore.isAdmin) {
return true
}
let risultato = false
if (userStore.my.profile.manage_mygroups) {
@@ -6664,6 +6719,10 @@ export const tools = {
isUserTheCreatorOfTheCircuit(name: string, username: string) {
const userStore = useUserStore()
if (userStore.my.username === username && userStore.isAdmin) {
return true
}
let risultato = false
if (userStore.my.profile.manage_mycircuits) {
@@ -6684,6 +6743,10 @@ export const tools = {
isUserAdminCircuit(name: string, username: string) {
const userStore = useUserStore()
if (userStore.my.username === username && userStore.isAdmin) {
return true
}
let risultato = false
if (userStore.my.profile.manage_mycircuits) {

View File

@@ -487,10 +487,31 @@ export const useUserStore = defineStore('UserStore', {
},
getMyCircuitsInCommonByUser(user: IUserFields): any[] {
let arrout = []
let vuoto = false
const circuitStore = useCircuitStore()
if (!this.my.profile.mycircuits || (!user || !user.profile || !user.profile.mycircuits))
return []
return tools.getCommon([...this.my.profile.mycircuits], [...user.profile.mycircuits], 'circuitname')
vuoto = true // ok
else
arrout = tools.getCommon([...this.my.profile.mycircuits], [...user.profile.mycircuits], 'circuitname')
// se non ho neanche 1 circuito in comune, metto il mio preferito
if (arrout.length <= 0) {
const circuit = circuitStore.getCircuitByProvince(this.my.profile.resid_province)
if (circuit)
arrout.push(circuit.name)
else {
if (this.my.profile.mycircuits.length > 0) {
arrout.push(this.my.profile.mycircuits[0].circuitname)
}
}
}
console.log('arrout', arrout)
return arrout
},
getMyCircuits(): any[] {
@@ -659,7 +680,7 @@ export const useUserStore = defineStore('UserStore', {
if (!!myrec.surname)
name += myrec.surname + ' '
if (!name) {
if (!name && myrec.username) {
name += myrec.username + ' '
}
if (col && col.field === 'extrarec' && !name) {
@@ -670,12 +691,18 @@ export const useUserStore = defineStore('UserStore', {
return myrec.descr
else if (myrec.hasOwnProperty('groupname'))
return myrec.groupname
else if (myrec.hasOwnProperty('grouporig'))
return myrec.grouporig
} else if (tipoconto === costanti.AccountType.COMMUNITY_ACCOUNT) {
if (myrec.hasOwnProperty('name'))
return myrec.name
else if (myrec.hasOwnProperty('contocom'))
return myrec.contocom
else if (myrec.hasOwnProperty('contoComDest'))
return myrec.contoComDest
}
if (!name && myrec.extrarec && myrec.extrarec.hasOwnProperty('contoComDest'))
return myrec.extrarec.contoComDest
return name
},
@@ -1772,6 +1799,25 @@ export const useUserStore = defineStore('UserStore', {
},
showButtonSendCoin(myuser: IUserFields) {
const oldway = false
if (oldway)
return this.getMyCircuitsInCommonByUser(myuser).length > 0
let yes = true
// Check if I have at least 1 Circuit
yes = yes && (this.my.profile.mycircuits.length > 0)
if (myuser && myuser.profile && myuser.profile.mycircuits) {
// Check if myuser has at least 1 Circuit
yes = yes && (myuser.profile.mycircuits.length > 0)
}
return yes
},
async setSeen($q: any, t: any, id: any, table: string, myrec: any) {
let value = false