ver: 0.5.62

Conti Collettivi visibili solo se sei admin...
This commit is contained in:
Surya Paolo
2023-02-02 02:31:09 +01:00
parent cfa2457147
commit d5831e3dbf
13 changed files with 196 additions and 81 deletions

View File

@@ -38,11 +38,6 @@ export default defineComponent({
required: false,
default: null,
},
from_contocom: {
type: String,
required: false,
default: '',
},
to_contocom: {
type: String,
required: false,
@@ -65,20 +60,29 @@ export default defineComponent({
const from_username = ref(userStore.my.username)
const from_groupname = ref('')
const from_contocom = ref('')
const circuitsel = ref('')
const qty = ref(<string | number>'')
const causal = ref('')
const loading = ref(false)
const bothcircuits = ref(<any>[])
const groupSel = ref(<IMyGroup | null | undefined>null)
const circuitloaded = ref(<ICircuit | undefined>undefined)
const circuittoload = ref(<ICircuit | undefined>undefined)
const circuitloaded = ref(<ICircuit>{})
const circuitdest = ref(<ICircuit | undefined>undefined)
const accountloaded = ref(<IAccount | undefined | null>undefined)
const accountdest = ref(<IAccount | undefined>undefined)
const remainingCoins = ref(0)
const maxsendable = ref(0)
const numstep = ref(0)
const arrTypesAccounts = ref(<any>[
{
label: t('circuit.user'),
value: costanti.AccountType.USER,
},
])
const tipoConto = ref(costanti.AccountType.USER)
const priceLabel = computed(() => circuitloaded.value ? `${qty.value} ` + circuitloaded.value.symbol : '')
@@ -113,68 +117,112 @@ export default defineComponent({
show.value = newval
})
function aggiorna() {
async function aggiorna() {
loading.value = true
groupSel.value = null
from_contocom.value = ''
accountloaded.value = null
circuitloaded.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value)
if (circuitloaded.value) {
if (tipoConto.value === costanti.AccountType.USER) {
accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
} else if (tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT) {
groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname)
accountloaded.value = groupSel.value ? groupSel.value.account : null
} else if (tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT) {
groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname)
accountloaded.value = groupSel.value ? groupSel.value.account : null
}
circuittoload.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value)
if (circuittoload.value) {
await userStore.loadCircuit(circuittoload.value.path, '').then(({ data, status }: { data: any, status: number }) => {
try {
arrTypesAccounts.value = [
{
label: t('circuit.user'),
value: costanti.AccountType.USER,
},
]
groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin()
arrGroupsList.value = []
if (!!data.circuit) {
circuitloaded.value = data.circuit
for (const group of groupsListAdmin.value) {
arrGroupsList.value.push({ label: group.groupname, value: group.groupname });
}
if (tipoConto.value === costanti.AccountType.USER) {
accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
} else if (tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT) {
groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname)
if (tools.iAmAdminCircuit(circuitloaded.value.name))
arrGroupsList.value.push({ label: circuitloaded.value.name, value: circuitloaded.value.path });
accountloaded.value = groupSel.value ? groupSel.value.account : null
} else if (tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT) {
from_contocom.value = circuitloaded.value.path
accountloaded.value = circuitloaded.value ? circuitloaded.value.account : null
}
// accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
if (accountloaded.value) {
remainingCoins.value = circuitStore.getRemainingCoinsToSend(accountloaded.value)
if (accountloaded.value.saldo > 0) {
maxsendable.value = accountloaded.value.saldo + accountloaded.value.fidoConcesso
} else {
maxsendable.value = accountloaded.value.fidoConcesso
}
groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin(circuitloaded.value.name)
console.log('groupsListAdmin.value', groupsListAdmin.value)
if (remainingCoins.value < 10) {
remainingCoins.value = 10
}
arrGroupsList.value = []
numstep.value = Math.round(maxsendable.value / 10)
if (numstep.value < 1) {
numstep.value = 1
}
if (groupsListAdmin.value) {
for (const group of groupsListAdmin.value) {
arrGroupsList.value.push({ label: group.groupname, value: group.groupname });
}
}
const quanti = [...Array(20).keys()].map(i => i + 1)
for (const ind of quanti) {
let valuenorm = ind * numstep.value
let value = ind * numstep.value
if (value > remainingCoins.value) {
break
} else {
const label = valuenorm.toString()
arrayMarkerLabel.value.push({ value, label })
if (arrGroupsList.value.length > 0) {
arrTypesAccounts.value.push(
{
label: t('circuit.conticollettivi'),
value: costanti.AccountType.COLLECTIVE_ACCOUNT,
})
}
if (tools.iCanSendCoinsSuperUserCircuit(circuitsel.value)) {
arrTypesAccounts.value.push({
label: t('circuit.contocom'),
value: costanti.AccountType.COMMUNITY_ACCOUNT,
})
}
// if (tools.iAmAdminCircuit(circuitloaded.value.name))
// arrGroupsList.value.push({ label: circuitloaded.value.name, value: circuitloaded.value.path });
// accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
if (accountloaded.value) {
remainingCoins.value = circuitStore.getRemainingCoinsToSend(accountloaded.value)
if (accountloaded.value.saldo > 0) {
maxsendable.value = accountloaded.value.saldo + accountloaded.value.fidoConcesso
} else {
maxsendable.value = accountloaded.value.fidoConcesso
}
if (remainingCoins.value < 10) {
remainingCoins.value = 10
}
numstep.value = Math.round(maxsendable.value / 10)
if (numstep.value < 1) {
numstep.value = 1
}
const quanti = [...Array(20).keys()].map(i => i + 1)
for (const ind of quanti) {
let valuenorm = ind * numstep.value
let value = ind * numstep.value
if (value > remainingCoins.value) {
break
} else {
const label = valuenorm.toString()
arrayMarkerLabel.value.push({ value, label })
}
}
}
}
} finally {
loading.value = false
}
}
})
}
}
function mounted() {
arrTypesAccounts.value = [
{
label: t('circuit.user'),
value: costanti.AccountType.USER,
},
]
// ....
if (props.to_user) {
@@ -255,7 +303,7 @@ export default defineComponent({
myrecsendcoin.groupdest = props.to_group ? props.to_group.groupname : ''
myrecsendcoin.contoComDest = props.to_contocom
myrecsendcoin.grouporig = tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT ? from_groupname.value : ''
myrecsendcoin.contoComOrig = tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT ? props.from_contocom : ''
myrecsendcoin.contoComOrig = tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT ? from_contocom.value : ''
myrecsendcoin.dest = props.to_user ? props.to_user.username : ''
@@ -302,6 +350,9 @@ export default defineComponent({
tipoConto,
arrGroupsList,
from_groupname,
from_contocom,
arrTypesAccounts,
loading,
}
},
})