Visu Sent Monete

This commit is contained in:
Paolo Arena
2022-09-13 12:28:33 +02:00
parent f59691985a
commit 44c75768c6
29 changed files with 301 additions and 69 deletions

View File

@@ -58,7 +58,6 @@ export default defineComponent({
return {
showingtooltip,
t,
$q,
}
},
})

View File

@@ -27,7 +27,7 @@
<q-icon v-else name="fas fa-coins" size="sm"/>
</template>
<template v-slot:control>
<div class="align_elem_right">{{ value }}
<div class="align_elem_right">{{ value.toFixed(2) }}
<q-tooltip :offset="[10, 10]" v-model="showingtooltip">{{tips}}</q-tooltip>
</div>
</template>

View File

@@ -114,6 +114,8 @@ export default defineComponent({
const mypagination = computed(() => {
if (props.table === toolsext.TABMYBACHECAS)
return { sortBy: 'dateTimeStart', descending: false, page: 1, rowsNumber: 20, rowsPerPage: 20 }
else if (props.table === toolsext.TABMOVEMENTS)
return { sortBy: 'transactionDate', descending: true, page: 1, rowsNumber: 20, rowsPerPage: 20 }
return { sortBy: 'date_created', descending: true, page: 1, rowsNumber: 20, rowsPerPage: 20 }
})

View File

View File

@@ -0,0 +1,75 @@
import { defineComponent, onMounted, PropType, ref, watch } from 'vue'
import { useQuasar } from 'quasar'
import { useI18n } from '@/boot/i18n'
import { useGlobalStore } from '@store/globalStore'
import { useUserStore } from '@store/UserStore'
import { fieldsTable } from '@store/Modules/fieldsTable'
import { tools } from '@store/Modules/tools'
import { costanti } from '@costanti'
import { shared_consts } from '@/common/shared_vuejs'
import { CMyFieldDb } from '@/components/CMyFieldDb'
import { CDateTime } from '@/components/CDateTime'
import { toolsext } from '@src/store/Modules/toolsext'
import { computed } from 'vue'
import { INotif } from 'model'
import { useNotifStore } from '@store/NotifStore'
import { useCircuitStore } from '@store/CircuitStore'
import { useRouter } from 'vue-router'
import MixinUsers from '@/mixins/mixin-users'
export default defineComponent({
name: 'CNotifAtTop',
props: {
},
components: { },
setup(props, { emit }) {
const q = useQuasar()
const { t } = useI18n()
const globalStore = useGlobalStore()
const userStore = useUserStore()
const notifStore = useNotifStore()
const circuitStore = useCircuitStore()
const $router = useRouter()
const { getImgByNotif, getNotifText, getTypeDirNotif, getTypeIdNotif } = MixinUsers()
const lasts_notifs_req = computed(() => notifStore.getnotifs_coinsreq())
const num_notifs = computed(() => lasts_notifs_req.value.length)
function mounted() {
//
}
function clickNotif(notif: INotif) {
if (notif.openUrl) {
let mylink = tools.updateQueryStringParameter(notif.openUrl, 'idnotif', notif._id)
console.log('mylink', mylink, notif._id)
if (mylink) {
$router.replace(mylink)
}
}
}
onMounted(mounted)
return {
q,
t,
getImgByNotif,
getNotifText,
getTypeDirNotif,
getTypeIdNotif,
tools,
costanti,
shared_consts,
fieldsTable,
globalStore,
toolsext,
lasts_notifs_req,
num_notifs,
clickNotif,
}
},
})

View File

@@ -0,0 +1,58 @@
<template>
<q-banner
v-if="num_notifs > 0"
rounded
dense
class="bg-primary text-white"
color="primary q-title"
style="text-align: center;">
<template v-slot:avatar>
<q-icon name="fas fa-exclamation-triangle" color="yellow" size="xs" />
</template>
<q-item clickable v-for="(notif, index) in lasts_notifs_req" :key="index">
<!--<q-item-section avatar>
<q-avatar>
<q-item-label lines="1">{{ getTypeDirNotif(notif) }}</q-item-label>
</q-avatar>
</q-item-section>-->
<q-item-section avatar>
<q-avatar>
<img :src="notif.myimgsender" :alt="notif.sender">
</q-avatar>
</q-item-section>
<q-item-section v-ripple>
<q-item-label lines="5" :class="(!notif.read) ? 'unread' : 'read'" @click="clickNotif(notif)">
<div v-html="getNotifText($t, notif, false)"></div>
</q-item-label>
<q-item-label caption lines="2"
v-if="notif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS && notif.status === 0 && notif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ"
v-ripple>
<div class="row no-wrap justify-evenly q-pa-sm">
<q-btn
size="md"
icon="fas fa-coins"
color="positive" :label="$t('circuit.accept_coins_qty', {qty: notif.extrarec.qty, symbol: notif.extrarec.symbol})"
@click="tools.acceptCoins(q, notif.sender, notif)"
/>
<q-btn
size="md"
color="negative" :label="$t('circuit.refuse_coins_qty', {qty: notif.extrarec.qty, symbol: notif.extrarec.symbol})"
@click="tools.refuseCoins(q, notif.sender, notif.extrarec)"
/>
</div>
</q-item-label>
</q-item-section>
</q-item>
</q-banner>
</template>
<script lang="ts" src="./CNotifAtTop.ts">
</script>
<style lang="scss" scoped>
@import './CNotifAtTop.scss';
</style>

View File

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

View File

@@ -7,6 +7,8 @@ import { useUserStore } from '@store/UserStore'
import { useCircuitStore } from '@store/CircuitStore'
import { useQuasar } from 'quasar'
import { useI18n } from '@/boot/i18n'
import { CMyUser } from '@/components/CMyUser'
import { costanti } from '@costanti'
export default defineComponent({
name: 'CSendCoins',
@@ -21,7 +23,7 @@ export default defineComponent({
required: true,
},
},
components: { CCurrencyValue },
components: { CCurrencyValue, CMyUser },
setup(props, { emit }) {
const $q = useQuasar()
@@ -42,11 +44,13 @@ export default defineComponent({
const accountloaded = ref(<IAccount | undefined>undefined)
const accountdest = ref(<IAccount | undefined>undefined)
const remainingCoins = ref(0)
const maxsendable = ref(0)
const numstep = ref(0)
const priceLabel = computed(() => circuitloaded.value ? `${qty.value} ` + circuitloaded.value.symbol : '')
const arrayMarkerLabel = ref(<any>[])
const qtyRef = ref(null)
const qtyRef = ref(<any>null)
watch(() => circuitsel.value, (newval, oldval) => {
aggiorna()
@@ -63,15 +67,30 @@ export default defineComponent({
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)
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 value = ind * 10
let value = ind * numstep.value
if (value > remainingCoins.value) {
break
} else {
const label = value.toString()
arrayMarkerLabel.value.push({value, label})
arrayMarkerLabel.value.push({ value, label })
}
}
}
@@ -108,19 +127,19 @@ export default defineComponent({
if (props.to_user.username && qty.value && circuitloaded.value) {
const myrecsendcoin: ISendCoin = {
qty: qty.value,
qty: tools.convstrToNum(qty.value),
dest: props.to_user.username,
circuitname: circuitsel.value,
causal: causal.value,
symbol: circuitloaded.value.symbol,
}
console.log('myrecsendcoin', myrecsendcoin)
if (circuitloaded.value) {
tools.sendCoinsByCircuit($q, circuitloaded.value, myrecsendcoin).then((ris: any) => {
if (ris) {
show.value = false
}
})
if (myrecsendcoin) {
tools.sendCoinsByCircuit($q, circuitloaded.value, myrecsendcoin)
.then((ris: any) => {
if (ris) {
show.value = false
}
})
}
}
}
@@ -145,6 +164,11 @@ export default defineComponent({
arrayMarkerLabel,
remainingCoins,
qtyRef,
maxsendable,
circuitStore,
numstep,
costanti,
userStore,
}
},
})

View File

@@ -1,6 +1,6 @@
<template>
<div>
<q-dialog v-model="show" :maximized="$q.screen.lt.sm" @hide="hide">
<q-dialog v-model="show" :maximized="$q.screen.lt.sm" @hide="hide" @show="qtyRef.focus()">
<q-card class="dialog_card">
<q-toolbar class="bg-primary text-white">
<q-toolbar-title>
@@ -22,48 +22,57 @@
</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>
<q-input v-model="from_username" label="Mittente" class="full-width" readonly>
</q-input>
<CMyUser
:mycontact="to_user"
:visu="costanti.FIND_PEOPLE"
@setCmd="tools.setCmd"
labelextra="Destinatario"
>
</CMyUser>
<q-input v-model="causal" label="Note" class="full-width">
</q-input>
<div>
<q-input
ref="qtyRef"
class="q-py-sm text-h5"
outlined v-model="qty" type="number"
:rules="[ val => val <= circuitStore.getRemainingCoinsToSend(accountloaded) || t('circuit.qta_remaining_to_send', { maxqta: circuitStore.getRemainingCoinsToSend(accountloaded), symbol: circuitloaded.symbol })]"
:label="t('movement.amount_to_send', {qtamax: circuitStore.getRemainingCoinsToSend(accountloaded).toFixed(2) + ` ` + circuitloaded.symbol})"
>
<!--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">
<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-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>
<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-slider
v-model="qty"
color="green"
markers
track-size="10px"
:step="numstep"
:marker-labels="arrayMarkerLabel"
label-always
:label-value="priceLabel"
switch-label-side
switch-marker-labels-side
:inner-max="remainingCoins"
:min="0"
:max="Number(maxsendable.toFixed(2))"
/>
</div>
</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"
:label="$t('circuit.sendcoinsto', {qty, coin: circuitsel, dest: to_user.username })" color="positive"
@click="sendCoin()"></q-btn>
<q-btn flat :label="$t('dialog.cancel')" color="primary" v-close-popup></q-btn>
</q-card-actions>

View File

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