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:
parent
c9f47797cf
commit
f1451abebe
@ -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') {
|
||||
|
@ -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)
|
||||
|| []
|
||||
}
|
||||
})
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user