From 71d58318b6bf0a33d1b2fc589f3eb9ac8cd78c49 Mon Sep 17 00:00:00 2001
From: Zaldimmar
Date: Tue, 3 Nov 2026 02:04:06 -0600
Subject: [PATCH 1/2] Schedule tags: a block's own tags, tag tabs, chips, a tag
filter and tag slides
A schedule block gets its own tags (content_block_tags, migration 087):
a name, a color and whether it's a tab. Entries and sub-items pick them
from a checklist. Each tag is a tab after the days, gathering what it's
on from every day under the day's name; a tagged entry comes whole and
an untagged block brings only its tagged sub-items. Rows show their tags
as chips. The presentation can show only one tag's entries and adds a
slide per tag after the days.
Entries name a tag by a key the admin makes when the tag is added, so a
rename keeps them, since the block's rows are rewritten on every save.
For that the admin engine gets a function blank (fresh values for every
new row and copy, with a `seeded` column that doesn't count as input),
`lends` (a row's options for the collections nested in it) and a
checklist widget.
Co-Authored-By: Claude Opus 5.5
---
docs/updating-data-in-code.md | 2 +-
server/src/admin-crud.js | 2 +
server/src/admin-schema/columns.js | 18 ++
server/src/migrations/087_schedule_tags.sql | 28 +++
server/src/seed-showcase.js | 16 +-
server/src/shape.js | 29 ++-
src/components/ContentBlocks.tsx | 10 +-
src/components/ScheduleBlock.tsx | 245 ++++++++++++++------
src/components/admin/fields.tsx | 71 +++++-
src/lib/adminSchema/shared.ts | 33 +++
src/lib/useContent.ts | 7 +
src/pages/SchedulePresent.tsx | 200 ++++++++++++----
12 files changed, 539 insertions(+), 122 deletions(-)
create mode 100644 server/src/migrations/087_schedule_tags.sql
diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md
index 2134268..36d92c0 100644
--- a/docs/updating-data-in-code.md
+++ b/docs/updating-data-in-code.md
@@ -182,7 +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`. |
+| 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`. A schedule's own tags (087) are `content_block_tags`, rows of the block typed in the admin (not a fixed list); entries name them by `tag_key`, made in the admin as the tag is added. |
| 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-crud.js b/server/src/admin-crud.js
index 18bfdc5..9bd2723 100644
--- a/server/src/admin-crud.js
+++ b/server/src/admin-crud.js
@@ -494,6 +494,8 @@ function isBlankChildRow(child, raw) {
if (!raw || typeof raw !== "object") return true;
for (const column of child.columns) {
+ // A value the admin seeds every new row with (`seeded`), not input.
+ if (column.seeded) continue;
const value = raw[column.name];
if (value === undefined || value === null || value === "") continue;
// An unchecked box is the default state of a new row, not input.
diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js
index a25b0c2..3416e07 100644
--- a/server/src/admin-schema/columns.js
+++ b/server/src/admin-schema/columns.js
@@ -196,6 +196,8 @@ export const blocksChild = (ownerKind) => ({
time("start_time"),
time("end_time"),
bool("featured"),
+ // The block's tags it has, by key, comma-separated (087).
+ text("tags"),
],
children: [
{
@@ -220,10 +222,26 @@ export const blocksChild = (ownerKind) => ({
text("map"),
text("map_image"),
bool("featured"),
+ text("tags"),
],
},
],
},
+ {
+ // A schedule's own tags (087).
+ key: "tags",
+ table: "content_block_tags",
+ owner: { column: "block_id" },
+ order: "sort_order",
+ when: { column: "type", value: "schedule" },
+ columns: [
+ // Made by the admin as the row is added, so it isn't input.
+ text("tag_key", { required: true, seeded: true }),
+ text("name", { required: true }),
+ text("color"),
+ bool("no_tab"),
+ ],
+ },
],
});
diff --git a/server/src/migrations/087_schedule_tags.sql b/server/src/migrations/087_schedule_tags.sql
new file mode 100644
index 0000000..78feba1
--- /dev/null
+++ b/server/src/migrations/087_schedule_tags.sql
@@ -0,0 +1,28 @@
+-- ═══════════════════════════════════════════════════════════════
+-- 087 SCHEDULE TAGS
+--
+-- A schedule block's own tags, eg. Youth or Worship: entries and
+-- sub-items are tagged with them, a tag can be a tab of its own
+-- gathering every entry it's on (across the days), and the schedule
+-- presentation can show only one tag's entries and a slide per tag.
+--
+-- These are the block's, not Data → Tags (070). The block's rows are
+-- rewritten on every save, so entries name a tag by `tag_key` (made
+-- in the admin when the tag is added, kept when it's renamed), not
+-- by its row id. An entry's `tags` is its keys, comma-separated; a
+-- key no tag has any more is skipped.
+-- ═══════════════════════════════════════════════════════════════
+
+CREATE TABLE content_block_tags (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ block_id INTEGER NOT NULL REFERENCES content_blocks (id) ON DELETE CASCADE,
+ sort_order INTEGER NOT NULL DEFAULT 0,
+ tag_key TEXT NOT NULL,
+ name TEXT NOT NULL,
+ color TEXT, -- null: the event's accent
+ no_tab INTEGER NOT NULL DEFAULT 0 CHECK (no_tab IN (0, 1)),
+ UNIQUE (block_id, tag_key)
+) STRICT;
+
+ALTER TABLE content_block_items ADD COLUMN tags TEXT;
+ALTER TABLE content_block_subitems ADD COLUMN tags TEXT;
diff --git a/server/src/seed-showcase.js b/server/src/seed-showcase.js
index d50303d..07c8a77 100644
--- a/server/src/seed-showcase.js
+++ b/server/src/seed-showcase.js
@@ -86,24 +86,29 @@ const PAST = "showcase-past-event";
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). */
+ tags (one a tab of its own in its color, one with No tab), 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", start_time: "16:00", text: "Arrivals and check-in", location: "Front desk" },
+ { day: "Friday", start_time: "16:00", text: "Arrivals and check-in", location: "Front desk", tags: "showcase-youth,showcase-all" },
{ 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", 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." },
+ { start_time: "09:00", end_time: "09:45", text: "Speaking with confidence", location: "Room B", featured: 1, tags: "showcase-youth", 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: "Saturday", start_time: "19:00", featured: 1, tags: "showcase-youth", 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" },
],
+ [
+ { tag_key: "showcase-youth", name: "Youth", color: "#00748a" },
+ { tag_key: "showcase-all", name: "Everyone", no_tab: 1 },
+ ],
];
/* Every block type, for the blog showcase. [type, fields, items?] */
@@ -208,7 +213,7 @@ function insert(table, row) {
}
function blocks(ownerKind, ownerId, slot, list) {
- list.forEach(([type, f, items = []], order) => {
+ list.forEach(([type, f, items = [], tags = []], order) => {
const { lastInsertRowid } = insert("content_blocks", {
owner_kind: ownerKind,
owner_id: ownerId,
@@ -221,6 +226,7 @@ function blocks(ownerKind, ownerId, slot, list) {
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 }));
});
+ tags.forEach((tag, i) => insert("content_block_tags", { block_id: lastInsertRowid, sort_order: i, ...tag }));
});
}
diff --git a/server/src/shape.js b/server/src/shape.js
index dd9456e..aee9313 100644
--- a/server/src/shape.js
+++ b/server/src/shape.js
@@ -108,7 +108,7 @@ 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,
+ i.description, i.media, i.media_alt, i.map, i.map_image, i.featured, i.tags,
p.id AS person_id, p.display_name AS person_name,
p.photo AS person_photo, p.tagline AS person_tagline`;
@@ -146,6 +146,32 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
for (const row of subRows) itemsById.get(row.item_id)?.items.push(scheduleEntry(row));
}
+ // A schedule's own tags (087), and each entry's cut to the ones
+ // the block still has.
+ const tagRows = db
+ .prepare(
+ `SELECT block_id, tag_key, name, color, no_tab
+ FROM content_block_tags
+ WHERE block_id IN (${placeholders(blockIds.length)})
+ ORDER BY block_id, sort_order`,
+ )
+ .all(...blockIds);
+ for (const row of tagRows) {
+ const block = byId.get(row.block_id);
+ if (!block) continue;
+ block.tags ??= [];
+ block.tags.push({ key: row.tag_key, name: row.name, color: row.color, tab: row.no_tab === 0 });
+ }
+ for (const block of byId.values()) {
+ if (block.type !== "schedule") continue;
+ const known = new Set((block.tags ??= []).map((tag) => tag.key));
+ const cut = (entry) => {
+ entry.tags = entry.tags.filter((key) => known.has(key));
+ entry.items?.forEach(cut);
+ };
+ block.items.forEach(cut);
+ }
+
return out;
}
@@ -167,6 +193,7 @@ function scheduleEntry(row) {
map: row.map,
map_image: row.map_image,
featured: row.featured === 1,
+ tags: row.tags ? row.tags.split(",").filter(Boolean) : [],
person: row.person_id
? {
id: row.person_id,
diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx
index 2c846d5..4d9299e 100644
--- a/src/components/ContentBlocks.tsx
+++ b/src/components/ContentBlocks.tsx
@@ -385,7 +385,15 @@ function Block({
case 'schedule':
if (!block.items?.length) return null
- return
+ return (
+
+ )
case 'people': {
const picked = (block.items ?? [])
diff --git a/src/components/ScheduleBlock.tsx b/src/components/ScheduleBlock.tsx
index f57d1ac..ef7a5a2 100644
--- a/src/components/ScheduleBlock.tsx
+++ b/src/components/ScheduleBlock.tsx
@@ -26,6 +26,12 @@
across. The time shown is `time`, which the API has already made
from the picked times or the typed override.
+ Tags (087) are the block's own: an entry or sub-item shows its
+ tags as chips, and each tag (unless it's set No tab) is a tab
+ after the days, gathering what it's on from every day under the
+ day's name. A tagged entry comes whole; an untagged block comes
+ with only its tagged sub-items. A tag on nothing draws no tab.
+
On an event page a Present button opens the schedule as a
slideshow for a screen (SchedulePresent.tsx).
@@ -37,12 +43,12 @@
═══════════════════════════════════════════════════════════════ */
import { CaretDown, Presentation, Star } from '@phosphor-icons/react'
-import { Fragment, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
+import { Fragment, createContext, useContext, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
import { Link } from 'react-router-dom'
import { personHref } from '../lib/hrefs.ts'
import { mediaUrl, initials } from '../lib/media.ts'
-import type { ContentBlockItem } from '../lib/useContent.ts'
+import type { ContentBlockItem, ScheduleTag } from '../lib/useContent.ts'
import { Anchor, Paragraphs } from './InlineText.tsx'
import { withAlpha, accentText, readableOn } from '../lib/color.ts'
import { useSmallImage } from '../lib/useSmallImage.ts'
@@ -68,6 +74,57 @@ export function groupByDay(items: ContentBlockItem[]): Day[] {
return days
}
+/* What a tag is on (087): a tagged entry whole, and an untagged
+ block with only its tagged sub-items. */
+export function withTag(entries: ContentBlockItem[], key: string): ContentBlockItem[] {
+ return entries.flatMap((entry) => {
+ if (entry.tags?.includes(key)) return [entry]
+ if (entry.kind !== 'block') return []
+ const items = (entry.items ?? []).filter((item) => item.tags?.includes(key))
+ return items.length ? [{ ...entry, items }] : []
+ })
+}
+
+/* The days, each cut to what a tag is on, empty ones dropped. */
+export const daysWithTag = (days: Day[], key: string): Day[] =>
+ days.map((day) => ({ name: day.name, entries: withTag(day.entries, key) })).filter((day) => day.entries.length)
+
+/* The schedule's tags, for its rows' chips. */
+export const ScheduleTags = createContext([])
+
+/* An entry's tags as chips, each in its tag's color (else the
+ accent). `className` sizes them. */
+export function TagChips({
+ keys,
+ tags,
+ accent,
+ className = 'px-2 py-0.5 text-xs',
+}: {
+ keys?: string[]
+ tags: ScheduleTag[]
+ accent: string
+ className?: string
+}) {
+ const shown = tags.filter((tag) => keys?.includes(tag.key))
+ if (shown.length === 0) return null
+ return (
+
+ {shown.map((tag) => {
+ const color = tag.color || accent
+ return (
+
+ {tag.name}
+
+ )
+ })}
+
+ )
+}
+
/* The tab to open with: today's weekday if a tab starts with it (or
its three-letter form), else the first. */
function todayIndex(days: Day[]): number {
@@ -119,6 +176,7 @@ export const featuredStyle = (accent: string) => ({
})
function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent: string; sub?: boolean }) {
+ const tags = useContext(ScheduleTags)
const [open, setOpen] = useState(false)
// Google's map loads only when asked for (Privacy page).
const [showMap, setShowMap] = useState(false)
@@ -196,6 +254,11 @@ function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent
{entry.detail}
)}
+ {entry.tags?.length ? (
+
+
+
+ ) : null}
{more && (
@@ -300,7 +363,7 @@ function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent
}
/* One entry in reading mode, a block's sub-items in a list under it. */
-function readingEntry(entry: ContentBlockItem, accent: string, key: number): ReactNode {
+function readingEntry(entry: ContentBlockItem, accent: string, key: number, tags: ScheduleTag[]): ReactNode {
if (entry.kind === 'heading') {
return (
@@ -332,6 +395,9 @@ function readingEntry(entry: ContentBlockItem, accent: string, key: number): Rea
))}
{entry.detail &&
+
)
}
diff --git a/src/components/admin/fields.tsx b/src/components/admin/fields.tsx
index 3243c02..b80c2fc 100644
--- a/src/components/admin/fields.tsx
+++ b/src/components/admin/fields.tsx
@@ -24,7 +24,18 @@
server doesn't also declare as a column default. If you give a
blank row a starting value here, add the matching default: to
that column in the server's admin-schema.js or the row will be
- saved as real input.
+ saved as real input. `blank` can be a function instead, for a
+ value made fresh for every new row and every copy (a schedule
+ tag's key); mark that column `seeded` on the server so a row with
+ only that in it still counts as blank.
+
+ `lends: (row) => ({ name: [{ id, label }] })` on a collection gives
+ the collections nested in each row (at any depth) more options,
+ made from that row: a schedule block lends its tags to its
+ entries and their sub-items.
+
+ `widget: "checklist"` is a checkbox per option of `optionsFrom`,
+ saved as the picked ids, comma-separated, in the options' order.
In a repeater row, `when: { path, value }` shows a field only
while another field of the row holds that value (or one of them,
@@ -226,8 +237,49 @@ function withoutIds(value) {
return copy;
}
+/* A new row, and the fresh values a function `blank` gives every
+ new row (a copy keeps the rest of what it copies). */
+const newRow = (spec) => (typeof spec.blank === "function" ? spec.blank() : { ...spec.blank });
+const seeded = (spec) => (typeof spec.blank === "function" ? spec.blank() : {});
+
const helpText = (field, row) => (typeof field.help === "function" ? field.help(row) : field.help);
+/* `widget: "checklist"`: the picked ids, comma-separated. An id no
+ option has any more is dropped at the next change. */
+function Checklist({ id, options, value, disabled, empty, onChange }: {
+ id: string
+ options: { id: string; label: string }[]
+ value?: string | null
+ disabled?: boolean
+ empty?: string
+ onChange: (value: string) => void
+}) {
+ const picked = new Set((value ?? "").split(",").filter(Boolean));
+ if (options.length === 0) return