fix(filters): invalid filter range when converting dates to strings
continuous-integration/drone/push Build is passing Details

Resolves https://community.vikunja.io/t/my-vikunja-instance-creates-tasks-with-due-date-time-of-9am-for-tasks-with-the-word-today-word-in-it/2105/10
This commit is contained in:
kolaente 2024-03-11 23:28:35 +01:00
parent 3f380e0d61
commit 85fb8e3443
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 6 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import TaskModel from '@/models/task'
import type {ITask} from '@/modelTypes/ITask'
export interface TaskFilterParams {
sort_by: ('start_date' | 'done' | 'id' | 'position' | 'kanban_position')[],
sort_by: ('start_date' | 'end_date' | 'due_date' | 'done' | 'id' | 'position' | 'kanban_position')[],
order_by: ('asc' | 'desc')[],
filter: string,
filter_include_nulls: boolean,

View File

@ -173,7 +173,7 @@ function setShowNulls(show: boolean) {
})
}
async function loadPendingTasks(from: string, to: string) {
async function loadPendingTasks(from: Date|string, to: Date|string) {
// FIXME: HACK! This should never happen.
// 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
@ -187,16 +187,18 @@ async function loadPendingTasks(from: string, to: string) {
order_by: ['asc', 'desc'],
filter: 'done = false',
filter_include_nulls: showNulls,
s: '',
}
if (!showAll.value) {
params.filter += ` && due_date < '${to}'`
params.filter += ` && due_date < '${to instanceof Date ? to.toISOString() : to}'`
// 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'.
if (!showOverdue) {
params.filter += ` && due_date > '${from}'`
params.filter += ` && due_date > '${from instanceof Date ? from.toISOString() : from}'`
}
}