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
2 changed files with 20 additions and 22 deletions
Showing only changes of commit f691e96e22 - Show all commits

View File

@ -533,6 +533,7 @@
"titleCurrent": "Current Tasks",
"titleDates": "Tasks from {from} until {to}",
"noDates": "Show tasks without dates",
"overdue": "Show overdue tasks",
"fromuntil": "Tasks from {from} until {until}",
"select": "Select a range:",
"today": "Today",

View File

@ -1,17 +1,24 @@
<template>
<div class="is-max-width-desktop show-tasks">
<fancycheckbox
@change="setDate"
class="is-pulled-right"
v-if="!showAll"
v-model="showNulls"
>
{{ $t('task.show.noDates') }}
</fancycheckbox>
<h3 class="mb-2">
{{ pageTitle }}
</h3>
<p v-if="!showAll">
<fancycheckbox
@change="setDate"
v-model="showNulls"
>
{{ $t('task.show.noDates') }}
</fancycheckbox>
<fancycheckbox
@change="setDate"
v-model="showOverdue"
>
{{ $t('task.show.overdue') }}
</fancycheckbox>
{{ showOverdue ? 'true' : 'false'}}
{{ $t('task.show.select') }}
<datepicker-with-range @dateChanged="setDate"/>
</p>
@ -135,8 +142,8 @@ export default {
this.$router.push({
name: this.$route.name,
query: {
from: +new Date(dateFrom),
to: +new Date(dateTo),
from: +new Date(dateFrom ?? this.dateFrom),
to: +new Date(dateTo ?? this.dateTo),
showOverdue: this.showOverdue,
showNulls: this.showNulls,
dpschen marked this conversation as resolved Outdated

Mhh that is a bit annoying that we have to convert to strings here :/
But I also don't have a better idea for now.
Right now this might be still fine, but I remember similar usecases where the conversion from state object to the url representation was quite complex.

We might need to abstract this in the future, so let's keep that in the back of our head =)

Mhh that is a bit annoying that we have to convert to strings here :/ But I also don't have a better idea for now. Right now this might be still fine, but I remember similar usecases where the conversion from state object to the url representation was quite complex. We might need to abstract this in the future, so let's keep that in the back of our head =)
},
@ -150,8 +157,8 @@ export default {
return
}
this.showOverdue = this.$route.query.showOverdue
this.showNulls = this.$route.query.showNulls
this.showOverdue = this.$route.query.showOverdue === 'true'
this.showNulls = this.$route.query.showNulls === 'true'
const params = {
sort_by: ['due_date', 'id'],
@ -166,16 +173,6 @@ export default {
// FIXME: Add button to show / hide overdue
konrad marked this conversation as resolved Outdated

This should be marked as a Hack because it's something that shouldn't happen.
When I tried to change the auth these days I tried to fix this, but got tangled.
We should try to solve this in the future because else we will just add more and more hacks =)

This should be marked as a Hack because it's something that shouldn't happen. When I tried to change the auth these days I tried to fix this, but got tangled. We should try to solve this in the future because else we will just add more and more hacks =)

Done.

Done.
if (!this.showAll) {
if (this.showNulls) {
params.filter_by.push('start_date')
params.filter_value.push(this.dateFrom)
params.filter_comparator.push('greater')
params.filter_by.push('end_date')
params.filter_value.push(this.dateTo)
params.filter_comparator.push('less')
}
params.filter_by.push('due_date')
params.filter_value.push(this.dateTo)
params.filter_comparator.push('less')