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 <noreply@anthropic.com>
This commit is contained in:
parent
7885d10249
commit
71d58318b6
12 changed files with 539 additions and 122 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue