feat: Daily Report two-zone picker with pre-add quantity entry

Split the Daily Report form into a top position picker (system filter,
live search) and a bottom added-items list grouped by system, with
quantity edit and remove. Switching systems no longer drops the added
list; A1->B1->A2 keeps all three.

Quantity can be entered in the picker before pressing Добавить and is
carried into the selected list; removing a position returns it to the
picker with the typed quantity intact. Draft quantities of never-added
positions stay out of POST via a submit guard, so they never become
Daily Report facts. Server rows are always rendered client-filtered;
POST contract and apply_quantities unchanged.
This commit is contained in:
Арсентьев Александр
2026-10-08 17:12:13 +03:00
parent a8be9db476
commit e7abc7c86c
8 changed files with 1513 additions and 61 deletions
+6 -4
View File
@@ -85,7 +85,7 @@ def _render_form(request, db, project_obj, system_id=None, report=None, errors=N
).order_by(boq.System.sort_order, boq.System.id).all()
unclassified_selected = token == "unclassified" or (report is not None and report.system_id is None and token is None)
selected_system = None
rows = []
selected_id = None
if token is not None:
if token == "unclassified":
if not unclassified:
@@ -99,13 +99,15 @@ def _render_form(request, db, project_obj, system_id=None, report=None, errors=N
selected_system = next((row for row in systems if row.id == selected_id), None)
if selected_system is None:
raise HTTPException(status_code=400, detail="System does not belong to this project effective plan")
rows = _report_rows(db, project_obj.id, selected_id, report.id if report else None,
all_systems=True)
# DOC-C10: always render every effective position — the picker filters by
# system client-side and switching systems must not drop already-added rows.
rows = _report_rows(db, project_obj.id, selected_id, report.id if report else None,
all_systems=True)
current = {line.work_item_id: line.completed_quantity for line in report.items} if report else {}
for row in rows:
row["current_quantity"] = current.get(row["item"].id)
row["over_plan"] = row["accumulated"] + Decimal(str(row["current_quantity"] or 0)) > row["planned_quantity"]
row["in_selection"] = row["item"].system_id == selected_id
row["in_selection"] = token is not None and row["item"].system_id == selected_id
return request.app.templates.TemplateResponse("projects/daily_report_form.html", {
"request": request, "project": project_obj, "systems": systems,
"has_unclassified_items": bool(unclassified), "unclassified_selected": unclassified_selected,