From 4837aca0bd2b2c8e8709507fd8039b81e3567af4 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 14:37:49 +0100 Subject: [PATCH] remove moment, localize datetime --- admin/src/pages/Creation.spec.js | 11 +---------- admin/src/pages/Creation.vue | 33 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/admin/src/pages/Creation.spec.js b/admin/src/pages/Creation.spec.js index 01a884f54..3de9ba9e4 100644 --- a/admin/src/pages/Creation.spec.js +++ b/admin/src/pages/Creation.spec.js @@ -32,22 +32,13 @@ const toastErrorMock = jest.fn() const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), $apollo: { query: apolloQueryMock, }, $toasted: { error: toastErrorMock, }, - $moment: jest.fn(() => { - return { - format: jest.fn((m) => m), - subtract: jest.fn(() => { - return { - format: jest.fn((m) => m), - } - }), - } - }), } describe('Creation', () => { diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 0de804288..20bb586c8 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -71,15 +71,9 @@ export default { { key: 'lastName', label: this.$t('lastname') }, { key: 'creation', - // label: this.$t('open_creation') + 'Jan | Feb | März', - label: - this.$moment().subtract(2, 'month').format('MMM') + - ' | ' + - this.$moment().subtract(1, 'month').format('MMM') + - ' | ' + - this.$moment().format('MMM'), + label: this.creationLabel, formatter: (value, key, item) => { - return String(value[0]) + ` | ` + String(value[1]) + ` | ` + String(value[2]) + return value.join(' | ') }, }, { key: 'email', label: this.$t('e_mail') }, @@ -90,15 +84,9 @@ export default { { key: 'lastName', label: this.$t('lastname') }, { key: 'creation', - // label: this.$t('open_creation') + 'Jan | Feb | März', - label: - this.$moment().subtract(2, 'month').format('MMM') + - ' | ' + - this.$moment().subtract(1, 'month').format('MMM') + - ' | ' + - this.$moment().format('MMM'), + label: this.creationLabel, formatter: (value, key, item) => { - return String(value[0]) + ` | ` + String(value[1]) + ` | ` + String(value[2]) + return value.join(' | ') }, }, { key: 'bookmark', label: this.$t('remove') }, @@ -111,6 +99,7 @@ export default { rows: 0, currentPage: 1, perPage: 25, + now: Date.now(), } }, async created() { @@ -166,6 +155,18 @@ export default { this.itemsMassCreation = [] }, }, + computed: { + creationLabel() { + const now = new Date(this.now) + const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1) + const beforeLastMonth = new Date(now.getFullYear(), now.getMonth() - 2, 1) + return [ + this.$d(beforeLastMonth, 'monthShort'), + this.$d(lastMonth, 'monthShort'), + this.$d(now, 'monthShort'), + ].join(' | ') + }, + }, watch: { currentPage() { this.getUsers()