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
This commit is contained in:
parent
66bad4b2b1
commit
ac6c4cf2bc
@ -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 {useRoute} from 'vue-router'
|
||||||
|
|
||||||
import TaskCollectionService from '@/services/taskCollection'
|
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.
|
* This mixin provides a base set of methods and properties to get tasks.
|
||||||
*/
|
*/
|
||||||
export function useTaskList(projectId: ShallowReactive<IProject['id']>, sortByDefault: SortBy = SORT_BY_DEFAULT) {
|
export function useTaskList(projectIdGetter: ComputedGetter<IProject['id']>, sortByDefault: SortBy = SORT_BY_DEFAULT) {
|
||||||
|
|
||||||
|
const projectId = computed(() => projectIdGetter())
|
||||||
|
|
||||||
const params = ref({...getDefaultParams()})
|
const params = ref({...getDefaultParams()})
|
||||||
|
|
||||||
const search = ref('')
|
const search = ref('')
|
||||||
@ -69,8 +72,6 @@ export function useTaskList(projectId: ShallowReactive<IProject['id']>, sortByDe
|
|||||||
|
|
||||||
const sortBy = ref({ ...sortByDefault })
|
const sortBy = ref({ ...sortByDefault })
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const getAllTasksParams = computed(() => {
|
const getAllTasksParams = computed(() => {
|
||||||
let loadParams = {...params.value}
|
let loadParams = {...params.value}
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ export function useTaskList(projectId: ShallowReactive<IProject['id']>, sortByDe
|
|||||||
loadParams = formatSortOrder(sortBy.value, loadParams)
|
loadParams = formatSortOrder(sortBy.value, loadParams)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{projectId: projectId},
|
{projectId: projectId.value},
|
||||||
loadParams,
|
loadParams,
|
||||||
page.value || 1,
|
page.value || 1,
|
||||||
]
|
]
|
||||||
|
@ -168,7 +168,7 @@ const {
|
|||||||
searchTerm,
|
searchTerm,
|
||||||
params,
|
params,
|
||||||
sortByParam,
|
sortByParam,
|
||||||
} = useTaskList(projectId, {position: 'asc' })
|
} = useTaskList(() => projectId, {position: 'asc' })
|
||||||
|
|
||||||
|
|
||||||
const isAlphabeticalSorting = computed(() => {
|
const isAlphabeticalSorting = computed(() => {
|
||||||
|
@ -231,7 +231,7 @@ const SORT_BY_DEFAULT: SortBy = {
|
|||||||
const activeColumns = useStorage('tableViewColumns', {...ACTIVE_COLUMNS_DEFAULT})
|
const activeColumns = useStorage('tableViewColumns', {...ACTIVE_COLUMNS_DEFAULT})
|
||||||
const sortBy = useStorage<SortBy>('tableViewSortBy', {...SORT_BY_DEFAULT})
|
const sortBy = useStorage<SortBy>('tableViewSortBy', {...SORT_BY_DEFAULT})
|
||||||
|
|
||||||
const taskList = useTaskList(projectId, sortBy.value)
|
const taskList = useTaskList(() => projectId, sortBy.value)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
loading,
|
loading,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user