feat: implement custom fields, gantt view, calendar view, and file encryption
- Custom Fields (FEAT-001): - CustomField and TaskCustomValue models with formula support - CRUD API for custom field management - Formula engine for calculated fields - Frontend: CustomFieldEditor, CustomFieldInput, ProjectSettings page - Task list API now includes custom_values - KanbanBoard displays custom field values - Gantt View (FEAT-003): - TaskDependency model with FS/SS/FF/SF dependency types - Dependency CRUD API with cycle detection - start_date field added to tasks - GanttChart component with Frappe Gantt integration - Dependency type selector in UI - Calendar View (FEAT-004): - CalendarView component with FullCalendar integration - Date range filtering API for tasks - Drag-and-drop date updates - View mode switching in Tasks page - File Encryption (FEAT-010): - AES-256-GCM encryption service - EncryptionKey model with key rotation support - Admin API for key management - Encrypted upload/download for confidential projects - Migrations: 011 (custom fields), 012 (encryption keys), 013 (task dependencies) - Updated issues.md with completion status 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
# Proposal: Add Custom Fields
|
||||
|
||||
**Change ID:** `add-custom-fields`
|
||||
**Issue Reference:** `FEAT-001` (issues.md)
|
||||
**Status:** Draft
|
||||
**Author:** Claude
|
||||
**Date:** 2026-01-05
|
||||
|
||||
## Summary
|
||||
|
||||
實作自定義欄位功能,允許專案管理者為任務新增自定義欄位,包含文字、數字、下拉選單、日期、人員標籤和公式等類型。
|
||||
|
||||
## Motivation
|
||||
|
||||
目前系統僅支援固定的任務欄位(標題、描述、狀態、優先級等)。不同專案可能需要追蹤特定資料,例如:
|
||||
- 半導體製程:封裝類型、機台編號、預計良率
|
||||
- 軟體開發:Sprint 編號、Story Points、影響版本
|
||||
- 行銷活動:活動代碼、預算類別、目標受眾
|
||||
|
||||
自定義欄位讓專案管理者可以根據需求彈性擴展任務資料結構。
|
||||
|
||||
## Scope
|
||||
|
||||
### In Scope
|
||||
- Backend: CustomField 和 TaskCustomValue models
|
||||
- Backend: Custom fields CRUD API endpoints
|
||||
- Backend: Formula field 計算引擎
|
||||
- Frontend: Custom fields 管理 UI(專案設定頁面)
|
||||
- Frontend: Task form 動態渲染自定義欄位
|
||||
- Frontend: Task list/kanban 顯示自定義欄位值
|
||||
|
||||
### Out of Scope
|
||||
- 跨專案共用欄位定義
|
||||
- 自定義欄位匯入/匯出
|
||||
- 複雜公式函數(僅支援基本數學運算)
|
||||
|
||||
## Design Decisions
|
||||
|
||||
### 欄位類型
|
||||
| Type | 說明 | 儲存格式 |
|
||||
|------|------|----------|
|
||||
| text | 單行文字 | VARCHAR |
|
||||
| number | 數字 | DECIMAL |
|
||||
| dropdown | 下拉選單 | VARCHAR (選項儲存於 options JSON) |
|
||||
| date | 日期 | DATE |
|
||||
| person | 人員標籤 | UUID (FK -> users) |
|
||||
| formula | 公式計算 | DECIMAL (計算結果) |
|
||||
|
||||
### 公式欄位
|
||||
- 支援基本數學運算:`+`, `-`, `*`, `/`
|
||||
- 可引用其他數字欄位:`{field_name}`
|
||||
- 可引用任務內建欄位:`{original_estimate}`, `{time_spent}`
|
||||
- 範例公式:`{time_spent} / {original_estimate} * 100`
|
||||
|
||||
### API 設計
|
||||
```
|
||||
POST /api/projects/{project_id}/custom-fields # 新增欄位定義
|
||||
GET /api/projects/{project_id}/custom-fields # 列出所有欄位
|
||||
PUT /api/custom-fields/{field_id} # 更新欄位定義
|
||||
DELETE /api/custom-fields/{field_id} # 刪除欄位(含所有值)
|
||||
|
||||
# 欄位值透過現有 task API 操作
|
||||
PUT /api/tasks/{task_id} # body 包含 custom_values
|
||||
```
|
||||
|
||||
## Affected Specs
|
||||
|
||||
| Spec | Change Type |
|
||||
|------|-------------|
|
||||
| task-management | MODIFIED (Custom Fields requirement 實作細節) |
|
||||
|
||||
## Risks & Mitigations
|
||||
|
||||
| Risk | Mitigation |
|
||||
|------|------------|
|
||||
| 公式欄位循環引用 | 建立欄位時驗證公式不引用自己或形成循環 |
|
||||
| 大量自定義欄位影響效能 | 限制每專案最多 20 個自定義欄位 |
|
||||
| 刪除欄位遺失資料 | 刪除前顯示確認對話框,說明將刪除所有相關值 |
|
||||
|
||||
## Dependencies
|
||||
|
||||
- 無外部依賴
|
||||
- 需要現有 tasks API 支援
|
||||
@@ -0,0 +1,54 @@
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Custom Fields
|
||||
系統 SHALL 支援自定義欄位,包含下拉選單、公式、人員標籤等類型。
|
||||
|
||||
#### Scenario: 新增自定義欄位
|
||||
- **GIVEN** 專案管理者需要追蹤特定資料(如:封裝類型、機台編號、預計良率)
|
||||
- **WHEN** 管理者在專案中新增自定義欄位
|
||||
- **THEN** 系統建立欄位定義並套用至該專案所有任務
|
||||
|
||||
#### Scenario: 編輯自定義欄位
|
||||
- **GIVEN** 專案已有自定義欄位
|
||||
- **WHEN** 管理者修改欄位名稱或選項
|
||||
- **THEN** 系統更新欄位定義
|
||||
- **AND** 現有任務的欄位值保持不變
|
||||
|
||||
#### Scenario: 刪除自定義欄位
|
||||
- **GIVEN** 專案已有自定義欄位且有任務包含該欄位的值
|
||||
- **WHEN** 管理者刪除該欄位
|
||||
- **THEN** 系統顯示確認對話框說明將刪除所有相關值
|
||||
- **AND** 確認後刪除欄位定義及所有任務的該欄位值
|
||||
|
||||
#### Scenario: 公式欄位計算
|
||||
- **GIVEN** 任務包含公式類型的自定義欄位
|
||||
- **WHEN** 相依欄位的值發生變更
|
||||
- **THEN** 系統自動重新計算公式欄位的值
|
||||
|
||||
#### Scenario: 公式欄位循環引用檢查
|
||||
- **GIVEN** 管理者建立公式欄位
|
||||
- **WHEN** 公式引用自己或形成循環引用
|
||||
- **THEN** 系統拒絕建立並顯示錯誤訊息
|
||||
|
||||
#### Scenario: 人員標籤欄位
|
||||
- **GIVEN** 任務包含人員標籤類型的自定義欄位
|
||||
- **WHEN** 使用者選擇人員
|
||||
- **THEN** 系統驗證人員存在並建立關聯
|
||||
- **AND** 被標籤的人員可收到相關通知
|
||||
|
||||
#### Scenario: 下拉選單欄位
|
||||
- **GIVEN** 任務包含下拉選單類型的自定義欄位
|
||||
- **WHEN** 使用者選擇選項
|
||||
- **THEN** 系統儲存選擇的值
|
||||
- **AND** 選項列表由欄位定義提供
|
||||
|
||||
#### Scenario: 自定義欄位值顯示
|
||||
- **GIVEN** 任務有自定義欄位值
|
||||
- **WHEN** 使用者在列表或看板視角查看任務
|
||||
- **THEN** 自定義欄位值顯示在任務資訊中
|
||||
- **AND** 公式欄位顯示計算結果(唯讀)
|
||||
|
||||
#### Scenario: 欄位數量限制
|
||||
- **GIVEN** 專案已有 20 個自定義欄位
|
||||
- **WHEN** 管理者嘗試新增第 21 個欄位
|
||||
- **THEN** 系統拒絕新增並顯示數量已達上限的訊息
|
||||
@@ -0,0 +1,82 @@
|
||||
# Tasks: Add Custom Fields
|
||||
|
||||
## Backend Tasks
|
||||
|
||||
### 1. Create CustomField and TaskCustomValue models
|
||||
- [x] Create `backend/app/models/custom_field.py` with CustomField model
|
||||
- [x] Create `backend/app/models/task_custom_value.py` with TaskCustomValue model
|
||||
- [x] Update `backend/app/models/__init__.py` to export new models
|
||||
- [x] Create Alembic migration for new tables
|
||||
- **驗證**: Migration 成功執行,tables 建立正確
|
||||
|
||||
### 2. Create Custom Fields API endpoints
|
||||
- [x] Create `backend/app/api/custom_fields/router.py`
|
||||
- [x] Implement `POST /api/projects/{project_id}/custom-fields` - 新增欄位
|
||||
- [x] Implement `GET /api/projects/{project_id}/custom-fields` - 列出欄位
|
||||
- [x] Implement `PUT /api/custom-fields/{field_id}` - 更新欄位
|
||||
- [x] Implement `DELETE /api/custom-fields/{field_id}` - 刪除欄位
|
||||
- [x] Add permission checks (only project owner/manager can manage fields)
|
||||
- [x] Register router in main.py
|
||||
- **驗證**: API endpoints 可正常呼叫,權限檢查正確
|
||||
|
||||
### 3. Implement formula calculation engine
|
||||
- [x] Create `backend/app/services/formula_service.py`
|
||||
- [x] Implement formula parsing (extract field references)
|
||||
- [x] Implement formula validation (detect circular references)
|
||||
- [x] Implement formula calculation
|
||||
- [x] Add unit tests for formula service
|
||||
- **驗證**: 公式計算正確,循環引用被拒絕
|
||||
|
||||
### 4. Integrate custom values with Tasks API
|
||||
- [x] Modify `TaskCreate` schema to accept `custom_values`
|
||||
- [x] Modify `TaskUpdate` schema to accept `custom_values`
|
||||
- [x] Modify `TaskResponse` schema to include `custom_values`
|
||||
- [x] Update `create_task` endpoint to save custom values
|
||||
- [x] Update `update_task` endpoint to save custom values
|
||||
- [x] Update `get_task` endpoint to return custom values
|
||||
- [x] Trigger formula recalculation on value change
|
||||
- **驗證**: 任務 CRUD 包含自定義欄位值
|
||||
|
||||
### 5. Add backend tests
|
||||
- [x] Test custom field CRUD operations
|
||||
- [x] Test permission checks
|
||||
- [x] Test formula calculation
|
||||
- [x] Test task integration with custom values
|
||||
- **驗證**: 所有測試通過 (20/20 tests passed)
|
||||
|
||||
## Frontend Tasks
|
||||
|
||||
### 6. Create Custom Fields management UI
|
||||
- [x] Create `frontend/src/pages/ProjectSettings.tsx` or extend existing
|
||||
- [x] Create `frontend/src/components/CustomFieldEditor.tsx` - 欄位編輯表單
|
||||
- [x] Create `frontend/src/components/CustomFieldList.tsx` - 欄位列表
|
||||
- [x] Add custom fields API service in `frontend/src/services/customFields.ts`
|
||||
- **驗證**: 可在專案設定中管理自定義欄位
|
||||
|
||||
### 7. Dynamic field rendering in Task forms
|
||||
- [x] Create `frontend/src/components/CustomFieldInput.tsx` - 動態欄位輸入
|
||||
- [x] Integrate into TaskDetailModal.tsx
|
||||
- [x] Integrate into task creation form
|
||||
- [x] Handle different field types (text, number, dropdown, date, person)
|
||||
- [x] Display formula fields as read-only
|
||||
- **驗證**: 任務表單正確顯示和儲存自定義欄位
|
||||
|
||||
### 8. Display custom fields in task views
|
||||
- [x] Add custom field columns to List view
|
||||
- [x] Display custom field values in Kanban cards (optional, configurable)
|
||||
- [x] Add column visibility toggle for custom fields
|
||||
- **驗證**: 自定義欄位值在各視角中正確顯示
|
||||
|
||||
## Task Dependencies
|
||||
|
||||
```
|
||||
[1] Models -> [2] API -> [4] Task Integration -> [5] Tests
|
||||
\
|
||||
[3] Formula Engine /
|
||||
|
||||
[6] Management UI -> [7] Task Forms -> [8] View Display
|
||||
```
|
||||
|
||||
- Tasks 1-5 (Backend) 可平行於 Tasks 6-8 (Frontend) 開發
|
||||
- Task 2 完成後 Task 6 可開始(需要 API)
|
||||
- Task 4 完成後 Task 7 可開始(需要 Task API 支援 custom values)
|
||||
Reference in New Issue
Block a user