From a4c3939fb66a25e4e2b50098283378735f7585b2 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 13 Jul 2022 17:52:42 +0200 Subject: [PATCH] fix: make sure saved filter data is correctly populated when editing a filter Resolves https://kolaente.dev/vikunja/frontend/issues/2114 --- src/components/date/datepickerWithRange.vue | 22 +++++++++++-- src/components/list/partials/filters.vue | 35 ++++++++++++++++----- src/views/filters/FilterEdit.vue | 25 ++++++++------- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/src/components/date/datepickerWithRange.vue b/src/components/date/datepickerWithRange.vue index d4acf6623..00302eac1 100644 --- a/src/components/date/datepickerWithRange.vue +++ b/src/components/date/datepickerWithRange.vue @@ -85,7 +85,12 @@ import DatemathHelp from '@/components/date/datemathHelp.vue' const store = useStore() const {t} = useI18n({useScope: 'global'}) -const emit = defineEmits(['dateChanged']) +const emit = defineEmits(['dateChanged', 'update:modelValue']) +const props = defineProps({ + modelValue: { + required: false, + }, +}) // FIXME: This seems to always contain the default value - that breaks the picker const weekStart = computed(() => store.state.auth.settings.weekStart ?? 0) @@ -108,11 +113,22 @@ const flatpickrRange = ref('') const from = ref('') const to = ref('') +watch( + () => props.modelValue, + newValue => { + from.value = newValue.dateFrom + to.value = newValue.dateTo + flatpickrRange.value = `${from.value} to ${to.value}` + }, +) + function emitChanged() { - emit('dateChanged', { + const args = { dateFrom: from.value === '' ? null : from.value, dateTo: to.value === '' ? null : to.value, - }) + } + emit('dateChanged', args) + emit('update:modelValue', args) } watch( diff --git a/src/components/list/partials/filters.vue b/src/components/list/partials/filters.vue index d63fd6642..d2b92967f 100644 --- a/src/components/list/partials/filters.vue +++ b/src/components/list/partials/filters.vue @@ -67,7 +67,9 @@
- +