GDD filter

This commit is contained in:
Moriz Wahl 2022-03-08 05:15:58 +01:00 committed by ogerly
parent 690e8a817e
commit 53611ba51e
13 changed files with 25 additions and 40 deletions

View File

@ -13,9 +13,9 @@
</b-col> </b-col>
<b-col cols="6"> <b-col cols="6">
<div> <div>
{{ $n(Number(balance) - Number(decay.decay), 'decimal') }} {{ (Number(balance) - Number(decay.decay)) | GDD }}
GDD {{ $n(Number(decay.decay) * -1, 'decimal') }} GDD = {{ decay.decay | GDD }} =
<b>{{ $n(Number(balance), 'decimal') }} GDD</b> <b>{{ balance | GDD }}</b>
</div> </div>
</b-col> </b-col>
</b-row> </b-row>

View File

@ -21,7 +21,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.decay * -1, 'decimal') }}</div> <div>{{ decay.decay | GDD }}</div>
</b-col> </b-col>
</b-row> </b-row>
<hr class="mt-2 mb-2" /> <hr class="mt-2 mb-2" />
@ -37,8 +37,7 @@
<div v-if="typeId === '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="typeId === 'SEND'"> {{ $n(amount * -1, 'decimal') }}</div> <div>{{ amount | GDD }}</div>
<div v-if="typeId === 'RECEIVE'">{{ $n(amount, 'decimal') }}</div>
</b-col> </b-col>
</b-row> </b-row>
<!-- Decay--> <!-- Decay-->
@ -47,7 +46,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.decay * -1, 'decimal') }}</div> <div>{{ decay.decay | GDD }}</div>
</b-col> </b-col>
</b-row> </b-row>
<!-- Total--> <!-- Total-->
@ -56,15 +55,7 @@
<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="typeId === 'SEND'"> <b>{{ (Number(amount) + Number(decay.decay)) | GDD }}</b>
<b> {{ $n((Number(amount) + Number(decay.decay)) * -1, 'decimal') }}</b>
</div>
<div v-if="typeId === 'RECEIVE'">
<b>{{ $n(Number(amount) + Number(decay.decay), 'decimal') }}</b>
</div>
<div v-if="typeId === 'CREATION'">
<b>{{ $n(Number(amount) + Number(decay.decay), 'decimal') }}</b>
</div>
</b-col> </b-col>
</b-row> </b-row>
</div> </div>

View File

@ -42,7 +42,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.decay * -1, 'decimal') }}</div> <div>{{ decay.decay | GDD }}</div>
</b-col> </b-col>
</b-row> </b-row>
<hr class="mt-2 mb-2" /> <hr class="mt-2 mb-2" />
@ -58,8 +58,7 @@
<div v-if="typeId === '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="typeId === 'SEND'"> {{ $n(amount * -1, 'decimal') }}</div> <div>{{ amount | GDD }}</div>
<div v-if="typeId === 'RECEIVE'">{{ $n(amount, 'decimal') }}</div>
</b-col> </b-col>
</b-row> </b-row>
<!-- Decay--> <!-- Decay-->
@ -68,7 +67,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.decay * -1, 'decimal') }}</div> <div>{{ decay.decay | GDD }}</div>
</b-col> </b-col>
</b-row> </b-row>
<!-- Total--> <!-- Total-->
@ -77,15 +76,7 @@
<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="typeId === 'SEND'"> <b>{{ (Number(amount) + Number(decay.decay)) | GDD }}</b>
<b> {{ $n((Number(amount) + Number(decay.decay)) * -1, 'decimal') }}</b>
</div>
<div v-if="typeId === 'RECEIVE'">
<b>{{ $n(Number(amount) + Number(decay.decay), 'decimal') }}</b>
</div>
<div v-if="typeId === 'CREATION'">
<b>{{ $n(Number(amount) + Number(decay.decay), 'decimal') }}</b>
</div>
</b-col> </b-col>
</b-row> </b-row>
</div> </div>

View File

@ -7,7 +7,6 @@ const mocks = {
$i18n: { $i18n: {
locale: 'en', locale: 'en',
}, },
$n: jest.fn((n) => n),
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
$d: jest.fn((d) => d), $d: jest.fn((d) => d),
} }

