From ac6c4cf2bc7b083fd7c69d6e60062ef8cef2e1ec Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 28 Jun 2023 14:38:10 +0200 Subject: [PATCH] fix(project): make sure the correct tasks are loaded when switching between projects Resolves https://community.vikunja.io/t/filter-table-view-not-sorting/1416/3 --- src/composables/useTaskList.ts | 11 ++++++----- src/views/project/ProjectList.vue | 2 +- src/views/project/ProjectTable.vue | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/composables/useTaskList.ts b/src/composables/useTaskList.ts index 92d7a9ced..ed23b5d65 100644 --- a/src/composables/useTaskList.ts +++ b/src/composables/useTaskList.ts @@ -1,4 +1,4 @@ -import {ref, shallowReactive, watch, computed, type ShallowReactive} from 'vue' +import {ref, shallowReactive, watch, computed, type ComputedGetter} from 'vue' import {useRoute} from 'vue-router' import TaskCollectionService from '@/services/taskCollection' @@ -61,7 +61,10 @@ const SORT_BY_DEFAULT: SortBy = { /** * This mixin provides a base set of methods and properties to get tasks. */ -export function useTaskList(projectId: ShallowReactive, sortByDefault: SortBy = SORT_BY_DEFAULT) { +export function useTaskList(projectIdGetter: ComputedGetter, sortByDefault: SortBy = SORT_BY_DEFAULT) { + + const projectId = computed(() => projectIdGetter()) + const params = ref({...getDefaultParams()}) const search = ref('') @@ -69,8 +72,6 @@ export function useTaskList(projectId: ShallowReactive, sortByDe const sortBy = ref({ ...sortByDefault }) - - const getAllTasksParams = computed(() => { let loadParams = {...params.value} @@ -81,7 +82,7 @@ export function useTaskList(projectId: ShallowReactive, sortByDe loadParams = formatSortOrder(sortBy.value, loadParams) return [ - {projectId: projectId}, + {projectId: projectId.value}, loadParams, page.value || 1, ] diff --git a/src/views/project/ProjectList.vue b/src/views/project/ProjectList.vue index 95c59a52c..e8354ae94 100644 --- a/src/views/project/ProjectList.vue +++ b/src/views/project/ProjectList.vue @@ -168,7 +168,7 @@ const { searchTerm, params, sortByParam, -} = useTaskList(projectId, {position: 'asc' }) +} = useTaskList(() => projectId, {position: 'asc' }) const isAlphabeticalSorting = computed(() => { diff --git a/src/views/project/ProjectTable.vue b/src/views/project/ProjectTable.vue index 529be947c..9ef40db05 100644 --- a/src/views/project/ProjectTable.vue +++ b/src/views/project/ProjectTable.vue @@ -231,7 +231,7 @@ const SORT_BY_DEFAULT: SortBy = { const activeColumns = useStorage('tableViewColumns', {...ACTIVE_COLUMNS_DEFAULT}) const sortBy = useStorage('tableViewSortBy', {...SORT_BY_DEFAULT}) -const taskList = useTaskList(projectId, sortBy.value) +const taskList = useTaskList(() => projectId, sortBy.value) const { loading,