1
0

fix(home): explicitly use filter for tasks on home page when one is set

Resolves https://github.com/go-vikunja/vikunja/issues/289
Resolves https://community.vikunja.io/t/various-sorting-filtering-issues/2781/5

(cherry picked from commit 97e030a1fc032c73ca6144139a488c18979fb310)
This commit is contained in:
kolaente 2024-09-12 15:51:04 +02:00
parent c9f47797cf
commit f1451abebe
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
3 changed files with 16 additions and 5 deletions

View File

@ -31,9 +31,17 @@ export default class TaskCollectionService extends AbstractService<ITask> {
constructor() {
super({
getAll: '/projects/{projectId}/views/{viewId}/tasks',
// /projects/{projectId}/tasks when viewId is not provided
})
}
getReplacedRoute(path: string, pathparams: Record<string, unknown>): string {
if (!pathparams.viewId) {
return super.getReplacedRoute('/projects/{projectId}/tasks', pathparams)
}
return super.getReplacedRoute(path, pathparams)
}
modelFactory(data) {
// FIXME: There must be a better way for this…
if (typeof data.project_view_id !== 'undefined') {

View File

@ -66,7 +66,7 @@ export const useProjectStore = defineStore('project', () => {
return search(query)
?.filter(value => value > 0)
.map(id => projects.value[id])
.filter(project => project.isArchived === includeArchived)
.filter(project => project?.isArchived === includeArchived)
|| []
}
})
@ -76,7 +76,7 @@ export const useProjectStore = defineStore('project', () => {
return search(query)
?.filter(value => getSavedFilterIdFromProjectId(value) > 0)
.map(id => projects.value[id])
.filter(project => project.isArchived === includeArchived)
.filter(project => project?.isArchived === includeArchived)
|| []
}
})

View File

@ -86,6 +86,7 @@ import {useAuthStore} from '@/stores/auth'
import {useTaskStore} from '@/stores/tasks'
import {useProjectStore} from '@/stores/projects'
import type {TaskFilterParams} from '@/services/taskCollection'
import TaskCollectionService from '@/services/taskCollection'
const props = withDefaults(defineProps<{
dateFrom?: Date | string,
@ -105,6 +106,7 @@ const {t} = useI18n({useScope: 'global'})
const tasks = ref<ITask[]>([])
const showNothingToDo = ref<boolean>(false)
const taskCollectionService = ref(new TaskCollectionService())
const projectStore = useProjectStore()
@ -131,7 +133,7 @@ const pageTitle = computed(() => {
})
const hasTasks = computed(() => tasks.value && tasks.value.length > 0)
const userAuthenticated = computed(() => authStore.authenticated)
const loading = computed(() => taskStore.isLoading)
const loading = computed(() => taskStore.isLoading || taskCollectionService.value.loading)
interface dateStrings {
dateFrom: string,
@ -199,8 +201,9 @@ async function loadPendingTasks(from: Date|string, to: Date|string) {
}
}
if (showAll.value && authStore.settings.frontendSettings.filterIdUsedOnOverview && typeof projectStore.projects[authStore.settings.frontendSettings.filterIdUsedOnOverview] !== 'undefined') {
tasks.value = await taskStore.loadTasks(params, authStore.settings.frontendSettings.filterIdUsedOnOverview)
const filterId = authStore.settings.frontendSettings.filterIdUsedOnOverview
if (showAll.value && filterId && typeof projectStore.projects[filterId] !== 'undefined') {
tasks.value = await taskCollectionService.value.getAll({projectId: filterId}, params)
return
}