Skip to content

Commit e5d7631

Browse files
author
赵汝波
committed
Enhance task management with board view and improved UI components
- Implemented the first version of the board view for tasks, allowing users to visualize tasks by status. - Updated the project plan to reflect the addition of the "筛选结果概览" module and the board view feature. - Introduced keyboard shortcuts for focusing keyword search and improved URL management for view switching. - Refactored the `TasksView` component to support both list and board views, enhancing user experience. - Added new `TaskBoardCard` and `TasksBoard` components for better task organization and interaction.
1 parent edfbd23 commit e5d7631

8 files changed

Lines changed: 1072 additions & 810 deletions

File tree

PROJECT_PLAN.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
- [x] `P1` 展示最近 7 天新增趋势
124124
- [x] `P1` 展示项目分布情况
125125
- [ ] `P2` 新增“筛选结果概览”模块
126-
- [ ] `P2` 评估是否增加看板视图
126+
- [x] `P2` 看板视图第一版:`/tasks?view=board`,按状态分列(只读,未做拖拽)
127127

128128
---
129129

@@ -216,5 +216,6 @@
216216
- [x] Vitest:`date-query` 日历与区间(parse / normalize / filter)
217217
- [x] 任务优先级(`TaskPriority`)+ 截止日期(`dueDate`),列表/详情/新建/命令面板展示,URL `priority=` 筛选,排序 `due_asc` / `due_desc`
218218
- [x] `/tasks` 快捷键 `C`:打开新建任务 Sheet 并保留当前筛选参数
219+
- [x] `/tasks` 快捷键 `F`:聚焦关键词搜索;`Input` 改为 `forwardRef`
220+
- [x] 列表/看板切换写入 URL `view=`,命令面板「任务看板」入口
219221
- [x] Prisma 索引:`@@index([userId, dueDate])`
220-

src/app/projects/[id]/page.tsx

Lines changed: 78 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,93 @@
1-
import { auth } from "@/auth";
2-
import { CreateTaskSheet } from "@/components/create-task-sheet";
3-
import { TasksView } from "@/components/tasks-view";
4-
import { can } from "@/lib/acl";
5-
import { prisma } from "@/lib/db";
6-
import type { TaskListItem } from "@/types/task";
7-
import { notFound, redirect } from "next/navigation";
1+
import { auth } from '@/auth'
2+
import { CreateTaskSheet } from '@/components/create-task-sheet'
3+
import { TasksView } from '@/components/tasks-view'
4+
import { can } from '@/lib/acl'
5+
import { prisma } from '@/lib/db'
6+
import type { TaskListItem } from '@/types/task'
7+
import { notFound, redirect } from 'next/navigation'
88

99
interface ProjectDetailPageProps {
10-
params: Promise<{ id: string }>;
10+
params: Promise<{ id: string }>
1111
}
1212

1313
export default async function ProjectDetailPage({
14-
params,
14+
params,
1515
}: ProjectDetailPageProps) {
16-
const session = await auth();
17-
if (!session?.user?.id) {
18-
redirect("/login");
19-
}
16+
const session = await auth()
17+
if (!session?.user?.id) {
18+
redirect('/login')
19+
}
2020

21-
const { id } = await params;
21+
const { id } = await params
2222

23-
const project = await prisma.project.findUnique({
24-
where: { id },
25-
});
23+
const project = await prisma.project.findUnique({
24+
where: { id },
25+
})
2626

27-
if (!project) {
28-
notFound();
29-
}
27+
if (!project) {
28+
notFound()
29+
}
3030

31-
if (
32-
!can(session.user.id, "read", {
33-
type: "project",
34-
ownerId: project.userId,
35-
})
36-
) {
37-
notFound();
38-
}
31+
if (
32+
!can(session.user.id, 'read', {
33+
type: 'project',
34+
ownerId: project.userId,
35+
})
36+
) {
37+
notFound()
38+
}
3939

40-
const rows = await prisma.task.findMany({
41-
where: { projectId: id, userId: session.user.id },
42-
orderBy: { updatedAt: "desc" },
43-
include: { project: { select: { id: true, name: true } } },
44-
});
40+
const rows = await prisma.task.findMany({
41+
where: { projectId: id, userId: session.user.id },
42+
orderBy: { updatedAt: 'desc' },
43+
include: { project: { select: { id: true, name: true } } },
44+
})
4545

46-
const tasks: TaskListItem[] = rows.map((t) => ({
47-
id: t.id,
48-
title: t.title,
49-
description: t.description,
50-
status: t.status,
51-
priority: t.priority,
52-
dueDate: t.dueDate?.toISOString() ?? null,
53-
projectId: t.projectId,
54-
project: t.project,
55-
}));
46+
const tasks: TaskListItem[] = rows.map(t => ({
47+
id: t.id,
48+
title: t.title,
49+
description: t.description,
50+
status: t.status,
51+
priority: t.priority,
52+
dueDate: t.dueDate?.toISOString() ?? null,
53+
projectId: t.projectId,
54+
project: t.project,
55+
}))
5656

57-
return (
58-
<main className="mx-auto flex w-full max-w-4xl flex-1 flex-col gap-6 px-4 py-12">
59-
<section className="flex items-start justify-between gap-4">
60-
<div>
61-
<p className="font-mono text-xs uppercase tracking-wider text-zinc-400">
62-
Project
63-
</p>
64-
<h1 className="mt-1 text-2xl font-semibold tracking-tight text-zinc-900">
65-
{project.name}
66-
</h1>
67-
<p className="mt-2 text-sm text-zinc-500">
68-
仅项目所有者可访问;任务列表同样按用户隔离。
69-
</p>
70-
</div>
71-
<CreateTaskSheet
72-
projects={[{ id: project.id, name: project.name }]}
73-
defaultProjectId={project.id}
74-
/>
75-
</section>
57+
return (
58+
<main className='mx-auto flex w-full max-w-4xl flex-1 flex-col gap-6 px-4 py-12'>
59+
<section className='flex items-start justify-between gap-4'>
60+
<div>
61+
<p className='font-mono text-xs uppercase tracking-wider text-zinc-400'>
62+
Project
63+
</p>
64+
<h1 className='mt-1 text-2xl font-semibold tracking-tight text-zinc-900'>
65+
{project.name}
66+
</h1>
67+
<p className='mt-2 text-sm text-zinc-500'>
68+
仅项目所有者可访问;任务列表同样按用户隔离。
69+
</p>
70+
</div>
71+
<CreateTaskSheet
72+
projects={[{ id: project.id, name: project.name }]}
73+
defaultProjectId={project.id}
74+
/>
75+
</section>
7676

77-
<TasksView
78-
tasks={tasks}
79-
projects={[{ id: project.id, name: project.name }]}
80-
currentQuery={{
81-
keyword: "",
82-
status: "all",
83-
projectId: project.id,
84-
sort: "updated_desc",
85-
dateFrom: "",
86-
dateTo: "",
87-
priority: "all",
88-
}}
89-
/>
90-
</main>
91-
);
77+
<TasksView
78+
tasks={tasks}
79+
projects={[{ id: project.id, name: project.name }]}
80+
currentQuery={{
81+
keyword: '',
82+
status: 'all',
83+
projectId: project.id,
84+
sort: 'updated_desc',
85+
dateFrom: '',
86+
dateTo: '',
87+
priority: 'all',
88+
view: 'list',
89+
}}
90+
/>
91+
</main>
92+
)
9293
}

0 commit comments

Comments
 (0)