From 710e56925c3e6c61c3d7a2d1e2631aaa645586df Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 25 Jan 2022 14:28:01 +0100 Subject: [PATCH] mixin for creationMonths, refactor CreationFormular --- admin/src/components/CreationFormular.vue | 103 ++++++++-------------- admin/src/mixins/creationMonths.js | 24 +++++ 2 files changed, 62 insertions(+), 65 deletions(-) create mode 100644 admin/src/mixins/creationMonths.js diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 2751eee97..7cec112da 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -3,52 +3,16 @@ {{ $t('creation_form.form') }}
- + - - - - - - - - - - - - - - - + -
@@ -60,7 +24,6 @@ :max="rangeMax" > - {{ $t('creation_form.submit_creation') }} @@ -121,11 +84,12 @@
diff --git a/admin/src/mixins/creationMonths.js b/admin/src/mixins/creationMonths.js new file mode 100644 index 000000000..56dca5c56 --- /dev/null +++ b/admin/src/mixins/creationMonths.js @@ -0,0 +1,24 @@ +export const creationMonths = { + computed: { + creationDates() { + const now = new Date(Date.now()) + const dates = [now] + for (let i = 1; i < 3; i++) { + dates.push(new Date(now.getFullYear(), now.getMonth() - i, 1)) + } + return dates.reverse() + }, + creationDateObjects() { + const result = [] + this.creationDates.forEach((date) => { + result.push({ + short: this.$d(date, 'month'), + long: this.$d(date, 'short'), + year: this.$d(date, 'year'), + date: this.$d(date, 'short', 'en'), + }) + }) + return result + }, + }, +}