{# Ops Console semantic chip macros (V3 #208). Canonical label-to-semantic mapping for the Ops Console chip system. Import: {% from "fragments/_chips.html" import chip %} Usage: {{ chip("done") }} {{ chip("needs review") }} The mapping is the single source; R1-R6 consume it via the macro. Extending: add a row to CHIP_MAP below and the CSS class if needed. #} {# Map: label → (css_class, display_text). Labels are the canonical user-facing strings from the design spec (#208). "needs you" / "need you" are deprecated aliases kept for backward compat; the canonical label is "needs review" (S17 glossary). #} {% set CHIP_MAP = { "verified": ("chip-ok", "✓ verified"), "verified by you": ("chip-ok", "✓ verified by you"), "reviewed": ("chip-ok", "✓ reviewed"), "all reviewed": ("chip-ok", "✓ all reviewed"), "done": ("chip-ok", "Done"), "transcribing": ("chip-info", none), "needs review": ("chip-warn", "Needs review"), "needs you": ("chip-warn", "Needs review"), "need you": ("chip-warn", "Needs review"), "failed": ("chip-danger", "Failed"), "active": ("chip-ok", "Active"), "archived": ("chip-neutral", "Archived"), "watched": ("chip-neutral", "Watched"), "learned": ("chip-info", none), "unknown": ("chip-neutral", "Unknown"), "completed": ("chip-ok", "Completed"), "succeeded": ("chip-ok", "Completed"), "ready": ("chip-ok", "Ready"), "requeued": ("chip-ok", "Requeued"), "running": ("chip-info", "Running"), "working": ("chip-info", "Working"), "busy": ("chip-info", "Busy"), "queued": ("chip-neutral", "Queued"), "awaiting_adjudication": ("chip-warn", "Needs review"), "awaiting adjudication": ("chip-warn", "Needs review"), "cancelled": ("chip-neutral", "Cancelled"), "skipped": ("chip-neutral", "Skipped"), "idle": ("chip-neutral", "Idle"), "no speakers": ("chip-neutral", "No speakers"), "paused": ("chip-warn", "Paused"), "unverified": ("chip-warn", "Unverified"), "restart pending": ("chip-warn", "Restart pending"), "disabled": ("chip-warn", "Disabled"), "enabled": ("chip-ok", "Enabled"), "interrupted": ("chip-warn", "Interrupted"), "out of date": ("chip-danger", "Out of date"), } %} {# Count-inflected "needs review" chip. Owns BOTH the inflection and the warn class, so call sites cannot drift into subject-verb disagreement or fall through the exact-key chip() lookup to chip-neutral. #} {% macro needs_review_chip(count) -%} {{ count }} voice{{ "s" if count != 1 else "" }} need{{ "s" if count == 1 else "" }} review {%- endmacro %} {% macro chip(label, extra_class="") -%} {%- set parts = label.split() -%} {%- set key = parts[0]|lower if parts and parts[0]|lower in ["transcribing", "learned"] else label.lower() -%} {%- set entry = CHIP_MAP.get(key, ("chip-neutral", none)) -%} {{ entry[1] or label }} {%- endmacro %}