Map block: sections of its own, shown one at a time
Migration 094 adds content_block_map_sections: a map block groups its venue's locations for its page, eg. Main spaces, without changing the venue. With sections the API cuts the block's venue to the locations they hold, in their order; the list groups under their names, and buttons (All, then each section) show one section's marks and rows. A schedule's place links only when a map on the page shows it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
06bf033448
commit
56a6e11655
8 changed files with 200 additions and 43 deletions
|
|
@ -187,6 +187,32 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) {
|
|||
attachVenues(db, [...byId.values()]);
|
||||
attachEvents(db, [...byId.values()], depth);
|
||||
|
||||
// A map block's sections (094): each names some of its venue's
|
||||
// locations. With any, the block's venue is cut to the locations
|
||||
// they name, in their order, so the page, its schedule's links
|
||||
// and the presentation all see the same places, numbered alike.
|
||||
const sectionRows = db
|
||||
.prepare(
|
||||
`SELECT block_id, name, location_keys
|
||||
FROM content_block_map_sections
|
||||
WHERE block_id IN (${placeholders(blockIds.length)})
|
||||
ORDER BY block_id, sort_order`,
|
||||
)
|
||||
.all(...blockIds);
|
||||
for (const row of sectionRows) {
|
||||
const block = byId.get(row.block_id);
|
||||
if (!block?.venue) continue;
|
||||
const known = new Set(block.venue.locations.map((location) => location.key));
|
||||
const keys = (row.location_keys ?? "").split(",").filter((key) => known.has(key));
|
||||
if (keys.length) (block.map_sections ??= []).push({ name: row.name, keys });
|
||||
}
|
||||
for (const block of byId.values()) {
|
||||
if (!block.map_sections) continue;
|
||||
const byKey = new Map(block.venue.locations.map((location) => [location.key, location]));
|
||||
const shown = [...new Set(block.map_sections.flatMap((section) => section.keys))];
|
||||
block.venue = { ...block.venue, locations: shown.map((key) => byKey.get(key)) };
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue