feat: inline edit for patterns in library (name, description, category, direction, regime)

- Backend: PATCH /api/patterns/custom/{id} — partial update, only provided fields changed
- useApi.ts: usePatchPattern mutation hook
- PatternCard: pencil icon (non-builtin only) → edit mode with inline inputs for name, description, direction (select), category, and #regime; ✓/✗ buttons to save or cancel; card border highlights blue while editing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-22 21:13:34 +02:00
parent d794ad68aa
commit a2315c3b78
3 changed files with 156 additions and 31 deletions

View File

@@ -61,6 +61,34 @@ def update_pattern(pat_id: str, req: PatternRequest):
return {"id": pat_id, "status": "updated"}
class PatternPatchRequest(BaseModel):
name: Optional[str] = None
description: Optional[str] = None
category: Optional[str] = None
signal_direction: Optional[str] = None
regime_tag: Optional[str] = None
@router.patch("/custom/{pat_id}")
def patch_pattern(pat_id: str, req: PatternPatchRequest):
"""Partial update — only provided fields are changed."""
from services.database import get_conn
conn = get_conn()
if not conn.execute("SELECT id FROM custom_patterns WHERE id=?", (pat_id,)).fetchone():
conn.close()
raise HTTPException(404, "Pattern not found")
updates = {k: v for k, v in req.model_dump().items() if v is not None}
if updates:
set_clause = ", ".join(f"{k}=?" for k in updates)
conn.execute(
f"UPDATE custom_patterns SET {set_clause}, updated_at=datetime('now') WHERE id=?",
list(updates.values()) + [pat_id],
)
conn.commit()
conn.close()
return {"id": pat_id, "status": "updated", "fields": list(updates.keys())}
@router.delete("/purge-all")
def purge_all_patterns():
"""Delete ALL custom/backtested patterns from the pattern library."""