Send Coins

This commit is contained in:
Paolo Arena
2022-09-12 18:36:54 +02:00
parent d28050e71f
commit f59691985a
28 changed files with 507 additions and 95 deletions

View File

@@ -0,0 +1,64 @@
import { defineComponent, onMounted, PropType, ref, watch } from 'vue'
import { tools } from '@src/store/Modules/tools'
import { date, useQuasar } from 'quasar'
import { useI18n } from '@/boot/i18n'
export default defineComponent({
name: 'CCurrencyValue',
props: {
label: {
type: String,
required: false,
default: '',
},
tips: {
type: String,
required: false,
default: '',
},
readonly: {
type: Boolean,
required: false,
default: false,
},
symbol: {
type: String,
required: true,
},
color: {
type: String,
required: false,
default: '',
},
icon: {
type: String,
required: false,
default: '',
},
value: {
type: Number,
required: true,
},
},
components: {},
setup(props, { emit }) {
const $q = useQuasar()
const { t } = useI18n()
const showingtooltip = ref(false)
function created() {
// created
}
onMounted(created)
return {
showingtooltip,
t,
$q,
}
},
})

View File

@@ -0,0 +1,51 @@
<template>
<div v-if="value !== null" class="text-h5 bordo_stondato_stretto full-width">
<div class="text-center text-h7-dense text-italic text-grey-14">
{{ label }}
</div>
<div>
<q-field
dense
borderless
:readonly="readonly"
type="number"
rounded
class="q-px-sm text-h5"
color="green"
>
<template v-slot:prepend>
<!--<img src="https://cdn.quasar.dev/logo-v2/svg/logo.svg">-->
<q-btn v-if="tips"
icon="fas fa-info"
color="primary" text-color="white"
round
size="sm"
@click="showingtooltip = !showingtooltip"
>
</q-btn>
<q-icon v-else name="fas fa-coins" size="sm"/>
</template>
<template v-slot:control>
<div class="align_elem_right">{{ value }}
<q-tooltip :offset="[10, 10]" v-model="showingtooltip">{{tips}}</q-tooltip>
</div>
</template>
<template v-slot:append>
<div class="text-h5">
<em class="q-px-sm text-white rounded-borders" :style="`background-color: ` + (color ? color : '#ff5500')">{{ symbol }}</em>
</div>
</template>
</q-field>
</div>
</div>
</template>
<script lang="ts" src="./CCurrencyValue.ts">
</script>
<style lang="scss" scoped>
@import './CCurrencyValue.scss';
</style>

View File

@@ -0,0 +1 @@
export {default as CCurrencyValue} from './CCurrencyValue.vue'

View File

