Skip to content

feat(admin/contagens): nova-contagem form with topology + flow diagram - #161

Open
iacapuca wants to merge 2 commits into
feat/admin-areafrom
feat/admin-nova-contagem
Open

feat(admin/contagens): nova-contagem form with topology + flow diagram#161
iacapuca wants to merge 2 commits into
feat/admin-areafrom
feat/admin-nova-contagem

Conversation

@iacapuca

@iacapuca iacapuca commented May 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds /admin/contagens/nova — a form to register a new contagem. UI-only for this PR (the would-be payload is logged on submit; data layer is a follow-up).

Stacks on top of #160 — base is feat/admin-area. Will retarget main once #160 merges.

Local section

  • Tab to either pick an existing point or describe a new one
  • Topology picker — Ponto / Junção em T / Cruzamento with thumbnail SVGs
  • Approach inputs — 2/3/4 fields the user names freely (start unlabelled)
  • Live SVG diagram with:
    • Soft road background
    • Cubic-bezier flow arrows whose tangents follow each leg's axis (straights render straight, right-turns curve gently, left-turns swing wide)
    • Thin brand-teal strokes (1.0–2.6 px, log-scaled with count)
    • Tiny arrowheads, count labels with halo
    • Skips count=0 movements for visual quiet

Resultados section

  • N×N movement matrix (diagonal greyed). 2/6/12 inputs depending on topology
  • total_cyclists derived from the matrix (read-only badge)
  • max_hour_cyclists stays a manual input

Other sections

  • Sessão (date / start / end)
  • Características (14 fields grouped: perfil / comportamento / modal / ambiente)
  • Observações (clima + notas)
  • Inline validation surfaces only after first submit attempt; toast on error

shadcn primitives added

label, textarea, select, popover, command, sonner, dialog (transitive). Toaster mounted in admin layout (light theme — next-themes was pulled and removed; site is light-only).

Misc

  • "Nova contagem" button on /admin/contagens now links to the new page.

Test plan

  • pnpm build succeeds
  • pnpm install --frozen-lockfile succeeds
  • Form renders for all 3 topologies; topology switch resyncs approaches/movements
  • Diagram updates live as the matrix is filled; total badge tracks the sum
  • Submit with errors → toast + inline messages; submit clean → success toast + payload in console

🤖 Generated with Claude Code

iacapuca and others added 2 commits May 1, 2026 18:30
…trix

A counts page is rarely a single number — at a junction, every
from→to movement matters. This page captures that, plus all the
existing per-count fields. UI-only for now; the data layer is a
follow-up (the would-be payload is logged on submit).

Local section
- Tabs to either pick an existing point or describe a new one.
- Topology picker: Ponto (2 sentidos) / Junção em T (3) / Cruzamento (4),
  rendered as visual options with thumbnail SVGs.
- Approach inputs: 2/3/4 unlabelled fields the user names freely.
- Live static SVG diagram showing the topology with the user's labels
  and per-leg approach volume (sum of movements leaving that leg).

Resultados section
- Square movement matrix (NxN with the diagonal greyed out): inputs for
  every from→to pair excluding U-turns. 2/6/12 entries depending on
  topology.
- Total de ciclistas is derived from the matrix (read-only badge).
- Pico em 1h stays a manual input.

Other sections
- Sessão (date, start_time, end_time), Características (14 fields
  grouped into perfil/comportamento/modal/ambiente), Observações.
- Inline validation surfaces only after first submit attempt; toast on
  validation error; success toast logs the structured payload.

shadcn primitives added
- label, textarea, select, popover, command, sonner, dialog (transitive).
- Toaster mounted in the admin layout (light theme; site is light-only).
- next-themes pulled in by sonner was removed; Toaster hardcoded.

Misc
- "Nova contagem" button on /admin/contagens now links to the new page.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous arrow rendering looked busy — heavy strokes, oversized
arrowheads, and the per-leg sigma duplicated the matrix.

- Cubic bezier per movement with tangents along source/destination leg
  axes, so straights render straight, right-turns curve gently, and
  left-turns swing wide.
- Thin strokes (1.0-2.6 px) with subtle log-based magnitude scaling.
- Tiny arrowheads (5x5 marker), brand-teal at 70% opacity.
- Count labels at curve midpoint, 9 px with background halo.
- Dropped redundant per-leg outgoing total (matrix is the truth).
- Softer roads (lighter opacity, slightly wider so curves don't hide).
- Skip rendering count=0 movements to keep the diagram quiet until
  data is entered.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant