Rolodex UX: add /rolodex/{id}/edit route, prefill support for new form, fix edit links, and improve empty state guidance. Also fix header width lints in template.

This commit is contained in:
HotSwapp
2025-10-13 10:37:20 -05:00
parent 42ea13e413
commit 4cd35c66fd
3 changed files with 36 additions and 12 deletions

View File

@@ -2604,12 +2604,37 @@ async def rolodex_list(
@app.get("/rolodex/new")
async def rolodex_new(request: Request):
async def rolodex_new(
request: Request,
prefill: str | None = Query(None, alias="_prefill"),
db: Session = Depends(get_db),
):
user = get_current_user_from_session(request.session)
if not user:
return RedirectResponse(url="/login", status_code=302)
return templates.TemplateResponse("rolodex_edit.html", {"request": request, "user": user, "client": None})
client = None
if prefill:
try:
client_id = int(prefill)
client = db.query(Client).filter(Client.id == client_id).first()
except ValueError:
client = None
return templates.TemplateResponse("rolodex_edit.html", {"request": request, "user": user, "client": client})
@app.get("/rolodex/{client_id}/edit")
async def rolodex_edit(client_id: int, request: Request, db: Session = Depends(get_db)):
user = get_current_user_from_session(request.session)
if not user:
return RedirectResponse(url="/login", status_code=302)
client = db.query(Client).filter(Client.id == client_id).first()
if not client:
raise HTTPException(status_code=404, detail="Client not found")
return templates.TemplateResponse("rolodex_edit.html", {"request": request, "user": user, "client": client})
@app.get("/rolodex/{client_id}")