Skip to content

Designer ergonomics: background picker, quick-add, slugify, live status#15

Open
ArneeMe wants to merge 5 commits into
mainfrom
claude/multi-org-support-JUBYE
Open

Designer ergonomics: background picker, quick-add, slugify, live status#15
ArneeMe wants to merge 5 commits into
mainfrom
claude/multi-org-support-JUBYE

Conversation

@ArneeMe

@ArneeMe ArneeMe commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

Five small, focused improvements to the template-creation flow, on top of #14. The theme is let admins ship a usable cert PDF with fewer manual steps, leveraging org_assets defaults so the designer's outputs are wired up the moment a field hits the canvas.

Commits

# Commit What & why
1 Background picker Swatch row in the designer — pick a page color (Krem / Mynte / Lyseblå / …) without uploading a PDF. Implemented as a full-page rectangle at index 0 of the schemas array so it's editable, swappable, and lives in the same jsonb column as everything else.
2 Auto-bind system slots qr_code / qr_info / qr_page / today / signature_date fields auto-wire themselves to the matching system slot on save. Manual configuration always wins — only fills gaps. One fewer bindings-editor visit for the most common case.
3 Slugify label → key Type "Mottakers navn" as the label, key auto-fills as mottakers_navn (ASCII, underscores, Norwegian accents folded). Sticky-edit: hand-editing the key flips autoKey: false so subsequent label edits don't clobber. Field labels also come before keys in the row now.
4 Quick-add toolbar "+ QR-kode" / "+ Signatur" / "+ Logo" / "+ Tekstblokk" / "+ attester.no-merke" buttons. Each drops a pre-wired field (or 3-field block for signature) bound to the org's default asset at the next free position. Cascades on repeated clicks so a dual-signature row is two clicks instead of six.
5 Designer polish Live "Klar til lagring" chip with specific reason if not; beforeunload guard on unsaved changes (loads + saves don't trigger); up/down reorder arrows in SchemaEditor; missing-defaults hint under the quick-add row pointing to Innhold if no default signature/logo/body_text is set up.

Test plan

  • Background picker: click each swatch, confirm page color updates in the designer. Save + reload — color persists.
  • Auto-bind: drop a fresh qr_code field via pdfme's left panel (no manual binding), save, reopen — the binding shows system: qr_code.
  • Slugify: in SchemaEditor, add a new field, type "Født år" in label → key becomes fodt_ar. Hand-edit the key → subsequent label edits no longer overwrite.
  • Quick-add: empty designer → click "+ QR-kode" then "+ Signatur" twice → see QR + 2-signature row, all bound. Click "+ Signatur" again with no default signature → field appears, hint mentions Innhold link.
  • Live chip: with neither QR nor "attester.no" → orange Mangler QR-kode · Mangler attester.no-tekst. Add QR → chip updates to just Mangler attester.no-tekst. Add brand → green ✓.
  • Reorder: SchemaEditor with 3+ fields → up/down arrows reorder, disabled at edges.
  • beforeunload: edit a field, try to navigate away → browser confirm prompt. Save → no prompt.

Out of scope (still queued)

Visual binding badge per pdfme field, asset thumbnails in BindingsEditor, inline lookup-list add, starter gallery preview cards, drag-to-reorder (we shipped up/down arrows instead).


Generated by Claude Code

claude added 5 commits June 18, 2026 16:57
Why: getting from "blank white page" to "this looks like a real
cert" used to require uploading a custom PDF — a hard step for
admins who don't already have one. Now they click a colored circle
and the page has a tone (cream / mynte / lyseblå / etc.).

Implementation: a full-page rectangle field with name __background__
inserted at index 0 of the schemas so other fields render on top.
Wired through pdfme's rectangle plugin in the Designer, the
production generator, and the preview generator. The picker also
shows a transparent "✕" swatch to clear the background, plus a
visual ring on whichever color is active.

Lives entirely in the schemas jsonb — no new column, no basePdf
upload required, survives template save/load round-trip.

https://claude.ai/code/session_0142AspkipemJMg1ggSqfQzg
Why: every admin who places a qr_code / qr_info / qr_page / today /
signature_date field in the designer ends up wiring it to the
matching system slot via the bindings editor. It's tedious, error-
prone (you can pick the wrong slot), and there's only one right
answer. fromPdfmeTemplate now does it automatically at save:

- If a pdfme field name matches one of the known system slot names
  AND the admin hasn't already configured a binding for it, the
  save layer fills in `{ source: 'system', system: <slot> }` for
  them.
- Existing bindings are never overwritten — manual configuration
  always wins.

Result: admins drop a qr_code field, hit save, and the cert URL is
already wired up. One fewer thing to think about for the common
case; bindings editor is still there for everything else.

https://claude.ai/code/session_0142AspkipemJMg1ggSqfQzg
Why: admins shouldn't have to think about internal field keys. They
type the label they want their volunteers to see ("Mottakers navn")
and the key fills itself in ("mottakers_navn") — lowercase ASCII,
underscores for spaces, Norwegian characters de-accented (æ→a,
ø→o, å→a, é→e). The Etikett field now comes BEFORE Nøkkel in the
row so the natural typing order matches.

Sticky-edit rule: as soon as the admin hand-edits the key, an
`autoKey: false` flag flips on for that field and subsequent label
edits no longer overwrite. So one-off renames don't get clobbered;
admins who want full control just type a key once and that's that.

Side effect: typing in the key field also runs the slugifier, so
spaces and special characters can't sneak into keys via direct
input either.

https://claude.ai/code/session_0142AspkipemJMg1ggSqfQzg
Why: admins kept landing in the bindings editor right after placing a
field, because every QR / signature / logo / body-text needs exactly
the same wiring every time. Bundle the placement + wiring into one
click, and leverage what they've already uploaded as default org
assets:

- "+ QR-kode" drops a qrcode field already bound to system: qr_code.
- "+ Signatur" drops a 3-field block (photo / name / role) all bound
  to asset_default kind=signature at the next free position. Clicking
  again gives you a second signature next to the first — no manual
  position math.
- "+ Logo" drops an image bound to default logo.
- "+ Tekstblokk" drops a text region bound to default body_text.
- "+ attester.no-merke" drops the brand text the save guard requires
  (idempotent — no-op if already present).

Position cascades on repeated clicks of the same button so fields
don't stack on top of each other. Admin still drags to fine-tune,
but the starting point is much closer to done.

When no default asset of that kind exists yet the field still gets
added — it just renders empty until the admin uploads one in Innhold.
That's a feature, not a bug: it visualises the slot so the admin
knows what to upload.

https://claude.ai/code/session_0142AspkipemJMg1ggSqfQzg
Four ergonomic wins for the create-template flow:

- Live "ready to save" chip in the toolbar: green ✓ "Klar til lagring"
  when validateTemplateForSave passes, orange ⚠ with the specific
  reason ("Mangler QR-kode" / "Mangler attester.no-tekst") otherwise.
  Admin no longer finds out at save time that something's missing —
  feedback is continuous as they design. Save button also shows " *"
  when there are unsaved changes.

- beforeunload prompt if the admin has unsaved schema / bindings /
  form changes and tries to close the tab or hit refresh. Standard
  browser confirm; prevents lost work after 20 minutes of layout
  iteration. Dirty flag flips off on save and on load (loading a
  starter or existing template isn't an edit).

- Up/down reorder buttons next to each row in SchemaEditor. Reordering
  used to require delete-and-re-add; now it's two clicks. Buttons
  disable at the edges so admins can't move past the ends.

- "Ingen standard signatur / logo / tekstblokk satt opp enda" hint
  under the quick-add buttons when the org's Innhold is missing those
  defaults. Explains upfront why clicking "+ Signatur" might drop an
  empty placeholder, and links to Innhold to fix it.

https://claude.ai/code/session_0142AspkipemJMg1ggSqfQzg
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying inf319-certificate with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7839735
Status: ✅  Deploy successful!
Preview URL: https://10ffb9ec.inf319-certificate.pages.dev
Branch Preview URL: https://claude-multi-org-support-jub.inf319-certificate.pages.dev

View logs

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.

2 participants