View File

@ -23,9 +23,8 @@
<b-row> <b-row>
<b-col cols="5"> <b-col cols="5">
<div class="text-right"> <div class="text-right">
<span class="gdd-transaction-list-item-operator">+</span>
<span class="gdd-transaction-list-item-amount"> <span class="gdd-transaction-list-item-amount">
{{ amount | amount }} {{ amount | GDD }}
</span> </span>
</div> </div>
</b-col> </b-col>

View File

@ -7,7 +7,6 @@ const mocks = {
$i18n: { $i18n: {
locale: 'en', locale: 'en',
}, },
$n: jest.fn((n) => n),
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
$d: jest.fn((d) => d), $d: jest.fn((d) => d),
} }

View File

@ -7,7 +7,6 @@ const mocks = {
$i18n: { $i18n: {
locale: 'en', locale: 'en',
}, },
$n: jest.fn((n) => n),
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
$d: jest.fn((d) => d), $d: jest.fn((d) => d),
} }

View File

@ -26,9 +26,8 @@
<b-row> <b-row>
<b-col cols="5"> <b-col cols="5">
<div class="text-right"> <div class="text-right">
<span class="gdd-transaction-list-item-operator">+</span>
<span class="gdd-transaction-list-item-amount"> <span class="gdd-transaction-list-item-amount">
{{ amount | amount }} {{ amount | GDD }}
</span> </span>
</div> </div>
</b-col> </b-col>

View File

@ -7,7 +7,6 @@ const mocks = {
$i18n: { $i18n: {
locale: 'en', locale: 'en',
}, },
$n: jest.fn((n) => n),
$t: jest.fn((t) => t), $t: jest.fn((t) => t),
$d: jest.fn((d) => d), $d: jest.fn((d) => d),
} }

View File

@ -24,7 +24,7 @@
<b-col cols="5"> <b-col cols="5">
<div class="text-right"> <div class="text-right">
<span class="gdd-transaction-list-item-amount"> <span class="gdd-transaction-list-item-amount">
{{ amount | amount }} {{ amount | GDD }}
</span> </span>
</div> </div>
</b-col> </b-col>
@ -78,7 +78,7 @@
<b-collapse class="pb-4 pt-5" v-model="visible"> <b-collapse class="pb-4 pt-5" v-model="visible">
<decay-information-before-startblock v-if="decay.start === null" /> <decay-information-before-startblock v-if="decay.start === null" />
<decay-information-decay-startblock <decay-information-decay-startblock
v-else-if="true" v-else-if="isStartBlock"
:amount="amount" :amount="amount"
:decay="decay" :decay="decay"
:typeId="typeId" :typeId="typeId"

View File

@ -2,10 +2,17 @@ let i18n
export const loadFilters = (_i18n) => { export const loadFilters = (_i18n) => {
i18n = _i18n i18n = _i18n
return { amount } return { amount, GDD }
} }
const amount = (value) => { const amount = (value) => {
if (!value) return '' if (!value) return ''
return i18n.n(value.toString(), 'decimal').replace('-', ' ') return i18n.n(value.toString(), 'decimal').replace('-', ' ')
} }
const GDD = (value) => {
if (!value) return ''
value = amount(value)
if (!value.match(/^ /)) value = '+ ' + value
return value + ' GDD'
}

View File

@ -23,6 +23,7 @@ Vue.config.productionTip = false
Vue.mixin(toasters) Vue.mixin(toasters)
const filters = loadFilters(i18n) const filters = loadFilters(i18n)
Vue.filter('amount', filters.amount) Vue.filter('amount', filters.amount)
Vue.filter('GDD', filters.GDD)
loadAllRules(i18n) loadAllRules(i18n)

View File

@ -57,6 +57,7 @@ global.localVue.mixin(toasters)
const filters = loadFilters(i18nMock) const filters = loadFilters(i18nMock)
global.localVue.filter('amount', filters.amount) global.localVue.filter('amount', filters.amount)
global.localVue.filter('GDD', filters.GDD)
// Filter the warnings for portal vue // Filter the warnings for portal vue
// https://github.com/BeniRupp/bug_portal-vue-target-already-exists // https://github.com/BeniRupp/bug_portal-vue-target-already-exists