Files
myprojplanet_vite/src/components/CSendCoins/CSendCoins.vue

273 lines
8.6 KiB
Vue
Raw Normal View History

2022-09-03 13:06:35 +02:00
<template>
<div>
2023-01-12 01:03:19 +01:00
<q-dialog
v-model="show"
:maximized="$q.screen.lt.sm"
@hide="hide"
@show="qtyRef ? qtyRef.focus() : ''"
>
2022-09-03 13:06:35 +02:00
<q-card class="dialog_card">
<q-toolbar class="bg-primary text-white">
<q-toolbar-title>
{{ $t('circuit.sendcoins') }}
</q-toolbar-title>
<q-btn flat round color="white" icon="close" v-close-popup></q-btn>
</q-toolbar>
<q-card-section class="q-pa-xs inset-shadow">
2022-12-02 10:55:04 +01:00
<q-select
2023-01-12 01:03:19 +01:00
:behavior="$q.platform.is.ios === true ? 'dialog' : 'menu'"
rounded
outlined
v-model="circuitsel"
:options="bothcircuits"
label="Circuito"
>
2022-09-03 13:06:35 +02:00
</q-select>
<q-banner
rounded
dense
class="shadow-5 q-my-sm"
color="primary q-title"
style="text-align: center"
2023-01-12 01:03:19 +01:00
>
<div class="mybanner_left bg-blue text-white q-mb-sm">
{{ $t('circuit.sender') }}:
</div>
<div>
<q-btn-toggle
2023-02-02 13:53:09 +01:00
v-if="arrTypesAccounts.length > 0"
v-model="tipoConto"
class="my-custom-toggle"
no-caps
rounded
unelevated
toggle-color="primary"
color="white"
text-color="primary"
:options="arrTypesAccounts"
/>
</div>
<q-input
v-if="tipoConto === costanti.AccountType.USER"
v-model="from_username"
class="full-width"
readonly
>
</q-input>
<div
v-else-if="tipoConto === costanti.AccountType.COLLECTIVE_ACCOUNT"
>
<q-select
v-model="from_groupname"
:options="arrGroupsList"
:label="$t('circuit.choosecontocom')"
rounded
emit-value
map-options
>
<!-- 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>
2023-01-12 01:03:19 +01:00
<CSaldo
v-if="circuitloaded"
:symbol="circuitloaded.symbol"
:color="circuitloaded.color"
:saldo="accountloaded ? accountloaded.saldo : 0"
:qtarem="
accountloaded
? circuitStore.getRemainingCoinsToSend(accountloaded)
: 0
"
2023-01-12 01:03:19 +01:00
>
</CSaldo>
</q-banner>
2023-01-12 01:03:19 +01:00
<q-banner
rounded
dense
class="shadow-5 q-my-sm"
color="primary q-title"
2022-09-13 12:28:33 +02:00
>
<div class="mybanner_left bg-green text-white q-mb-sm">
{{ $t('circuit.dest') }}
</div>
2022-09-03 13:06:35 +02:00
<!-- Destination -->
<CMyUserOnlyView
v-if="to_user"
:mycontact="to_user"
:visu="costanti.FIND_PEOPLE"
@setCmd="tools.setCmd"
>
</CMyUserOnlyView>
<CMyGroupOnlyView
v-if="to_group"
:mygrp="to_group"
:visu="costanti.USER_GROUPS"
:circuitname="circuitloaded.name"
>
</CMyGroupOnlyView>
2023-02-01 01:19:58 +01:00
<CMyGroupOnlyView
v-if="circuitloaded && to_contocom"
:mygrp="{ groupname: to_contocom }"
2023-02-01 01:19:58 +01:00
:visu="costanti.USER_GROUPS"
:circuitname="circuitloaded.name"
>
</CMyGroupOnlyView>
</q-banner>
2023-01-12 01:03:19 +01:00
<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"
rounded
class="bg-red text-white"
2023-01-12 01:03:19 +01:00
style="text-align: center"
>
2023-01-12 01:03:19 +01:00
<em style="font-weight: bold">{{
$t('circuit.transactionsEnabled_text')
}}</em
><br />
</q-banner>
2022-09-13 12:28:33 +02:00
<q-input
ref="qtyRef"
class="q-py-sm text-h5"
2023-01-12 01:03:19 +01:00
outlined
v-model="qty"
type="number"
:rules="[
2023-01-12 01:03:19 +01:00
(val) =>
val <= circuitStore.getRemainingCoinsToSend(accountloaded) ||
t('circuit.qta_remaining_to_send', {
maxqta: circuitStore.getRemainingCoinsToSend(accountloaded),
symbol: circuitloaded.symbol,
}),
(val) => val > 0 || t('circuit.qta_not_valid'),
]"
:label="
t('movement.amount_to_send', {
qtamax: circuitStore.getRemainingCoinsToSend(accountloaded)
? circuitStore
.getRemainingCoinsToSend(accountloaded)
.toFixed(2)
: 0 + ` ` + circuitloaded.symbol,
})
"
input-class="text-right"
v-on:keyup.enter="$event.target.nextElementSibling.focus()"
2022-09-13 12:28:33 +02:00
>
<!--val => val > circuitStore.getMaxCoinsToSend(accountloaded) || t('circuit.qta_max_to_send', { maxqta: tools.getRemainingCoinsToSend(accountloaded), symbol: circuitloaded.symbol })]" -->
<template v-slot:append>
<div class="text-h5">
2023-01-12 01:03:19 +01:00
<em
class="q-px-sm text-white rounded-borders"
:style="
`background-color: ` +
(circuitloaded.color ? circuitloaded.color : '#ff5500')
"
>{{ circuitloaded.symbol }}</em
>
2022-09-13 12:28:33 +02:00
</div>
</template>
</q-input>
<!--<q-slider
2022-09-14 11:31:48 +02:00
class="q-ma-xs"
2023-01-12 01:03:19 +01:00
v-if="
qty !== '' &&
circuitStore.getRemainingCoinsToSend(accountloaded) > 0
"
2022-09-13 12:28:33 +02:00
v-model="qty"
color="green"
markers
track-size="10px"
2023-01-12 01:03:19 +01:00
:step="numstep / 2"
2022-09-13 12:28:33 +02:00
:marker-labels="arrayMarkerLabel"
label-always
:label-value="priceLabel"
switch-label-side
switch-marker-labels-side
:inner-max="remainingCoins"
:min="0"
2023-01-12 01:03:19 +01:00
:max="Number(maxsendable ? maxsendable : 0)"
2022-09-13 12:28:33 +02:00
/>
--></div>
<q-input
ref="causalRef"
2023-01-12 01:03:19 +01:00
v-model="causal"
:label="$t('circuit.note')"
2023-01-12 01:03:19 +01:00
class="q-my-sm full-width"
>
2022-09-14 11:31:48 +02:00
</q-input>
2022-09-03 13:06:35 +02:00
</q-card-section>
<q-card-actions align="center">
<q-btn
v-if="circuitloaded"
2023-01-12 01:03:19 +01:00
: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 &&
!from_contocom)
2023-01-12 01:03:19 +01:00
: false
"
:label="
$t('circuit.sendcoinsto', {
qty,
coin: circuitsel,
dest: to_group
? to_group.groupname
: to_user
? to_user.username
: to_contocom,
2023-01-12 01:03:19 +01:00
})
"
color="positive"
@click="sendCoin()"
></q-btn>
<q-btn
flat
:label="$t('dialog.cancel')"
color="primary"
v-close-popup
></q-btn>
2022-09-03 13:06:35 +02:00
</q-card-actions>
</q-card>
</q-dialog>
</div>
</template>
<script lang="ts" src="./CSendCoins.ts">
</script>
<style lang="scss" scoped>
@import './CSendCoins.scss';
</style>