feat: add per-event badge editor, pretix company import, smart guides
Badge Designer (admin): per-event WYSIWYG badge/PDF layout editor with mm canvas, text/QR/image elements, multi-select, Word+PowerPoint alignment, PowerPoint-style smart guides with snapping, Delete-key, preview and JSON views. Migration 20261015194531_badge_editor (badge_layouts + admin-only save/set-default/delete RPCs). Company import: migration 20261015200719_events_company adds events.company; the sidecar pretix sync now fetches the organizer display name and stores it (best-effort). Bindable on badges as Company/organizer. Tests: 15 SQL rollback assertions + 13 mocked browser tests. Docs synced. Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
4ec03410ff
commit
5cb67afb5e
16 files changed
+1914
-9
No files matched your search
@@ -419,6 +419,37 @@ admin-readable via RLS. All three functions are `security definer` with an empty
|
||||
`search_path`, revoke execution from `PUBLIC` / `anon`, and grant it back only to
|
||||
`authenticated` (the admin check is enforced inside each function).
|
||||
|
||||
## Badge editor
|
||||
|
||||
Source: [20261015194531_badge_editor.sql](../../supabase/migrations/20261015194531_badge_editor.sql).
|
||||
|
||||
The admin **Badges** view is a per-event WYSIWYG badge / PDF layout editor
|
||||
(modelled on pretix's "PDF Editor / Badge layout"). Each event owns one or more
|
||||
named **layouts** in `badge_layouts`: a page size in millimetres plus an ordered
|
||||
`elements` JSON array (text boxes, QR codes, images) with mm-based geometry, so
|
||||
the on-screen canvas maps 1:1 to print. Text/QR elements bind to attendee fields
|
||||
(`attendee_name`, `email`, `ticket_type`, `qr_token`, `event_name`, `company`, …)
|
||||
and are previewed against a real sample registration. The `company` field reads
|
||||
`events.company` (the Pretix organizer name — see
|
||||
[sidecar.md](./sidecar.md#pretix-sync)).
|
||||
|
||||
- `save_badge_layout(p_event_id, p_name, p_page_width_mm, p_page_height_mm, p_elements, p_is_default)`
|
||||
→ `badge_layouts` row — **admin-only.** Upserts the layout matched on
|
||||
`(event_id, name)`. When `p_is_default` is true, every other layout for the
|
||||
event is demoted first, so the "one default per event" invariant holds
|
||||
transactionally. Rejects blank names and non-array `elements`.
|
||||
- `set_default_badge_layout(p_id)` → `void` — **admin-only.** Promotes one layout
|
||||
to the event's default and demotes the previous one.
|
||||
- `delete_badge_layout(p_id)` → `void` — **admin-only.** Removes a layout; the
|
||||
default may not be deleted while other layouts exist (a usable default must
|
||||
remain).
|
||||
|
||||
`badge_layouts` cascades on event deletion, is admin-readable via RLS
|
||||
(`badge_layouts_admin_read`), and has a partial unique index enforcing a single
|
||||
default per event. All three functions are `security definer` with an empty
|
||||
`search_path`, revoke execution from `PUBLIC` / `anon`, and grant it back only to
|
||||
`authenticated` (the admin check is enforced inside each function).
|
||||
|
||||
## Error handling
|
||||
|
||||
RPCs raise Postgres exceptions with human-readable messages (e.g. `you cannot
|
||||
|
||||
@@ -71,6 +71,7 @@ queries everything for the active event and handles "no active event" gracefully
|
||||
| `name` | `text` | e.g. "APPE 2026" |
|
||||
| `start_date` / `end_date` | `date` | |
|
||||
| `location` | `text` | nullable |
|
||||
| `company` | `text` | nullable — the owning organisation / company (e.g. the **Pretix organizer name**). Auto-filled by the Pretix sync; bindable on badges (see [sidecar.md](./sidecar.md)) |
|
||||
| `is_active` | `boolean` | default `false` |
|
||||
| `avg_feedback` | `numeric` | maintained aggregate |
|
||||
| `num_sessions` | `integer` | maintained aggregate |
|
||||
|
||||
@@ -1,3 +1,29 @@
|
||||
# Badge Editor Regression
|
||||
|
||||
After applying `20261015194531_badge_editor`, run:
|
||||
|
||||
```sh
|
||||
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
|
||||
-v ON_ERROR_STOP=1 < supabase/tests/badge_layout_tests.sql
|
||||
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- badge-editor.spec.ts --project=chromium
|
||||
```
|
||||
|
||||
The SQL fixture is rollback-only: fifteen assertions cover creating a default
|
||||
layout, upserting the same `(event_id, name)` in place, the one-default-per-event
|
||||
invariant when a new default is saved, per-event scoping, `set_default`
|
||||
promote/demote, refusing to delete the default while other layouts exist,
|
||||
deleting a non-default layout, rejecting blank names, and admin/non-admin/anon
|
||||
authorization (the non-admin read check runs as the real `authenticated` role so
|
||||
RLS is enforced). The browser suite is API-mocked and covers loading the default
|
||||
layout onto the millimetre canvas with a bound attendee name, adding/selecting a
|
||||
text element and its handles, editing `x` to move an element, saving via
|
||||
`save_badge_layout`, preview mode hiding the handles, the JSON view, a failed
|
||||
save, the mobile layout, the **Delete key** removing the selection, binding the
|
||||
**company / organizer** field, **align-centre** on the page, and **Shift-click
|
||||
multi-select** for group alignment. No real attendee data changes.
|
||||
|
||||
See [RPC rules](./rpcs.md#badge-editor) and the [Badges view](../frontend/admin-app.md).
|
||||
|
||||
# Raffle Regression
|
||||
|
||||
After applying `20261015180640_raffle`, run:
|
||||
|
||||
Reference in new issue
Block a user