feat: make sure showTasks can handle dynamic dates
This commit is contained in:
parent
6667df5f1f
commit
dabe87af4b
1 changed files with 17 additions and 13 deletions
|
@ -47,6 +47,18 @@ import {LOADING, LOADING_MODULE} from '@/store/mutation-types'
|
||||||
import LlamaCool from '@/assets/llama-cool.svg?component'
|
import LlamaCool from '@/assets/llama-cool.svg?component'
|
||||||
import DatepickerWithRange from '@/components/date/datepickerWithRange'
|
import DatepickerWithRange from '@/components/date/datepickerWithRange'
|
||||||
|
|
||||||
|
function parseDate(query, fallback) {
|
||||||
|
if (typeof query === 'undefined') {
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
const d = new Date(query)
|
||||||
|
|
||||||
|
return !isNaN(d)
|
||||||
|
? d
|
||||||
|
: query
|
||||||
|
}
|
||||||
|
|
||||||
function getNextWeekDate() {
|
function getNextWeekDate() {
|
||||||
return new Date((new Date()).getTime() + 7 * 24 * 60 * 60 * 1000)
|
return new Date((new Date()).getTime() + 7 * 24 * 60 * 60 * 1000)
|
||||||
}
|
}
|
||||||
|
@ -82,18 +94,10 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
dateFrom() {
|
dateFrom() {
|
||||||
const d = new Date(Number(this.$route.query.from))
|
return parseDate(this.$route.query.from, new Date())
|
||||||
|
|
||||||
return !isNaN(d)
|
|
||||||
? d
|
|
||||||
: new Date()
|
|
||||||
},
|
},
|
||||||
dateTo() {
|
dateTo() {
|
||||||
const d = new Date(Number(this.$route.query.to))
|
return parseDate(this.$route.query.to, getNextWeekDate())
|
||||||
|
|
||||||
return !isNaN(d)
|
|
||||||
? d
|
|
||||||
: getNextWeekDate()
|
|
||||||
},
|
},
|
||||||
showNulls() {
|
showNulls() {
|
||||||
return this.$route.query.showNulls === 'true'
|
return this.$route.query.showNulls === 'true'
|
||||||
|
@ -138,8 +142,8 @@ export default {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: this.$route.name,
|
name: this.$route.name,
|
||||||
query: {
|
query: {
|
||||||
from: +new Date(dateFrom ?? this.dateFrom),
|
from: dateFrom ?? this.dateFrom,
|
||||||
to: +new Date(dateTo ?? this.dateTo),
|
to: dateTo ?? this.dateTo,
|
||||||
showOverdue: this.showOverdue,
|
showOverdue: this.showOverdue,
|
||||||
showNulls: this.showNulls,
|
showNulls: this.showNulls,
|
||||||
},
|
},
|
||||||
|
@ -185,7 +189,7 @@ export default {
|
||||||
params.filter_by.push('due_date')
|
params.filter_by.push('due_date')
|
||||||
params.filter_value.push(this.dateTo)
|
params.filter_value.push(this.dateTo)
|
||||||
params.filter_comparator.push('less')
|
params.filter_comparator.push('less')
|
||||||
|
|
||||||
// NOTE: Ideally we could also show tasks with a start or end date in the specified range, but the api
|
// NOTE: Ideally we could also show tasks with a start or end date in the specified range, but the api
|
||||||
// is not capable (yet) of combining multiple filters with 'and' and 'or'.
|
// is not capable (yet) of combining multiple filters with 'and' and 'or'.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue