diff --git a/CHANGELOG.md b/CHANGELOG.md
index a70ec9a6f..8e422025e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,12 @@ Please check our [developers guide](https://gitlab.com/tokend/developers-guide)
for further information about branching and tagging conventions.
## [Unreleased]
+#### Changed
+- Move formatNumber filter to helper
+- Move formatPercent to formatNumber helper
+- Move formatInteger to formatNumber helper
+- Move cropAddress to text helper and rename to abbrCenter
+
### Fixed
- New version of vue: 2.7.14
- New version of vue-template-compiler": 2.7.14
diff --git a/src/i18n/index.js b/src/i18n/index.js
index b41265547..6c913177b 100644
--- a/src/i18n/index.js
+++ b/src/i18n/index.js
@@ -193,18 +193,6 @@ class I18n {
return param.currency
? result.concat(' ', param.currency)
: result
- case 'number':
- return MathUtil
- .format(param, _get(lngConfig, 'number.formats.default'))
- case 'integer':
- return MathUtil
- .format(param, _get(lngConfig, 'number.formats.integer'))
- case 'percent':
- const convertedPercent = MathUtil.multiply(param, 100)
- return MathUtil.format(
- convertedPercent,
- _get(lngConfig, 'number.formats.percent')
- )
default:
console.warn(`Unknown format: ${format}, skipping…`)
return param
diff --git a/src/js/helpers/number-helper.js b/src/js/helpers/number-helper.js
new file mode 100644
index 000000000..930c95784
--- /dev/null
+++ b/src/js/helpers/number-helper.js
@@ -0,0 +1,20 @@
+import { MathUtil } from '@/js/utils'
+
+export function formatNumber (
+ number,
+ decimalPlaces = 0,
+ suffix = 0,
+) {
+ const cfg =
+ ({
+ decimalSeparator: '.',
+ groupSeparator: '',
+ groupSize: 3,
+ suffix,
+ decimalPlaces,
+ })
+ return MathUtil.format(
+ number,
+ cfg,
+ )
+}
diff --git a/src/vue/filters/cropAddress.js b/src/js/helpers/text-helper.js
similarity index 59%
rename from src/vue/filters/cropAddress.js
rename to src/js/helpers/text-helper.js
index 6e4c158bb..823d02cb4 100644
--- a/src/vue/filters/cropAddress.js
+++ b/src/js/helpers/text-helper.js
@@ -1,3 +1,3 @@
-export function cropAddress (value) {
+export function abbrCenter (value) {
return `${value.slice(0, 4)}…${value.slice(-4)}`
}
diff --git a/src/main.js b/src/main.js
index c03325c6b..1ac48fcd9 100644
--- a/src/main.js
+++ b/src/main.js
@@ -19,15 +19,11 @@ import { globalize } from '@/vue/filters/globalize'
import { globalizeCountry } from './vue/filters/globalizeCountry'
import { formatDate } from '@/vue/filters/formatDate'
import { formatMoney } from '@/vue/filters/formatMoney'
-import { formatNumber } from '@/vue/filters/formatNumber'
-import { formatInteger } from '@/vue/filters/formatInteger'
-import { formatPercent } from '@/vue/filters/formatPercent'
import { formatCalendar } from '@/vue/filters/formatCalendar'
import { formatCalendarInline } from '@/vue/filters/formatCalendarInline'
import { formatDateDMY } from '@/vue/filters/formatDateDMY'
import { formatDateDMYT } from '@/vue/filters/formatDateDMYT'
import { abbreviate } from '@/vue/filters/abbreviate'
-import { cropAddress } from '@/vue/filters/cropAddress'
import { ErrorTracker } from '@/js/helpers/error-tracker'
import { vueRoutes } from './vue-router/routes'
import { useBrowserUpdateBanner } from './browser-update'
@@ -59,13 +55,9 @@ async function init () {
Vue.filter('formatDateDMY', formatDateDMY)
Vue.filter('formatDateDMYT', formatDateDMYT)
Vue.filter('formatMoney', formatMoney)
- Vue.filter('formatNumber', formatNumber)
- Vue.filter('formatPercent', formatPercent)
- Vue.filter('formatInteger', formatInteger)
Vue.filter('formatCalendar', formatCalendar)
Vue.filter('formatCalendarInline', formatCalendarInline)
Vue.filter('abbreviate', abbreviate)
- Vue.filter('cropAddress', cropAddress)
Vue.component('i18n', i18nComponent)
Vue.prototype.$config = config
Vue.prototype.$routes = vueRoutes
diff --git a/src/vue/common/EmailGetter.vue b/src/vue/common/EmailGetter.vue
index 1792011ce..5edc73f12 100644
--- a/src/vue/common/EmailGetter.vue
+++ b/src/vue/common/EmailGetter.vue
@@ -20,7 +20,7 @@
- {{ accountId || balanceId | cropAddress }}
+ {{ accountId || abbrCenter(balanceId) }}
@@ -55,12 +55,14 @@ import IdentityGetterMixin from '@/vue/mixins/identity-getter'
import { api } from '@/api'
import { ErrorHandler } from '@/js/helpers/error-handler'
+import { defineComponent } from 'vue'
+import { abbrCenter } from '@/js/helpers/text-helper'
import Clipboard from 'clipboard'
import Tooltip from '@/vue/common/Tooltip'
import safeGet from 'lodash/get'
-export default {
+export default defineComponent({
components: {
Tooltip,
},
@@ -170,7 +172,12 @@ export default {
}, hideTooltipTimeout)
},
},
-}
+ setup () {
+ return {
+ abbrCenter,
+ }
+ },
+})