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:
committed 2026-10-15 22:25:15 +02:00
1 parent 4ec03410ff
commit 5cb67afb5e
16 files changed
+1914 -9

No files matched your search

+31
View File
@@ -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