fix(kanban): correctly paginate filtered kanban buckets
Resolves https://github.com/go-vikunja/vikunja/issues/314 (cherry picked from commit 1451f6e46f03c30384834ff99e0cbe7f15958536)
This commit is contained in:
parent
89d643b9cf
commit
971f328256
@ -266,15 +266,6 @@ export const useKanbanStore = defineStore('kanban', () => {
|
||||
}
|
||||
}
|
||||
|
||||
function getPaginatedTaskResult(result: IBucket[], bucketId: IBucket['id']): ITask[] {
|
||||
const bucket = result.find(b => b.id === bucketId)
|
||||
if (!bucket) {
|
||||
return []
|
||||
}
|
||||
|
||||
return bucket.tasks
|
||||
}
|
||||
|
||||
async function loadNextTasksForBucket(
|
||||
projectId: IProject['id'],
|
||||
viewId: IProjectView['id'],
|
||||
@ -306,8 +297,7 @@ export const useKanbanStore = defineStore('kanban', () => {
|
||||
|
||||
const taskService = new TaskCollectionService()
|
||||
try {
|
||||
const result = await taskService.getAll({projectId, viewId}, params, page)
|
||||
const tasks = getPaginatedTaskResult(result as unknown as IBucket[], bucketId)
|
||||
const tasks = await taskService.getAll({projectId, viewId}, params, page)
|
||||
addTasksToBucket(tasks, bucketId)
|
||||
setTasksLoadedForBucketPage({bucketId, page})
|
||||
if (taskService.totalPages <= page) {
|
||||
|
@ -137,7 +137,11 @@ func getTaskFilterOptsFromCollection(tf *TaskCollection, projectView *ProjectVie
|
||||
return opts, err
|
||||
}
|
||||
|
||||
func getTaskOrTasksInBuckets(s *xorm.Session, a web.Auth, projects []*Project, view *ProjectView, opts *taskSearchOptions) (tasks interface{}, resultCount int, totalItems int64, err error) {
|
||||
func getTaskOrTasksInBuckets(s *xorm.Session, a web.Auth, projects []*Project, view *ProjectView, opts *taskSearchOptions, filteringForBucket bool) (tasks interface{}, resultCount int, totalItems int64, err error) {
|
||||
if filteringForBucket {
|
||||
return getTasksForProjects(s, projects, a, opts, view)
|
||||
}
|
||||
|
||||
if view != nil && !strings.Contains(opts.filter, "bucket_id") {
|
||||
if view.BucketConfigurationMode != BucketConfigurationModeNone {
|
||||
tasksInBuckets, err := GetTasksInBucketsForView(s, view, projects, opts, a)
|
||||
@ -262,6 +266,7 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa
|
||||
}
|
||||
|
||||
var view *ProjectView
|
||||
var filteringForBucket bool
|
||||
if tf.ProjectViewID != 0 {
|
||||
view, err = GetProjectViewByIDAndProject(s, tf.ProjectViewID, tf.ProjectID)
|
||||
if err != nil {
|
||||
@ -277,6 +282,7 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa
|
||||
}
|
||||
|
||||
if view.BucketConfigurationMode == BucketConfigurationModeFilter && strings.Contains(tf.Filter, "bucket_id") {
|
||||
filteringForBucket = true
|
||||
tf.Filter, err = getFilterValueForBucketFilter(tf.Filter, view)
|
||||
if err != nil {
|
||||
return nil, 0, 0, err
|
||||
@ -318,7 +324,7 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa
|
||||
if err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
return getTaskOrTasksInBuckets(s, a, []*Project{project}, view, opts)
|
||||
return getTaskOrTasksInBuckets(s, a, []*Project{project}, view, opts, filteringForBucket)
|
||||
}
|
||||
|
||||
projects, err := getRelevantProjectsFromCollection(s, a, tf)
|
||||
@ -326,5 +332,5 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
|
||||
return getTaskOrTasksInBuckets(s, a, projects, view, opts)
|
||||
return getTaskOrTasksInBuckets(s, a, projects, view, opts, filteringForBucket)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user