From 6d62ca1adaf4be5f94dac1a3840834e881b30aa3 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Tue, 7 Dec 2021 19:40:50 +0100 Subject: [PATCH] fix: check now just once --- src/views/list/ListGantt.vue | 17 +++++++++++------ src/views/tasks/ShowTasks.vue | 16 +++++++++------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/views/list/ListGantt.vue b/src/views/list/ListGantt.vue index f5278a34..15b11747 100644 --- a/src/views/list/ListGantt.vue +++ b/src/views/list/ListGantt.vue @@ -68,21 +68,26 @@ import { ref, computed } from 'vue' import flatPickr from 'vue-flatpickr-component' -import { i18n } from '@/i18n' -import { store } from '@/store' +import { useI18n } from 'vue-i18n' +import { useStore } from 'vuex' import ListWrapper from './ListWrapper' import GanttChart from '@/components/tasks/gantt-component' import Fancycheckbox from '@/components/input/fancycheckbox' +const DEFAULT_DAY_COUNT = 35 + const showTaskswithoutDates = ref(false) -const dayWidth = ref(35) -const dateFrom = ref(new Date((new Date()).setDate((new Date()).getDate() - 15))) -const dateTo = ref(new Date((new Date()).setDate((new Date()).getDate() + 30))) +const dayWidth = ref(DEFAULT_DAY_COUNT) +const now = ref(new Date()) +const dateFrom = ref(new Date((new Date()).setDate(now.value.getDate() - 15))) +const dateTo = ref(new Date((new Date()).setDate(now.value.getDate() + 30))) +const {t} = useI18n() +const {store} = useStore() const flatPickerConfig = computed(() => ({ - altFormat: i18n.global.t('date.altFormatShort'), + altFormat: t('date.altFormatShort'), altInput: true, dateFormat: 'Y-m-d', enableTime: false, diff --git a/src/views/tasks/ShowTasks.vue b/src/views/tasks/ShowTasks.vue index d4f06ba3..9b139984 100644 --- a/src/views/tasks/ShowTasks.vue +++ b/src/views/tasks/ShowTasks.vue @@ -231,23 +231,25 @@ export default { }, setDatesToNextWeek() { - this.cStartDate = new Date() - this.cEndDate = new Date((new Date()).getTime() + 7 * 24 * 60 * 60 * 1000) + const now = new Date() + this.cStartDate = now + this.cEndDate = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000) this.showOverdue = false this.setDate() }, setDatesToNextMonth() { - this.cStartDate = new Date() - this.cEndDate = new Date((new Date()).setMonth((new Date()).getMonth() + 1)) + const now = new Date() + this.cStartDate = now + this.cEndDate = new Date((new Date()).setMonth(now.getMonth() + 1)) this.showOverdue = false this.setDate() }, showTodaysTasks() { - const d = new Date() - this.cStartDate = new Date() - this.cEndDate = new Date(d.setDate(d.getDate() + 1)) + const now = new Date() + this.cStartDate = now + this.cEndDate = new Date((new Date()).setDate(now.getDate() + 1)) this.showOverdue = true this.setDate() },