Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
4.2 KiB
4.2 KiB
Context
Design: docs/superpowers/specs/2026-12-03-page-builder-design.md, change 2. A page is one cms_page row (slug, title, meta description, status, hide header, blocks JSON), saved whole by CmsPageService.save after CmsBlockValidator; mobile-api scopes every call to the caller's company; the portal editor saves through /api/pages.
Goals / Non-Goals
Goals: draft and live separation for published pages; Publish changes and Discard changes; starter templates; Duplicate.
Non-Goals: version history; scheduled publishing; templates saved by staff; drafts for pages that were never published (they have no visitors, so they save directly as today).
Decisions
- One nullable JSON column
draftoncms_page, holding{slug, title, metaDescription, hideHeader, blocks}. Status and company stay on the row. - Save rules (
/counter/cmsPage/save, unchanged request):- New page, or a stored page whose status is DRAFT: writes the row as today (including going straight to PUBLISHED).
- Stored page PUBLISHED, request status PUBLISHED: validates exactly as today and writes the content into
draft. The live columns do not change. - Stored page PUBLISHED, request status DRAFT (unpublish): writes the row from the request and clears
draft; with no visitors the split no longer matters. - Slug uniqueness is checked against the other pages' live slugs, as today.
- Publish (
/counter/cmsPage/publish, body: id and user): when a draft exists, validates it again (an event may have ended, an image may be gone) and checks its slug again, copies it into the live columns, clears it. With no draft it returns the page unchanged. A refusal comes back like a save refusal, so the editor shows it at its field. - Discard (
/counter/cmsPage/discard, body: id): clearsdraft. - Reads.
findByIdreturns the live fields plusdraft(or null).searchrows carryhasDraft.findPublishedreads only the live columns, so visitors never see a draft. - mobile-api adds
POST /api/admin/pages/{id}/publishand/discard, each loading the page through the caller's scope first (another company's page is "not found"), relaying refusals like save. - Portal editor. It edits the draft when there is one, else the live content. On a published page:
- Save stores the draft; a banner then says visitors still see the published version, with Publish changes and Discard changes (Discard asks first);
- Publish changes saves the current edits, then publishes.
- Status radio Draft plus Save unpublishes, as today.
- "View page" opens the live page; Preview shows the draft.
- Pages list shows an "Unpublished changes" badge next to the status for rows with
hasDraft. - Templates are block lists in portal code (
app/lib/pageTemplates.ts), English placeholder text, no images, the FORM block with no event and link namesignup, buttons linking to#signup.- Event sign-up: HERO (Dark), TRUST, FEATURES, STEPS (Muted), FAQ, FORM (Muted).
- Service showcase: HERO (Dark), TRUST, FEATURES, STEPS, FAQ, CTA (Accent), FORM (Muted).
/pages/newfirst shows a picker (Blank and the two templates, each with a one-line description); choosing one opens the editor filled with its blocks. A test runs every template through the same rules the server applies, apart from the event and images that staff fill in.
- Duplicate (list row action and editor button) opens
/pages/new?from=<id>. The editor loads that page (its draft if any), clears the id, sets status Draft, title "