feat: implement soft delete, task editing fixes, and UI improvements

Backend:
- Add soft delete for spaces and projects (is_active flag)
- Add status_id and assignee_id to TaskUpdate schema
- Fix task PATCH endpoint to update status and assignee
- Add validation for assignee_id and status_id in task updates
- Fix health service to count tasks with "Blocked" status as blockers
- Filter out deleted spaces/projects from health dashboard
- Add workload cache invalidation on assignee changes

Frontend:
- Add delete confirmation dialogs for spaces and projects
- Fix UserSelect to display selected user name (valueName prop)
- Fix task detail modal to refresh data after save
- Enforce 2-level subtask depth limit in UI
- Fix timezone bug in date formatting (use local timezone)
- Convert NotificationBell from Tailwind to inline styles
- Add i18n translations for health, workload, settings pages
- Add parent_task_id to Task interface across components

OpenSpec:
- Archive add-delete-capability change

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beabigegg
2026-01-10 01:32:13 +08:00
parent 2796cbb42d
commit 55f85d0d3c
44 changed files with 1854 additions and 297 deletions

View File

@@ -9,7 +9,7 @@ from typing import List, Optional, Dict, Any
from sqlalchemy.orm import Session
from app.models import Project, Task, TaskStatus, Blocker, ProjectHealth
from app.models import Project, Task, TaskStatus, Blocker, ProjectHealth, Space
from app.schemas.project_health import (
RiskLevel,
ScheduleStatus,
@@ -83,15 +83,25 @@ def calculate_health_metrics(db: Session, project: Project) -> Dict[str, Any]:
and not (task.status and task.status.is_done)
)
# Count unresolved blockers
# Count unresolved blockers from Blocker table
task_ids = [t.id for t in tasks]
blocker_count = 0
blocker_table_count = 0
if task_ids:
blocker_count = db.query(Blocker).filter(
blocker_table_count = db.query(Blocker).filter(
Blocker.task_id.in_(task_ids),
Blocker.resolved_at.is_(None)
).count()
# Also count tasks with "Blocked" status (status name contains 'block', case-insensitive)
blocked_status_count = sum(
1 for task in tasks
if task.status and task.status.name and 'block' in task.status.name.lower()
and not task.status.is_done
)
# Total blocker count = blocker table records + tasks with blocked status
blocker_count = blocker_table_count + blocked_status_count
# Calculate completion rate
completion_rate = 0.0
if task_count > 0:
@@ -234,7 +244,11 @@ def get_project_health(
Returns:
ProjectHealthWithDetails or None if project not found
"""
project = db.query(Project).filter(Project.id == project_id).first()
project = db.query(Project).join(Space, Project.space_id == Space.id).filter(
Project.id == project_id,
Project.is_active == True,
Space.is_active == True
).first()
if not project:
return None
@@ -261,7 +275,10 @@ def get_all_projects_health(
Returns:
ProjectHealthDashboardResponse with projects list and summary
"""
query = db.query(Project)
query = db.query(Project).join(Space, Project.space_id == Space.id).filter(
Project.is_active == True,
Space.is_active == True
)
if status_filter:
query = query.filter(Project.status == status_filter)
@@ -314,12 +331,21 @@ def _build_health_with_details(
def _calculate_summary(
projects_health: List[ProjectHealthWithDetails]
) -> ProjectHealthSummary:
"""Calculate summary statistics for health dashboard."""
"""Calculate summary statistics for health dashboard.
Thresholds match _determine_risk_level():
- healthy (low risk): >= 80
- at_risk (medium risk): 60-79
- high_risk (high risk): 40-59
- critical (critical risk): < 40
"""
total_projects = len(projects_health)
healthy_count = sum(1 for p in projects_health if p.health_score >= 80)
at_risk_count = sum(1 for p in projects_health if 50 <= p.health_score < 80)
critical_count = sum(1 for p in projects_health if p.health_score < 50)
# Use consistent thresholds with risk_level calculation
healthy_count = sum(1 for p in projects_health if p.health_score >= RISK_LOW_THRESHOLD)
at_risk_count = sum(1 for p in projects_health if RISK_MEDIUM_THRESHOLD <= p.health_score < RISK_LOW_THRESHOLD)
high_risk_count = sum(1 for p in projects_health if RISK_HIGH_THRESHOLD <= p.health_score < RISK_MEDIUM_THRESHOLD)
critical_count = sum(1 for p in projects_health if p.health_score < RISK_HIGH_THRESHOLD)
average_health_score = 0.0
if total_projects > 0:
@@ -335,6 +361,7 @@ def _calculate_summary(
total_projects=total_projects,
healthy_count=healthy_count,
at_risk_count=at_risk_count,
high_risk_count=high_risk_count,
critical_count=critical_count,
average_health_score=round(average_health_score, 1),
projects_with_blockers=projects_with_blockers,