teqo-backup/.agents/rules/campanha-edit-where-you-see.mdc
Francisco Ignácio Fontoura Solla a2fbcb9c00 chore(agents): reorganiza árvore de skills — .claude/.cursor → .agents
- Remove .claude/skills (symlinks) e a árvore .cursor (rules, hooks, skills)
- Adiciona .agents/ com skills (+ references/), rules/, hooks/ e scripts
- Adiciona .codex/hooks.json (hook do impeccable)
- Corrige referências .cursor → .agents em environment.json, hooks.json e AGENTS.md
2026-08-03 21:24:11 -03:00

33 lines
2.9 KiB
Text

---
description: /campanha staff UIs — edit mutable data in context (not read-only by default)
globs: src/app/(campaign)/**/*,src/components/campaign/**/*,src/utilities/campaign*/**,src/utilities/municipality*/**,src/utilities/votePledge*
alwaysApply: false
---
# Edit where you see (`/campanha`)
Canonical principles: `PRODUCT.md` § Design Principles — **Edit where you see** + **Auto-save, no Save button**. Precedente: B9 (`MunicipalityList*Control` + `municipalityStaffFormActions`).
When adding or changing a **staff** (coordinator / advisor) view that displays mutable campaign data:
1. **Default to in-context edit** if the role can update that field — list cell, detail card, queue row — not a dead readout that only links to `/editar`.
2. **Reuse existing server actions** and the **same access** as the full form. Thin route wrappers OK; do not invent a generic quick-edit service (<3 call sites → named controls).
3. **UX pattern:** named Popover / select / short number input per affordance; touch `min-h-11`. **Auto-save** on select change, blur, or short debounce — no “Salvar” button on single-field / in-context edits. Show pending / saved / error on the control (Feel the action). Then server revalidate / RSC refresh.
- **Exception — relation-by-chips cells** (B34, 2026-07-27): a column whose value is a set of related records (municípios de uma liderança, carteira de um assessor) may mount its editor inline, always, **with a fine pointer** — chips with a hover/focus-revealed remove button plus a trailing "add" input, no Popover trigger and no table-wide "Editar" toggle. On any other pointer the same cell is a read-only trigger that opens a **Drawer** for editing, because a coarse pointer scrolling a table cannot be asked to distinguish "tap to navigate" from "tap to delete". This is the only sanctioned always-mounted input; single-value fields keep the Popover.
4. **Keep `/editar` (or long Sheet) + explicit submit** only for multi-field strategy forms, rare fields, and flows that need a note, confirmation, or legal consent.
5. **Never** expose staff-only fields to `leader`. View models stay role-split.
## Anti-goals
- Full-row spreadsheet / data-grid mode
- A table-wide "Editar" toggle that flips every column into inputs
- Always-mounted inputs on every list row — except the relation-by-chips cell of rule 3
- Generic `EditableCell` / contentEditable mass edit
- Optimistic UI that skips server refresh when the list is source of truth
- Save buttons on Popovers / quick-edit cells “just in case”
- Silent auto-save with no status feedback
- Saving on every keystroke for free-text without debounce
## Plan / Impeccable brief
For UI items (B/C/D): answer explicitly — _does this surface need in-context edit?_ Cite these principles and B9 when yes; name rabbit hole “spreadsheet mode” when scoping. Prefer auto-save over an explicit Save button unless the write is multi-field / confirmatory / consent.