From 7885d10249418bc681f9332b91271368dcfe486b Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Mon, 2 Nov 2026 23:15:53 -0600 Subject: [PATCH] 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 --- docs/updating-data-in-code.md | 1 + server/src/admin-schema/columns.js | 31 ++ .../migrations/086_schedule_entry_types.sql | 47 +++ server/src/seed-showcase.js | 26 +- server/src/shape.js | 94 ++++-- src/components/ScheduleBlock.tsx | 170 ++++++++--- src/lib/adminSchema/shared.ts | 79 +++++- src/lib/useContent.ts | 8 + src/pages/SchedulePresent.tsx | 267 +++++++++++++++--- 9 files changed, 603 insertions(+), 120 deletions(-) create mode 100644 server/src/migrations/086_schedule_entry_types.sql diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index 0a26bc9..2134268 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -182,6 +182,7 @@ also in `server/src/admin-schema/` and a CHECK): | Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. | | Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) | | Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). | +| Content blocks → Schedule items → Type | (blank: normal entry), block, break, heading | **yes**, migration 086 | `SCHEDULE_KINDS` in `src/lib/adminSchema/shared.ts`; drawn by `ScheduleBlock.tsx` and `SchedulePresent.tsx` (which slides each kind gets). A block's sub-items are `content_block_subitems`. | | Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` | | Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` | | Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping | diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js index b39f6d5..a25b0c2 100644 --- a/server/src/admin-schema/columns.js +++ b/server/src/admin-schema/columns.js @@ -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"), + ], + }, ], }, ], diff --git a/server/src/migrations/086_schedule_entry_types.sql b/server/src/migrations/086_schedule_entry_types.sql new file mode 100644 index 0000000..b0d2e60 --- /dev/null +++ b/server/src/migrations/086_schedule_entry_types.sql @@ -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); diff --git a/server/src/seed-showcase.js b/server/src/seed-showcase.js index 8c88440..d50303d 100644 --- a/server/src/seed-showcase.js +++ b/server/src/seed-showcase.js @@ -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 })); + }); }); } diff --git a/server/src/shape.js b/server/src/shape.js index b14868e..dd9456e 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -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] diff --git a/src/components/ScheduleBlock.tsx b/src/components/ScheduleBlock.tsx index 733a11d..f57d1ac 100644 --- a/src/components/ScheduleBlock.tsx +++ b/src/components/ScheduleBlock.tsx @@ -18,6 +18,14 @@ the place typed in, with a link out to the full map; an entry's own map image (069) shows instead, the link out kept. + An entry's kind (086): a normal entry; a block, its sub-items + listed under it, each a row of its own with its own fold-out; a + break (a meal, free time), a quieter row with no fold-out; or a + heading across the day. A featured entry stands out in the + accent, with a star. Rows alternate a faint tint, for reading + across. The time shown is `time`, which the API has already made + from the picked times or the typed override. + On an event page a Present button opens the schedule as a slideshow for a screen (SchedulePresent.tsx). @@ -28,7 +36,7 @@ it, no map frame (ReadingSchedule). ═══════════════════════════════════════════════════════════════ */ -import { CaretDown, Presentation } from '@phosphor-icons/react' +import { CaretDown, Presentation, Star } from '@phosphor-icons/react' import { Fragment, useId, useState, type KeyboardEvent, type ReactNode } from 'react' import { Link } from 'react-router-dom' @@ -93,7 +101,24 @@ export function Avatar({ person, size }: { person: NonNullable +