Circuits OK

Accounts Ok
Movements OK
This commit is contained in:
Paolo Arena
2022-09-14 11:31:48 +02:00
parent 44c75768c6
commit 25a60472ab
34 changed files with 299 additions and 119 deletions

View File

@@ -34,9 +34,9 @@ export const DB = {
}
export function allTables() {
const myarr = OtherTables
for (const tab of MainTables) {
for (const method of allMethod) {
const myarr = costanti.OtherTables
for (const tab of costanti.MainTables) {
for (const method of costanti.allMethod) {
myarr.push(method + tab)
}
}

View File

@@ -161,6 +161,18 @@ export const costanti = {
small: true,
visuonstat: true,
},
{
visible: false,
title: 'Circuiti',
to: '/circuits',
table: 'circuits',
icon: 'fas fa-coins',
color: 'orange-6',
hint: '',
disable: true,
small: true,
visuonstat: true,
},
],
BINARY_CHECK: 1,

View File

@@ -2417,7 +2417,6 @@ export const colTableSubCashCategory = [
]
export const colTableCircuitComplete = [
AddCol({ name: 'Num', label_trans: 'circuit.num', fieldtype: costanti.FieldType.number }),
// AddCol({ name: 'groupnameId', label_trans: 'circuit.groupnameId', fieldtype: costanti.FieldType.select, jointable: 'mygroups' }), // da togliere poi
AddCol({ name: 'name', label_trans: 'circuit.name',
maxlength: 40,
@@ -2521,8 +2520,8 @@ export const colTableCircuit = [
fieldtype: costanti.FieldType.currency, required: true, visulabel: true }),
AddCol({ name: 'qta_max_default', label_trans: 'circuit.qta_max_default',
fieldtype: costanti.FieldType.currency, required: true, visulabel: true }),
AddCol({ name: 'regulation', label_trans: 'circuit.regulation', fieldtype: costanti.FieldType.html }),
AddCol({ name: 'deperimento', label_trans: 'circuit.deperimento', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'regulation', label_trans: 'circuit.regulation', fieldtype: costanti.FieldType.html, required: true }),
// AddCol({ name: 'deperimento', label_trans: 'circuit.deperimento', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'data_costituz', label_trans: 'circuit.data_costituz', fieldtype: costanti.FieldType.date }),
AddCol({
name: 'photos',
@@ -2537,7 +2536,7 @@ export const colTableCircuit = [
]
export const colmyUserCircuit = [
AddCol({ name: 'circuitId', label_trans: 'account.circuitId', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'circuitId', label_trans: 'account.circuitId', fieldtype: costanti.FieldType.string }),
AddCol({ name: 'userId', label_trans: 'account.users', fieldtype: costanti.FieldType.select, jointable: 'users', }),
AddCol({ name: 'name', label_trans: 'circuit.name' }),
AddCol({ name: 'deperibile', label_trans: 'account.deperibile', fieldtype: costanti.FieldType.boolean }),
@@ -2552,8 +2551,8 @@ export const colmyUserCircuit = [
export const colTableMovement = [
AddCol({ name: 'transactionDate', label_trans: 'movement.transactionDate', fieldtype: costanti.FieldType.date }),
AddCol({ name: 'accountFromId', label_trans: 'movement.accountFromId', fieldtype: costanti.FieldType.number, required: true }),
AddCol({ name: 'accountToId', label_trans: 'movement.accountToId', fieldtype: costanti.FieldType.number, required: true }),
AddCol({ name: 'accountFromId', label_trans: 'movement.accountFromId', fieldtype: costanti.FieldType.string, required: true }),
AddCol({ name: 'accountToId', label_trans: 'movement.accountToId', fieldtype: costanti.FieldType.string, required: true }),
AddCol({ name: 'amount', label_trans: 'movement.amount', fieldtype: costanti.FieldType.number, required: true }),
AddCol({ name: 'causal', label_trans: 'movement.causal' }),
AddCol({ name: 'causal_table', label_trans: 'movement.causal_table' }),

View File

@@ -67,6 +67,7 @@ export const tools = {
FRIENDS_SEARCH: 'FR_SE',
GROUP_SEARCH: 'GR_SE',
CIRCUIT_SEARCH: 'CI_SE',
CIRCUIT_USE: 'CIR_U',
getprefCountries: ['it', 'es', 'us'],
@@ -4328,6 +4329,7 @@ export const tools = {
'blue': '#0000ff',
'blue-3': '#90caf9',
'blue-4': '#64b5f6',
'amber-10': '#ff6f00',
'blue-6': '#2196f3',
'blueviolet': '#8a2be2',
'brown': '#a52a2a',
@@ -4796,6 +4798,10 @@ export const tools = {
.then((res: any) => {
if (res) {
if (res.cansend) {
if (res.user) {
userStore.my = res.user
}
console.log('useraccounts', userStore.my.profile.useraccounts)
tools.showPositiveNotif($q, t('circuit.coins_accepted'))
} else {
tools.showNegativeNotif($q, res.errormsg)
@@ -4804,10 +4810,11 @@ export const tools = {
})
},
refuseCoins($q: any, username: string, recsendcoin: ISendCoin) {
refuseCoins($q: any, username: string, notif: any) {
const userStore = useUserStore()
userStore.setCircuitCmd($q, t, username, recsendcoin.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_REFUSE, recsendcoin)
notif.extrarec.notifId = notif._id
userStore.setCircuitCmd($q, t, username, notif.extrarec.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_REFUSE, 0, notif.extrarec)
.then((res: any) => {
if (res) {
tools.showPositiveNotif($q, t('circuit.coins_refused'))
@@ -5295,6 +5302,9 @@ export const tools = {
if (res.useraccounts && res.useraccounts.length > 0) {
userStore.my.profile.useraccounts = res.useraccounts
}
if (res.user) {
userStore.my = res.user
}
tools.showPositiveNotif($q, t('circuit.coins_sendrequest_sent'))
} else {
tools.showNegativeNotif($q, res.errormsg)
@@ -5344,7 +5354,7 @@ export const tools = {
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 }))
tools.showPositiveNotif($q, t('circuit.refusedcircuit', { username }))
}
})
})
@@ -5653,8 +5663,18 @@ export const tools = {
tools.addToMyCircuits($q, username, dest)
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
tools.setRequestCircuit($q, username, dest, value)
} else if (cmd === shared_consts.CIRCUITCMD.CANCEL_REQ) {
tools.cancelReqCircuit($q, username, dest)
} else if (cmd === shared_consts.CIRCUITCMD.REFUSE_REQ) {
tools.refuseReqCircuit($q, username, dest)
} else if (cmd === shared_consts.CIRCUITCMD.DELETE) {
tools.DeleteCircuit($q, username, dest)
} else if (cmd === shared_consts.CIRCUITCMD.ADDADMIN) {
tools.addtoAdminOfCircuit($q, username, dest)
} else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) {
tools.removeAdminOfCircuit($q, username, dest)
} else if (cmd === shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST) {
tools.removeFromMyCircuits($q, username, dest)
}
},
isCallable(anything: any) {
@@ -6257,8 +6277,13 @@ export const tools = {
// Function to return commonElements
getCommon(arr1: any, arr2: any, field: string): any[] {
arr1.sort((a: any, b: any) => b[field] - a[field]) // Sort both the arrays
arr2.sort((a: any, b: any) => b[field] - a[field])
// @ts-ignore
arr1.sort((a: any, b: any) => (a[field] > b[field]) - (a[field] < b[field])) // Sort both the arrays
// @ts-ignore
arr2.sort((a: any, b: any) => (a[field] > b[field]) - (a[field] < b[field]))
// console.log('arr1', arr1)
// console.log('arr2', arr2)
let common = [] // Array to contain common elements
let i = 0, j = 0 // i points to arr1 and j to arr2
// Break if one of them runs out
@@ -6284,9 +6309,9 @@ export const tools = {
if (rec && rec.userfrom) {
const userStore = useUserStore()
if (userStore.my.username === rec.userfrom.username) {
type = rec.amount > 0 ? costanti.TypeMov.Uscita : (rec.amount < 0 ? costanti.TypeMov.Entrata : costanti.TypeMov.Nessuno)
type = costanti.TypeMov.Uscita
} else if (userStore.my.username === rec.userto.username) {
type = rec.amount > 0 ? costanti.TypeMov.Entrata : (rec.amount < 0 ? costanti.TypeMov.Uscita : costanti.TypeMov.Nessuno)
type = costanti.TypeMov.Entrata
}
}