feat: return-to-project redirects from create/edit forms
When creating or editing items from a project detail tab, users now return to that project's tab instead of the entity's own page. Edit links pass from_project param; forms include hidden field. Reassigning to a different project redirects to the new project. Decisions/meetings create from project context inserts junction rows. File uploads from project context redirect back to project files tab. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -322,7 +322,7 @@ async def task_detail(
|
||||
|
||||
|
||||
@router.get("/{task_id}/edit")
|
||||
async def edit_form(task_id: str, request: Request, db: AsyncSession = Depends(get_db)):
|
||||
async def edit_form(task_id: str, request: Request, from_project: Optional[str] = None, db: AsyncSession = Depends(get_db)):
|
||||
repo = BaseRepository("tasks", db)
|
||||
sidebar = await get_sidebar_data(db)
|
||||
item = await repo.get(task_id)
|
||||
@@ -344,6 +344,7 @@ async def edit_form(task_id: str, request: Request, db: AsyncSession = Depends(g
|
||||
"page_title": f"Edit Task", "active_nav": "tasks",
|
||||
"item": item,
|
||||
"prefill_domain_id": "", "prefill_project_id": "", "prefill_parent_id": "",
|
||||
"from_project": from_project or "",
|
||||
})
|
||||
|
||||
|
||||
@@ -363,6 +364,7 @@ async def update_task(
|
||||
tags: Optional[str] = Form(None),
|
||||
estimated_minutes: Optional[str] = Form(None),
|
||||
energy_required: Optional[str] = Form(None),
|
||||
from_project: Optional[str] = Form(None),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
repo = BaseRepository("tasks", db)
|
||||
@@ -392,6 +394,13 @@ async def update_task(
|
||||
data["completed_at"] = None
|
||||
|
||||
await repo.update(task_id, data)
|
||||
|
||||
# Redirect back to project context if applicable
|
||||
new_project = data.get("project_id")
|
||||
if from_project and from_project.strip():
|
||||
if new_project and new_project != from_project:
|
||||
return RedirectResponse(url=f"/projects/{new_project}?tab=tasks", status_code=303)
|
||||
return RedirectResponse(url=f"/projects/{from_project}?tab=tasks", status_code=303)
|
||||
return RedirectResponse(url=f"/tasks/{task_id}", status_code=303)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user