Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ ESM-пакет, Node 22+. SDK — `@modelcontextprotocol/sdk` (`McpServer` + `St

**Истории в бэклоге.** `BoardGroup.sprintId` хранит плановый спринт истории; пустая история показывается в назначенном блоке. История с задачами также появляется в блоках их спринтов, поэтому индивидуально перенесённые задачи остаются видимыми. Меню строки и drag за ручку истории вызывают `PATCH /projects/:projectId/groups/:id/sprint` с `{ sprintId: UUID | null }`: история и все её задачи вне закрытых спринтов переносятся атомарно, включая скрытые выполненные. Задачи закрытых спринтов сохраняются. Новая задача наследует спринт истории только при отсутствующем `sprintId`; явный `null` оставляет её в бэклоге. Завершение спринта переносит открытые истории, удаление очищает FK. Фильтры не ограничивают перенос и общий счётчик. Для drag историй используется группа `sprint-stories`, для задач — `sprint-backlog`; пустой блок имеет видимую область переноса истории. Drop задачи в строку принимает только задачи той же истории. Новая задача в истории выпущенного релиза создаётся с явным `releaseId: null`; будущий релиз можно выбрать в карточке задачи.

## Drag-and-drop (две системы — выбирать по контексту)
## Drag-and-drop (выбирать по контексту)

В кодбазе сосуществуют два независимых DnD-стека. Не смешивать.
В кодбазе используются отдельные DnD-контроллеры по контексту. Не смешивать.

- **Кастомный движок на PointerEvents** в `features/tasks/lib/dnd/` (`useTaskDnd`, `useDragSource`, `useDropTarget`, `useReorderList`) + `<TaskDragGhost />` через teleport в `App.vue`. Используется для: reorder задач в Inbox (`TasksView`) и в проекте-list-без-колонок (`ProjectView` когда `columns.length === 0`), drop задач на проекты/Inbox в сайдбаре. Жесты: drag-handle (немедленно) + long-press 350ms на mobile + threshold 5px на desktop.
- **`vuedraggable`** в `features/projects/ui/BoardView.vue`, `BoardColumn.vue`, `ProjectTreeNav.vue`. Используется для: задач внутри колонок board-view, переупорядочивания самих колонок, переупорядочивания проектов в сайдбаре. Не трогать без явной задачи.
- **`vuedraggable`** в `features/projects/ui/BoardView.vue`, `BoardColumn.vue`. Используется для: задач внутри колонок board-view, переупорядочивания самих колонок. Не трогать без явной задачи.
- **Дерево проектов** — отдельный PointerEvents-контроллер `features/projects/lib/use-project-tree-drag.ts`: плоские видимые строки, удержание названия 350 мс запускает перенос, вертикаль выбирает место, горизонталь — уровень. Движение до удержания оставляет нативную прокрутку; click после переноса подавляется. Перенос ветки сохраняется атомарно через `PATCH /projects/:id/move` (`parentId`, `beforeId`, оба nullable). Не заменять двумя запросами parentId + reorder.
- **Drag-create в календаре** — `features/calendar/lib/use-create-slot-drag.ts` (рисование задачи по сетке часов). Использует те же константы (`LONG_PRESS_DELAY_MS=350`, `TOUCH_DRAG_THRESHOLD_PX=8`), что и `features/tasks/lib/dnd/use-drag-source.ts`, чтобы на mobile сохранять нативный scroll до осознанного long-press. На desktop drag стартует мгновенно.

# UI conventions — shadcn-vue
Expand Down
4 changes: 3 additions & 1 deletion alfy-bot-frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ src/
### Drag-and-drop — два независимых стека (не смешивать)

- **Кастомный движок на PointerEvents** (`features/tasks/lib/dnd/`) — reorder задач в Inbox и list-проектах, drop на проекты/Inbox в сайдбаре, drag-create в календаре. Long-press 350ms на mobile, threshold 5px на desktop.
- **vuedraggable** — задачи внутри board-колонок, переупорядочивание колонок и проектов в сайдбаре.
- **vuedraggable** — задачи внутри board-колонок, переупорядочивание колонок.

> **Типы вопросов** грузятся с бэкенда (`GET /api/question-types` через `stores/question-types-store.ts`), не хардкодятся на фронте — иначе бот и веб рассинхронизируются.

Expand All @@ -62,3 +62,5 @@ npx vue-tsc --noEmit -p tsconfig.app.json # тип-чек без билда
- `VITE_DEV_TELEGRAM_ID` — dev-флаг для авторизации без Telegram WebApp.

Авторизация: `main.ts` пробует `authorize()` при наличии `Telegram.WebApp.initData` или dev-флага. Router guard редиректит на `/login` любой не-public маршрут без токена (`meta: { public: true }` — исключения).

Для переноса проекта удерживайте его название 350 мс, затем двигайте: вправо — вложить под предыдущий проект, влево — поднять уровень, вверх/вниз — выбрать место. Линия и подпись показывают назначение. Escape отменяет перенос. Ветка переносится вместе с потомками; меню «На уровень выше» даёт тот же выход из родителя без drag.
15 changes: 10 additions & 5 deletions alfy-bot-frontend/src/components/AppHeader.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { ArrowLeft, Target, Menu } from 'lucide-vue-next'
import { ArrowLeft, Target, PanelLeftOpen } from 'lucide-vue-next'
import { inject, ref, type Ref } from 'vue'
import { useRouter } from 'vue-router'
import { Button } from '@/components/ui/button'

Expand All @@ -11,6 +12,7 @@ const props = defineProps<{
}>()

const router = useRouter()
const desktopSidebarCollapsed = inject<Ref<boolean>>('desktopSidebarCollapsed', ref(false))
</script>

<template>
Expand All @@ -28,15 +30,18 @@ const router = useRouter()
<ArrowLeft class="w-5 h-5" />
</Button>
<Button
v-else-if="onMenuClick"
v-if="onMenuClick && !showBack"
variant="ghost"
size="icon"
class="flex-shrink-0 sm:hidden"
class="flex-shrink-0"
:class="desktopSidebarCollapsed ? '' : 'sm:hidden'"
aria-label="Открыть боковое меню"
title="Открыть боковое меню"
@click="onMenuClick"
>
<Menu class="w-5 h-5" />
<PanelLeftOpen class="w-5 h-5" />
</Button>
<Target v-else class="w-5 h-5 text-primary flex-shrink-0" />
<Target v-else-if="!showBack" class="w-5 h-5 text-primary flex-shrink-0" />
<slot name="title">
<span class="font-semibold text-base truncate">{{ title }}</span>
</slot>
Expand Down
11 changes: 7 additions & 4 deletions alfy-bot-frontend/src/components/AppLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const TasksSidebarSection = defineAsyncComponent(() =>

const route = useRoute()
const sidebarOpen = ref(false)
const desktopCollapsed = ref(false)
const isTasksSection = computed(() => route.matched.some(record => record.meta.sectionNav === 'tasks'))
const desktopSidebarCollapsed = computed(() => isTasksSection.value && desktopCollapsed.value)

const sectionNavRegistry: Record<string, NavLink[]> = {
tasks: tasksNavLinks,
Expand All @@ -36,23 +39,23 @@ const sectionExtra = computed<Component | undefined>(() => {
})

function openSidebar() {
sidebarOpen.value = true
if (window.matchMedia('(min-width: 640px)').matches) desktopCollapsed.value = false
else sidebarOpen.value = true
}

function closeSidebar() {
sidebarOpen.value = false
}

// На мобильной версии sidebar — оверлей; после перехода по разделу его надо свернуть.
// На десктопе панель видна всегда (CSS), поэтому вызов безвреден.
watch(() => route.path, () => closeSidebar())

provide('openSidebar', openSidebar)
provide('desktopSidebarCollapsed', desktopSidebarCollapsed)
</script>

<template>
<div class="flex min-h-[100dvh]">
<AppSidebar :open="sidebarOpen" :links="sectionLinks" @close="closeSidebar" @open="openSidebar">
<AppSidebar :open="sidebarOpen" :links="sectionLinks" :collapsible="isTasksSection" :desktop-collapsed="desktopSidebarCollapsed" @collapse="desktopCollapsed = true" @close="closeSidebar" @open="openSidebar">
<template v-if="sectionExtra" #section-extra>
<component :is="sectionExtra" />
</template>
Expand Down
35 changes: 25 additions & 10 deletions alfy-bot-frontend/src/components/AppSidebar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { PanelLeftClose } from 'lucide-vue-next'
import { Button } from '@/components/ui/button'
import UserSection from './UserSection.vue'
import SidebarNav from './SidebarNav.vue'
import type { NavLink } from '@/types/navigation'
Expand All @@ -8,10 +10,13 @@
const props = defineProps<{
open: boolean
links?: NavLink[]
desktopCollapsed?: boolean
collapsible?: boolean
}>()

const emit = defineEmits<{
close: []
collapse: []
open: []
}>()

Expand Down Expand Up @@ -117,12 +122,17 @@

<template>
<!-- Desktop sidebar -->
<aside class="hidden sm:flex flex-col w-64 flex-shrink-0 border-r border-sidebar-border bg-sidebar h-screen sticky top-0">
<div class="p-4 pt-5">
<UserSection :links="navLinks" />
<aside :class="desktopCollapsed ? 'hidden' : 'hidden sm:flex'" class="flex-col w-64 flex-shrink-0 border-r border-sidebar-border bg-sidebar h-dvh sticky top-0 overflow-hidden">
<div class="shrink-0 flex items-center gap-1 p-4 pt-5">
<div class="min-w-0 flex-1"><UserSection :links="navLinks" /></div>

Check warning on line 127 in alfy-bot-frontend/src/components/AppSidebar.vue

View workflow job for this annotation

GitHub Actions / Frontend (alfy-bot-frontend)

Expected 1 line break before closing tag (`</div>`), but no line breaks found

Check warning on line 127 in alfy-bot-frontend/src/components/AppSidebar.vue

View workflow job for this annotation

GitHub Actions / Frontend (alfy-bot-frontend)

Expected 1 line break after opening tag (`<div>`), but no line breaks found
<Button v-if="collapsible" variant="ghost" size="icon" class="shrink-0" aria-label="Скрыть боковое меню" title="Скрыть боковое меню" @click="emit('collapse')">
<PanelLeftClose class="h-5 w-5" />
</Button>
</div>
<div class="min-h-0 flex-1 overflow-y-auto overscroll-contain" data-sidebar-scroll>
<SidebarNav v-if="links?.length" :links="links" />
<slot name="section-extra" />
</div>
<SidebarNav v-if="links?.length" :links="links" />
<slot name="section-extra" />
</aside>

<!-- Mobile: edge detector for swipe-to-open + sliding panel -->
Expand All @@ -147,18 +157,23 @@
@click="emit('close')"
/>
<aside
class="absolute left-0 top-0 h-full w-72 bg-sidebar border-r border-sidebar-border shadow-lg"
class="absolute left-0 top-0 h-full w-72 flex flex-col overflow-hidden bg-sidebar border-r border-sidebar-border shadow-lg"
:style="[panelStyle, { touchAction: 'pan-y' }]"
@touchstart.passive="onTouchStart($event, 'close')"
@touchmove.passive="onTouchMove"
@touchend="onTouchEnd"
@touchcancel="resetDrag"
>
<div class="p-4 pt-5">
<UserSection :links="navLinks" />
<div class="shrink-0 flex items-center gap-1 p-4 pt-5">
<div class="min-w-0 flex-1"><UserSection :links="navLinks" /></div>

Check warning on line 168 in alfy-bot-frontend/src/components/AppSidebar.vue

View workflow job for this annotation

GitHub Actions / Frontend (alfy-bot-frontend)

Expected 1 line break before closing tag (`</div>`), but no line breaks found

Check warning on line 168 in alfy-bot-frontend/src/components/AppSidebar.vue

View workflow job for this annotation

GitHub Actions / Frontend (alfy-bot-frontend)

Expected 1 line break after opening tag (`<div>`), but no line breaks found
<Button variant="ghost" size="icon" class="shrink-0" aria-label="Закрыть боковое меню" @click="emit('close')">
<PanelLeftClose class="h-5 w-5" />
</Button>
</div>
<div class="min-h-0 flex-1 overflow-y-auto overscroll-contain" data-sidebar-scroll>
<SidebarNav v-if="links?.length" :links="links" />
<slot name="section-extra" />
</div>
<SidebarNav v-if="links?.length" :links="links" />
<slot name="section-extra" />
</aside>
</div>
</Teleport>
Expand Down
33 changes: 33 additions & 0 deletions alfy-bot-frontend/src/features/projects/lib/project-tree-drag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { ProjectTreeNode } from '../model/types'

export const PROJECT_INDENT = 20
export interface ProjectTreeRow { node: ProjectTreeNode, depth: number }
export interface ProjectDestination { parentId: string | null, beforeId: string | null, depth: number, index: number }

/** Возвращает видимые строки дерева, исключая переносимую ветку целиком. */
export function flattenProjects(nodes: ProjectTreeNode[], collapsed: Set<string>, excludedId: string | null): ProjectTreeRow[] {
const result: ProjectTreeRow[] = []
const visit = (items: ProjectTreeNode[], depth: number) => {
for (const node of items) {
if (node.id === excludedId)
continue
result.push({ node, depth })
if (!collapsed.has(node.id))
visit(node.children, depth + 1)
}
}
visit(nodes, 0)
return result
}

/** Вычисляет родителя и соседа по месту вставки и желаемой глубине; index относится к строкам без переносимой ветки. */
export function projectDestination(rows: ProjectTreeRow[], index: number, desiredDepth: number): ProjectDestination {
const previous = rows[index - 1]
const depth = Math.max(0, Math.min(desiredDepth, previous ? previous.depth + 1 : 0))
const parent = depth === 0 ? null : rows.slice(0, index).reverse().find(row => row.depth === depth - 1)
const parentId = parent?.node.id ?? null
while (rows[index] && rows[index]!.depth > depth) index++
const next = rows[index]
const beforeId = next?.depth === depth && next.node.parentId === parentId ? next.node.id : null
return { parentId, beforeId, depth, index }
}
Loading
Loading