Schedule: entry types, picked times, striped rows, blocks in the presentation

Entries get a type (normal, block, break, heading) and a Featured tick.
Times are picked (start, optional end) and shown as 7:00pm or 9:00 to
10:30am; the typed time stays as the override, so existing entries look
the same. A block holds sub-items (content_block_subitems, migration 086),
each with every entry field. Rows alternate a faint tint. The presentation
gets a Blocks slide (its own seconds) before each sub-item's spotlight,
and sub-items get their own checkboxes on the setup page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-11-02 23:15:53 -06:00
parent 274ffc26e0
commit 7885d10249
9 changed files with 603 additions and 120 deletions

View file

@ -191,6 +191,37 @@ export const blocksChild = (ownerKind) => ({
text("media_alt"),
text("map"),
text("map_image"),
// Its kind, picked times and Featured tick (086).
enumeration("kind", ["block", "break", "heading"]),
time("start_time"),
time("end_time"),
bool("featured"),
],
children: [
{
// A block entry's sub-items (086).
key: "items",
table: "content_block_subitems",
owner: { column: "item_id" },
order: "sort_order",
when: { column: "kind", value: "block" },
columns: [
text("text", { required: true }),
text("detail"),
url("url"),
time("start_time"),
time("end_time"),
text("time"),
text("location"),
text("person_id"),
text("description"),
text("media"),
text("media_alt"),
text("map"),
text("map_image"),
bool("featured"),
],
},
],
},
],

View file

