feat: add date math for filters #1342

Merged
konrad merged 88 commits from feature/date-math into main 2022-03-28 17:30:43 +00:00
1 changed files with 9 additions and 4 deletions
Showing only changes of commit 4d23fae9ad - Show all commits

View File

@ -27,7 +27,7 @@
{{ $t('input.datepickerRange.from') }}
<div class="field has-addons">
<div class="control is-fullwidth">
<input class="input" type="text" v-model="from" @change="emitChanged"/>
<input class="input" type="text" v-model="from" @change="inputChanged"/>
konrad marked this conversation as resolved Outdated

Instead of calling inputChanged from here better watch the from and below the to value.
This prevents future mistakes

Instead of calling `inputChanged` from here better watch the `from` and below the `to` value. This prevents future mistakes

Changed. I kept inputChanged though because I need to watchers.

Changed. I kept `inputChanged` though because I need to watchers.
</div>
<div class="control">
<x-button icon="calendar" variant="secondary" data-toggle/>
@ -38,7 +38,7 @@
{{ $t('input.datepickerRange.to') }}
<div class="field has-addons">
<div class="control is-fullwidth">
<input class="input" type="text" v-model="to" @change="emitChanged"/>
<input class="input" type="text" v-model="to" @change="inputChanged"/>
</div>
<div class="control">
<x-button icon="calendar" variant="secondary" data-toggle/>
@ -95,6 +95,11 @@ function emitChanged() {
})
}
function inputChanged() {
flatpickrRange.value = ''
emitChanged()
}
watch(
() => flatpickrRange.value,
(newVal: string | null) => {
@ -119,7 +124,7 @@ function setDateRange(range: string[] | null) {
if (range === null) {
from.value = ''
to.value = ''
emitChanged()
inputChanged()
return
}
@ -127,7 +132,7 @@ function setDateRange(range: string[] | null) {
from.value = range[0]
to.value = range[1]
emitChanged()
inputChanged()
}
const dateRanges = {