Add a Schedule content block with day tabs

A schedule block's entries (migration 034) each have a day, time,
title, detail, location, person and link, and fold out for a longer
description, the person's photo and page, a graphic and a Google map
of a place or address. Entries sit in one tab per day, in the order
entered; the tab for today's weekday opens first, and a one-day
schedule draws no tabs.

In the editor, the entry fields show only under a schedule block:
repeater `when` can now look at the parent row (scope "parent"), and
a field's label can depend on the row. The block preview names an
entry's person. The showcase retreat and post each have a schedule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-27 21:12:47 -05:00
parent d6477b6d30
commit 71a470b66f
10 changed files with 556 additions and 29 deletions

View file

@ -179,6 +179,7 @@ const blocksChild = (ownerKind) => ({
"video",
"button",
"callout",
"schedule",
],
{ required: true },
),
@ -198,6 +199,14 @@ const blocksChild = (ownerKind) => ({
text("text", { required: true }),
text("detail"),
text("url"),
// Schedule entries only (034_schedule_block.sql).
text("day"),
text("time"),
text("location"),
text("person_id"),
text("description"),
text("media"),
text("map"),
],
},
],

View file

@ -0,0 +1,99 @@
-- ═══════════════════════════════════════════════════════════════
-- 034 CONTENT BLOCKS: SCHEDULE
--
-- A 'schedule' block: the block's items are its entries, grouped
-- into one tab per day. Each entry says when, what and where, and
-- folds out for more. The block's own text is an optional intro.
--
-- content_block_items gains the entry's fields. A list or link-row
-- block leaves them empty:
--
-- day the tab it sits under, eg. 'Friday'. Tabs follow
-- the order entries are in; blank means one untitled
-- day, and a schedule of one day draws no tabs
-- time '7:00pm', '9:00 to 10:30am': shown as typed
-- location where it happens, eg. 'Main Hall'
-- person_id who hosts or speaks: a people row, drawn with its
-- photo and linked to its page. ON DELETE SET NULL,
-- and an unpublished person isn't shown
-- description the fold-out text, formatted like a paragraph
-- media a graphic in the fold-out: '/uploads/…' or a URL
-- map a place or address to show on a Google map in the
-- fold-out, eg. 'Camp Hebron, Halifax PA'
--
-- text is the entry's title, detail a line under it, url a link on
-- the title, as for list items.
--
-- The type list is a CHECK, so content_blocks is rebuilt the way
-- 031 and 032 did it (legacy_alter_table around the rename, then
-- the index and the owner trigger again). The item columns are
-- plain ADD COLUMNs.
--
-- PRAGMA user_version; -- reads 33 before this file
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE content_blocks_new (
id INTEGER PRIMARY KEY AUTOINCREMENT,
owner_kind TEXT NOT NULL
CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post')),
owner_id TEXT NOT NULL,
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body')),
sort_order INTEGER NOT NULL DEFAULT 0,
type TEXT NOT NULL
CHECK (type IN ('heading', 'subheading', 'paragraph',
'list', 'links', 'quote', 'image', 'divider',
'video', 'button', 'callout', 'schedule')),
text TEXT,
media TEXT,
href TEXT,
alt TEXT,
cite TEXT
) STRICT;
INSERT INTO content_blocks_new
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite)
SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite
FROM content_blocks;
PRAGMA legacy_alter_table = ON;
DROP TABLE content_blocks;
ALTER TABLE content_blocks_new RENAME TO content_blocks;
PRAGMA legacy_alter_table = OFF;
CREATE INDEX content_blocks_owner_idx
ON content_blocks (owner_kind, owner_id, slot, sort_order);
ALTER TABLE content_block_items ADD COLUMN day TEXT;
ALTER TABLE content_block_items ADD COLUMN time TEXT;
ALTER TABLE content_block_items ADD COLUMN location TEXT;
ALTER TABLE content_block_items ADD COLUMN person_id TEXT
REFERENCES people (id) ON DELETE SET NULL;
ALTER TABLE content_block_items ADD COLUMN description TEXT;
ALTER TABLE content_block_items ADD COLUMN media TEXT;
ALTER TABLE content_block_items ADD COLUMN map TEXT;
-- ── Triggers last (see CLAUDE.md, Migrations) ──
CREATE TRIGGER content_blocks_owner_exists
BEFORE INSERT ON content_blocks
BEGIN
SELECT CASE
WHEN new.owner_kind = 'event'
AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such event')
WHEN new.owner_kind = 'organization'
AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such organization')
WHEN new.owner_kind = 'person'
AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such person')
WHEN new.owner_kind = 'team'
AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such team')
WHEN new.owner_kind = 'blog_post'
AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such blog post')
END;
END;

