From 27cb6e337222c4de6148cf23acce41b1b267d24b Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 16 Mar 2024 15:19:17 +0100 Subject: [PATCH] fix(views): make bucket edit work --- frontend/src/stores/kanban.ts | 13 ------------- frontend/src/views/project/ProjectKanban.vue | 14 +++++++++++++- pkg/models/kanban_rights.go | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/frontend/src/stores/kanban.ts b/frontend/src/stores/kanban.ts index 600150c18..d31dc8c4e 100644 --- a/frontend/src/stores/kanban.ts +++ b/frontend/src/stores/kanban.ts @@ -346,18 +346,6 @@ export const useKanbanStore = defineStore('kanban', () => { } } - async function updateBucketTitle({id, title}: { id: IBucket['id'], title: IBucket['title'] }) { - const bucket = findById(buckets.value, id) - - if (bucket?.title === title) { - // bucket title has not changed - return - } - - await updateBucket({id, title}) - success({message: i18n.global.t('project.kanban.bucketTitleSavedSuccess')}) - } - return { buckets, isLoading: readonly(isLoading), @@ -376,7 +364,6 @@ export const useKanbanStore = defineStore('kanban', () => { createBucket, deleteBucket, updateBucket, - updateBucketTitle, } }) diff --git a/frontend/src/views/project/ProjectKanban.vue b/frontend/src/views/project/ProjectKanban.vue index b041f3ff2..91ea8b6df 100644 --- a/frontend/src/views/project/ProjectKanban.vue +++ b/frontend/src/views/project/ProjectKanban.vue @@ -304,6 +304,7 @@ import type {TaskFilterParams} from '@/services/taskCollection' import type {IProjectView} from '@/modelTypes/IProjectView' import TaskPositionService from '@/services/taskPosition' import TaskPositionModel from '@/models/taskPosition' +import {i18n} from '@/i18n' const { projectId, @@ -615,10 +616,19 @@ async function focusBucketTitle(e: Event) { } async function saveBucketTitle(bucketId: IBucket['id'], bucketTitle: string) { - await kanbanStore.updateBucketTitle({ + + const bucket = kanbanStore.getBucketById(bucketId) + if (bucket?.title === bucketTitle) { + bucketTitleEditable.value = false + return + } + + await kanbanStore.updateBucket({ id: bucketId, title: bucketTitle, + projectId, }) + success({message: i18n.global.t('project.kanban.bucketTitleSavedSuccess')}) bucketTitleEditable.value = false } @@ -638,6 +648,7 @@ function updateBucketPosition(e: { newIndex: number }) { kanbanStore.updateBucket({ id: bucket.id, + projectId, position: calculateItemPosition( bucketBefore !== null ? bucketBefore.position : null, bucketAfter !== null ? bucketAfter.position : null, @@ -652,6 +663,7 @@ async function saveBucketLimit(bucketId: IBucket['id'], limit: number) { await kanbanStore.updateBucket({ ...kanbanStore.getBucketById(bucketId), + projectId, limit, }) success({message: t('project.kanban.bucketLimitSavedSuccess')}) diff --git a/pkg/models/kanban_rights.go b/pkg/models/kanban_rights.go index 55958abb3..9438e7803 100644 --- a/pkg/models/kanban_rights.go +++ b/pkg/models/kanban_rights.go @@ -48,7 +48,7 @@ func (b *Bucket) canDoBucket(s *xorm.Session, a web.Auth) (bool, error) { } pv := &ProjectView{ ID: bb.ProjectViewID, - ProjectID: bb.ProjectID, + ProjectID: b.ProjectID, } return pv.CanUpdate(s, a) }