feat: add date math for filters #1342
|
@ -4,21 +4,12 @@
|
|||
{{ pageTitle }}
|
||||
</h3>
|
||||
<p v-if="!showAll">
|
||||
<fancycheckbox
|
||||
@change="setDate"
|
||||
v-model="showNulls"
|
||||
>
|
||||
<fancycheckbox @change="setShowNulls">
|
||||
{{ $t('task.show.noDates') }}
|
||||
</fancycheckbox>
|
||||
<fancycheckbox
|
||||
@change="setDate"
|
||||
v-model="showOverdue"
|
||||
>
|
||||
<fancycheckbox @change="setShowOverdue">
|
||||
{{ $t('task.show.overdue') }}
|
||||
</fancycheckbox>
|
||||
|
||||
{{ showOverdue ? 'true' : 'false'}}
|
||||
|
||||
{{ $t('task.show.select') }}
|
||||
<datepicker-with-range @dateChanged="setDate"/>
|
||||
</p>
|
||||
|
@ -66,12 +57,6 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
tasks: [],
|
||||
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,
|
||||
}
|
||||
},
|
||||
|
@ -108,6 +93,12 @@ export default {
|
|||
? d
|
||||
: this.endDate
|
||||
},
|
||||
showNulls() {
|
||||
return this.$route.query.showNulls === 'true'
|
||||
konrad marked this conversation as resolved
Outdated
|
||||
},
|
||||
konrad marked this conversation as resolved
Outdated
dpschen
commented
Remove title var and return directly:
Remove title var and return directly:
```js
if (typeof predefinedRange !== 'undefined') {
return t(`input.datepickerRange.ranges.${predefinedRangeKey}`)
} else {
return showAll
? t('task.show.titleCurrent')
: t('task.show.fromuntil', {
from: formatDate(dateFrom, 'PPP'),
until: formatDate(dateTo, 'PPP'),
})
}
konrad
commented
Done. Done.
|
||||
showOverdue() {
|
||||
return this.$route.query.showOverdue === 'true'
|
||||
},
|
||||
pageTitle() {
|
||||
const title = this.showAll
|
||||
? this.$t('task.show.titleCurrent')
|
||||
|
@ -149,6 +140,24 @@ export default {
|
|||
},
|
||||
})
|
||||
},
|
||||
setShowOverdue(show) {
|
||||
this.$router.push({
|
||||
name: this.$route.name,
|
||||
query: {
|
||||
...this.$route.query,
|
||||
showOverdue: show,
|
||||
dpschen marked this conversation as resolved
Outdated
dpschen
commented
Mhh that is a bit annoying that we have to convert to strings here :/ 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 =)
|
||||
},
|
||||
})
|
||||
},
|
||||
setShowNulls(show) {
|
||||
this.$router.push({
|
||||
name: this.$route.name,
|
||||
query: {
|
||||
...this.$route.query,
|
||||
showNulls: show,
|
||||
},
|
||||
})
|
||||
},
|
||||
async loadPendingTasks() {
|
||||
// Since this route is authentication only, users would get an error message if they access the page unauthenticated.
|
||||
// Since this component is mounted as the home page before unauthenticated users get redirected
|
||||
|
@ -157,9 +166,6 @@ export default {
|
|||
return
|
||||
}
|
||||
|
||||
this.showOverdue = this.$route.query.showOverdue === 'true'
|
||||
this.showNulls = this.$route.query.showNulls === 'true'
|
||||
|
||||
const params = {
|
||||
sort_by: ['due_date', 'id'],
|
||||
order_by: ['desc', 'desc'],
|
||||
|
|
Reference in New Issue
Unsure: I think eslint doesn't complain here if you use underscore (
_
) to spread the unused variable.Add
?.[0]
so we return the key, which is what we actually want to use and adjust variable name.Nope, does not seem to have an effect.
Done.
Interesting!