Phase 8: Project Management, find bar, presence and motion
The Project Management screen (/pm, view only) with Overview, Projects & units, Bottlenecks & aging, Hours vs target, Quality & issues and Find jobs, the period picker, health per unit and per project, drill down, Excel (CSV) per table and for all, and the PESCO production status report PDF with the controlled-copy stamp; every export logged as "report exported". The find bar on every home screen: the full search set, the dropdowns, quick flags with Mine, the flag kinds, Board and List with sorts, filters saved per browser; every filter applied by the server on the list and the boards, with facets. Presence in packets with role, lock and revoke drop; the motion switch with reduced motion honoured, card glides, glow and count-up; Back restores the scroll spot; sheet placement and the iPad layout pass. The data book compared page by page with the old build and six layout differences fixed. Tests for the PM aggregates, search, filters, presence and exports; Playwright scenarios for the PM screen, the find bar and presence at desktop and iPad viewports. Docs updated; PLAN.md questions 38 to 42. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
@@ -8,8 +8,10 @@ Every mutating answer is the full read model.
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from datetime import UTC, date, datetime
|
||||
from decimal import Decimal
|
||||
from typing import Any, Literal
|
||||
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||
|
||||
from fastapi import APIRouter, Depends, Query, Request
|
||||
from psycopg.types.json import Jsonb
|
||||
@@ -18,7 +20,7 @@ from pydantic import BaseModel, Field
|
||||
from .. import audit, events, policy
|
||||
from ..domain import assets as asset_store
|
||||
from ..domain import ncr as ncrs
|
||||
from ..domain import packets, shop
|
||||
from ..domain import packets, search, shop
|
||||
from ..domain import qc as qc_dom
|
||||
from ..domain.pipeline import (
|
||||
Expect,
|
||||
@@ -294,32 +296,69 @@ def _pp(d: Db, p: Principal) -> policy.Principal:
|
||||
# ---------------------------------------------------------------- list and read
|
||||
|
||||
|
||||
@router.get("")
|
||||
def list_packets(
|
||||
p: Principal = Depends(current_principal), # noqa: B008
|
||||
d: Db = Depends(get_db), # noqa: B008
|
||||
def site_today(request: Request) -> date:
|
||||
"""Today in the site time zone (settings.site_tz), once per request."""
|
||||
try:
|
||||
tz: Any = ZoneInfo(settings_of(request).site_tz)
|
||||
except (ZoneInfoNotFoundError, ValueError):
|
||||
tz = UTC
|
||||
return datetime.now(tz).date()
|
||||
|
||||
|
||||
def find_query(
|
||||
q: str = Query("", max_length=200),
|
||||
status: str = Query("", max_length=200),
|
||||
dept: str = Query("", max_length=10),
|
||||
station_id: int | None = Query(None, ge=1, le=2**62),
|
||||
welder_id: str = Query("", max_length=40),
|
||||
flags: str = Query("", max_length=100),
|
||||
flag: str = Query("", max_length=20),
|
||||
sort: str = Query("", max_length=20),
|
||||
mine_screen: str = Query("", max_length=20),
|
||||
mine_station_id: int | None = Query(None, ge=1, le=2**62),
|
||||
) -> dict[str, Any]:
|
||||
"""The find bar's query values, shared by GET /api/packets, the boards and the PM reports."""
|
||||
return {
|
||||
"q": q,
|
||||
"status": status,
|
||||
"dept": dept,
|
||||
"station_id": station_id,
|
||||
"welder_id": welder_id,
|
||||
"flags": flags,
|
||||
"flag": flag,
|
||||
"sort": sort,
|
||||
"mine_screen": mine_screen,
|
||||
"mine_station_id": mine_station_id,
|
||||
}
|
||||
|
||||
|
||||
FIND = Depends(find_query)
|
||||
|
||||
|
||||
@router.get("")
|
||||
def list_packets(
|
||||
request: Request,
|
||||
p: Principal = Depends(current_principal), # noqa: B008
|
||||
d: Db = Depends(get_db), # noqa: B008
|
||||
find: dict[str, Any] = FIND,
|
||||
unit_id: int | None = Query(None),
|
||||
project_id: int | None = Query(None),
|
||||
q: str = Query("", max_length=200),
|
||||
flag: str = Query("", max_length=20),
|
||||
co: str = Query("", max_length=20),
|
||||
facets: int = Query(0, ge=0, le=1),
|
||||
limit: int = Query(500, ge=1, le=2000),
|
||||
removed: int = Query(0, ge=0, le=1),
|
||||
) -> dict[str, Any]:
|
||||
filters = {
|
||||
"status": status,
|
||||
"dept": dept.strip() or None,
|
||||
"unit_id": unit_id,
|
||||
"project_id": project_id,
|
||||
"q": clean_text(q, 200),
|
||||
"flag": flag,
|
||||
"co": co.strip().lower() or None,
|
||||
"limit": limit,
|
||||
"removed": bool(removed) and p.is_admin,
|
||||
}
|
||||
return {"packets": packets.list_cards(d.conn, _pp(d, p), filters)}
|
||||
"""The cards for a list. The find bar's filters are applied here; `facets=1` adds the stations and workers
|
||||
among the packets in the project and unit scope."""
|
||||
pp = _pp(d, p)
|
||||
filters = search.parse_filters(
|
||||
{**find, "unit_id": unit_id, "project_id": project_id}, pp, screen=None, today=site_today(request)
|
||||
)
|
||||
filters.update({"co": co.strip().lower() or None, "limit": limit, "removed": bool(removed) and p.is_admin})
|
||||
out: dict[str, Any] = {"packets": packets.list_cards(d.conn, pp, filters)}
|
||||
if facets:
|
||||
out["facets"] = search.facets(d.conn, project_id=project_id, unit_id=unit_id)
|
||||
return out
|
||||
|
||||
|
||||
@router.post("", status_code=201, dependencies=WRITE)
|
||||
|
||||
Reference in New Issue
Block a user