feat(list view): show subtasks nested
Resolves https://kolaente.dev/vikunja/frontend/issues/363
This commit is contained in:
parent
842e2c2811
commit
e41712647d
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
<div
|
<div
|
||||||
:class="{'is-loading': taskService.loading}"
|
:class="{'is-loading': taskService.loading}"
|
||||||
class="task loader-container"
|
class="task loader-container"
|
||||||
@ -39,14 +40,6 @@
|
|||||||
|
|
||||||
<priority-label :priority="task.priority" :done="task.done"/>
|
<priority-label :priority="task.priority" :done="task.done"/>
|
||||||
|
|
||||||
<!-- Show any parent tasks to make it clear this task is a sub task of something -->
|
|
||||||
<span class="parent-tasks" v-if="typeof task.relatedTasks?.parenttask !== 'undefined'">
|
|
||||||
<template v-for="(pt, i) in task.relatedTasks.parenttask">
|
|
||||||
{{ pt.title }}<template v-if="(i + 1) < task.relatedTasks.parenttask.length">, </template>
|
|
||||||
</template>
|
|
||||||
›
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<router-link
|
<router-link
|
||||||
:to="taskDetailRoute"
|
:to="taskDetailRoute"
|
||||||
class="task-link"
|
class="task-link"
|
||||||
@ -133,6 +126,22 @@
|
|||||||
</BaseButton>
|
</BaseButton>
|
||||||
<slot/>
|
<slot/>
|
||||||
</div>
|
</div>
|
||||||
|
<template v-if="typeof task.relatedTasks?.subtask !== 'undefined'">
|
||||||
|
<template v-for="subtask in task.relatedTasks.subtask">
|
||||||
|
<template v-if="getTaskById(subtask.id)">
|
||||||
|
<single-task-in-project
|
||||||
|
:key="subtask.id"
|
||||||
|
:the-task="getTaskById(subtask.id)"
|
||||||
|
:show-project-color="showProjectColor"
|
||||||
|
:disabled="disabled"
|
||||||
|
:can-mark-as-done="canMarkAsDone"
|
||||||
|
:all-tasks="allTasks"
|
||||||
|
class="ml-5"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -173,6 +182,7 @@ const {
|
|||||||
disabled = false,
|
disabled = false,
|
||||||
showProjectColor = false,
|
showProjectColor = false,
|
||||||
canMarkAsDone = true,
|
canMarkAsDone = true,
|
||||||
|
allTasks = [],
|
||||||
} = defineProps<{
|
} = defineProps<{
|
||||||
theTask: ITask,
|
theTask: ITask,
|
||||||
isArchived?: boolean,
|
isArchived?: boolean,
|
||||||
@ -180,8 +190,17 @@ const {
|
|||||||
disabled?: boolean,
|
disabled?: boolean,
|
||||||
showProjectColor?: boolean,
|
showProjectColor?: boolean,
|
||||||
canMarkAsDone?: boolean,
|
canMarkAsDone?: boolean,
|
||||||
|
allTasks?: ITask[],
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
function getTaskById(taskId: number): ITask | undefined {
|
||||||
|
if (typeof allTasks === 'undefined' || allTasks.length === 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return allTasks.find(t => t.id === taskId)
|
||||||
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['task-updated'])
|
const emit = defineEmits(['task-updated'])
|
||||||
|
|
||||||
const {t} = useI18n({useScope: 'global'})
|
const {t} = useI18n({useScope: 'global'})
|
||||||
@ -289,6 +308,7 @@ function hideDeferDueDatePopup(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const taskLink = ref<HTMLElement | null>(null)
|
const taskLink = ref<HTMLElement | null>(null)
|
||||||
|
|
||||||
function openTaskDetail() {
|
function openTaskDetail() {
|
||||||
const isTextSelected = window.getSelection().toString()
|
const isTextSelected = window.getSelection().toString()
|
||||||
if (!isTextSelected) {
|
if (!isTextSelected) {
|
||||||
|
@ -95,6 +95,7 @@
|
|||||||
:can-mark-as-done="canWrite || isSavedFilter(project)"
|
:can-mark-as-done="canWrite || isSavedFilter(project)"
|
||||||
:the-task="t"
|
:the-task="t"
|
||||||
@taskUpdated="updateTasks"
|
@taskUpdated="updateTasks"
|
||||||
|
:all-tasks="allTasks"
|
||||||
>
|
>
|
||||||
<template v-if="canWrite">
|
<template v-if="canWrite">
|
||||||
<span class="icon handle">
|
<span class="icon handle">
|
||||||
@ -120,7 +121,7 @@ export default { name: 'List' }
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, computed, nextTick, onMounted} from 'vue'
|
import {ref, computed, nextTick, onMounted, watch} from 'vue'
|
||||||
import draggable from 'zhyswan-vuedraggable'
|
import draggable from 'zhyswan-vuedraggable'
|
||||||
import {useRoute, useRouter} from 'vue-router'
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
|
|
||||||
@ -160,7 +161,7 @@ const DRAG_OPTIONS = {
|
|||||||
} as const
|
} as const
|
||||||
|
|
||||||
const {
|
const {
|
||||||
tasks,
|
tasks: allTasks,
|
||||||
loading,
|
loading,
|
||||||
totalPages,
|
totalPages,
|
||||||
currentPage,
|
currentPage,
|
||||||
@ -170,6 +171,13 @@ const {
|
|||||||
sortByParam,
|
sortByParam,
|
||||||
} = useTaskList(() => projectId, {position: 'asc' })
|
} = useTaskList(() => projectId, {position: 'asc' })
|
||||||
|
|
||||||
|
const tasks = ref<ITask[]>([])
|
||||||
|
watch(
|
||||||
|
allTasks,
|
||||||
|
() => {
|
||||||
|
tasks.value = [...allTasks.value].filter(t => typeof t.relatedTasks?.parenttask === 'undefined')
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
const isAlphabeticalSorting = computed(() => {
|
const isAlphabeticalSorting = computed(() => {
|
||||||
return params.value.sort_by.find(sortBy => sortBy === ALPHABETICAL_SORT) !== undefined
|
return params.value.sort_by.find(sortBy => sortBy === ALPHABETICAL_SORT) !== undefined
|
||||||
|
Loading…
x
Reference in New Issue
Block a user