From 3b48adad675b0b20dc91a08f8ebbfe1dd1c3806b Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 20 Jul 2022 18:44:17 +0200 Subject: [PATCH] feat: dynamically set default date --- src/components/tasks/gantt-chart.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/tasks/gantt-chart.vue b/src/components/tasks/gantt-chart.vue index 2a548350c..071d5f1b7 100644 --- a/src/components/tasks/gantt-chart.vue +++ b/src/components/tasks/gantt-chart.vue @@ -48,12 +48,12 @@ const props = defineProps({ const tasks = ref([]) const ganttBars = ref([]) +const defaultStartDate = format(new Date(), dateFormat) +const defaultEndDate = format(new Date((new Date()).setDate((new Date()).getDate() + 7)), dateFormat) + // We need a "real" ref object for the gantt bars to instantly update the tasks when they are dragged on the chart. // A computed won't work directly. function mapGanttBars() { - const defaultStartDate = format(new Date(), dateFormat) - const defaultEndDate = format(new Date((new Date()).setDate((new Date()).getDate() + 7)), dateFormat) - tasks.value.forEach(t => ganttBars.value.push([{ startDate: t.startDate ? format(t.startDate, dateFormat) : defaultStartDate, endDate: t.endDate ? format(t.endDate, dateFormat) : defaultEndDate,