View file

@ -16,7 +16,8 @@
/people/showcase-person person: bio, links, roles past and
current, events, awards, private data
/events/showcase-event upcoming retreat: hosts, billed
people, links, blocks, background
people, links, blocks, background,
a three-day schedule
/events/showcase-series weekly series with times
/events/showcase-past-event past event where the award was given
/blog/content-block-showcase every content block type
@ -81,6 +82,23 @@ const PAST = "showcase-past-event";
/* ── Content ───────────────────────────────────────────────── */
/* A schedule over three days, using every entry field: a plain
entry, one with a location and person, one folding out with a
description, graphic and map, one linked, and one with no day
(it lands in a tab of its own). */
const SCHEDULE = [
"schedule",
{ text: "The weekend at a glance. Tap an entry for more." },
[
{ day: "Friday", time: "4:00pm", text: "Arrivals and check-in", location: "Front desk" },
{ day: "Friday", time: "7:00 to 8:30pm", text: "Opening session", location: "Main Hall", person_id: "showcase-person", detail: "Welcome and worship", description: "The **opening session** sets the theme for the weekend.\n\nBring a notebook.", media: "/uploads/showcase.jpg", map: "Camp Hebron, Halifax PA" },
{ day: "Saturday", time: "9:00am", text: "Workshops", location: "Classrooms", person_id: "showcase-member-2", detail: "Pick one of three", url: "/blog/content-block-showcase" },
{ day: "Saturday", time: "7:00pm", text: "Talent night", location: "Main Hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." },
{ day: "Sunday", time: "10:00am", text: "Closing service", location: "Chapel", map: "Main Street, Halifax PA" },
{ time: "Any time", text: "Quiet room open", location: "Library", detail: "An entry with no day" },
],
];
/* Every block type, for the blog showcase. [type, fields, items?] */
const ALL_BLOCKS = [
["paragraph", { text: "Every content block type, top to bottom, with each of its options. Use it to check the page after changing how blocks draw." }],
@ -109,6 +127,8 @@ const ALL_BLOCKS = [
["subheading", { text: "Images" }],
["image", { media: IMAGE, alt: "Describe the picture here", text: "An image with a caption and alt text" }],
["image", { media: IMAGE, alt: "The same picture, linked", href: "/history" }],
["subheading", { text: "Schedule" }],
SCHEDULE,
["subheading", { text: "Video" }],
["video", { href: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", text: "A YouTube video, with its own thumbnail" }],
["video", { href: "https://vimeo.com/76979871", media: IMAGE, text: "A Vimeo video with an uploaded still" }],
@ -354,7 +374,7 @@ tx(db, () => {
{ kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" },
]);
blocks("event", EVENT, "card", cardText("event"));
blocks("event", EVENT, "body", pageBody("event"));
blocks("event", EVENT, "body", [...pageBody("event"), ["heading", { text: "Schedule" }], SCHEDULE]);
insert("events", {
id: SERIES,

View file

@ -98,18 +98,39 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
const itemRows = db
.prepare(
`SELECT block_id, text, detail, url
FROM content_block_items
WHERE block_id IN (${placeholders(blockIds.length)})
ORDER BY block_id, sort_order`,
`SELECT i.block_id, i.text, i.detail, i.url,
i.day, i.time, i.location, i.description, i.media, i.map,
p.id AS person_id, p.display_name AS person_name,
p.photo AS person_photo, p.tagline AS person_tagline
FROM content_block_items i
LEFT JOIN people p ON p.id = i.person_id AND p.is_published = 1
WHERE i.block_id IN (${placeholders(blockIds.length)})
ORDER BY i.block_id, i.sort_order`,
)
.all(...blockIds);
// The schedule fields are null on a list or link-row item; they
// ride along anyway rather than branching on the block's type.
// An unpublished person comes back as no person.
for (const row of itemRows) {
byId.get(row.block_id)?.items.push({
text: row.text,
detail: row.detail,
url: row.url,
day: row.day,
time: row.time,
location: row.location,
description: row.description,
media: row.media,
map: row.map,
person: row.person_id
? {
id: row.person_id,
name: row.person_name,
photo: row.person_photo,
tagline: row.person_tagline,
}
: null,
});
}