@@ -881,7 +881,13 @@ export default defineComponent({
try {
numRecLoaded.value = numRecLoaded.value + (returnedData.value ? returnedData.value.length : 0)
// console.log(' ...numRecLoaded.value', numRecLoaded.value)
serverData.value = [...serverData.value, ...returnedData.value]
let toadd = []
for (const elem of returnedData.value) {
if (serverData.value.findIndex((rec: any) => rec._id === elem._id) < 0) {
toadd.push(elem)
}
}
serverData.value = [...serverData.value, ...toadd]
} catch (e) {
serverData.value = []
}

View File

@@ -9,3 +9,8 @@
.clpopupVisuCard{
/*border-radius: $generic-border-radius */
}
.extrafield{
color: black;
font-size: 1rem;
padding: 4px;
}

View File

@@ -10,6 +10,7 @@ import { CDateTime } from '../CDateTime'
import { CLabel } from '../CLabel'
import { CMyToggleList } from '../CMyToggleList'
import { CMySelect } from '../CMySelect'
import { CCurrencyValue } from '../CCurrencyValue'
import { CMyEditor } from '../CMyEditor'
import { CGallery } from '../CGallery'
import { CAccomodation } from '../CAccomodation'
@@ -185,7 +186,8 @@ export default defineComponent({
default: false,
},
},
components: { CMyChipList, CDateTime, CDate, CMyToggleList, CMySelect, CMyEditor, CGallery, CLabel, CAccomodation },
components: { CMyChipList, CDateTime, CDate, CMyToggleList, CMySelect, CMyEditor, CGallery,
CCurrencyValue, CLabel, CAccomodation },
setup(props, { emit }) {
const $q = useQuasar()
const { t } = useI18n()

View File

@@ -10,13 +10,14 @@
<div v-if="col.fieldtype === costanti.FieldType.boolean">
<div v-if="isInModif">
<q-toggle
:disable="!isInModif"
dark color="green" v-model="myvalue" :label="col.title ? col.title : col.label"
@update:model-value="changevalRec"></q-toggle>
</div>
<div v-else>
<q-toggle
dark color="green" v-model="myvalue" :label="col.title"
:disable="disable && col.name !== 'profile.saw_zoom_presentation'"
:disable="disable && (col.name !== 'profile.saw_zoom_presentation') || !isInModif"
@update:model-value="Savedb"></q-toggle>
</div>
</div>
@@ -53,6 +54,9 @@
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.username_chip">
<div class="q-ma-xs">
<span v-if="col.extrafield">
<span class="extrafield">{{t(col.extrafield)}}</span>
</span>
<q-btn v-if="col.tipovisu === costanti.TipoVisu.LINK && myvalue"
rounded size="md"
:class="{disabled: disable }"
@@ -115,7 +119,7 @@
<span v-else :class="{disabled: disable }" v-html="visuValByType(myvalue, col, row)"></span>
</div>
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.number">
<div v-else-if="col.fieldtype === costanti.FieldType.number || col.fieldtype === costanti.FieldType.currency">
<div v-if="canEdit || isInModif">
<q-input
v-bind="$attrs"
@@ -129,6 +133,15 @@
</q-input>
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.currency">
<CCurrencyValue
:symbol="tools.getSymbolByCircuit(row)"
:color="tools.getColorByCircuit(row)"
:value="myvalue"
:label="t(col.label_trans)">
</CCurrencyValue>
</div>
<div v-else>
<span v-html="visuValByType(myvalue, col, row)"></span>
</div>
@@ -640,6 +653,16 @@
<span v-html="visuValByType(myvalue, col, row)"></span>
</div>
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.currency">
<CCurrencyValue
:symbol="tools.getSymbolByCircuit(row)"
:color="tools.getColorByCircuit(row)"
:value="scope.value"
:label="t(col.label_trans)">
</CCurrencyValue>
</div>
<div v-else-if="col.fieldtype === costanti.FieldType.hours">
<div v-if="visulabel">
<q-input

View File

@@ -9,11 +9,12 @@ import { toolsext } from '@store/Modules/toolsext'
import { useQuasar } from 'quasar'
import { useI18n } from '@/boot/i18n'
import { CMyCardPopup } from '@/components/CMyCardPopup'
import { CCurrencyValue } from '@/components/CCurrencyValue'
// import { useRouter } from 'vue-router'
export default defineComponent({
name: 'CMyRecCircuitCard',
components: { CMyCardPopup },
components: { CMyCardPopup, CCurrencyValue },
emits: ['setCmd', 'cmdext'],
props: {
table: {

View File

@@ -21,6 +21,17 @@
</q-item-label>
<q-item-label lines="3" v-if="myrec.longdescr">{{ myrec.longdescr }}<br>
</q-item-label>
<!--
<CCurrencyValue
:symbol="myrec.symbol"
:tips="t('account.saldo_tips')"
:color="myrec.color"
:value="myrec.account.saldo"
label="Saldo">
</CCurrencyValue>
-->
</q-item-section>
<q-item-section side v-if="tools.canModifyThisRec(myrec, table)">
<q-item-label>

View File

@@ -1,10 +1,12 @@
import { computed, defineComponent, onMounted, PropType, ref, watch } from 'vue'
import { ICircuit, IOperators, ISendCoin, ISpecialField, IUserFields } from '../../model'
import { IAccount, ICircuit, IOperators, ISendCoin, ISpecialField, IUserFields } from '../../model'
import { tools } from '@store/Modules/tools'
import { CCurrencyValue } from '@/components/CCurrencyValue'
import { useUserStore } from '@store/UserStore'
import { useCircuitStore } from '@store/CircuitStore'
import { useQuasar } from 'quasar'
import { useI18n } from '@/boot/i18n'
export default defineComponent({
name: 'CSendCoins',
@@ -19,9 +21,11 @@ export default defineComponent({
required: true,
},
},
components: { CCurrencyValue },
setup(props, { emit }) {
const $q = useQuasar()
const { t } = useI18n()
const show = ref(false)
const userStore = useUserStore()
const circuitStore = useCircuitStore()
@@ -33,8 +37,16 @@ export default defineComponent({
const causal = ref('')
const bothcircuits = ref(<any>[])
const circuitloaded = ref(<ICircuit|undefined>undefined)
const circuitloaded = ref(<ICircuit | undefined>undefined)
const circuitdest = ref(<ICircuit | undefined>undefined)
const accountloaded = ref(<IAccount | undefined>undefined)
const accountdest = ref(<IAccount | undefined>undefined)
const remainingCoins = ref(0)
const priceLabel = computed(() => circuitloaded.value ? `${qty.value} ` + circuitloaded.value.symbol : '')
const arrayMarkerLabel = ref(<any>[])
const qtyRef = ref(null)
watch(() => circuitsel.value, (newval, oldval) => {
aggiorna()
@@ -47,7 +59,28 @@ export default defineComponent({
function aggiorna() {
circuitloaded.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value)
if (circuitloaded.value) {
accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
// accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
if (accountloaded.value) {
remainingCoins.value = tools.getRemainingCoinsToSend(accountloaded.value)
const quanti = [ ...Array(100).keys() ].map( i => i+1)
for (const ind of quanti) {
let value = ind * 10
if (value > remainingCoins.value) {
break
} else {
const label = value.toString()
arrayMarkerLabel.value.push({value, label})
}
}
}
}
console.log('circuitStore.listcircuits', circuitStore.listcircuits, 'aggiorna', circuitloaded.value)
console.log('userStore.my.profile.mycircuits', userStore.my.profile.mycircuits)
}
function mounted() {
@@ -95,16 +128,23 @@ export default defineComponent({
onMounted(mounted)
return {
t,
tools,
show,
bothcircuits,
from_username,
circuitsel,
circuitloaded,
accountloaded,
accountdest,
qty,
hide,
sendCoin,
causal,
priceLabel,
arrayMarkerLabel,
remainingCoins,
qtyRef,
}
},
})

View File

@@ -13,6 +13,15 @@
<q-select rounded outlined v-model="circuitsel" :options="bothcircuits" label="Circuito">
</q-select>
<CCurrencyValue
:symbol="circuitloaded.symbol"
:tips="t('account.saldo_tips')"
:color="circuitloaded.color"
:value="accountloaded ? accountloaded.saldo : 0"
:label="t('account.saldo')">
</CCurrencyValue>
<q-input v-model="from_username" label="Mittente" class="full-width" disable>
</q-input>
<q-input v-model="to_user.username" label="Destinatario" class="full-width" disable>
@@ -21,21 +30,39 @@
</q-input>
<q-input outlined v-model="qty" type="number"
label="Quantità"
:prefix="circuitloaded.symbol">
<q-input
ref="qtyRef"
class="q-px-sm text-h5"
outlined v-model="qty" type="number"
:rules="[ val => val < tools.getRemainingCoinsToSend(accountloaded) || t('circuit.qta_remaining_to_send', { maxqta: tools.getRemainingCoinsToSend(accountloaded), symbol: circuitloaded.symbol })]" :label="t('movement.amount')"
>
<!--val => val > tools.getMaxCoinsToSend(accountloaded) || t('circuit.qta_max_to_send', { maxqta: tools.getRemainingCoinsToSend(accountloaded), symbol: circuitloaded.symbol })]" -->
<template v-slot:append>
<q-avatar>
<img src="https://cdn.quasar.dev/logo-v2/svg/logo.svg">
</q-avatar>
<div class="text-h5">
<em class="q-px-sm text-white rounded-borders" :style="`background-color: ` + (circuitloaded.color ? circuitloaded.color : '#ff5500')">{{ circuitloaded.symbol }}</em>
</div>
</template>
</q-input>
<q-slider
v-model="qty"
color="green"
markers
:step="5"
:marker-labels="arrayMarkerLabel"
label-always
:label-value="priceLabel"
switch-label-side
switch-marker-labels-side
:inner-max="remainingCoins"
:min="0"
:max="accountloaded.fidoConcesso"
/>
</q-card-section>
<q-card-actions align="center">
<q-btn
:disable="qtyRef ? qtyRef.hasError : false"
:label="$t('circuit.sendcoinsto', {qty, coin: circuitsel, dest: to_user.username })" color="primary"
@click="sendCoin()"></q-btn>
<q-btn flat :label="$t('dialog.cancel')" color="primary" v-close-popup></q-btn>

View File

@@ -1,3 +1,8 @@
.q-tab__label {
font-size: 0.7rem !important;
}
.q-tab {
padding-left: 2px;
padding-right: 2px;
}

View File

@@ -6,7 +6,9 @@
>
<q-tabs
dense
class="text-grey-10 mylabfooter"
class="text-grey-10 mylabfooter mysmalltabs"
style="padding: 0px !important;"
content-class="mysmalltabs"
active-color="primary"
no-caps
indicator-color="transparent"
@@ -24,6 +26,13 @@
to="/groups"
icon="fas fa-users"
/>
<q-route-tab
v-if="static_data.functionality.ENABLE_CIRCUITS"
class="mylabfooter"
:label="$t('tabdown.circuits')"
to="/circuits"
icon="fas fa-coins"
/>
<q-route-tab
v-if="static_data.functionality.ENABLE_VIEW_USERS"
class="mylabfooter"
@@ -52,6 +61,6 @@
<script lang="ts" src="./MyFooter.ts">
</script>
<style lang="scss">
<style lang="scss" scoped>
@import './MyFooter.scss';
</style>

View File

@@ -61,3 +61,4 @@ export * from './CKeyAndValue'
export * from './CNotifSettings'
// export * from './CPreloadImages'
export * from './CSendCoins'
export * from './CCurrencyValue'