modify my task

This commit is contained in:
2026-03-01 11:30:40 +08:00
parent de59b57ee7
commit c8c4c99a6e
14 changed files with 696 additions and 91 deletions
@@ -0,0 +1,95 @@
## Context
此變更旨在為 VFX 專案管理系統新增一個「我的任務」(My Tasks) 頁面,讓用戶能夠在一個統一的視圖中查看所有專案中分配給自己的任務。目前用戶需要逐一進入每個專案才能看到被分配的任務,這對於同時管理多個專案的 Director、Coordinator 等角色而言效率較低。
現有系統已經具備:
- 完善的任務管理系統(Task entity with assignments
- 專案內的任務頁面(使用 DataTable 元件)
- 基於角色的存取控制 (RBAC)
- JWT 認證機制
## Goals / Non-Goals
**Goals:**
- 建立一個統一的「我的任務」頁面,展示所有分配給當前用戶的任務
- 重用現有的專案任務頁面 layout 與 DataTable 元件,確保 UI 一致性
- 支援按專案、狀態等條件篩選任務
- 支援任務排序功能
- 提供從任務列表直接導航到任務詳細頁面的功能
**Non-Goals:**
- 不會修改現有專案內的任務頁面行為
- 不會新增任務管理功能(如建立、編輯、刪除任務)- 這些應在專案上下文完成
- 不會提供跨專案的任務批量操作
## Decisions
### 1. API 設計:獨立端點 vs 擴展現有端點
**Decision**: 建立獨立的 `/api/tasks/my-tasks` 端點
**Rationale**:
- 獨立端點可讓權限過濾更清晰(僅顯示用戶有權限存取的專案任務)
- 回應格式可針對 My Tasks 視圖優化(如包含專案資訊)
- 未來擴展(如分頁、進階篩選)更彈性
**Alternative considered**: 擴展現有的 `/api/projects/{id}/tasks` 端點
- 這個方法需要傳遞多個專案 ID,不適合跨專案查詢場景
### 2. 前端架構:新建元件 vs 重用現有元件
**Decision**: 重用現有的 ProjectTaskPage layout 與 DataTable 元件
**Rationale**:
- 確保 UI/UX 一致性,用戶在專案內和 My Tasks 頁面有相同體驗
- 減少開發時間和維護成本
- DataTable 元件已經支援排序、篩選、分頁等功能
**Alternative considered**: 建立全新的 MyTasksPage 元件
- 需要重複實作相同功能,增加維護負擔
### 3. 權限模型:僅顯示有權限的任務
**Decision**: API 僅返回用戶有存取權限的專案任務
**Rationale**:
- 符合最小權限原則
- 避免資安風險(用戶不應看到無權限專案的任務)
- 與現有 RBAC 系統整合
### 4. 資料庫查詢策略
**Decision**: 單一查詢取得所有任務(而非多次查詢)
**Rationale**:
- 減少網路往返次數
- 雖然查詢較複雜,但可通過 SQLAlchemy 優化
- 考量未來加入分頁以處理大量任務
**Risks**:
- [Risk] 大型系統中任務數量可能很大 → **Mitigation**: 實作分頁機制
- [Risk] 跨專案查詢效能 → **Mitigation**: 確保 task.assignee_id 和 task.project_id 有適當索引
## Migration Plan
此變更為純新增功能,不需要資料遷移。部署步驟:
1. **後端部署**
- 部署新 API 端點 `/api/tasks/my-tasks`
- 確認任務查詢效能(如需要則新增資料庫索引)
2. **前端部署**
- 新增 My Tasks 頁面路由
- 確保導航選單有 My Tasks 入口
3. **驗證**
- 測試不同角色用戶的 My Tasks 顯示正確性
- 驗證篩選、排序功能正常運作
- 確認權限控制正確(無權限專案的任務不顯示)
## Open Questions
- **Q1**: My Tasks 頁面是否需要顯示任務的詳細進度(如 shot/asset 進度)?
- **目前建議**: 暫不包含,保持與專案任務頁面一致
- **Q2**: 是否需要支援「我的最愛」或「追蹤中」的任務功能?
- **目前建議**: 留待未來擴展
- **Q3**: 如何處理任務數量眾多的效能問題?
- **建議**: 採用分頁(預設 50 筆),並在未來根據需求考慮虛擬滾動
@@ -0,0 +1,31 @@
## Why
目前系統沒有提供一個統一的「我的任務」視圖,讓用戶能夠查看所有專案中分配給自己的任務。用戶需要逐一進入每個專案才能看到被分配的任務,這種體驗不夠效率。透過在 My Task 頁面整合顯示所有專案的任務,能夠提升用戶的工作效率,特別是對於需要同時管理多個專案的 Director、Coordinator 等角色。
## What Changes
- **新增 My Task 頁面**:在現有的導航系統中新增或強化 My Task 頁面入口
- **跨專案任務列表**:顯示所有專案中分配給當前登入用戶的任務
- **整合專案任務視圖**:使用現有專案內的 task page layout 與 data table 元件
- **篩選與排序功能**:支援依專案、狀態、優先級等條件篩選任務
- **快速導航**:點擊任務可直接跳轉至該任務所在專案的詳細頁面
## Capabilities
### New Capabilities
- `my-tasks-view`: 新增跨專案的「我的任務」視圖頁面,使用與專案任務頁面相同的 layout 與 data table 元件,呈現所有分配給當前用戶的任務
### Modified Capabilities
- (無)
## Impact
- **前端**
- 新增或修改 My Task 頁面元件
- 使用現有的 project task page layout 與 data table 元件
- 可能需要新增任務篩選與排序元件
- **後端**
- 新增 API 端點以取得用戶在所有專案中被分配的任務
- 需要考量權限過濾(只顯示有權限存取的專案任務)
- **資料庫**
- 可能需要針對任務查詢效能進行優化(如新增索引)
@@ -0,0 +1,68 @@
## ADDED Requirements
### Requirement: My Tasks View displays all tasks assigned to the current user across projects
The system SHALL provide a My Tasks page that displays a unified list of all tasks assigned to the currently logged-in user, aggregated from all projects where the user has access.
#### Scenario: User accesses My Tasks page
- **WHEN** the user navigates to the My Tasks page (e.g., /my-tasks)
- **THEN** the system SHALL display a list of all tasks assigned to the user across all accessible projects
#### Scenario: My Tasks page shows task details
- **WHEN** the My Tasks list is displayed
- **THEN** each task item SHALL display at minimum: task name, project name, status, due date, and assignee
#### Scenario: User can filter tasks by project
- **WHEN** the user selects a specific project from the project filter dropdown
- **THEN** the list SHALL display only tasks from the selected project
#### Scenario: User can filter tasks by status
- **WHEN** the user selects a specific status from the status filter dropdown
- **THEN** the list SHALL display only tasks with the selected status
#### Scenario: User can sort tasks
- **WHEN** the user clicks a column header to sort
- **THEN** the list SHALL be sorted by that column in ascending/descending order
### Requirement: My Tasks View uses project task page layout and data table
The system SHALL reuse the existing project task page layout and data table components for rendering the My Tasks list to ensure visual and behavioral consistency.
#### Scenario: My Tasks uses consistent layout
- **WHEN** the My Tasks page is rendered
- **THEN** it SHALL use the same layout structure as the project task page (header, filters, data table, pagination)
#### Scenario: My Tasks uses data table component
- **WHEN** the task list is rendered
- **THEN** it SHALL use the same DataTable component used in project task pages
#### Scenario: Task columns match project task page
- **WHEN** the My Tasks data table is displayed
- **THEN** it SHALL display columns consistent with the project task page (e.g., Name, Project, Status, Priority, Due Date, Assignee)
### Requirement: User can navigate to task details from My Tasks
The system SHALL allow users to click on a task in the My Tasks list to navigate directly to that task's detail page within its project context.
#### Scenario: User clicks on a task
- **WHEN** the user clicks on a task row in the My Tasks list
- **THEN** the system SHALL navigate to the task detail page in its project (e.g., /projects/{project_id}/tasks/{task_id})
### Requirement: My Tasks only shows accessible projects
The system SHALL only include tasks from projects where the current user has at least read access.
#### Scenario: User sees only accessible tasks
- **WHEN** the My Tasks list is loaded
- **THEN** tasks from projects where the user lacks access SHALL NOT be displayed
### Requirement: API endpoint returns user's tasks across projects
The system SHALL provide an API endpoint that returns all tasks assigned to the current user, with optional filtering parameters.
#### Scenario: API returns user's tasks
- **WHEN** a authenticated user requests GET /api/tasks/my-tasks
- **THEN** the system SHALL return a list of tasks assigned to that user
#### Scenario: API supports project filter
- **WHEN** the user requests GET /api/tasks/my-tasks?project_id={id}
- **THEN** the system SHALL return only tasks from the specified project
#### Scenario: API supports status filter
- **WHEN** the user requests GET /api/tasks/my-tasks?status={status}
- **THEN** the system SHALL return only tasks with the specified status
@@ -0,0 +1,42 @@
## 1. 後端 API 開發
- [x] 1.1 在 `backend/routers/tasks.py` 新增 `/tasks/my-tasks` 端點
- [x] 1.2 在 `backend/schemas/` 使用現有的 `TaskListResponse` schema
- [x] 1.3 在 router 中實作權限過濾邏輯(基本權限檢查)
- [x] 1.4 支援查詢參數 `project_id` 進行專案篩選
- [x] 1.5 支援查詢參數 `status` 進行狀態篩選
- [x] 1.6 支援分頁參數 `skip`, `limit`
## 2. 前端 - My Tasks 頁面
- [x] 2.1 修改 `frontend/src/views/TasksView.vue` 頁面使用新 API
- [x] 2.2 使用現有的 `/tasks` 路由
- [x] 2.3 使用現有的導航選單入口
## 3. 前端 - 重用現有元件
- [x] 3.1 在 TasksView 中使用 TaskList 元件顯示任務列表
- [x] 3.2 在 TasksView 中使用 TaskDetailPanel 顯示任務詳細
- [x] 3.3 使用 TasksDataTable 顯示正確的欄位
## 4. 前端 - 篩選與排序功能
- [x] 4.1 在 TasksView 中新增專案篩選下拉選單
- [x] 4.2 在 TasksView 中新增狀態篩選下拉選單
- [x] 4.3 確認 DataTable 的排序功能正常運作
- [x] 4.4 呼叫後端 API 時傳遞篩選參數
## 5. 前端 - 導航功能
- [x] 5.1 實作點擊任務列顯示 TaskDetailPanel 功能
- [x] 5.2 實作雙擊任務導航到 `/projects/{project_id}/tasks?taskId={task_id}`
## 6. 測試與驗證
- [ ] 6.1 撰寫後端單元測試驗證 `/api/tasks/my-tasks` API
- [ ] 6.2 測試不同角色用戶的 My Tasks 顯示正確性
- [ ] 6.3 測試權限控制(無權限專案的任務不應顯示)
- [x] 6.4 測試篩選功能正確運作(API 已測試)
- [ ] 6.5 測試排序功能正確運作
- [x] 6.6 測試任務點擊顯示詳細功能
- [ ] 6.7 前端整合測試確保 My Tasks 頁面正常運作