From 1fdda07f650702b7e3943e0afc7532367ee20100 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Fri, 23 Sep 2022 11:45:52 +0200 Subject: [PATCH 1/2] feat: move tasks to stores --- src/store/index.ts | 2 -- src/{store/modules => stores}/tasks.ts | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) rename src/{store/modules => stores}/tasks.ts (98%) diff --git a/src/store/index.ts b/src/store/index.ts index 6c530b531..40690179d 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -14,7 +14,6 @@ import { QUICK_ACTIONS_ACTIVE, } from './mutation-types' import kanban from './modules/kanban' -import tasks from './modules/tasks' import ListModel from '@/models/list' @@ -35,7 +34,6 @@ export const store = createStore({ strict: import.meta.env.DEV, modules: { kanban, - tasks, }, state: () => ({ loading: false, diff --git a/src/store/modules/tasks.ts b/src/stores/tasks.ts similarity index 98% rename from src/store/modules/tasks.ts rename to src/stores/tasks.ts index 9f7248aa0..5ef453a71 100644 --- a/src/store/modules/tasks.ts +++ b/src/stores/tasks.ts @@ -7,8 +7,8 @@ import TaskAssigneeService from '@/services/taskAssignee' import LabelTaskService from '@/services/labelTask' import UserService from '@/services/user' -import {HAS_TASKS} from '../mutation-types' -import {setLoading} from '../helper' +import {HAS_TASKS} from '../store/mutation-types' +import {setLoading} from '../store/helper' import {getQuickAddMagicMode} from '@/helpers/quickAddMagicMode' import {parseTaskText} from '@/modules/parseTaskText' -- 2.40.1 From 34ffd1d5729341bdede217387a4a4c490d7d60d8 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Fri, 23 Sep 2022 12:55:53 +0200 Subject: [PATCH 2/2] feat: port tasks store to pinia --- .../quick-actions/quick-actions.vue | 4 +- src/components/tasks/add-task.vue | 9 +- src/components/tasks/partials/description.vue | 11 +- .../tasks/partials/editAssignees.vue | 11 +- src/components/tasks/partials/editLabels.vue | 20 +-- src/components/tasks/partials/heading.vue | 8 +- src/components/tasks/partials/kanban-card.vue | 3 +- .../tasks/partials/relatedTasks.vue | 6 +- .../tasks/partials/singleTaskInList.vue | 3 +- src/helpers/attachments.ts | 4 +- src/main.ts | 5 +- src/pinia.ts | 5 + src/store/index.ts | 3 +- src/store/types.ts | 4 +- src/stores/labels.ts | 2 +- src/stores/tasks.ts | 158 ++++++++++-------- src/views/list/ListKanban.vue | 8 +- src/views/list/ListList.vue | 11 +- src/views/tasks/ShowTasks.vue | 4 +- src/views/tasks/TaskDetailView.vue | 6 +- 20 files changed, 157 insertions(+), 128 deletions(-) create mode 100644 src/pinia.ts diff --git a/src/components/quick-actions/quick-actions.vue b/src/components/quick-actions/quick-actions.vue index a71d7b386..a90467a7a 100644 --- a/src/components/quick-actions/quick-actions.vue +++ b/src/components/quick-actions/quick-actions.vue @@ -73,6 +73,7 @@ import {PREFIXES} from '@/modules/parseTaskText' import {useListStore} from '@/stores/lists' import {useNamespaceStore} from '@/stores/namespaces' import {useLabelStore} from '@/stores/labels' +import {useTaskStore} from '@/stores/tasks' const TYPE_LIST = 'list' const TYPE_TASK = 'task' @@ -412,7 +413,8 @@ export default defineComponent({ return } - const task = await this.$store.dispatch('tasks/createNewTask', { + const taskStore = useTaskStore() + const task = await taskStore.createNewTask({ title: this.query, listId: this.currentList.id, }) diff --git a/src/components/tasks/add-task.vue b/src/components/tasks/add-task.vue index d6873a165..2a2953866 100644 --- a/src/components/tasks/add-task.vue +++ b/src/components/tasks/add-task.vue @@ -43,12 +43,11 @@ diff --git a/src/views/tasks/ShowTasks.vue b/src/views/tasks/ShowTasks.vue index ab80110cd..de2acce3c 100644 --- a/src/views/tasks/ShowTasks.vue +++ b/src/views/tasks/ShowTasks.vue @@ -60,9 +60,11 @@ import {LOADING, LOADING_MODULE} from '@/store/mutation-types' import LlamaCool from '@/assets/llama-cool.svg?component' import type {ITask} from '@/modelTypes/ITask' import {useAuthStore} from '@/stores/auth' +import {useTaskStore} from '@/stores/tasks' const store = useStore() const authStore = useAuthStore() +const taskStore = useTaskStore() const route = useRoute() const router = useRouter() const {t} = useI18n({useScope: 'global'}) @@ -180,7 +182,7 @@ async function loadPendingTasks(from: string, to: string) { } } - tasks.value = await store.dispatch('tasks/loadTasks', params) + tasks.value = await taskStore.loadTasks(params) } // FIXME: this modification should happen in the store diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue index ea67956e1..ab61a0774 100644 --- a/src/views/tasks/TaskDetailView.vue +++ b/src/views/tasks/TaskDetailView.vue @@ -464,6 +464,7 @@ import type {IList} from '@/modelTypes/IList' import {colorIsDark} from '@/helpers/color/colorIsDark' import {useNamespaceStore} from '@/stores/namespaces' import {useAttachmentStore} from '@/stores/attachments' +import {useTaskStore} from '@/stores/tasks' function scrollIntoView(el) { if (!el) { @@ -696,7 +697,8 @@ export default defineComponent({ task.endDate = task.dueDate } - this.task = await this.$store.dispatch('tasks/update', task) + + this.task = await useTaskStore().update(task) if (!showNotification) { return @@ -728,7 +730,7 @@ export default defineComponent({ }, async deleteTask() { - await this.$store.dispatch('tasks/delete', this.task) + await useTaskStore().delete(this.task) this.$message.success({message: this.$t('task.detail.deleteSuccess')}) this.$router.push({name: 'list.index', params: {listId: this.task.listId}}) }, -- 2.40.1