@ -0,0 +1,47 @@
-- ═══════════════════════════════════════════════════════════════
-- 086 SCHEDULE ENTRY TYPES
--
-- A schedule entry gets a kind:
-- null a normal entry
-- block a time frame holding several things, its sub-items
-- (content_block_subitems below), each with its own time
-- break a meal or free time: a quieter row, no spotlight slide
-- heading a label across the day, eg. Evening sessions
-- and `featured`, which makes the row stand out.
--
-- Times are picked (start_time, end_time, HH:MM 24-hour) and shown
-- as 7:00pm or 9:00 to 10:30am (shape.js). The old typed `time`
-- stays as the override: when it's filled it shows instead, so the
-- entries typed before this look the same.
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE content_block_items ADD COLUMN kind TEXT
CHECK (kind IN ('block', 'break', 'heading'));
ALTER TABLE content_block_items ADD COLUMN start_time TEXT;
ALTER TABLE content_block_items ADD COLUMN end_time TEXT;
ALTER TABLE content_block_items ADD COLUMN featured INTEGER NOT NULL DEFAULT 0
CHECK (featured IN (0, 1));
-- A block entry's sub-items: every field an entry has but day and
-- kind (they're under their block's day, and don't nest further).
CREATE TABLE content_block_subitems (
id INTEGER PRIMARY KEY AUTOINCREMENT,
item_id INTEGER NOT NULL REFERENCES content_block_items (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
text TEXT NOT NULL,
detail TEXT,
url TEXT,
start_time TEXT,
end_time TEXT,
time TEXT, -- the override, as on an entry
location TEXT,
person_id TEXT REFERENCES people (id) ON DELETE SET NULL,
description TEXT,
media TEXT,
media_alt TEXT,
map TEXT,
map_image TEXT,
featured INTEGER NOT NULL DEFAULT 0 CHECK (featured IN (0, 1))
) STRICT;
CREATE INDEX content_block_subitems_item_idx
ON content_block_subitems (item_id, sort_order);

View file

@ -82,18 +82,25 @@ 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). */
/* A schedule over three days, using every entry field and kind: a
plain entry, one with a location and person, one folding out with
a description, graphic and map, one linked, a heading, a featured
entry, a block with sub-items, a break, typed and picked times,
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", start_time: "16:00", text: "Arrivals and check-in", location: "Front desk" },
{ day: "Friday", kind: "heading", text: "Evening", detail: "A heading across the day" },
{ 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", map_image: "/uploads/showcase.jpg" },
{ 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: "Saturday", start_time: "08:00", end_time: "09:00", kind: "break", text: "Breakfast", location: "Dining hall" },
{ day: "Saturday", start_time: "09:00", end_time: "10:30", kind: "block", text: "Workshops", location: "Classrooms", detail: "Pick one of three", items: [
{ start_time: "09:00", end_time: "09:45", text: "Leading worship", location: "Room A", person_id: "showcase-member-2", url: "/blog/content-block-showcase" },
{ start_time: "09:00", end_time: "09:45", text: "Speaking with confidence", location: "Room B", featured: 1, description: "A featured sub-item that folds out." },
{ time: "After the first round", text: "Open questions", location: "Room C" },
] },
{ day: "Saturday", start_time: "19:00", featured: 1, 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" },
],
@ -210,7 +217,10 @@ function blocks(ownerKind, ownerId, slot, list) {
type,
...f,
});
items.forEach((item, i) => insert("content_block_items", { block_id: lastInsertRowid, sort_order: i, ...item }));
items.forEach(({ items: subitems = [], ...item }, i) => {
const entry = insert("content_block_items", { block_id: lastInsertRowid, sort_order: i, ...item });
subitems.forEach((sub, j) => insert("content_block_subitems", { item_id: entry.lastInsertRowid, sort_order: j, ...sub }));
});
});
}

View file

@ -107,12 +107,14 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
const blockIds = [...byId.keys()];
const ENTRY_FIELDS = `i.text, i.detail, i.url, i.start_time, i.end_time, i.time, i.location,
i.description, i.media, i.media_alt, i.map, i.map_image, i.featured,
p.id AS person_id, p.display_name AS person_name,
p.photo AS person_photo, p.tagline AS person_tagline`;
const itemRows = db
.prepare(
`SELECT i.block_id, i.text, i.detail, i.url,
i.day, i.time, i.location, i.description, i.media, i.media_alt, i.map, i.map_image,
p.id AS person_id, p.display_name AS person_name,
p.photo AS person_photo, p.tagline AS person_tagline
`SELECT i.id, i.block_id, i.day, i.kind, ${ENTRY_FIELDS}
FROM content_block_items i
LEFT JOIN v_people_public p ON p.id = i.person_id AND p.is_published = 1
WHERE i.block_id IN (${placeholders(blockIds.length)})
@ -122,34 +124,74 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
// 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.
const itemsById = new Map();
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,
media_alt: row.media_alt,
map: row.map,
map_image: row.map_image,
person: row.person_id
? {
id: row.person_id,
name: row.person_name,
photo: row.person_photo,
tagline: row.person_tagline,
}
: null,
});
const item = { ...scheduleEntry(row), day: row.day, kind: row.kind ?? "entry", items: [] };
itemsById.set(row.id, item);
byId.get(row.block_id)?.items.push(item);
}
// A block entry's sub-items (086).
const blockEntryIds = itemRows.filter((row) => row.kind === "block").map((row) => row.id);
if (blockEntryIds.length) {
const subRows = db
.prepare(
`SELECT i.item_id, ${ENTRY_FIELDS}
FROM content_block_subitems i
LEFT JOIN v_people_public p ON p.id = i.person_id AND p.is_published = 1
WHERE i.item_id IN (${placeholders(blockEntryIds.length)})
ORDER BY i.item_id, i.sort_order`,
)
.all(...blockEntryIds);
for (const row of subRows) itemsById.get(row.item_id)?.items.push(scheduleEntry(row));
}
return out;
}
/* A schedule entry or sub-item as the page gets it. `time` is what
to show: the typed override, else the picked times (086). An
unpublished person comes back as no person. */
function scheduleEntry(row) {
return {
text: row.text,
detail: row.detail,
url: row.url,
time: row.time || clockRange(row.start_time, row.end_time),
start_time: row.start_time,
end_time: row.end_time,
location: row.location,
description: row.description,
media: row.media,
media_alt: row.media_alt,
map: row.map,
map_image: row.map_image,
featured: row.featured === 1,
person: row.person_id
? {
id: row.person_id,
name: row.person_name,
photo: row.person_photo,
tagline: row.person_tagline,
}
: null,
};
}
/* "19:00" → 7:00pm, and a range as 9:00 to 10:30am, or 11:30am to
1:00pm when it crosses noon. */
export function clockRange(start, end) {
if (!start) return null;
const clock = (hhmm) => {
const [h, m] = hhmm.split(":").map(Number);
return { text: `${h % 12 || 12}:${String(m).padStart(2, "0")}`, half: h < 12 ? "am" : "pm" };
};
const from = clock(start);
if (!end) return from.text + from.half;
const to = clock(end);
return `${from.text}${from.half === to.half ? "" : from.half} to ${to.text}${to.half}`;
}
/* ── Card description ──────────────────────────────────────────
The card slot is paragraphs by convention, so it collapses to
an array of strings, desc_a and desc_b become description[0]