Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

feat: task dependencies in detailed panel

Nikolai Gimanc1685e42b837
diff --git a/api/src/tv-modules/graph/GraphControler.ts b/api/src/tv-modules/graph/GraphControler.ts
index 130a89b..ed7c5ed 100644
--- a/api/src/tv-modules/graph/GraphControler.ts
+++ b/api/src/tv-modules/graph/GraphControler.ts
@@ -33,6 +33,15 @@ export class GraphController {
return res.tvJson(edges);
};
+ fetchTaskEdges = async (req: Request, res: Response) => {
+ const taskId = Number(req.params.taskId);
+ if (!Number.isFinite(taskId)) {
+ return res.status(400).send('Task ID is required');
+ }
+ const edges = await req.appUser.graphManager.fetchEdgesForTask(taskId);
+ return res.tvJson(edges);
+ };
+
deleteEdge = async (req: Request, res: Response) => {
if (!req.params.id) {
return res.status(400).send('Edge ID is required');
diff --git a/api/src/tv-modules/graph/GraphManager.ts b/api/src/tv-modules/graph/GraphManager.ts
index fab0724..9e8530d 100644
--- a/api/src/tv-modules/graph/GraphManager.ts
+++ b/api/src/tv-modules/graph/GraphManager.ts
@@ -19,6 +19,10 @@ export class GraphManager {
return await this.repository.fetchAllEdges(goalId);
}
+ async fetchEdgesForTask(taskId: number) {
+ return await this.repository.fetchEdgesForTask(taskId);
+ }
+
async deleteEdge(id: number) {
return await this.repository.deleteEdge(id);
}
diff --git a/api/src/tv-modules/graph/GraphRepository.ts b/api/src/tv-modules/graph/GraphRepository.ts
index 6d99678..17e49ca 100644
--- a/api/src/tv-modules/graph/GraphRepository.ts
+++ b/api/src/tv-modules/graph/GraphRepository.ts
@@ -1,4 +1,4 @@
-import { eq } from 'drizzle-orm';
+import { eq, or } from 'drizzle-orm';
import { GraphRelationsSchema } from 'taskview-db-schemas';
import { Database } from '../../modules/db';
import { callWithCatch } from '../../utils/helpers';
@@ -32,6 +32,16 @@ export class GraphRepository {
return result ?? [];
}
+ public async fetchEdgesForTask(taskId: number): Promise<GraphReturnRelationsType[]> {
+ const result = await callWithCatch(() =>
+ this.db.dbDrizzle
+ .select()
+ .from(GraphRelationsSchema)
+ .where(or(eq(GraphRelationsSchema.fromTaskId, taskId), eq(GraphRelationsSchema.toTaskId, taskId)))
+ );
+ return result ?? [];
+ }
+
public async deleteEdge(id: number): Promise<boolean> {
const result = await callWithCatch(() =>
this.db.dbDrizzle.delete(GraphRelationsSchema).where(eq(GraphRelationsSchema.id, id))
diff --git a/api/src/tv-modules/graph/GraphRoutes.ts b/api/src/tv-modules/graph/GraphRoutes.ts
index c136517..501d045 100644
--- a/api/src/tv-modules/graph/GraphRoutes.ts
+++ b/api/src/tv-modules/graph/GraphRoutes.ts
@@ -21,6 +21,7 @@ export default class GraphRoutes implements Routable {
initRoutes() {
this.router.post('', [IsLoggedIn, CanManageGraph], this.graphController.addEdge);
+ this.router.get('/task/:taskId', [IsLoggedIn, CanViewGraph], this.graphController.fetchTaskEdges);
this.router.get('/:goalId', [IsLoggedIn, CanViewGraph], this.graphController.fetchAllEdges);
this.router.delete('/:id', [IsLoggedIn, CanManageGraph], this.graphController.deleteEdge);
}
diff --git a/api/src/tv-modules/graph/middlewares/resolveGoalId.ts b/api/src/tv-modules/graph/middlewares/resolveGoalId.ts
index cc26308..e0f580b 100644
--- a/api/src/tv-modules/graph/middlewares/resolveGoalId.ts
+++ b/api/src/tv-modules/graph/middlewares/resolveGoalId.ts
@@ -15,6 +15,14 @@ export async function resolveGoalId(req: Request): Promise<number | null> {
return isNaN(id) ? null : id;
}
+ if (req.params.taskId) {
+ const taskId = Number(req.params.taskId);
+ if (isNaN(taskId)) return null;
+ const tasksRepo = new TasksRepository();
+ const task = await tasksRepo.fetchTaskByIdNew(taskId);
+ return task?.goalId ?? null;
+ }
+
// addEdge: resolve goalId from task
if (req.body?.source) {
const taskId = Number(req.body.source);
diff --git a/taskview-packages/taskview-api/src/api/graph.ts b/taskview-packages/taskview-api/src/api/graph.ts
index ac342fb..8964e12 100644
--- a/taskview-packages/taskview-api/src/api/graph.ts
+++ b/taskview-packages/taskview-api/src/api/graph.ts
@@ -13,6 +13,14 @@ export default class TvGraph extends TvApiBase {
);
}
+ public async fetchTaskEdges(taskId: number) {
+ return this.request(
+ this.$axios.get<AppResponse<GraphResponseAddEdge[]>>(
+ `${this.moduleUrl}/task/${taskId}`
+ )
+ );
+ }
+
public async fetchAllEdges(goalId: number) {
return this.request(
this.$axios.get<AppResponse<GraphResponseAddEdge[]>>(
diff --git a/web/src/components/features/tasks/TaskDetailPanel.vue b/web/src/components/features/tasks/TaskDetailPanel.vue
index 4ce8f80..4a2ae04 100644
--- a/web/src/components/features/tasks/TaskDetailPanel.vue
+++ b/web/src/components/features/tasks/TaskDetailPanel.vue
@@ -103,6 +103,12 @@
:class="colClass(fieldId)"
/>
</template>
+ <TaskDependencies
+ v-else-if="fieldId === 'dependencies'"
+ :task-id="task.id"
+ :goal-id="task.goalId"
+ :class="colClass(fieldId)"
+ />
<TaskAmountEditor
v-else-if="fieldId === 'amount'"
:task-id="task.id"
@@ -169,6 +175,7 @@ import TvDeadlineSelect from '@/components/features/base/TvDeadlineSelect.vue'
import TaskRecurrence from '@/components/features/tasks/parts/TaskRecurrence.vue'
import TaskSourceLink from '@/components/features/tasks/parts/TaskSourceLink.vue'
import TaskSubtasks from '@/components/features/tasks/parts/TaskSubtasks.vue'
+import TaskDependencies from '@/components/features/tasks/parts/TaskDependencies.vue'
import TaskIdCopy from '@/components/features/tasks/parts/TaskIdCopy.vue'
import TvSprintSelect from '@/components/features/base/TvSprintSelect.vue'
import TaskEstimateInput from '@/components/features/tasks/parts/TaskEstimateInput.vue'
diff --git a/web/src/components/features/tasks/parts/TaskDependencies.types.ts b/web/src/components/features/tasks/parts/TaskDependencies.types.ts
new file mode 100644
index 0000000..3dc38cb
--- /dev/null
+++ b/web/src/components/features/tasks/parts/TaskDependencies.types.ts
@@ -0,0 +1,10 @@
+export type DependencyTask = {
+ id: number
+ description: string
+ complete: number | boolean
+}
+
+export type DependencyEntry = {
+ edgeId: number
+ task: DependencyTask
+}
diff --git a/web/src/components/features/tasks/parts/TaskDependencies.vue b/web/src/components/features/tasks/parts/TaskDependencies.vue
new file mode 100644
index 0000000..dc081f7
--- /dev/null
+++ b/web/src/components/features/tasks/parts/TaskDependencies.vue
@@ -0,0 +1,126 @@
+<template>
+ <div
+ v-if="canViewGraph"
+ class="w-full h-fit rounded-2xl bg-accented/20 p-3.5"
+ data-testid="task-dependencies"
+ >
+ <label class="text-sm text-muted mb-2 block">{{ t('tasks.dependencies.title') }}</label>
+
+ <div class="grid grid-cols-1 @lg:grid-cols-[1fr_auto_1fr] gap-3 items-stretch">
+ <TaskDependencyGroup
+ :title="t('tasks.dependencies.previous')"
+ icon="i-lucide-move-left"
+ direction="previous"
+ :entries="previous"
+ :goal-id="goalId"
+ :excluded-ids="excludedIds"
+ :can-manage="canManageGraph"
+ @open="openTask"
+ @add="(task) => addEdge({ source: task.id, target: taskId, task })"
+ @remove="removeEdge"
+ />
+
+ <div class="hidden @lg:flex flex-col items-center self-center text-dimmed">
+ <UIcon
+ name="i-lucide-git-commit-horizontal"
+ class="size-5"
+ />
+ </div>
+
+ <TaskDependencyGroup
+ :title="t('tasks.dependencies.next')"
+ icon="i-lucide-move-right"
+ direction="next"
+ :entries="next"
+ :goal-id="goalId"
+ :excluded-ids="excludedIds"
+ :can-manage="canManageGraph"
+ @open="openTask"
+ @add="(task) => addEdge({ source: taskId, target: task.id, task })"
+ @remove="removeEdge"
+ />
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { computed, ref, watch } from 'vue'
+import { useI18n } from 'vue-i18n'
+import type { GraphResponseAddEdge } from 'taskview-api'
+import { $tvApi } from '@/plugins/axios'
+import { logError } from '@/helpers/Helper'
+import { useGoalPermissions } from '@/composables/useGoalPermissions'
+import { useTaskDetailPanel } from '@/composables/useTaskDetailPanel'
+import TaskDependencyGroup from './TaskDependencyGroup.vue'
+import type { DependencyEntry, DependencyTask } from './TaskDependencies.types'
+
+const props = defineProps<{
+ taskId: number
+ goalId: number
+}>()
+
+const { t } = useI18n()
+const { canViewGraph, canManageGraph } = useGoalPermissions()
+const { openTask } = useTaskDetailPanel()
+
+const edges = ref<GraphResponseAddEdge[]>([])
+const taskNames = ref(new Map<number, DependencyTask>())
+
+const taskEdges = computed(() =>
+ edges.value.filter((e) => e.fromTaskId === props.taskId || e.toTaskId === props.taskId),
+)
+
+function toEntries(direction: 'previous' | 'next'): DependencyEntry[] {
+ return taskEdges.value
+ .filter((e) => (direction === 'previous' ? e.toTaskId === props.taskId : e.fromTaskId === props.taskId))
+ .map((e) => {
+ const linkedId = direction === 'previous' ? e.fromTaskId : e.toTaskId
+ const task = taskNames.value.get(linkedId)
+ return task ? { edgeId: e.id, task } : null
+ })
+ .filter((entry): entry is DependencyEntry => entry !== null)
+}
+
+const previous = computed(() => toEntries('previous'))
+const next = computed(() => toEntries('next'))
+
+const excludedIds = computed(() => [
+ props.taskId,
+ ...taskEdges.value.flatMap((e) => [e.fromTaskId, e.toTaskId]),
+])
+
+async function resolveNames() {
+ const ids = new Set(
+ taskEdges.value.flatMap((e) => [e.fromTaskId, e.toTaskId]).filter((id) => id !== props.taskId),
+ )
+ await Promise.all(
+ [...ids]
+ .filter((id) => !taskNames.value.has(id))
+ .map(async (id) => {
+ const task = await $tvApi.tasks.fetchTaskById(id).catch((err: unknown) => logError(err))
+ if (task) taskNames.value.set(id, { id: task.id, description: task.description, complete: task.complete })
+ }),
+ )
+}
+
+async function load() {
+ const result = await $tvApi.graph.fetchTaskEdges(props.taskId).catch((err: unknown) => logError(err))
+ edges.value = result ?? []
+ await resolveNames()
+}
+
+watch(() => props.taskId, load, { immediate: true })
+
+async function addEdge({ source, target, task }: { source: number; target: number; task: DependencyTask }) {
+ const edge = await $tvApi.graph.addEdge({ source, target }).catch((err: unknown) => logError(err))
+ if (!edge) return
+ taskNames.value.set(task.id, task)
+ edges.value.push(edge)
+}
+
+async function removeEdge(edgeId: number) {
+ const result = await $tvApi.graph.deleteEdge(edgeId).catch((err: unknown) => logError(err))
+ if (!result) return
+ edges.value = edges.value.filter((e) => e.id !== edgeId)
+}
+</script>
diff --git a/web/src/components/features/tasks/parts/TaskDependencyGroup.vue b/web/src/components/features/tasks/parts/TaskDependencyGroup.vue
new file mode 100644
index 0000000..45c816c
--- /dev/null
+++ b/web/src/components/features/tasks/parts/TaskDependencyGroup.vue
@@ -0,0 +1,84 @@
+<template>
+ <div class="flex flex-col gap-1 min-w-0 h-full">
+ <div class="flex items-center gap-1.5 px-1">
+ <UIcon
+ :name="icon"
+ class="size-3.5 text-muted"
+ />
+ <span class="text-xs text-muted">{{ title }}</span>
+ </div>
+
+ <div
+ v-for="entry in entries"
+ :key="entry.edgeId"
+ class="flex items-center gap-2 rounded-xl bg-default shadow-xs px-3 py-2"
+ :data-testid="`dependency-${direction}-${entry.task.id}`"
+ >
+ <UIcon
+ :name="entry.task.complete ? 'i-lucide-circle-check' : 'i-lucide-circle-dashed'"
+ class="size-3.5 shrink-0"
+ :class="entry.task.complete ? 'text-success' : 'text-muted'"
+ />
+ <button
+ type="button"
+ class="flex-1 min-w-0 text-left text-sm truncate cursor-pointer"
+ :class="{ 'text-muted line-through': entry.task.complete }"
+ @click="$emit('open', entry.task.id)"
+ >
+ {{ entry.task.description }}
+ </button>
+ <UButton
+ v-if="canManage"
+ icon="i-lucide-x"
+ color="error"
+ variant="ghost"
+ size="xs"
+ class="shrink-0"
+ :aria-label="t('common.delete')"
+ @click="$emit('remove', entry.edgeId)"
+ />
+ </div>
+
+ <p
+ v-if="entries.length === 0"
+ class="text-sm text-dimmed px-2 py-1"
+ >
+ {{ t('tasks.dependencies.none') }}
+ </p>
+
+ <div
+ v-if="canManage"
+ class="mt-auto"
+ >
+ <TaskDependencyPicker
+ :goal-id="goalId"
+ :excluded-ids="excludedIds"
+ @select="(task) => $emit('add', task)"
+ />
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { useI18n } from 'vue-i18n'
+import TaskDependencyPicker from './TaskDependencyPicker.vue'
+import type { DependencyEntry, DependencyTask } from './TaskDependencies.types'
+
+defineProps<{
+ title: string
+ icon: string
+ direction: 'previous' | 'next'
+ entries: DependencyEntry[]
+ goalId: number
+ excludedIds: number[]
+ canManage: boolean
+}>()
+
+defineEmits<{
+ open: [taskId: number]
+ add: [task: DependencyTask]
+ remove: [edgeId: number]
+}>()
+
+const { t } = useI18n()
+</script>
diff --git a/web/src/components/features/tasks/parts/TaskDependencyPicker.vue b/web/src/components/features/tasks/parts/TaskDependencyPicker.vue
new file mode 100644
index 0000000..a3ab269
--- /dev/null
+++ b/web/src/components/features/tasks/parts/TaskDependencyPicker.vue
@@ -0,0 +1,121 @@
+<template>
+ <UPopover
+ v-model:open="open"
+ class="w-full"
+ >
+ <UButton
+ icon="i-lucide-plus"
+ :label="t('tasks.dependencies.add')"
+ color="neutral"
+ variant="soft"
+ size="sm"
+ block
+ class="text-muted"
+ :ui="{ base: 'rounded-xl justify-start' }"
+ />
+ <template #content>
+ <div class="w-72 p-2 flex flex-col gap-2">
+ <UInput
+ v-model="query"
+ :placeholder="t('tasks.dependencies.searchPlaceholder')"
+ icon="i-lucide-search"
+ variant="soft"
+ size="sm"
+ autofocus
+ :loading="loading"
+ />
+ <div class="max-h-64 overflow-y-auto flex flex-col gap-0.5">
+ <button
+ v-for="option in options"
+ :key="option.id"
+ type="button"
+ class="flex items-center gap-2 w-full text-left rounded-10 px-2 py-1.5 hover:bg-muted/10 cursor-pointer"
+ @click="pick(option)"
+ >
+ <UIcon
+ :name="option.complete ? 'i-lucide-circle-check' : 'i-lucide-circle-dashed'"
+ class="size-3.5 shrink-0"
+ :class="option.complete ? 'text-success' : 'text-muted'"
+ />
+ <span
+ class="text-sm truncate"
+ :class="{ 'text-muted line-through': option.complete }"
+ >
+ {{ option.description }}
+ </span>
+ </button>
+ <p
+ v-if="!loading && options.length === 0"
+ class="text-sm text-muted text-center py-3"
+ >
+ {{ t('tasks.dependencies.noResults') }}
+ </p>
+ </div>
+ </div>
+ </template>
+ </UPopover>
+</template>
+
+<script setup lang="ts">
+import { computed, ref, watch } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { useDebounceFn } from '@vueuse/core'
+import { ALL_TASKS_LIST_ID } from 'taskview-api'
+import { $tvApi } from '@/plugins/axios'
+import { logError } from '@/helpers/Helper'
+import type { DependencyTask } from './TaskDependencies.types'
+
+const props = defineProps<{
+ goalId: number
+ excludedIds: number[]
+}>()
+
+const emit = defineEmits<{
+ select: [task: DependencyTask]
+}>()
+
+const { t } = useI18n()
+
+const open = ref(false)
+const query = ref('')
+const loading = ref(false)
+const results = ref<DependencyTask[]>([])
+
+const options = computed(() =>
+ results.value.filter((task) => !props.excludedIds.includes(task.id)),
+)
+
+async function search() {
+ loading.value = true
+ const tasks = await $tvApi.tasks
+ .fetch({
+ goalId: props.goalId,
+ componentId: ALL_TASKS_LIST_ID,
+ page: 0,
+ showCompleted: 0,
+ ignoreCompleted: true,
+ firstNew: 1,
+ searchText: query.value.trim() || undefined,
+ })
+ .catch((err: unknown) => logError(err))
+ results.value = tasks ?? []
+ loading.value = false
+}
+
+const debouncedSearch = useDebounceFn(search, 300)
+
+watch(query, () => debouncedSearch())
+
+watch(open, (isOpen) => {
+ if (isOpen) {
+ query.value = ''
+ results.value = []
+ search()
+ }
+})
+
+function pick(task: DependencyTask) {
+ open.value = false
+ emit('select', task)
+}
+</script>
diff --git a/web/src/composables/useTaskDetailPanel.ts b/web/src/composables/useTaskDetailPanel.ts
index e9b1666..b8ecdaf 100644
--- a/web/src/composables/useTaskDetailPanel.ts
+++ b/web/src/composables/useTaskDetailPanel.ts
@@ -46,10 +46,14 @@ const _useTaskDetailPanel = () => {
const taskId = String(task.id)
if (route.params.taskId !== taskId) {
- router.push({
- name: 'user',
- params: { projectId, listId, taskId },
- })
+ // Switching from one open task to another (e.g. via dependencies) replaces
+ // the history entry, so back/close returns to the list, not the previous task
+ const target = { name: 'user', params: { projectId, listId, taskId } }
+ if (route.params.taskId) {
+ router.replace(target)
+ } else {
+ router.push(target)
+ }
}
}
}
diff --git a/web/src/locales/de.ts b/web/src/locales/de.ts
index 7deb0dc..48e612d 100644
--- a/web/src/locales/de.ts
+++ b/web/src/locales/de.ts
@@ -535,6 +535,15 @@ export default {
sprint: 'Sprint',
estimate: 'Schätzung',
},
+ dependencies: {
+ title: 'Abhängigkeiten',
+ previous: 'Vorherige Aufgaben',
+ next: 'Nächste Aufgaben',
+ add: 'Hinzufügen',
+ searchPlaceholder: 'Aufgaben suchen…',
+ noResults: 'Nichts gefunden',
+ none: 'Keine',
+ },
status: 'Status',
selectStatus: 'Status auswählen',
searchStatuses: 'Status suchen...',
@@ -827,6 +836,7 @@ export default {
estimate: 'Schätzung',
tags: 'Tags',
deadline: 'Frist',
+ dependencies: 'Abhängigkeiten',
amount: 'Betrag',
timeTracking: 'Zeiterfassung',
history: 'Verlauf',
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index 6ab32bd..38f948f 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -549,6 +549,15 @@ export default {
sprint: 'Sprint',
estimate: 'Estimate',
},
+ dependencies: {
+ title: 'Dependencies',
+ previous: 'Previous tasks',
+ next: 'Next tasks',
+ add: 'Add',
+ searchPlaceholder: 'Search tasks…',
+ noResults: 'Nothing found',
+ none: 'None',
+ },
status: 'Status',
selectStatus: 'Select status',
searchStatuses: 'Search statuses...',
@@ -841,6 +850,7 @@ export default {
estimate: 'Estimate',
tags: 'Tags',
deadline: 'Deadline',
+ dependencies: 'Dependencies',
amount: 'Amount',
timeTracking: 'Time tracking',
history: 'History',
diff --git a/web/src/locales/es.ts b/web/src/locales/es.ts
index ddda0b6..83e0ea9 100644
--- a/web/src/locales/es.ts
+++ b/web/src/locales/es.ts
@@ -535,6 +535,15 @@ export default {
sprint: 'Sprint',
estimate: 'Estimación',
},
+ dependencies: {
+ title: 'Dependencias',
+ previous: 'Tareas anteriores',
+ next: 'Tareas siguientes',
+ add: 'Añadir',
+ searchPlaceholder: 'Buscar tareas…',
+ noResults: 'Sin resultados',
+ none: 'Ninguna',
+ },
status: 'Estado',
selectStatus: 'Seleccionar estado',
searchStatuses: 'Buscar estados...',
@@ -827,6 +836,7 @@ export default {
estimate: 'Estimación',
tags: 'Etiquetas',
deadline: 'Fecha límite',
+ dependencies: 'Dependencias',
amount: 'Importe',
timeTracking: 'Registro de tiempo',
history: 'Historial',
diff --git a/web/src/locales/ru.ts b/web/src/locales/ru.ts
index d4c8049..0bd4d76 100644
--- a/web/src/locales/ru.ts
+++ b/web/src/locales/ru.ts
@@ -522,6 +522,15 @@ export default {
sprint: 'Спринт',
estimate: 'Оценка',
},
+ dependencies: {
+ title: 'Зависимости',
+ previous: 'Предыдущие задачи',
+ next: 'Следующие задачи',
+ add: 'Добавить',
+ searchPlaceholder: 'Поиск задач…',
+ noResults: 'Ничего не найдено',
+ none: 'Нет',
+ },
status: 'Статус',
selectStatus: 'Выбрать статус',
searchStatuses: 'Поиск статусов...',
@@ -814,6 +823,7 @@ export default {
estimate: 'Оценка',
tags: 'Теги',
deadline: 'Дедлайн',
+ dependencies: 'Зависимости',
amount: 'Сумма',
timeTracking: 'Учёт времени',
history: 'История',
diff --git a/web/src/uiCustomization/sections/tasks.types.ts b/web/src/uiCustomization/sections/tasks.types.ts
index 6dd27ae..ab4c6a0 100644
--- a/web/src/uiCustomization/sections/tasks.types.ts
+++ b/web/src/uiCustomization/sections/tasks.types.ts
@@ -16,6 +16,7 @@ export const TASK_DETAIL_FIELDS = [
{ id: 'estimate', width: 'narrow' },
{ id: 'tags', width: 'narrow' },
{ id: 'deadline', width: 'narrow' },
+ { id: 'dependencies', width: 'wide' },
{ id: 'amount', width: 'wide' },
{ id: 'timeTracking', width: 'wide' },
{ id: 'history', width: 'wide' },