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
{entry.detail}
} + {entry.tags?.length ? ( +Tags: {tags.filter((tag) => entry.tags!.includes(tag.key)).map((tag) => tag.name).join(', ')}
+ ) : null} {entry.person?.tagline &&{entry.person.tagline}
} {entry.description &&+ {day.name || 'Schedule'} +
+ )} +{empty ?? "Nothing to pick yet."}
; + const toggle = (key: string) => { + const next = new Set(picked); + if (next.has(key)) next.delete(key); + else next.add(key); + onChange(options.filter((o) => next.has(o.id)).map((o) => o.id).join(",")); + }; + return ( +