From 53611ba51e94bfc16639e832c07948fd819a2510 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 8 Mar 2022 05:15:58 +0100 Subject: [PATCH] GDD filter --- .../DecayInformation-Decay.vue | 6 +++--- .../DecayInformation-DecayStartblock.vue | 17 ++++------------- .../DecayInformations/DecayInformation-Long.vue | 17 ++++------------- .../Transactions/TransactionCreation.spec.js | 1 - .../Transactions/TransactionCreation.vue | 3 +-- .../Transactions/TransactionDecay.spec.js | 1 - .../Transactions/TransactionReceive.spec.js | 1 - .../Transactions/TransactionReceive.vue | 3 +-- .../Transactions/TransactionSend.spec.js | 1 - .../components/Transactions/TransactionSend.vue | 4 ++-- frontend/src/filters/amount.js | 9 ++++++++- frontend/src/main.js | 1 + frontend/test/testSetup.js | 1 + 13 files changed, 25 insertions(+), 40 deletions(-) diff --git a/frontend/src/components/DecayInformations/DecayInformation-Decay.vue b/frontend/src/components/DecayInformations/DecayInformation-Decay.vue index 0dc00a79a..80d45e242 100644 --- a/frontend/src/components/DecayInformations/DecayInformation-Decay.vue +++ b/frontend/src/components/DecayInformations/DecayInformation-Decay.vue @@ -13,9 +13,9 @@
- {{ $n(Number(balance) - Number(decay.decay), 'decimal') }} - GDD − {{ $n(Number(decay.decay) * -1, 'decimal') }} GDD = - {{ $n(Number(balance), 'decimal') }} GDD + {{ (Number(balance) - Number(decay.decay)) | GDD }} + {{ decay.decay | GDD }} = + {{ balance | GDD }}
diff --git a/frontend/src/components/DecayInformations/DecayInformation-DecayStartblock.vue b/frontend/src/components/DecayInformations/DecayInformation-DecayStartblock.vue index 678fc9f09..cf95cff1b 100644 --- a/frontend/src/components/DecayInformations/DecayInformation-DecayStartblock.vue +++ b/frontend/src/components/DecayInformations/DecayInformation-DecayStartblock.vue @@ -21,7 +21,7 @@
{{ $t('decay.decay') }}
-
− {{ $n(decay.decay * -1, 'decimal') }}
+
{{ decay.decay | GDD }}

@@ -37,8 +37,7 @@
{{ $t('decay.received') }}
-
− {{ $n(amount * -1, 'decimal') }}
-
{{ $n(amount, 'decimal') }}
+
{{ amount | GDD }}
@@ -47,7 +46,7 @@
{{ $t('decay.decay') }}
-
− {{ $n(decay.decay * -1, 'decimal') }}
+
{{ decay.decay | GDD }}
@@ -56,15 +55,7 @@
{{ $t('decay.total') }}
-
- − {{ $n((Number(amount) + Number(decay.decay)) * -1, 'decimal') }} -
-
- {{ $n(Number(amount) + Number(decay.decay), 'decimal') }} -
-
- {{ $n(Number(amount) + Number(decay.decay), 'decimal') }} -
+ {{ (Number(amount) + Number(decay.decay)) | GDD }}
diff --git a/frontend/src/components/DecayInformations/DecayInformation-Long.vue b/frontend/src/components/DecayInformations/DecayInformation-Long.vue index ac53b77b7..7fdf65f04 100644 --- a/frontend/src/components/DecayInformations/DecayInformation-Long.vue +++ b/frontend/src/components/DecayInformations/DecayInformation-Long.vue @@ -42,7 +42,7 @@
{{ $t('decay.decay') }}
-
− {{ $n(decay.decay * -1, 'decimal') }}
+
{{ decay.decay | GDD }}

