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.
TypeScript graphviewkanban-boardnodejsproductivityproject-managementself-hostedtasktask-managementtask-managertodoapp
fix: task id and search
Nikolai Giman284a49ce8c21
diff --git a/api/src/tv-modules/start/StartManager.ts b/api/src/tv-modules/start/StartManager.tsindex 73a75e8..e34b74b 100644--- a/api/src/tv-modules/start/StartManager.ts+++ b/api/src/tv-modules/start/StartManager.ts@@ -89,7 +89,7 @@ export class StartManager {await this.fetchSharedGoals(organizationId);const goalIds = await this.getAllGoalsIds(organizationId);- const tasks = await this.repository.searchTask(description.trim(), goalIds);+ const tasks = await this.repository.searchTask({ description, goalsIds: goalIds });return tasks;}}diff --git a/api/src/tv-modules/start/StartRepository.ts b/api/src/tv-modules/start/StartRepository.tsindex 0e25382..935cf3f 100644--- a/api/src/tv-modules/start/StartRepository.ts+++ b/api/src/tv-modules/start/StartRepository.ts@@ -1,5 +1,5 @@-import { and, eq, inArray, isNotNull, or } from 'drizzle-orm';-import { GoalsSchema, GoalsListSchema } from 'taskview-db-schemas';+import { and, eq, ilike, inArray, isNotNull, isNull, or } from 'drizzle-orm';+import { GoalsSchema, GoalsListSchema, TasksSchema } from 'taskview-db-schemas';import type { AppUser } from '../../core/AppUser';import { Database } from '../../modules/db';import { $logger } from '../../modules/logget';@@ -8,7 +8,7 @@ import { logError } from '../../utils/api';import { callWithCatch } from '../../utils/helpers';import type { TagToTaskInDb } from '../tags/tags.types';import { TaskItemForClient } from '../tasks/TaskItemForClient';-import type { AssigneesForTaskFromDb, FetchAllListsResult, UsersByProjectsFromDb } from './start.types';+import type { AssigneesForTaskFromDb, FetchAllListsResult, SearchTaskArgs, SearchTaskResult, UsersByProjectsFromDb } from './start.types';//TODO: refactorexport class StartRepository {@@ -371,31 +371,38 @@ export class StartRepository {return [...taskIdToTaskMap.values()];}- async searchTask(description: string, goalsIds: number[]): Promise<TaskItemForClient[]> {- if (goalsIds.length === 0 || !description.trim()) {+ async searchTask(args: SearchTaskArgs): Promise<SearchTaskResult[]> {+ const description = args.description.trim();+ if (args.goalsIds.length === 0 || !description) {return [];}- const placeholders = goalsIds.map((_id, index) => {- return `$${index + 1}`;- });- const result = await this.db.query<TaskItemInDb>(- `select * from tasks.tasks where goal_id in (${placeholders.join(',')}) and complete = FALSE and parent_id is null and description ILIKE $${goalsIds.length + 1}`,- [...goalsIds, `%${description}%`]+ const idMatch = description.match(/^#(\d+)$/);+ const searchCondition = idMatch+ ? eq(TasksSchema.id, Number(idMatch[1]))+ : and(+ eq(TasksSchema.complete, false),+ isNull(TasksSchema.parentId),+ ilike(TasksSchema.description, `%${description}%`),+ );++ const result = await callWithCatch(() =>+ this.db.dbDrizzle+ .select()+ .from(TasksSchema)+ .where(and(inArray(TasksSchema.goalId, args.goalsIds), searchCondition)));if (!result) {return [];}- const map: Map<number, TaskItemForClient> = new Map();-- result.rows.forEach((t) => {- if (!map.get(t.id)) {- map.set(t.id, new TaskItemForClient(t));- }- });-- return [...map.values()];+ return result.map((task) => ({+ ...task,+ tags: [],+ assignedUsers: [],+ historyId: null,+ subtasks: [],+ }));}}diff --git a/api/src/tv-modules/start/start.types.ts b/api/src/tv-modules/start/start.types.tsindex d6e1e46..f6295a1 100644--- a/api/src/tv-modules/start/start.types.ts+++ b/api/src/tv-modules/start/start.types.ts@@ -1,3 +1,17 @@+import type { TasksSchemaTypeForSelect } from 'taskview-db-schemas';++export type SearchTaskArgs = {+ description: string;+ goalsIds: number[];+};++export type SearchTaskResult = TasksSchemaTypeForSelect & {+ tags: number[];+ assignedUsers: number[];+ historyId: number | null;+ subtasks: SearchTaskResult[];+};+export type FetchAllListsResult = {goalName: string | null;listName: string | null;diff --git a/web/src/components/features/tasks/TaskDetailPanel.vue b/web/src/components/features/tasks/TaskDetailPanel.vueindex 3372f88..06daf09 100644--- a/web/src/components/features/tasks/TaskDetailPanel.vue+++ b/web/src/components/features/tasks/TaskDetailPanel.vue@@ -26,6 +26,10 @@</UTextarea></div></div>+ <TaskIdCopy+ :task-id="task.id"+ class="self-start -mt-2"+ /><!-- Source link (GitHub/GitLab issue) --><av-if="task.sourceUrl"@@ -170,6 +174,7 @@ import TaskHistory from '@/components/features/tasks/parts/TaskHistory.vue'import TvDeadlineSelect from '@/components/features/base/TvDeadlineSelect.vue'import TaskRecurrence from '@/components/features/tasks/parts/TaskRecurrence.vue'import TaskSubtasks from '@/components/features/tasks/parts/TaskSubtasks.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'import type { PriorityValue } from '@/composables/usePriorityOptions'diff --git a/web/src/components/features/tasks/parts/TaskIdCopy.vue b/web/src/components/features/tasks/parts/TaskIdCopy.vuenew file mode 100644index 0000000..c2ecabc--- /dev/null+++ b/web/src/components/features/tasks/parts/TaskIdCopy.vue@@ -0,0 +1,34 @@+<template>+ <UButton+ variant="link"+ color="neutral"+ size="sm"+ :icon="copied ? 'i-lucide-check' : 'i-lucide-hash'"+ class="text-muted hover:text-default"+ :title="t('tasks.copyId')"+ @click="copyId"+ >+ {{ taskId }}+ </UButton>+</template>++<script setup lang="ts">+import { useClipboard } from '@vueuse/core'+import { useI18n } from 'vue-i18n'++const props = defineProps<{+ taskId: number+}>()++const { t } = useI18n()+const toast = useToast()+const { copy, copied } = useClipboard({ copiedDuring: 2000 })++async function copyId() {+ await copy(`#${props.taskId}`)+ toast.add({+ title: t('tasks.idCopied'),+ color: 'success',+ })+}+</script>diff --git a/web/src/locales/en.ts b/web/src/locales/en.tsindex 3e7e30a..c8040ac 100644--- a/web/src/locales/en.ts+++ b/web/src/locales/en.ts@@ -544,6 +544,8 @@ export default {subtasks: 'Subtasks',addSubtask: 'Add subtask',notFound: 'Task not found',+ copyId: 'Copy task ID',+ idCopied: 'Task ID copied',noTasks: 'No tasks',showCompleted: 'Show completed',hideCompleted: 'Hide completed',diff --git a/web/src/locales/ru.ts b/web/src/locales/ru.tsindex 2d6324d..79fbc0f 100644--- a/web/src/locales/ru.ts+++ b/web/src/locales/ru.ts@@ -517,6 +517,8 @@ export default {subtasks: 'Подзадачи',addSubtask: 'Добавить подзадачу',notFound: 'Задача не найдена',+ copyId: 'Скопировать ID задачи',+ idCopied: 'ID задачи скопирован',noTasks: 'Нет задач',showCompleted: 'Показать выполненные',hideCompleted: 'Скрыть выполненные',