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:
Zaldimmar 2026-11-11 03:42:50 -06:00
parent 06bf033448
commit 56a6e11655
8 changed files with 200 additions and 43 deletions

View file

@ -264,6 +264,15 @@ export const blocksChild = (ownerKind) => ({
bool("no_tab"),
],
},
{
// A map block's own sections of its venue's locations (094).
key: "map_sections",
table: "content_block_map_sections",
owner: { column: "block_id" },
order: "sort_order",
when: { column: "type", value: "map" },
columns: [text("name", { required: true }), text("location_keys")],
},
],
});

View file

@ -0,0 +1,27 @@
-- ═══════════════════════════════════════════════════════════════
-- 094 A MAP BLOCK'S SECTIONS
--
-- A map content block can group its venue's locations into
-- sections of its own, eg. Main spaces, Small group spaces: the
-- block's list shows them under those names, and a visitor can pick
-- one to see only its locations on the map. They're the block's,
-- not the venue's, so each event groups the same venue its own way.
--
-- With sections, the block shows only the locations they name (in
-- the sections' order); without, every location, as before.
--
-- location_keys the venue's location_keys (088) it holds,
-- comma-separated, as schedule tags are (087). A
-- key the venue no longer has is skipped.
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE content_block_map_sections (
id INTEGER PRIMARY KEY AUTOINCREMENT,
block_id INTEGER NOT NULL REFERENCES content_blocks (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
name TEXT NOT NULL,
location_keys TEXT
) STRICT;
CREATE INDEX content_block_map_sections_block_idx
ON content_block_map_sections (block_id, sort_order);

View file

@ -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;
}