restoring the transaction list

This commit is contained in:
ogerly 2022-02-28 20:28:27 +01:00
parent e35275cd55
commit 289ca9115a
5 changed files with 90 additions and 99 deletions

View File

@ -1,11 +1,11 @@
<template> <template>
<div class="decayinformation"> <div class="decayinformation">
<span v-if="decaytyp === 'short'"> <span v-if="decaytyp === 'short'">
{{ decay ? ' ' + $n(decay.balance, 'decimal') : '' }} {{ decay ? $n(decay.decay, 'decimal') : '' }}
</span> </span>
<div v-if="decaytyp === 'new' || decaytyp === 'decayLastTransaction'"> <div v-if="decaytyp === 'new' || decaytyp === 'decayLastTransaction'">
<div class="d-flex" v-if="!decay.decayStartBlock"> <div class="d-flex">
<div style="width: 100%" class="text-center pb-3"> <div style="width: 100%" class="text-center pb-3">
<b-icon icon="droplet-half" height="12" class="mb-2" /> <b-icon icon="droplet-half" height="12" class="mb-2" />
<b>{{ $t('decay.calculation_decay') }}</b> <b>{{ $t('decay.calculation_decay') }}</b>
@ -14,16 +14,13 @@
<b-row> <b-row>
<b-col cols="6" class="text-right"> <b-col cols="6" class="text-right">
<div v-if="!decay.decayStartBlock">{{ $t('decay.last_transaction') }}</div> <!-- <div v-if="!decay.decayStartBlock">{{ $t('decay.last_transaction') }}</div> -->
<div>{{ $t('decay.last_transaction') }}</div>
</b-col> </b-col>
<b-col cols="6"> <b-col cols="6">
<div v-if="decay.decayStartBlock > 0">
<div class="display-4">{{ $t('decay.Starting_block_decay') }}</div>
<div>{{ $t('decay.decay_introduced') }} :</div>
</div>
<div> <div>
<span v-if="decay.decayStart"> <span v-if="decay.start">
{{ $d(new Date(decay.decayStart * 1000), 'long') }} {{ $d(new Date(decay.start), 'long') }}
{{ $i18n.locale === 'de' ? 'Uhr' : '' }} {{ $i18n.locale === 'de' ? 'Uhr' : '' }}
</span> </span>
</div> </div>
@ -31,10 +28,10 @@
</b-row> </b-row>
<b-row> <b-row>
<b-col cols="6" class="text-right"> <b-col cols="6" class="text-right">
<div v-if="!decay.decayStartBlock">{{ $t('decay.past_time') }}</div> <!-- <div v-if="!decay.decayStartBlock">{{ $t('decay.past_time') }}</div> -->
<div>{{ $t('decay.past_time') }}</div>
</b-col> </b-col>
<b-col cols="6"> <b-col cols="6">
<div v-if="decay.decayStartBlock > 0">{{ $t('decay.since_introduction') }}</div>
<span v-if="duration"> <span v-if="duration">
<span v-if="duration.years > 0">{{ duration.years }} {{ $t('decay.year') }},</span> <span v-if="duration.years > 0">{{ duration.years }} {{ $t('decay.year') }},</span>
<span v-if="duration.months > 0">{{ duration.months }} {{ $t('decay.months') }},</span> <span v-if="duration.months > 0">{{ duration.months }} {{ $t('decay.months') }},</span>
@ -56,11 +53,10 @@
<div>{{ $t('decay.decay') }}</div> <div>{{ $t('decay.decay') }}</div>
</b-col> </b-col>
<b-col cols="6"> <b-col cols="6">
<div v-if="decaytyp === 'new'">- {{ $n(decay.balance, 'decimal') }}</div> <div v-if="decaytyp === 'new'">- {{ $n(decay.decay, 'decimal') }}</div>
<div v-if="decaytyp === 'decayLastTransaction'"> <div v-if="decaytyp === 'decayLastTransaction'">
{{ $n(decay.balance + gddbalance, 'decimal') }} GDD - {{ $n(decay.decay + amount, 'decimal') }} GDD - {{ $n(decay.decay, 'decimal') }} GDD =
{{ $n(decay.balance, 'decimal') }} GDD = <b>{{ $n(amount, 'decimal') }} GDD</b>
<b>{{ $n(gddbalance, 'decimal') }} GDD</b>
</div> </div>
</b-col> </b-col>
</b-row> </b-row>
@ -73,12 +69,12 @@
<!-- Type--> <!-- Type-->
<b-row v-if="decaytyp === 'new'"> <b-row v-if="decaytyp === 'new'">
<b-col cols="6" class="text-right"> <b-col cols="6" class="text-right">
<div v-if="type === 'send'">{{ $t('decay.sent') }}</div> <div v-if="typeId === 'SEND'">{{ $t('decay.sent') }}</div>
<div v-if="type === 'receive'">{{ $t('decay.received') }}</div> <div v-if="typeId === 'RECEIVE'">{{ $t('decay.received') }}</div>
</b-col> </b-col>
<b-col cols="6"> <b-col cols="6">
<div v-if="type === 'send'"> {{ $n(balance, 'decimal') }}</div> <div v-if="typeId === 'SEND'">{{ $n(amount, 'decimal') }}</div>
<div v-if="type === 'receive'">+ {{ $n(balance, 'decimal') }}</div> <div v-if="typeId === 'RECEIVE'">{{ $n(amount, 'decimal') }}</div>
</b-col> </b-col>
</b-row> </b-row>
<!-- Decay--> <!-- Decay-->
@ -87,7 +83,7 @@
<div>{{ $t('decay.decay') }}</div> <div>{{ $t('decay.decay') }}</div>
</b-col> </b-col>
<b-col cols="6"> <b-col cols="6">
<div> {{ $n(decay.balance, 'decimal') }}</div> <div>{{ $n(decay.decay, 'decimal') }}</div>
</b-col> </b-col>
</b-row> </b-row>
<!-- Total--> <!-- Total-->
@ -96,14 +92,14 @@
<div>{{ $t('decay.total') }}</div> <div>{{ $t('decay.total') }}</div>
</b-col> </b-col>
<b-col cols="6"> <b-col cols="6">
<div v-if="type === 'send'"> <div v-if="typeId === 'SEND'">
<b> {{ $n(balance + decay.balance, 'decimal') }}</b> <b>{{ $n(amount + decay.decay, 'decimal') }}</b>
</div> </div>
<div v-if="type === 'receive'"> <div v-if="typeId === 'RECEIVE'">
<b>{{ $n(balance - decay.balance, 'decimal') }}</b> <b>{{ $n(amount - decay.decay, 'decimal') }}</b>
</div> </div>
<div v-if="type === 'creation'"> <div v-if="typeId === 'CREATION'">
<b> {{ $n(balance - decay.balance, 'decimal') }}</b> <b>{{ $n(amount - decay.decay, 'decimal') }}</b>
</div> </div>
</b-col> </b-col>
</b-row> </b-row>
@ -114,21 +110,19 @@
export default { export default {
name: 'DecayInformation', name: 'DecayInformation',
props: { props: {
gddbalance: { type: Number }, amount: { type: String, default: '0' },
balance: { type: Number }, typeId: { type: String, default: '' },
type: { type: String, default: '' },
decay: { decay: {
balance: '', decay: '',
decayDuration: '', start: 0,
decayStart: 0, end: 0,
decayEnd: 0, duration: '',
decayStartBlock: 0,
}, },
decaytyp: { type: String, default: '' }, decaytyp: { type: String, default: '' },
}, },
computed: { computed: {
duration() { duration() {
return this.$moment.duration((this.decay.decayEnd - this.decay.decayStart) * 1000)._data return this.$moment.duration((this.decay.end - this.decay.start) * 1000)._data
}, },
}, },
} }

