From 943d5f79757b73f447c51641812e7766edeffe9e Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Thu, 15 Sep 2022 12:52:38 +0200 Subject: [PATCH 1/3] feat: task relatedTasks script setup --- .../tasks/partials/relatedTasks.vue | 427 +++++++++--------- src/modelTypes/ITask.ts | 2 +- src/models/task.ts | 6 +- src/models/taskRelation.ts | 8 +- src/models/user.ts | 2 +- src/router/index.ts | 16 +- src/stores/lists.ts | 4 +- 7 files changed, 239 insertions(+), 226 deletions(-) diff --git a/src/components/tasks/partials/relatedTasks.vue b/src/components/tasks/partials/relatedTasks.vue index 2e717fd9..ca56e4e0 100644 --- a/src/components/tasks/partials/relatedTasks.vue +++ b/src/components/tasks/partials/relatedTasks.vue @@ -25,49 +25,48 @@
- - - \ 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, From 43e2d036d77731fcce18cbea1d82196b10016609 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Wed, 21 Sep 2022 16:27:48 +0200 Subject: [PATCH 3/3] fix: remove console.log --- src/components/tasks/partials/relatedTasks.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/tasks/partials/relatedTasks.vue b/src/components/tasks/partials/relatedTasks.vue index dfff6951..df4ddf17 100644 --- a/src/components/tasks/partials/relatedTasks.vue +++ b/src/components/tasks/partials/relatedTasks.vue @@ -336,7 +336,6 @@ async function removeTaskRelation() { async function createAndRelateTask(title: string) { const newTask = await taskService.create(new TaskModel({title, listId: props.listId})) - console.log('new task created', JSON.parse(JSON.stringify(newTask))) newTaskRelation.task = newTask await addTaskRelation() }