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:
@@ -18,7 +18,7 @@ from psycopg.rows import dict_row
|
||||
from .. import policy
|
||||
from ..api import deps
|
||||
from ..api.errors import ApiError
|
||||
from . import checklists
|
||||
from . import checklists, search
|
||||
|
||||
HAND_FLAG = "Made by hand - check it and send it on"
|
||||
DRAWING_NEEDED_FLAG = "Made from VISUAL - drawing not attached yet"
|
||||
@@ -1246,7 +1246,7 @@ SELECT p.id, p.version, p.unit_id, u.lot, pr.number || u.lot AS unit_number, pr.
|
||||
st.name AS station_name, p.welder_id, wu.display_name AS welder_name, p.welder_stamp,
|
||||
p.routed_to::text AS routed_to, p.vclosed_at, p.vclosed_by, vu.display_name AS vclosed_name,
|
||||
p.source_kind::text AS source_kind, p.flags, p.drawing_state::text AS drawing_state, p.wh_skipped,
|
||||
p.heat_map, p.removed_at, coalesce(u.due, pr.due) AS due_effective, p.updated_at, p.visual,
|
||||
p.heat_map, p.removed_at, coalesce(u.due, pr.due) AS due_effective, p.updated_at, p.created_at, p.visual,
|
||||
p.visual_closed_at, p.visual_cancelled_at, p.wo_gone_at,
|
||||
EXISTS (SELECT 1 FROM change_orders c WHERE c.packet_id = p.id AND c.review = 'pending'
|
||||
AND c.origin IN ('visual', 'drawing')) AS co_pending,
|
||||
@@ -1277,13 +1277,6 @@ LEFT JOIN LATERAL (
|
||||
) bc ON true
|
||||
"""
|
||||
|
||||
FLAG_ON = ("1", "true", "yes", "any", "flagged")
|
||||
FLAG_OFF = ("0", "false", "no", "none")
|
||||
|
||||
|
||||
def _like(word: str) -> str:
|
||||
return "%" + word.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_") + "%"
|
||||
|
||||
|
||||
def card_state(r: Mapping[str, Any], names: Mapping[str, str]) -> policy.PacketState:
|
||||
"""PacketState from header columns and counts. Child-row facts the board does not load pass (the packet
|
||||
@@ -1331,7 +1324,8 @@ def wh_card(r: Mapping[str, Any]) -> dict[str, Any] | None:
|
||||
|
||||
|
||||
def card_where(filters: Mapping[str, Any]) -> tuple[list[str], list[Any]]:
|
||||
"""The WHERE terms and parameters of the card filters, over CARD_SQL's aliases (p, u, pr)."""
|
||||
"""The WHERE terms and parameters of the card filters, over CARD_SQL's aliases (p, u, pr, d, st, wu). The find
|
||||
bar terms (status words, q, flag, flags, station_id, welder_id) come from domain/search.py."""
|
||||
where: list[str] = []
|
||||
params: list[Any] = []
|
||||
if filters.get("ids") is not None:
|
||||
@@ -1339,7 +1333,7 @@ def card_where(filters: Mapping[str, Any]) -> tuple[list[str], list[Any]]:
|
||||
params.append([int(i) for i in filters["ids"]])
|
||||
if not filters.get("removed"):
|
||||
where.append("p.removed_at IS NULL")
|
||||
status = [s.strip() for s in str(filters.get("status") or "").split(",") if s.strip()]
|
||||
status = search.status_terms(str(filters.get("status") or ""))
|
||||
if status:
|
||||
where.append("p.status::text = ANY(%s)")
|
||||
params.append(status)
|
||||
@@ -1352,55 +1346,29 @@ def card_where(filters: Mapping[str, Any]) -> tuple[list[str], list[Any]]:
|
||||
if filters.get("project_id") is not None:
|
||||
where.append("u.project_id = %s")
|
||||
params.append(int(filters["project_id"]))
|
||||
flag = str(filters.get("flag") or "").strip().lower()
|
||||
if flag in FLAG_ON:
|
||||
where.append(FLAG_SQL)
|
||||
elif flag in FLAG_OFF:
|
||||
where.append("NOT " + FLAG_SQL)
|
||||
elif flag == "hand":
|
||||
# Made by hand, or a VISUAL draft with a drawing or BOM uploaded by hand.
|
||||
where.append("(p.status = 'draft' AND (p.source_kind = 'hand' OR p.flags && %s::text[]))")
|
||||
params.append(list(HAND_UPLOAD_FLAGS))
|
||||
elif flag in ("hand_upload", "hand_uploads"):
|
||||
where.append("(p.status = 'draft' AND p.flags && %s::text[])")
|
||||
params.append(list(HAND_UPLOAD_FLAGS))
|
||||
elif flag and RX_FLAG_KIND.match(flag):
|
||||
# One flag kind on the Flagged board (drafts). A visual draft whose flags are empty but whose drawing state
|
||||
# still names the problem counts too, the same way flag_of reads it.
|
||||
states = [st for st, k in STATE_KINDS.items() if k == flag]
|
||||
where.append(
|
||||
"(p.status = 'draft' AND (%s = ANY(p.flags) OR (cardinality(p.flags) = 0 AND p.source_kind = 'visual'"
|
||||
" AND p.drawing_state::text = ANY(%s))))"
|
||||
)
|
||||
params += [flag, states]
|
||||
co = str(filters.get("co") or "").strip().lower()
|
||||
if co == "pending":
|
||||
where.append(CO_PENDING_SQL)
|
||||
for word in str(filters.get("q") or "").split()[:8]:
|
||||
pat = _like(word)
|
||||
where.append(
|
||||
"(pr.number ILIKE %s OR pr.name ILIKE %s OR (pr.number || u.lot) ILIKE %s OR u.lot ILIKE %s"
|
||||
" OR p.drawing ILIKE %s OR p.customer ILIKE %s OR pr.customer ILIKE %s OR pr.po ILIKE %s"
|
||||
" OR p.title ILIKE %s OR EXISTS (SELECT 1 FROM packet_work_orders wo WHERE wo.packet_id = p.id"
|
||||
" AND wo.wo_base ILIKE %s))"
|
||||
)
|
||||
params += [pat] * 10
|
||||
return where, params
|
||||
w, p = search.filter_where(filters)
|
||||
return where + w, params + p
|
||||
|
||||
|
||||
def list_cards(conn: Any, policy_principal: policy.Principal, filters: Mapping[str, Any]) -> list[dict[str, Any]]:
|
||||
"""The board cards. Filters: status (comma list), dept, unit_id, project_id, q, flag (1|0|hand|hand_upload|
|
||||
<kind>), co (pending), ids (packet ids), limit, removed."""
|
||||
"""The board cards. Filters: status (comma list of raw statuses or find bar words), dept, unit_id, project_id,
|
||||
q, flag (a flag kind value or the old raw values), flags (quick flags; mine needs a MineScope in `mine`),
|
||||
station_id, welder_id, co (pending), ids (packet ids), sort (updated|project|due|status|dept), limit, removed,
|
||||
lite (skip `can` and `blocked`, for the reports)."""
|
||||
where, params = card_where(filters)
|
||||
sql = CARD_SQL + (" WHERE " + " AND ".join(where) if where else "")
|
||||
sql += " ORDER BY p.updated_at DESC, p.id DESC LIMIT %s"
|
||||
sql += " ORDER BY " + search.order_by(filters.get("sort")) + " LIMIT %s"
|
||||
params.append(int(filters.get("limit") or 500))
|
||||
lite = bool(filters.get("lite"))
|
||||
names = dept_labels(conn)
|
||||
transitions = {str(a) for a in policy.TRANSITIONS}
|
||||
out: list[dict[str, Any]] = []
|
||||
for r in rows(conn, sql, params):
|
||||
state = card_state(r, names)
|
||||
allowed, blocked = policy.can(policy_principal, state)
|
||||
allowed, blocked = ([], {}) if lite else policy.can(policy_principal, state)
|
||||
welder = (
|
||||
None
|
||||
if r["welder_id"] is None
|
||||
@@ -1448,6 +1416,7 @@ def list_cards(conn: Any, policy_principal: policy.Principal, filters: Mapping[s
|
||||
"bom_missing_heat": int(r["bom_missing_heat"] or 0),
|
||||
"due_effective": r["due_effective"],
|
||||
"updated_at": r["updated_at"],
|
||||
"created_at": r["created_at"],
|
||||
"holder": policy.holder_name(state, r["dept_name"], r["station_name"]),
|
||||
"can": [str(a) for a in allowed if str(a) in transitions],
|
||||
"blocked": {str(a): v for a, v in blocked.items() if str(a) in transitions},
|
||||
|
||||
Reference in New Issue
Block a user