View File

@ -25,6 +25,7 @@
:transactions="transactions" :transactions="transactions"
:transactionCount="transactionCount" :transactionCount="transactionCount"
:pending="pending" :pending="pending"
:decayStartBlock="decayStartBlock"
@update-balance="updateBalance" @update-balance="updateBalance"
@update-transactions="updateTransactions" @update-transactions="updateTransactions"
></router-view> ></router-view>
@ -60,6 +61,7 @@ export default {
transactionCount: 0, transactionCount: 0,
pending: true, pending: true,
visible: false, visible: false,
decayStartBlock: new Date(),
} }
}, },
methods: { methods: {
@ -92,11 +94,13 @@ export default {
const { const {
data: { transactionList }, data: { transactionList },
} = result } = result
this.GdtBalance = transactionList.gdtSum === null ? null : Number(transactionList.gdtSum) this.GdtBalance =
transactionList.balanceGDT === null ? null : Number(transactionList.balanceGDT)
this.transactions = transactionList.transactions this.transactions = transactionList.transactions
this.balance = Number(transactionList.decay) this.balance = Number(transactionList.balance)
this.bookedBalance = Number(transactionList.balance) // this.bookedBalance = Number(transactionList.balance)
this.transactionCount = transactionList.count this.transactionCount = transactionList.count
this.decayStartBlock = new Date(transactionList.decayStartBlock)
this.pending = false this.pending = false
}) })
.catch((error) => { .catch((error) => {

View File

@ -15,10 +15,10 @@
</b-col> </b-col>
</b-row> </b-row>
<gdd-transaction-list <gdd-transaction-list
:gddbalance="balance"
:transactions="transactions" :transactions="transactions"
:pageSize="5" :pageSize="5"
:timestamp="timestamp" :timestamp="timestamp"
:decayStartBlock="decayStartBlock"
:transaction-count="transactionCount" :transaction-count="transactionCount"
@update-transactions="updateTransactions" @update-transactions="updateTransactions"
/> />
@ -46,6 +46,7 @@ export default {
props: { props: {
balance: { type: Number, default: 0 }, balance: { type: Number, default: 0 },
GdtBalance: { type: Number, default: 0 }, GdtBalance: { type: Number, default: 0 },
decayStartBlock: { type: Date },
transactions: { transactions: {
default: () => [], default: () => [],
}, },

View File

@ -11,33 +11,22 @@
<b-icon icon="exclamation-triangle" class="mr-2" variant="danger"></b-icon> <b-icon icon="exclamation-triangle" class="mr-2" variant="danger"></b-icon>
<small>{{ $t('error.empty-transactionlist') }}</small> <small>{{ $t('error.empty-transactionlist') }}</small>
</div> </div>
<div <div
v-for="{ v-for="{ amount, balanceDate, decay, id, linkedUser, memo, typeId } in transactions"
decay, :key="id"
transactionId, :style="typeId === 'DECAY' ? 'background-color:#f1e0ae3d' : ''"
type,
date,
balance,
name,
memo,
firstTransaction,
decayDuration,
decayEnd,
decayStart,
} in transactions"
:key="transactionId"
:style="type === 'decay' ? 'background-color:#f1e0ae3d' : ''"
> >
<div <div
class="list-group-item gdd-transaction-list-item" class="list-group-item gdd-transaction-list-item"
:class="getCollapseState(transactionId) ? 'bg-secondary' : ''" :class="getCollapseState(id) ? 'bg-secondary' : ''"
v-b-toggle="'decay-' + transactionId" v-b-toggle="'decay-' + id"
> >
<!-- Collaps Button --> <!-- Collaps Button -->
<div class="text-right" style="width: 95%; position: absolute"> <div class="text-right" style="width: 95%; position: absolute">
<b-icon <b-icon
:icon="getCollapseState(transactionId) ? 'caret-up-square' : 'caret-down-square'" :icon="getCollapseState(id) ? 'caret-up-square' : 'caret-down-square'"
:class="getCollapseState(transactionId) ? 'text-black' : 'text-muted'" :class="getCollapseState(id) ? 'text-black' : 'text-muted'"
/> />
</div> </div>
<div> <div>
@ -45,7 +34,7 @@
<!-- ICON --> <!-- ICON -->
<b-col cols="1"> <b-col cols="1">
<div class="gdd-transaction-list-item-icon"> <div class="gdd-transaction-list-item-icon">
<b-icon :icon="getProperties(type).icon" :class="getProperties(type).class" /> <b-icon :icon="getProperties(typeId).icon" :class="getProperties(typeId).class" />
</div> </div>
</b-col> </b-col>
@ -55,22 +44,22 @@
<b-col cols="5"> <b-col cols="5">
<div class="text-right"> <div class="text-right">
<span class="gdd-transaction-list-item-operator"> <span class="gdd-transaction-list-item-operator">
{{ getProperties(type).operator }} {{ getProperties(typeId).operator }}
</span> </span>
<span class="gdd-transaction-list-item-amount"> <span class="gdd-transaction-list-item-amount">
{{ $n(balance, 'decimal') }} {{ $n(amount, 'decimal') }}
</span> </span>
</div> </div>
</b-col> </b-col>
<b-col cols="7"> <b-col cols="7">
<div class="gdd-transaction-list-item-name"> <div class="gdd-transaction-list-item-name">
{{ type !== 'decay' ? name : $t('decay.decay_since_last_transaction') }} {{ typeId !== 'DECAY' ? (linkedUser.firstName + linkedUser.lastName ) : $t('decay.decay_since_last_transaction') }}
</div> </div>
</b-col> </b-col>
</b-row> </b-row>
<!-- Nachricht --> <!-- Nachricht -->
<b-row v-if="type !== 'decay'"> <b-row v-if="typeId !== 'DECAY'">
<b-col cols="5"> <b-col cols="5">
<div class="text-right">{{ $t('form.memo') }}</div> <div class="text-right">{{ $t('form.memo') }}</div>
</b-col> </b-col>
@ -80,22 +69,28 @@
</b-row> </b-row>
<!-- Datum --> <!-- Datum -->
<b-row v-if="type !== 'decay'"> <b-row v-if="typeId !== 'DECAY'">
<b-col cols="5"> <b-col cols="5">
<div class="text-right">{{ $t('form.date') }}</div> <div class="text-right">{{ $t('form.date') }}</div>
</b-col> </b-col>
<b-col cols="7"> <b-col cols="7">
<div class="gdd-transaction-list-item-date"> <div class="gdd-transaction-list-item-date">
{{ $d(new Date(date), 'long') }} {{ $i18n.locale === 'de' ? 'Uhr' : '' }} {{ $d(new Date(balanceDate), 'long') }}
{{ $i18n.locale === 'de' ? 'Uhr' : '' }}
</div> </div>
</b-col> </b-col>
</b-row> </b-row>
<!-- Decay --> <!-- Decay -->
<b-row v-if="decay && !decay.decayStartBlock"> <b-row v-if="decay">
<b-col cols="5"> <b-col cols="5">
<div class="text-right"> <div class="text-right">
<b-icon v-if="type != 'decay'" icon="droplet-half" height="15" class="mb-1" /> <b-icon
v-if="typeId != 'DECAY'"
icon="droplet-half"
height="15"
class="mb-1"
/>
</div> </div>
</b-col> </b-col>
<b-col cols="7"> <b-col cols="7">
@ -104,10 +99,15 @@
</div> </div>
</b-col> </b-col>
</b-row> </b-row>
<b-row v-if="decay && decay.decayStartBlock"> <!-- <b-row v-if="decay && decayStartBlock">
<b-col cols="5"> <b-col cols="5">
<div class="text-right"> <div class="text-right">
<b-icon v-if="type != 'decay'" icon="droplet-half" height="15" class="mb-1" /> <b-icon
v-if="typeId != 'decay'"
icon="droplet-half"
height="15"
class="mb-1"
/>
</div> </div>
</b-col> </b-col>
<b-col cols="7"> <b-col cols="7">
@ -115,48 +115,41 @@
<b>{{ $t('decay.Starting_block_decay') }}</b> <b>{{ $t('decay.Starting_block_decay') }}</b>
</div> </div>
</b-col> </b-col>
</b-row> </b-row> -->
</b-col> </b-col>
</b-row> </b-row>
</div> </div>
<!-- Collaps Start --> <!-- Collaps Start -->
<!-- v-if=" <b-collapse class="pb-4" :id="'decay-' + id">
(type != 'decay' && decay) ||
firstTransaction ||
(!firstTransaction && decay === null)
" -->
<b-collapse class="pb-4" :id="'decay-' + transactionId">
<div class="pt-4 pb-4 bg-white border border-muted"> <div class="pt-4 pb-4 bg-white border border-muted">
<decay-information <decay-information
v-if="decay" v-if="decay.start !== null"
decaytyp="new" decaytyp="new"
:balance="balance" :amount="amount"
:decay="decay" :decay="decay"
:type="type" :typeId="typeId"
/> />
<div v-if="firstTransaction" class="mt-3 mb-3 text-center">
<!-- if decay.start === null - Wenn kein decay angegeben dan ist es die erste Transaktion-->
<div v-if="decay.start === null" class="mt-3 mb-3 text-center">
<b>{{ $t('decay.first_transaction') }}</b> <b>{{ $t('decay.first_transaction') }}</b>
</div> </div>
<!-- if balanceDate < decayStartBlock - Wenn die transaktion vor dem einführen der dacay function liegt. -->
<div <div
v-if="type !== 'decay' && !firstTransaction && decay === null" v-if="new Date(balanceDate).getTime() < new Date(decayStartBlock).getTime()"
class="mt-3 mb-3 text-center" class="mt-3 mb-3 text-center"
> >
<b>{{ $t('decay.befor_startblock_transaction') }}</b> <b>{{ $t('decay.befor_startblock_transaction') }}</b>
</div> </div>
<div v-if="type === 'decay'" class="mt-3 mb-3">
<div v-if="typeId === 'DECAY'" class="mt-3 mb-3">
<decay-information <decay-information
decaytyp="decayLastTransaction" decaytyp="decayLastTransaction"
:gddbalance="gddbalance" :amount="amount"
:balance="balance" :decay="decay"
:decay="{ :typeId="typeId"
balance: balance,
decayStart: parseInt(decayStart),
decayEnd: parseInt(decayEnd),
decayDuration: parseInt(decayDuration),
}"
:type="type"
/> />
</div> </div>
</div> </div>
@ -183,10 +176,10 @@ import PaginationButtons from '../../../components/PaginationButtons'
import DecayInformation from '../../../components/DecayInformation' import DecayInformation from '../../../components/DecayInformation'
const iconsByType = { const iconsByType = {
send: { icon: 'arrow-left-circle', classes: 'text-danger', operator: '' }, SEND: { icon: 'arrow-left-circle', classes: 'text-danger', operator: '' },
receive: { icon: 'arrow-right-circle', classes: 'gradido-global-color-accent', operator: '+' }, RECEIVE: { icon: 'arrow-right-circle', classes: 'gradido-global-color-accent', operator: '+' },
creation: { icon: 'gift', classes: 'gradido-global-color-accent', operator: '+' }, CREATION: { icon: 'gift', classes: 'gradido-global-color-accent', operator: '+' },
decay: { icon: 'droplet-half', classes: 'gradido-global-color-gray', operator: '' }, DECAY: { icon: 'droplet-half', classes: 'gradido-global-color-gray', operator: '' },
} }
export default { export default {
@ -202,7 +195,7 @@ export default {
} }
}, },
props: { props: {
gddbalance: { type: Number }, decayStartBlock: { type: Date },
transactions: { default: () => [] }, transactions: { default: () => [] },
pageSize: { type: Number, default: 25 }, pageSize: { type: Number, default: 25 },
timestamp: { type: Number, default: 0 }, timestamp: { type: Number, default: 0 },
@ -230,8 +223,8 @@ export default {
throwError(msg) { throwError(msg) {
throw new Error(msg) throw new Error(msg)
}, },
getCollapseState(transactionId) { getCollapseState(id) {
return this.collapseStatus.includes('decay-' + transactionId) return this.collapseStatus.includes('decay-' + id)
}, },
}, },
mounted() { mounted() {

View File

@ -5,7 +5,6 @@
<p class="tab-tex">{{ $t('transaction.gdd-text') }}</p> <p class="tab-tex">{{ $t('transaction.gdd-text') }}</p>
<gdd-transaction-list <gdd-transaction-list
:gddbalance="balance"
:timestamp="timestamp" :timestamp="timestamp"
:transactionCount="transactionCount" :transactionCount="transactionCount"
:transactions="transactions" :transactions="transactions"