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,
}
},
})

View File

@@ -32,7 +32,7 @@
style="text-align: center"
>
<div class="mybanner_left bg-blue text-white q-mb-sm">
{{$t('circuit.sender')}}:
{{ $t('circuit.sender') }}:
</div>
<div>
<q-btn-toggle
@@ -45,13 +45,7 @@
toggle-color="primary"
color="white"
text-color="primary"
:options="[
{ label: $t('circuit.user'), value: costanti.AccountType.USER },
{
label: $t('circuit.contocom'),
value: costanti.AccountType.COMMUNITY_ACCOUNT,
},
]"
:options="arrTypesAccounts"
/>
</div>
<q-input
@@ -61,7 +55,9 @@
readonly
>
</q-input>
<div v-else>
<div
v-else-if="tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT"
>
<q-select
v-model="from_groupname"
:options="arrGroupsList"
@@ -73,6 +69,17 @@
<!-- Mostra i gruppi su cui sei Admin -->
</q-select>
</div>
<div
v-else-if="tipoConto === costanti.AccountType.COMMUNITY_ACCOUNT"
>
<q-input
v-model="from_contocom"
:label="$t('circuit.contocom')"
readonly
class="q-my-sm"
>
</q-input>
</div>
<CSaldo
v-if="circuitloaded"
@@ -95,7 +102,7 @@
color="primary q-title"
>
<div class="mybanner_left bg-green text-white q-mb-sm">
{{$t('circuit.dest')}}
{{ $t('circuit.dest') }}
</div>
<!-- Destination -->
@@ -115,13 +122,17 @@
</CMyGroupOnlyView>
<CMyGroupOnlyView
v-if="circuitloaded && to_contocom"
:mygrp="{groupname: to_contocom}"
:mygrp="{ groupname: to_contocom }"
:visu="costanti.USER_GROUPS"
:circuitname="circuitloaded.name"
>
</CMyGroupOnlyView>
</q-banner>
<q-inner-loading id="spinner" :showing="loading">
<q-spinner-tail size="6em" color="primary" />
</q-inner-loading>
<div v-if="circuitloaded">
<q-banner
v-if="!circuitloaded.transactionsEnabled"
@@ -212,18 +223,30 @@
v-if="circuitloaded"
:disable="
qtyRef
? qtyRef.hasError || !circuitloaded.transactionsEnabled ||
((tipoConto === costanti.AccountType.USER) && to_user && (from_username === to_user.username)) ||
((tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT) && !from_groupname) ||
((tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT) && to_group && from_groupname && (to_group.groupname === from_groupname)) ||
((tipoConto === costanti.AccountType.COMMUNITY_ACCOUNT) && !to_contocom)
? qtyRef.hasError ||
!circuitloaded.transactionsEnabled ||
(tipoConto === costanti.AccountType.USER &&
to_user &&
from_username === to_user.username) ||
(tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT &&
!from_groupname) ||
(tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT &&
to_group &&
from_groupname &&
to_group.groupname === from_groupname) ||
(tipoConto === costanti.AccountType.COMMUNITY_ACCOUNT &&
!from_contocom)
: false
"
:label="
$t('circuit.sendcoinsto', {
qty,
coin: circuitsel,
dest: to_group ? to_group.groupname : (to_user ? to_user.username : to_contocom),
dest: to_group
? to_group.groupname
: to_user
? to_user.username
: to_contocom,
})
"
color="positive"