@@ -58,8 +58,7 @@
{{ $t('decay.received') }}
-
− {{ $n(amount * -1, 'decimal') }}
-
{{ $n(amount, 'decimal') }}
+
{{ amount | GDD }}
@@ -68,7 +67,7 @@
{{ $t('decay.decay') }}
-
− {{ $n(decay.decay * -1, 'decimal') }}
+
{{ decay.decay | GDD }}
@@ -77,15 +76,7 @@
{{ $t('decay.total') }}
-
- − {{ $n((Number(amount) + Number(decay.decay)) * -1, 'decimal') }} -
-
- {{ $n(Number(amount) + Number(decay.decay), 'decimal') }} -
-
- {{ $n(Number(amount) + Number(decay.decay), 'decimal') }} -
+ {{ (Number(amount) + Number(decay.decay)) | GDD }}
diff --git a/frontend/src/components/Transactions/TransactionCreation.spec.js b/frontend/src/components/Transactions/TransactionCreation.spec.js index 62de8a9a2..e1ea9e0b0 100644 --- a/frontend/src/components/Transactions/TransactionCreation.spec.js +++ b/frontend/src/components/Transactions/TransactionCreation.spec.js @@ -7,7 +7,6 @@ const mocks = { $i18n: { locale: 'en', }, - $n: jest.fn((n) => n), $t: jest.fn((t) => t), $d: jest.fn((d) => d), } diff --git a/frontend/src/components/Transactions/TransactionCreation.vue b/frontend/src/components/Transactions/TransactionCreation.vue index f1247b961..70cbc53cd 100644 --- a/frontend/src/components/Transactions/TransactionCreation.vue +++ b/frontend/src/components/Transactions/TransactionCreation.vue @@ -23,9 +23,8 @@
- + - {{ amount | amount }} + {{ amount | GDD }}
diff --git a/frontend/src/components/Transactions/TransactionDecay.spec.js b/frontend/src/components/Transactions/TransactionDecay.spec.js index 7b4b658a4..232e7f85a 100644 --- a/frontend/src/components/Transactions/TransactionDecay.spec.js +++ b/frontend/src/components/Transactions/TransactionDecay.spec.js @@ -7,7 +7,6 @@ const mocks = { $i18n: { locale: 'en', }, - $n: jest.fn((n) => n), $t: jest.fn((t) => t), $d: jest.fn((d) => d), } diff --git a/frontend/src/components/Transactions/TransactionReceive.spec.js b/frontend/src/components/Transactions/TransactionReceive.spec.js index 6643553f8..f5b27cf47 100644 --- a/frontend/src/components/Transactions/TransactionReceive.spec.js +++ b/frontend/src/components/Transactions/TransactionReceive.spec.js @@ -7,7 +7,6 @@ const mocks = { $i18n: { locale: 'en', }, - $n: jest.fn((n) => n), $t: jest.fn((t) => t), $d: jest.fn((d) => d), } diff --git a/frontend/src/components/Transactions/TransactionReceive.vue b/frontend/src/components/Transactions/TransactionReceive.vue index 3ba1f6a31..d12883adc 100644 --- a/frontend/src/components/Transactions/TransactionReceive.vue +++ b/frontend/src/components/Transactions/TransactionReceive.vue @@ -26,9 +26,8 @@
- + - {{ amount | amount }} + {{ amount | GDD }}
diff --git a/frontend/src/components/Transactions/TransactionSend.spec.js b/frontend/src/components/Transactions/TransactionSend.spec.js index 40c93437c..632c0857a 100644 --- a/frontend/src/components/Transactions/TransactionSend.spec.js +++ b/frontend/src/components/Transactions/TransactionSend.spec.js @@ -7,7 +7,6 @@ const mocks = { $i18n: { locale: 'en', }, - $n: jest.fn((n) => n), $t: jest.fn((t) => t), $d: jest.fn((d) => d), } diff --git a/frontend/src/components/Transactions/TransactionSend.vue b/frontend/src/components/Transactions/TransactionSend.vue index 438b8b08c..88028d1f4 100644 --- a/frontend/src/components/Transactions/TransactionSend.vue +++ b/frontend/src/components/Transactions/TransactionSend.vue @@ -24,7 +24,7 @@
- {{ amount | amount }} + {{ amount | GDD }}
@@ -78,7 +78,7 @@ { i18n = _i18n - return { amount } + return { amount, GDD } } const amount = (value) => { if (!value) return '' return i18n.n(value.toString(), 'decimal').replace('-', '− ') } + +const GDD = (value) => { + if (!value) return '' + value = amount(value) + if (!value.match(/^− /)) value = '+ ' + value + return value + ' GDD' +} diff --git a/frontend/src/main.js b/frontend/src/main.js index 85f5cc5ca..585b603cb 100755 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -23,6 +23,7 @@ Vue.config.productionTip = false Vue.mixin(toasters) const filters = loadFilters(i18n) Vue.filter('amount', filters.amount) +Vue.filter('GDD', filters.GDD) loadAllRules(i18n) diff --git a/frontend/test/testSetup.js b/frontend/test/testSetup.js index cec950813..0ceb5affd 100644 --- a/frontend/test/testSetup.js +++ b/frontend/test/testSetup.js @@ -57,6 +57,7 @@ global.localVue.mixin(toasters) const filters = loadFilters(i18nMock) global.localVue.filter('amount', filters.amount) +global.localVue.filter('GDD', filters.GDD) // Filter the warnings for portal vue // https://github.com/BeniRupp/bug_portal-vue-target-already-exists