feat(kanban): save done bucket with project instead of bucket

This commit is contained in:
kolaente 2023-09-03 15:51:22 +02:00
parent f6d1db3595
commit 3373b5fc45
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
5 changed files with 15 additions and 10 deletions

View File

@ -8,7 +8,6 @@ export interface IBucket extends IAbstract {
projectId: number
limit: number
tasks: ITask[]
isDoneBucket: boolean
position: number
count: number

View File

@ -19,6 +19,7 @@ export interface IProject extends IAbstract {
position: number
backgroundBlurHash: string
parentProjectId: number
doneBucketId: number
created: Date
updated: Date

View File

@ -12,7 +12,6 @@ export default class BucketModel extends AbstractModel<IBucket> implements IBuck
projectId = ''
limit = 0
tasks: ITask[] = []
isDoneBucket = false
position = 0
count = 0

View File

@ -23,6 +23,7 @@ export default class ProjectModel extends AbstractModel<IProject> implements IPr
position = 0
backgroundBlurHash = ''
parentProjectId = 0
doneBucketId = 0
created: Date = null
updated: Date = null

View File

@ -37,7 +37,7 @@
>
<div class="bucket-header" @click="() => unCollapseBucket(bucket)">
<span
v-if="bucket.isDoneBucket"
v-if="project.doneBucketId === bucket.id"
class="icon is-small has-text-success mr-2"
v-tooltip="$t('project.kanban.doneBucketHint')"
>
@ -98,7 +98,7 @@
@click.stop="toggleDoneBucket(bucket)"
v-tooltip="$t('project.kanban.doneBucketHintExtended')"
>
<span class="icon is-small" :class="{'has-text-success': bucket.isDoneBucket}">
<span class="icon is-small" :class="{'has-text-success': bucket.id === project.doneBucketId}">
<icon icon="check-double"/>
</span>
{{ $t('project.kanban.doneBucket') }}
@ -251,6 +251,7 @@ import {calculateItemPosition} from '@/helpers/calculateItemPosition'
import {isSavedFilter} from '@/services/savedFilter'
import {success} from '@/message'
import {useProjectStore} from '@/stores/projects'
const DRAG_OPTIONS = {
// sortable options
@ -268,6 +269,7 @@ const {t} = useI18n({useScope: 'global'})
const baseStore = useBaseStore()
const kanbanStore = useKanbanStore()
const taskStore = useTaskStore()
const projectStore = useProjectStore()
const taskContainerRefs = ref<{[id: IBucket['id']]: HTMLElement}>({})
@ -422,10 +424,9 @@ async function updateTaskPosition(e) {
)
if (
oldBucket !== undefined && // This shouldn't actually be `undefined`, but let's play it safe.
newBucket.id !== oldBucket.id &&
newBucket.isDoneBucket !== oldBucket.isDoneBucket
newBucket.id !== oldBucket.id
) {
newTask.done = newBucket.isDoneBucket
newTask.done = project.value.doneBucketId === newBucket.id
}
if (
oldBucket !== undefined && // This shouldn't actually be `undefined`, but let's play it safe.
@ -597,9 +598,13 @@ function dragstart(bucket: IBucket) {
}
async function toggleDoneBucket(bucket: IBucket) {
await kanbanStore.updateBucket({
...bucket,
isDoneBucket: !bucket.isDoneBucket,
const doneBucketId = project.value.doneBucketId === bucket.id
? 0
: bucket.id
await projectStore.updateProject({
...project.value,
doneBucketId,
})
success({message: t('project.kanban.doneBucketSavedSuccess')})
}