Conto Comunitario all'interno di un Circuito

This commit is contained in:
Surya Paolo
2023-01-21 19:02:26 +01:00
parent 42d68eb4b8
commit 98c0218ef7
18 changed files with 117 additions and 42 deletions

View File

@@ -620,6 +620,31 @@ export const colmyMovement = [
noshowlabel: true,
}),
AddCol({
name: 'groupfrom.groupname',
label_trans: 'groups.groupname',
field: 'groupfrom',
subfield: 'groupname',
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/my/groupfrom.groupname',
noshowlabel: true,
extrafield: 'movement.from',
}),
AddCol({
name: 'groupto.groupname',
label_trans: 'groups.groupname',
field: 'groupto',
subfield: 'groupname',
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/my/groupto.groupname',
extrafield: 'movement.to',
noshowlabel: true,
}),
AddCol({
name: 'amount', label_trans: 'movement.amount',
fieldtype: costanti.FieldType.currency, required: true, tipovisu: costanti.TipoVisu.TESTO_BORDATO
@@ -632,7 +657,9 @@ export const colmyMovementTable = [
// AddCol({ name: '_id', label_trans: 'reg.id' }),
AddCol({ name: 'transactionDate', label_trans: 'movement.transactionDate', fieldtype: costanti.FieldType.date }),
AddCol({ name: 'userfrom.username', field: 'userfrom', subfield: 'username', label_trans: 'movement.accountFromId', fieldtype: costanti.FieldType.string, required: true }),
AddCol({ name: 'groupfrom.groupname', field: 'groupfrom', subfield: 'groupname', label_trans: 'movement.accountFromComId', fieldtype: costanti.FieldType.string, required: true }),
AddCol({ name: 'userto.username', field: 'userto', subfield: 'username', label_trans: 'movement.accountToId', fieldtype: costanti.FieldType.string, required: true }),
AddCol({ name: 'groupto.groupname', field: 'groupto', subfield: 'groupname', label_trans: 'movement.accountToComId', fieldtype: costanti.FieldType.string, required: true }),
AddCol({
name: 'amount', label_trans: 'movement.amount',

View File

@@ -5653,7 +5653,11 @@ export const tools = {
acceptCoins($q: any, username: string, notif: any) {
const userStore = useUserStore()
const notifStore = useNotifStore()
notif.extrarec.notifId = notif._id
notif.extrarec.lastdr = notifStore.getLastDataRead(username)
userStore.setCircuitCmd($q, t, username, notif.extrarec.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT, 0, notif.extrarec)
.then((res: any) => {
if (res) {
@@ -5671,7 +5675,10 @@ export const tools = {
refuseCoins($q: any, username: string, notif: any) {
const userStore = useUserStore()
const notifStore = useNotifStore()
notif.extrarec.notifId = notif._id
notif.extrarec.lastdr = notifStore.getLastDataRead(username)
userStore.setCircuitCmd($q, t, username, notif.extrarec.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_REFUSE, 0, notif.extrarec)
.then((res: any) => {
if (res && res.result) {
@@ -7306,9 +7313,13 @@ export const tools = {
let type = costanti.TypeMov.Nessuno
if (rec && rec.userfrom) {
const userStore = useUserStore()
if (userStore.my.username === rec.userfrom.username) {
if (rec.userfrom && userStore.my.username === rec.userfrom.username) {
type = costanti.TypeMov.Uscita
} else if (userStore.my.username === rec.userto.username) {
} else if (rec.userto && userStore.my.username === rec.userto.username) {
type = costanti.TypeMov.Entrata
} else if (rec.groupfrom && tools.isUserAdminGroup(rec.groupfrom.groupname, userStore.my.username)) {
type = costanti.TypeMov.Uscita
} else if (rec.groupto && tools.isUserAdminGroup(rec.groupto.groupname, userStore.my.username)) {
type = costanti.TypeMov.Entrata
}
}

View File

@@ -32,7 +32,7 @@ export const useNotifStore = defineStore('NotifStore', {
},
getnotifs_coinsreq: (mystate: INotifState) => (): INotif[] => {
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 20).filter((rec) => rec.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS && rec.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ && rec.status === 0) : []
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 20).filter((rec) => rec.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS && rec.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ && rec.status === shared_consts.CircuitsNotif.STATUS_NONE) : []
return (ctrec)
},
@@ -84,6 +84,13 @@ export const useNotifStore = defineStore('NotifStore', {
}
}
},
updateArrRecNotifFromServer(arrrecnotif: INotif[]) {
if (arrrecnotif && arrrecnotif.length > 0) {
this.last_notifs = arrrecnotif
this.updateArrNotif()
}
},
async setBadgeIconApp() {
// Get our dummy count and update it,
@@ -244,6 +251,30 @@ export const useNotifStore = defineStore('NotifStore', {
setCountNotifs(num: number) {
this.countNotif = num
},
getLastNotif(username: string): any {
// Get msg for this chat
if (this.last_notifs)
return this.last_notifs.find((rec: INotif) => rec.dest === username)
// return users_msg_saved[username]
},
getLastDataRead(username: string): any {
// Get msg for this
let myrec = this.getLastNotif(username)
const lastdata: any = (myrec && myrec.lastdataread) ? myrec.lastdataread : tools.getLastDateReadReset()
let mydate = ''
if (!tools.isIsoDate(lastdata))
mydate = lastdata.toISOString()
else
return lastdata
return mydate
}
},
})

View File

@@ -491,8 +491,12 @@ export const useUserStore = defineStore('UserStore', {
let myrec = user
if (col && col.field === 'userto')
myrec = user.userto
if (col && col.field === 'groupto')
myrec = user.groupto
if (col && col.field === 'userfrom')
myrec = user.userfrom
if (col && col.field === 'groupfrom')
myrec = user.groupfrom
return myrec
},
@@ -1338,6 +1342,8 @@ export const useUserStore = defineStore('UserStore', {
const notifStore = useNotifStore()
notifStore.updateRecNotif(res.data.recnotif)
notifStore.updateArrRecNotifFromServer(res.data.arrrecnotif)
}
return res.data
}).catch((error) => {