From 8115563d674abae796c3d1084a5af89654b652c2 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 29 Dec 2021 15:44:13 +0100 Subject: [PATCH] feat: add new component for a datepicker with range --- src/components/date/datepickerWithRange.vue | 134 ++++++++++++++++++++ src/views/tasks/ShowTasks.vue | 18 ++- 2 files changed, 142 insertions(+), 10 deletions(-) create mode 100644 src/components/date/datepickerWithRange.vue diff --git a/src/components/date/datepickerWithRange.vue b/src/components/date/datepickerWithRange.vue new file mode 100644 index 000000000..1a4063406 --- /dev/null +++ b/src/components/date/datepickerWithRange.vue @@ -0,0 +1,134 @@ + + + + + diff --git a/src/views/tasks/ShowTasks.vue b/src/views/tasks/ShowTasks.vue index 89a7a182a..6328ab0c6 100644 --- a/src/views/tasks/ShowTasks.vue +++ b/src/views/tasks/ShowTasks.vue @@ -12,7 +12,7 @@ {{ pageTitle }} -

+

{{ $t('task.show.select') }} +

@@ -62,6 +63,7 @@ import Fancycheckbox from '@/components/input/fancycheckbox' import {LOADING, LOADING_MODULE} from '@/store/mutation-types' import LlamaCool from '@/assets/llama-cool.svg?component' +import DatepickerWithRange from '@/components/date/datepickerWithRange' function formatDate(date) { return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}` @@ -70,6 +72,7 @@ function formatDate(date) { export default { name: 'ShowTasks', components: { + DatepickerWithRange, Fancycheckbox, SingleTaskInList, flatPickr, @@ -81,6 +84,7 @@ export default { showNulls: true, showOverdue: false, + // TODO: Set the date range based on the default (to make sure it shows up in the picker) -> maybe also use a computed which depends on dateFrom and dateTo? dateRange: null, showNothingToDo: false, @@ -150,18 +154,12 @@ export default { }), }, methods: { - setDate() { - if (this.dateRange === null) { - return - } - - const [fromDate, toDate] = this.dateRange.split(' to ') - + setDate({dateFrom, dateTo}) { this.$router.push({ name: this.$route.name, query: { - from: +new Date(fromDate), - to: +new Date(toDate), + from: +new Date(dateFrom), + to: +new Date(dateTo), showOverdue: this.showOverdue, showNulls: this.showNulls, },