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/modelTypes/ITask.ts b/src/modelTypes/ITask.ts
index 86bae8c2..6616a680 100644
--- a/src/modelTypes/ITask.ts
+++ b/src/modelTypes/ITask.ts
@@ -31,7 +31,7 @@ export interface ITask extends IAbstract {
parentTaskId: ITask['id']
hexColor: string
percentDone: number
- relatedTasks: Partial>,
+ relatedTasks: Partial>,
attachments: IAttachment[]
identifier: string
index: number
diff --git a/src/models/task.ts b/src/models/task.ts
index 3d1a99bd..641b2bc5 100644
--- a/src/models/task.ts
+++ b/src/models/task.ts
@@ -56,7 +56,7 @@ export default class TaskModel extends AbstractModel implements ITask {
parentTaskId: ITask['id'] = 0
hexColor = ''
percentDone = 0
- relatedTasks: Partial> = {}
+ relatedTasks: Partial> = {}
attachments: IAttachment[] = []
identifier = ''
index = 0
@@ -73,7 +73,7 @@ export default class TaskModel extends AbstractModel implements ITask {
listId: IList['id'] = 0
bucketId: IBucket['id'] = 0
- constructor(data: Partial) {
+ constructor(data: Partial = {}) {
super()
this.assignData(data)
@@ -109,7 +109,7 @@ export default class TaskModel extends AbstractModel implements ITask {
this.hexColor = '#' + this.hexColor
}
- // Make all subtasks to task models
+ // Convert all subtasks to task models
Object.keys(this.relatedTasks).forEach(relationKind => {
this.relatedTasks[relationKind] = this.relatedTasks[relationKind].map(t => {
return new TaskModel(t)
diff --git a/src/models/taskRelation.ts b/src/models/taskRelation.ts
index 0dfdac81..a4df1159 100644
--- a/src/models/taskRelation.ts
+++ b/src/models/taskRelation.ts
@@ -5,15 +5,15 @@ import type {ITaskRelation} from '@/modelTypes/ITaskRelation'
import type {ITask} from '@/modelTypes/ITask'
import type {IUser} from '@/modelTypes/IUser'
-import type {IRelationKind} from '@/types/IRelationKind'
+import {RELATION_KIND, type IRelationKind} from '@/types/IRelationKind'
export default class TaskRelationModel extends AbstractModel implements ITaskRelation {
id = 0
otherTaskId: ITask['id'] = 0
taskId: ITask['id'] = 0
- relationKind: IRelationKind = ''
+ relationKind: IRelationKind = RELATION_KIND.RELATED
- createdBy: IUser = UserModel
- created: Date = null
+ createdBy: IUser = new UserModel()
+ created: Date = new Date
constructor(data: Partial) {
super()
diff --git a/src/models/user.ts b/src/models/user.ts
index a946b4a2..a0148445 100644
--- a/src/models/user.ts
+++ b/src/models/user.ts
@@ -14,7 +14,7 @@ export default class UserModel extends AbstractModel implements IUser {
updated: Date = null
settings: IUserSettings = null
- constructor(data: Partial) {
+ constructor(data: Partial = {}) {
super()
this.assignData(data)
diff --git a/src/router/index.ts b/src/router/index.ts
index 6028c988..2d150edf 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -3,8 +3,6 @@ import type { RouteLocation } from 'vue-router'
import {saveLastVisited} from '@/helpers/saveLastVisited'
import {store} from '@/store'
-import type ListModel from '@/models/list'
-
import {saveListView, getListView} from '@/helpers/saveListView'
import {parseDateOrString} from '@/helpers/time/parseDateOrString'
import {getNextWeekDate} from '@/helpers/time/getNextWeekDate'
@@ -223,7 +221,7 @@ const router = createRouter({
meta: {
showAsModal: true,
},
- props: route => ({ namespaceId: parseInt(route.params.id as string) }),
+ props: route => ({ namespaceId: Number(route.params.id as string) }),
},
{
path: '/namespaces/:namespaceId/settings/share',
@@ -255,7 +253,7 @@ const router = createRouter({
path: '/tasks/:id',
name: 'task.detail',
component: TaskDetailView,
- props: route => ({ taskId: parseInt(route.params.id as string) }),
+ props: route => ({ taskId: Number(route.params.id as string) }),
},
{
path: '/tasks/by/upcoming',
@@ -280,7 +278,7 @@ const router = createRouter({
path: '/lists/:listId/settings/edit',
name: 'list.settings.edit',
component: ListSettingEdit,
- props: route => ({ listId: parseInt(route.params.listId as ListModel['id']) }),
+ props: route => ({ listId: Number(route.params.listId as string) }),
meta: {
showAsModal: true,
},
@@ -372,21 +370,21 @@ const router = createRouter({
name: 'list.list',
component: ListList,
beforeEnter: (to) => saveListView(to.params.listId, to.name),
- props: route => ({ listId: parseInt(route.params.listId as string) }),
+ props: route => ({ listId: Number(route.params.listId as string) }),
},
{
path: '/lists/:listId/gantt',
name: 'list.gantt',
component: ListGantt,
beforeEnter: (to) => saveListView(to.params.listId, to.name),
- props: route => ({ listId: parseInt(route.params.listId as string) }),
+ props: route => ({ listId: Number(route.params.listId as string) }),
},
{
path: '/lists/:listId/table',
name: 'list.table',
component: ListTable,
beforeEnter: (to) => saveListView(to.params.listId, to.name),
- props: route => ({ listId: parseInt(route.params.listId as string) }),
+ props: route => ({ listId: Number(route.params.listId as string) }),
},
{
path: '/lists/:listId/kanban',
@@ -401,7 +399,7 @@ const router = createRouter({
setTitle(listFromStore.title)
}
},
- props: route => ({ listId: parseInt(route.params.listId as string) }),
+ props: route => ({ listId: Number(route.params.listId as string) }),
},
{
path: '/teams',
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/stores/lists.ts b/src/stores/lists.ts
index 2f5193bf..b12923cd 100644
--- a/src/stores/lists.ts
+++ b/src/stores/lists.ts
@@ -153,10 +153,10 @@ export const useListStore = defineStore('list', {
},
})
-export function useList(listId: MaybeRef) {
+export function useList(listId: MaybeRef) {
const listService = shallowReactive(new ListService())
const {loading: isLoading} = toRefs(listService)
- const list : ListModel = reactive(new ListModel({}))
+ const list: ListModel = reactive(new ListModel())
const {t} = useI18n({useScope: 'global'})
watch(
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,