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:
parent
274ffc26e0
commit
7885d10249
9 changed files with 603 additions and 120 deletions
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue