1
0

feat(filters): pass timezone down when filtering with relative date math

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/8
This commit is contained in:
kolaente
2024-03-11 16:13:42 +01:00
parent 6fc3d1e98f
commit a66e26678e
10 changed files with 65 additions and 19 deletions

View File

@ -9,6 +9,7 @@ import TaskService from '@/services/task'
import TaskModel from '@/models/task'
import {error, success} from '@/message'
import {useAuthStore} from '@/stores/auth'
// FIXME: unify with general `useTaskList`
export function useGanttTaskList<F extends Filters>(
@ -21,12 +22,18 @@ export function useGanttTaskList<F extends Filters>(
}) {
const taskCollectionService = shallowReactive(new TaskCollectionService())
const taskService = shallowReactive(new TaskService())
const authStore = useAuthStore()
const isLoading = computed(() => taskCollectionService.loading)
const tasks = ref<Map<ITask['id'], ITask>>(new Map())
async function fetchTasks(params: TaskFilterParams, page = 1): Promise<ITask[]> {
if(params.filter_timezone === '') {
params.filter_timezone = authStore.settings.timezone
}
const tasks = await taskCollectionService.getAll({projectId: filters.value.projectId}, params, page) as ITask[]
if (options.loadAll && page < taskCollectionService.totalPages) {
const nextTasks = await fetchTasks(params, page + 1)

View File

@ -85,6 +85,7 @@ import type {ITask} from '@/modelTypes/ITask'
import {useAuthStore} from '@/stores/auth'
import {useTaskStore} from '@/stores/tasks'
import {useProjectStore} from '@/stores/projects'
import type {TaskFilterParams} from '@/services/taskCollection'
// Linting disabled because we explicitely enabled destructuring in vite's config, this will work.
// eslint-disable-next-line vue/no-setup-props-destructure
@ -184,6 +185,7 @@ async function loadPendingTasks(from: string, to: string) {
const params = {
sortBy: ['due_date', 'id'],
orderBy: ['asc', 'desc'],
filterTimezone: authStore.settings.timezone,
filterBy: ['done'],
filterValue: ['false'],
filterComparator: ['equals'],