From ce0f58c7833bbb37974709112cdedad88ae07cc8 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 7 Sep 2022 17:47:07 +0200 Subject: [PATCH] feat: allow marking a related task done directly from the list --- src/components/tasks/partials/kanban-card.vue | 4 -- .../tasks/partials/relatedTasks.vue | 71 ++++++++++++++----- .../tasks/partials/singleTaskInList.vue | 6 +- src/store/modules/tasks.ts | 8 ++- src/views/tasks/TaskDetailView.vue | 4 -- 5 files changed, 60 insertions(+), 33 deletions(-) diff --git a/src/components/tasks/partials/kanban-card.vue b/src/components/tasks/partials/kanban-card.vue index 4ab004d1..68b0b480 100644 --- a/src/components/tasks/partials/kanban-card.vue +++ b/src/components/tasks/partials/kanban-card.vue @@ -68,7 +68,6 @@ \ No newline at end of file diff --git a/src/components/tasks/partials/singleTaskInList.vue b/src/components/tasks/partials/singleTaskInList.vue index 47f00a64..cfe3085d 100644 --- a/src/components/tasks/partials/singleTaskInList.vue +++ b/src/components/tasks/partials/singleTaskInList.vue @@ -114,7 +114,6 @@ import BaseButton from '@/components/base/BaseButton.vue' import Fancycheckbox from '../../input/fancycheckbox.vue' import DeferTask from './defer-task.vue' import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside' -import {playPop} from '@/helpers/playPop' import ChecklistSummary from './checklist-summary.vue' import {formatDateSince, formatISO, formatDateLong} from '@/helpers/time/formatDate' import ColorBubble from '@/components/misc/colorBubble.vue' @@ -208,10 +207,7 @@ export default defineComponent({ async markAsDone(checked: boolean) { const updateFunc = async () => { - const task = await this.taskService.update(this.task) - if (this.task.done) { - playPop() - } + const task = await this.$store.dispatch('tasks/update', this.task) this.task = task this.$emit('task-updated', task) this.$message.success({ diff --git a/src/store/modules/tasks.ts b/src/store/modules/tasks.ts index 5849bd7a..d18e218e 100644 --- a/src/store/modules/tasks.ts +++ b/src/store/modules/tasks.ts @@ -25,8 +25,9 @@ import type { IAttachment } from '@/modelTypes/IAttachment' import type { IList } from '@/modelTypes/IList' import type { RootStoreState, TaskState } from '@/store/types' -import { useLabelStore } from '@/stores/labels' -import { useListStore } from '@/stores/lists' +import {useLabelStore} from '@/stores/labels' +import {useListStore} from '@/stores/lists' +import {playPop} from '@/helpers/playPop' // IDEA: maybe use a small fuzzy search here to prevent errors function findPropertyByValue(object, key, value) { @@ -96,6 +97,9 @@ const tasksStore : Module= { try { const updatedTask = await taskService.update(task) ctx.commit('kanban/setTaskInBucket', updatedTask, {root: true}) + if (task.done) { + playPop() + } return updatedTask } finally { cancel() diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue index b75e7325..3ed00565 100644 --- a/src/views/tasks/TaskDetailView.vue +++ b/src/views/tasks/TaskDetailView.vue @@ -451,7 +451,6 @@ import ColorPicker from '../../components/input/colorPicker.vue' import heading from '@/components/tasks/partials/heading.vue' import Datepicker from '@/components/input/datepicker.vue' import BaseButton from '@/components/base/BaseButton.vue' -import {playPop} from '@/helpers/playPop' import TaskSubscription from '@/components/misc/subscription.vue' import {CURRENT_LIST} from '@/store/mutation-types' @@ -733,9 +732,6 @@ export default defineComponent({ ...this.task, done: !this.task.done, } - if (newTask.done) { - playPop() - } this.saveTask({ task: newTask,