feat: task relatedTasks script setup (#1939)

Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/1939
Reviewed-by: konrad <k@knt.li>
This commit is contained in:
konrad 2022-09-21 18:22:30 +00:00
commit d57e27b4a6
11 changed files with 296 additions and 257 deletions

View file

@ -68,7 +68,6 @@
<script lang="ts"> <script lang="ts">
import {defineComponent, type PropType} from 'vue' import {defineComponent, type PropType} from 'vue'
import {playPop} from '../../../helpers/playPop'
import PriorityLabel from '../../../components/tasks/partials/priorityLabel.vue' import PriorityLabel from '../../../components/tasks/partials/priorityLabel.vue'
import User from '../../../components/misc/user.vue' import User from '../../../components/misc/user.vue'
import Done from '@/components/misc/Done.vue' import Done from '@/components/misc/Done.vue'
@ -126,9 +125,6 @@ export default defineComponent({
...task, ...task,
done, done,
}) })
if (done) {
playPop()
}
} finally { } finally {
this.loadingInternal = false this.loadingInternal = false
} }

View file

@ -25,49 +25,48 @@
</transition> </transition>
</label> </label>
<div class="field" key="field-search"> <div class="field" key="field-search">
<multiselect <Multiselect
:placeholder="$t('task.relation.searchPlaceholder')" :placeholder="$t('task.relation.searchPlaceholder')"
@search="findTasks" @search="findTasks"
:loading="taskService.loading" :loading="taskService.loading"
:search-results="mappedFoundTasks" :search-results="mappedFoundTasks"
label="title" label="title"
v-model="newTaskRelationTask" v-model="newTaskRelation.task"
:creatable="true" :creatable="true"
:create-placeholder="$t('task.relation.createPlaceholder')" :create-placeholder="$t('task.relation.createPlaceholder')"
@create="createAndRelateTask" @create="createAndRelateTask"
@select="addTaskRelation"
> >
<template #searchResult="props"> <template #searchResult="{option: task}">
<span v-if="typeof props.option !== 'string'" class="search-result"> <span v-if="typeof task !== 'string'" class="search-result">
<span <span
class="different-list" class="different-list"
v-if="props.option.listId !== listId" v-if="task.listId !== listId"
> >
<span <span
v-if="props.option.differentNamespace !== null" v-if="task.differentNamespace !== null"
v-tooltip="$t('task.relation.differentNamespace')"> v-tooltip="$t('task.relation.differentNamespace')">
{{ props.option.differentNamespace }} > {{ task.differentNamespace }} >
</span> </span>
<span <span
v-if="props.option.differentList !== null" v-if="task.differentList !== null"
v-tooltip="$t('task.relation.differentList')"> v-tooltip="$t('task.relation.differentList')">
{{ props.option.differentList }} > {{ task.differentList }} >
</span> </span>
</span> </span>
{{ props.option.title }} {{ task.title }}
</span> </span>
<span class="search-result" v-else> <span class="search-result" v-else>
{{ props.option }} {{ task }}
</span> </span>
</template> </template>
</multiselect> </Multiselect>
</div> </div>
<div class="field has-addons mb-4" key="field-kind"> <div class="field has-addons mb-4" key="field-kind">
<div class="control is-expanded"> <div class="control is-expanded">
<div class="select is-fullwidth has-defaults"> <div class="select is-fullwidth has-defaults">
<select v-model="newTaskRelationKind"> <select v-model="newTaskRelation.kind">
<option value="unset">{{ $t('task.relation.select') }}</option> <option value="unset">{{ $t('task.relation.select') }}</option>
<option :key="rk" :value="rk" v-for="rk in relationKinds"> <option :key="`option_${rk}`" :value="rk" v-for="rk in RELATION_KINDS">
{{ $tc(`task.relation.kinds.${rk}`, 1) }} {{ $tc(`task.relation.kinds.${rk}`, 1) }}
</option> </option>
</select> </select>
@ -84,9 +83,16 @@
<span class="title">{{ rts.title }}</span> <span class="title">{{ rts.title }}</span>
<div class="tasks"> <div class="tasks">
<div :key="t.id" class="task" v-for="t in rts.tasks"> <div :key="t.id" class="task" v-for="t in rts.tasks">
<div class="is-flex is-align-items-center">
<Fancycheckbox
class="task-done-checkbox"
v-model="t.done"
@update:model-value="toggleTaskDone(t)"
/>
<router-link <router-link
:to="{ name: $route.name, params: { id: t.id } }" :to="{ name: route.name as string, params: { id: t.id } }"
:class="{ 'is-strikethrough': t.done}"> :class="{ 'is-strikethrough': t.done}"
>
<span <span
class="different-list" class="different-list"
v-if="t.listId !== listId" v-if="t.listId !== listId"
@ -104,9 +110,13 @@
</span> </span>
{{ t.title }} {{ t.title }}
</router-link> </router-link>
</div>
<BaseButton <BaseButton
v-if="editEnabled" v-if="editEnabled"
@click="() => {showDeleteModal = true; relationToDelete = {relationKind: rts.kind, otherTaskId: t.id}}" @click="setRelationToDelete({
relationKind: rts.kind,
otherTaskId: t.id
})"
class="remove" class="remove"
> >
<icon icon="trash-alt"/> <icon icon="trash-alt"/>
@ -118,12 +128,10 @@
{{ $t('task.relation.noneYet') }} {{ $t('task.relation.noneYet') }}
</p> </p>
<!-- Delete modal -->
<transition name="modal">
<modal <modal
@close="showDeleteModal = false" v-if="relationToDelete !== undefined"
@close="relationToDelete = undefined"
@submit="removeTaskRelation()" @submit="removeTaskRelation()"
v-if="showDeleteModal"
> >
<template #header><span>{{ $t('task.relation.delete') }}</span></template> <template #header><span>{{ $t('task.relation.delete') }}</span></template>
@ -134,53 +142,38 @@
</p> </p>
</template> </template>
</modal> </modal>
</transition>
</div> </div>
</template> </template>
<script lang="ts"> <script setup lang="ts">
import {defineComponent} from 'vue' import {ref, reactive, shallowReactive, watch, computed, type PropType} from 'vue'
import {useI18n} from 'vue-i18n'
import {useRoute} from 'vue-router'
import {useStore} from '@/store'
import TaskService from '../../../services/task' import TaskService from '@/services/task'
import TaskModel from '../../../models/task' import TaskModel from '@/models/task'
import TaskRelationService from '../../../services/taskRelation' import type {ITask} from '@/modelTypes/ITask'
import type {ITaskRelation} from '@/modelTypes/ITaskRelation'
import {RELATION_KINDS, RELATION_KIND, type IRelationKind} from '@/types/IRelationKind'
import TaskRelationService from '@/services/taskRelation'
import TaskRelationModel from '@/models/taskRelation' import TaskRelationModel from '@/models/taskRelation'
import { RELATION_KIND, RELATION_KINDS } from '@/types/IRelationKind'
import BaseButton from '@/components/base/BaseButton.vue' import BaseButton from '@/components/base/BaseButton.vue'
import Multiselect from '@/components/input/multiselect.vue' import Multiselect from '@/components/input/multiselect.vue'
import Fancycheckbox from '@/components/input/fancycheckbox.vue'
export default defineComponent({ import {error, success} from '@/message'
name: 'relatedTasks',
data() { const props = defineProps({
return {
relatedTasks: {},
taskService: new TaskService(),
foundTasks: [],
relationKinds: RELATION_KINDS,
newTaskRelationTask: new TaskModel(),
newTaskRelationKind: RELATION_KIND.RELATED,
taskRelationService: new TaskRelationService(),
showDeleteModal: false,
relationToDelete: {},
saved: false,
showNewRelationForm: false,
query: '',
}
},
components: {
BaseButton,
Multiselect,
},
props: {
taskId: { taskId: {
type: Number, type: Number,
required: true, required: true,
}, },
initialRelatedTasks: { initialRelatedTasks: {
type: Object, type: Object as PropType<ITask['relatedTasks']>,
default: () => { default: () => ({}),
},
}, },
showNoRelationsNotice: { showNoRelationsNotice: {
type: Boolean, type: Boolean,
@ -193,129 +186,176 @@ export default defineComponent({
editEnabled: { editEnabled: {
default: true, default: true,
}, },
},
watch: {
initialRelatedTasks: {
handler(value) {
this.relatedTasks = value
},
immediate: true,
},
},
computed: {
showCreate() {
return Object.keys(this.relatedTasks).length === 0 || this.showNewRelationForm
},
namespace() {
return this.$store.getters['namespaces/getListAndNamespaceById'](this.listId, true)?.namespace
},
mappedRelatedTasks() {
return Object.entries(this.relatedTasks).map(([kind, tasks]) => ({
title: this.$tc(`task.relation.kinds.${kind}`, tasks.length),
tasks: this.mapRelatedTasks(tasks),
kind,
}))
},
mappedFoundTasks() {
return this.mapRelatedTasks(this.foundTasks.filter(t => t.id !== this.taskId))
},
},
methods: {
async findTasks(query: string) {
this.query = query
this.foundTasks = await this.taskService.getAll({}, {s: query})
},
async addTaskRelation() {
if (this.newTaskRelationTask.id === 0 && this.query !== '') {
return this.createAndRelateTask(this.query)
}
if (this.newTaskRelationTask.id === 0) {
this.$message.error({message: this.$t('task.relation.taskRequired')})
return
}
const rel = new TaskRelationModel({
taskId: this.taskId,
otherTaskId: this.newTaskRelationTask.id,
relationKind: this.newTaskRelationKind,
}) })
await this.taskRelationService.create(rel)
if (!this.relatedTasks[this.newTaskRelationKind]) {
this.relatedTasks[this.newTaskRelationKind] = []
}
this.relatedTasks[this.newTaskRelationKind].push(this.newTaskRelationTask)
this.newTaskRelationTask = null
this.saved = true
this.showNewRelationForm = false
setTimeout(() => {
this.saved = false
}, 2000)
},
async removeTaskRelation() { const store = useStore()
const rel = new TaskRelationModel({ const route = useRoute()
relationKind: this.relationToDelete.relationKind, const {t} = useI18n({useScope: 'global'})
taskId: this.taskId,
otherTaskId: this.relationToDelete.otherTaskId, type TaskRelation = {kind: IRelationKind, task: ITask}
const taskService = shallowReactive(new TaskService())
const relatedTasks = ref<ITask['relatedTasks']>({})
const newTaskRelation: TaskRelation = reactive({
kind: RELATION_KIND.RELATED,
task: new TaskModel(),
}) })
try {
await this.taskRelationService.delete(rel)
const kind = this.relationToDelete.relationKind watch(
for (const t in this.relatedTasks[kind]) { () => props.initialRelatedTasks,
if (this.relatedTasks[kind][t].id === this.relationToDelete.otherTaskId) { (value) => {
this.relatedTasks[kind].splice(t, 1) relatedTasks.value = value
},
{immediate: true},
)
break const showNewRelationForm = ref(false)
} const showCreate = computed(() => Object.keys(relatedTasks.value).length === 0 || showNewRelationForm.value)
const query = ref('')
const foundTasks = ref<ITask[]>([])
async function findTasks(newQuery: string) {
query.value = newQuery
foundTasks.value = await taskService.getAll({}, {s: newQuery})
} }
this.saved = true const getListAndNamespaceById = (listId: number) => store.getters['namespaces/getListAndNamespaceById'](listId, true)
setTimeout(() => {
this.saved = false
}, 2000)
} finally {
this.showDeleteModal = false
}
},
async createAndRelateTask(title) { const namespace = computed(() => getListAndNamespaceById(props.listId)?.namespace)
const newTask = new TaskModel({title: title, listId: this.listId})
this.newTaskRelationTask = await this.taskService.create(newTask)
await this.addTaskRelation()
},
relationKindTitle(kind, length) { function mapRelatedTasks(tasks: ITask[]) {
return this.$tc(`task.relation.kinds.${kind}`, length) return tasks.map(task => {
},
mapRelatedTasks(tasks) {
return tasks
.map(task => {
// by doing this here once we can save a lot of duplicate calls in the template // by doing this here once we can save a lot of duplicate calls in the template
const listAndNamespace = this.$store.getters['namespaces/getListAndNamespaceById'](task.listId, true)
const { const {
list, list,
namespace, namespace: taskNamespace,
} = listAndNamespace === null ? {list: null, namespace: null} : listAndNamespace } = getListAndNamespaceById(task.listId) || {list: null, namespace: null}
return { return {
...task, ...task,
differentNamespace: differentNamespace:
(namespace !== null && (taskNamespace !== null &&
namespace.id !== this.namespace.id && taskNamespace.id !== namespace.value.id &&
namespace?.title) || null, taskNamespace?.title) || null,
differentList: differentList:
(list !== null && (list !== null &&
task.listId !== this.listId && task.listId !== props.listId &&
list?.title) || null, list?.title) || null,
} }
}) })
}, }
},
const mapRelationKindsTitleGetter = computed(() => ({
'subtask': (count: number) => t('task.relation.kinds.subtask', count),
'parenttask': (count: number) => t('task.relation.kinds.parenttask', count),
'related': (count: number) => t('task.relation.kinds.related', count),
'duplicateof': (count: number) => t('task.relation.kinds.duplicateof', count),
'duplicates': (count: number) => t('task.relation.kinds.duplicates', count),
'blocking': (count: number) => t('task.relation.kinds.blocking', count),
'blocked': (count: number) => t('task.relation.kinds.blocked', count),
'precedes': (count: number) => t('task.relation.kinds.precedes', count),
'follows': (count: number) => t('task.relation.kinds.follows', count),
'copiedfrom': (count: number) => t('task.relation.kinds.copiedfrom', count),
'copiedto': (count: number) => t('task.relation.kinds.copiedto', count),
}))
const mappedRelatedTasks = computed(() => Object.entries(relatedTasks.value).map(
([kind, tasks]) => ({
title: mapRelationKindsTitleGetter.value[kind as IRelationKind](tasks.length),
tasks: mapRelatedTasks(tasks),
kind: kind as IRelationKind,
}),
))
const mappedFoundTasks = computed(() => mapRelatedTasks(foundTasks.value.filter(t => t.id !== props.taskId)))
const taskRelationService = shallowReactive(new TaskRelationService())
const saved = ref(false)
async function addTaskRelation() {
if (newTaskRelation.task.id === 0 && query.value !== '') {
return createAndRelateTask(query.value)
}
if (newTaskRelation.task.id === 0) {
error({message: t('task.relation.taskRequired')})
return
}
await taskRelationService.create(new TaskRelationModel({
taskId: props.taskId,
otherTaskId: newTaskRelation.task.id,
relationKind: newTaskRelation.kind,
}))
relatedTasks.value[newTaskRelation.kind] = [
...(relatedTasks.value[newTaskRelation.kind] || []),
newTaskRelation.task,
]
newTaskRelation.task = new TaskModel()
saved.value = true
showNewRelationForm.value = false
setTimeout(() => {
saved.value = false
}, 2000)
}
const relationToDelete = ref<Partial<ITaskRelation>>()
function setRelationToDelete(relation: Partial<ITaskRelation>) {
relationToDelete.value = relation
}
async function removeTaskRelation() {
const relation = relationToDelete.value
if (!relation || !relation.relationKind || !relation.otherTaskId) {
relationToDelete.value = undefined
return
}
try {
const relationKind = relation.relationKind
await taskRelationService.delete(new TaskRelationModel({
relationKind,
taskId: props.taskId,
otherTaskId: relation.otherTaskId,
}))
relatedTasks.value[relationKind] = relatedTasks.value[relationKind]?.filter(
({id}) => id !== relation.otherTaskId,
)
saved.value = true
setTimeout(() => {
saved.value = false
}, 2000)
} finally {
relationToDelete.value = undefined
}
}
async function createAndRelateTask(title: string) {
const newTask = await taskService.create(new TaskModel({title, listId: props.listId}))
newTaskRelation.task = newTask
await addTaskRelation()
}
async function toggleTaskDone(task: ITask) {
await store.dispatch('tasks/update', task)
// Find the task in the list and update it so that it is correctly strike through
Object.entries(relatedTasks.value).some(([kind, tasks]) => {
return tasks.some((t, key) => {
const found = t.id === task.id
if (found) {
relatedTasks.value[kind as IRelationKind]![key] = task
}
return found
}) })
})
success({message: t('task.detail.updateSuccess')})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -366,15 +406,16 @@ export default defineComponent({
} }
} }
}
.remove { .remove {
text-align: center; text-align: center;
color: var(--danger); color: var(--danger);
opacity: 0; opacity: 0;
transition: opacity $transition; transition: opacity $transition;
} }
}
.related-tasks:hover .tasks .task .remove { .task:hover .remove {
opacity: 1; opacity: 1;
} }
@ -387,5 +428,13 @@ export default defineComponent({
padding: 0.5rem; padding: 0.5rem;
} }
// FIXME: The height of the actual checkbox in the <Fancycheckbox/> component is too much resulting in a
// weired positioning of the checkbox. Setting the height here is a workaround until we fix the styling
// of the component.
.task-done-checkbox {
padding: 0;
height: 18px; // The exact height of the checkbox in the container
}
@include modal-transition(); @include modal-transition();
</style> </style>

View file

@ -114,7 +114,6 @@ import BaseButton from '@/components/base/BaseButton.vue'
import Fancycheckbox from '../../input/fancycheckbox.vue' import Fancycheckbox from '../../input/fancycheckbox.vue'
import DeferTask from './defer-task.vue' import DeferTask from './defer-task.vue'
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside' import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
import {playPop} from '@/helpers/playPop'
import ChecklistSummary from './checklist-summary.vue' import ChecklistSummary from './checklist-summary.vue'
import {formatDateSince, formatISO, formatDateLong} from '@/helpers/time/formatDate' import {formatDateSince, formatISO, formatDateLong} from '@/helpers/time/formatDate'
import ColorBubble from '@/components/misc/colorBubble.vue' import ColorBubble from '@/components/misc/colorBubble.vue'
@ -208,10 +207,7 @@ export default defineComponent({
async markAsDone(checked: boolean) { async markAsDone(checked: boolean) {
const updateFunc = async () => { const updateFunc = async () => {
const task = await this.taskService.update(this.task) const task = await this.$store.dispatch('tasks/update', this.task)
if (this.task.done) {
playPop()
}
this.task = task this.task = task
this.$emit('task-updated', task) this.$emit('task-updated', task)
this.$message.success({ this.$message.success({

View file

@ -31,7 +31,7 @@ export interface ITask extends IAbstract {
parentTaskId: ITask['id'] parentTaskId: ITask['id']
hexColor: string hexColor: string
percentDone: number percentDone: number
relatedTasks: Partial<Record<IRelationKind, ITask>>, relatedTasks: Partial<Record<IRelationKind, ITask[]>>,
attachments: IAttachment[] attachments: IAttachment[]
identifier: string identifier: string
index: number index: number

View file

@ -56,7 +56,7 @@ export default class TaskModel extends AbstractModel<ITask> implements ITask {
parentTaskId: ITask['id'] = 0 parentTaskId: ITask['id'] = 0
hexColor = '' hexColor = ''
percentDone = 0 percentDone = 0
relatedTasks: Partial<Record<IRelationKind, ITask>> = {} relatedTasks: Partial<Record<IRelationKind, ITask[]>> = {}
attachments: IAttachment[] = [] attachments: IAttachment[] = []
identifier = '' identifier = ''
index = 0 index = 0
@ -73,7 +73,7 @@ export default class TaskModel extends AbstractModel<ITask> implements ITask {
listId: IList['id'] = 0 listId: IList['id'] = 0
bucketId: IBucket['id'] = 0 bucketId: IBucket['id'] = 0
constructor(data: Partial<ITask>) { constructor(data: Partial<ITask> = {}) {
super() super()
this.assignData(data) this.assignData(data)
@ -109,7 +109,7 @@ export default class TaskModel extends AbstractModel<ITask> implements ITask {
this.hexColor = '#' + this.hexColor this.hexColor = '#' + this.hexColor
} }
// Make all subtasks to task models // Convert all subtasks to task models
Object.keys(this.relatedTasks).forEach(relationKind => { Object.keys(this.relatedTasks).forEach(relationKind => {
this.relatedTasks[relationKind] = this.relatedTasks[relationKind].map(t => { this.relatedTasks[relationKind] = this.relatedTasks[relationKind].map(t => {
return new TaskModel(t) return new TaskModel(t)

View file

@ -5,15 +5,15 @@ import type {ITaskRelation} from '@/modelTypes/ITaskRelation'
import type {ITask} from '@/modelTypes/ITask' import type {ITask} from '@/modelTypes/ITask'
import type {IUser} from '@/modelTypes/IUser' 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<ITaskRelation> implements ITaskRelation { export default class TaskRelationModel extends AbstractModel<ITaskRelation> implements ITaskRelation {
id = 0 id = 0
otherTaskId: ITask['id'] = 0 otherTaskId: ITask['id'] = 0
taskId: ITask['id'] = 0 taskId: ITask['id'] = 0
relationKind: IRelationKind = '' relationKind: IRelationKind = RELATION_KIND.RELATED
createdBy: IUser = UserModel createdBy: IUser = new UserModel()
created: Date = null created: Date = new Date
constructor(data: Partial<ITaskRelation>) { constructor(data: Partial<ITaskRelation>) {
super() super()

View file

@ -14,7 +14,7 @@ export default class UserModel extends AbstractModel<IUser> implements IUser {
updated: Date = null updated: Date = null
settings: IUserSettings = null settings: IUserSettings = null
constructor(data: Partial<IUser>) { constructor(data: Partial<IUser> = {}) {
super() super()
this.assignData(data) this.assignData(data)

View file

@ -3,8 +3,6 @@ import type { RouteLocation } from 'vue-router'
import {saveLastVisited} from '@/helpers/saveLastVisited' import {saveLastVisited} from '@/helpers/saveLastVisited'
import {store} from '@/store' import {store} from '@/store'
import type ListModel from '@/models/list'
import {saveListView, getListView} from '@/helpers/saveListView' import {saveListView, getListView} from '@/helpers/saveListView'
import {parseDateOrString} from '@/helpers/time/parseDateOrString' import {parseDateOrString} from '@/helpers/time/parseDateOrString'
import {getNextWeekDate} from '@/helpers/time/getNextWeekDate' import {getNextWeekDate} from '@/helpers/time/getNextWeekDate'
@ -223,7 +221,7 @@ const router = createRouter({
meta: { meta: {
showAsModal: true, 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', path: '/namespaces/:namespaceId/settings/share',
@ -255,7 +253,7 @@ const router = createRouter({
path: '/tasks/:id', path: '/tasks/:id',
name: 'task.detail', name: 'task.detail',
component: TaskDetailView, component: TaskDetailView,
props: route => ({ taskId: parseInt(route.params.id as string) }), props: route => ({ taskId: Number(route.params.id as string) }),
}, },
{ {
path: '/tasks/by/upcoming', path: '/tasks/by/upcoming',
@ -280,7 +278,7 @@ const router = createRouter({
path: '/lists/:listId/settings/edit', path: '/lists/:listId/settings/edit',
name: 'list.settings.edit', name: 'list.settings.edit',
component: ListSettingEdit, component: ListSettingEdit,
props: route => ({ listId: parseInt(route.params.listId as ListModel['id']) }), props: route => ({ listId: Number(route.params.listId as string) }),
meta: { meta: {
showAsModal: true, showAsModal: true,
}, },
@ -372,21 +370,21 @@ const router = createRouter({
name: 'list.list', name: 'list.list',
component: ListList, component: ListList,
beforeEnter: (to) => saveListView(to.params.listId, to.name), 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', path: '/lists/:listId/gantt',
name: 'list.gantt', name: 'list.gantt',
component: ListGantt, component: ListGantt,
beforeEnter: (to) => saveListView(to.params.listId, to.name), 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', path: '/lists/:listId/table',
name: 'list.table', name: 'list.table',
component: ListTable, component: ListTable,
beforeEnter: (to) => saveListView(to.params.listId, to.name), 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', path: '/lists/:listId/kanban',
@ -401,7 +399,7 @@ const router = createRouter({
setTitle(listFromStore.title) setTitle(listFromStore.title)
} }
}, },
props: route => ({ listId: parseInt(route.params.listId as string) }), props: route => ({ listId: Number(route.params.listId as string) }),
}, },
{ {
path: '/teams', path: '/teams',

View file

@ -27,6 +27,7 @@ import type { IList } from '@/modelTypes/IList'
import type { RootStoreState, TaskState } from '@/store/types' import type { RootStoreState, TaskState } from '@/store/types'
import {useLabelStore} from '@/stores/labels' import {useLabelStore} from '@/stores/labels'
import {useListStore} from '@/stores/lists' import {useListStore} from '@/stores/lists'
import {playPop} from '@/helpers/playPop'
// IDEA: maybe use a small fuzzy search here to prevent errors // IDEA: maybe use a small fuzzy search here to prevent errors
function findPropertyByValue(object, key, value) { function findPropertyByValue(object, key, value) {
@ -96,6 +97,9 @@ const tasksStore : Module<TaskState, RootStoreState>= {
try { try {
const updatedTask = await taskService.update(task) const updatedTask = await taskService.update(task)
ctx.commit('kanban/setTaskInBucket', updatedTask, {root: true}) ctx.commit('kanban/setTaskInBucket', updatedTask, {root: true})
if (task.done) {
playPop()
}
return updatedTask return updatedTask
} finally { } finally {
cancel() cancel()

View file

@ -153,10 +153,10 @@ export const useListStore = defineStore('list', {
}, },
}) })
export function useList(listId: MaybeRef<ListModel['id']>) { export function useList(listId: MaybeRef<IList['id']>) {
const listService = shallowReactive(new ListService()) const listService = shallowReactive(new ListService())
const {loading: isLoading} = toRefs(listService) const {loading: isLoading} = toRefs(listService)
const list : ListModel = reactive(new ListModel({})) const list: ListModel = reactive(new ListModel())
const {t} = useI18n({useScope: 'global'}) const {t} = useI18n({useScope: 'global'})
watch( watch(

View file

@ -451,7 +451,6 @@ import ColorPicker from '../../components/input/colorPicker.vue'
import heading from '@/components/tasks/partials/heading.vue' import heading from '@/components/tasks/partials/heading.vue'
import Datepicker from '@/components/input/datepicker.vue' import Datepicker from '@/components/input/datepicker.vue'
import BaseButton from '@/components/base/BaseButton.vue' import BaseButton from '@/components/base/BaseButton.vue'
import {playPop} from '@/helpers/playPop'
import TaskSubscription from '@/components/misc/subscription.vue' import TaskSubscription from '@/components/misc/subscription.vue'
import {CURRENT_LIST} from '@/store/mutation-types' import {CURRENT_LIST} from '@/store/mutation-types'
@ -733,9 +732,6 @@ export default defineComponent({
...this.task, ...this.task,
done: !this.task.done, done: !this.task.done,
} }
if (newTask.done) {
playPop()
}
this.saveTask({ this.saveTask({
task: newTask, task: newTask,