Organization cards: list partners, ministries or a hand-picked set (migration 067)

The Partners section's preset gets "Cards: list" (partners by default,
ministries, or both) and an optional hand-picked list
(page_section_orgs, partners or ministries only, enforced by trigger)
that replaces it in its own order. /organizations takes kind=ministry
and ids=; the plain list still leaves ministries out. Ministry cards
link to their website only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-04 22:40:24 -05:00
parent 635dd21083
commit fd7e1b6fc1
11 changed files with 146 additions and 23 deletions

View file

@ -72,7 +72,7 @@ const content = new Hono();
// Kinds with a public page. A ministry (063_ministries.sql) has none:
// it's only named on its groups' pages, so no route here serves one.
const ORG_KINDS = ["national", "region", "group", "partner"];
const ORG_KINDS = ["national", "region", "group", "partner", "ministry"];
/* ── Loaders ───────────────────────────────────────────────── */
@ -597,6 +597,11 @@ content.get("/events/:id", (c) => {
GET /organizations every published, listed org
GET /organizations?kind=region one kind
GET /organizations?kind=region,group
GET /organizations?ids=a,b these, published, listed or
not (a hand-picked list, 067)
Ministries come only when asked for, by kind or id: they have no
page, so the plain list leaves them out.
Whatever the kind, the common card fields are in the same
places, so a list component reads `name`, `color`, `logo` and
@ -616,19 +621,21 @@ content.get("/organizations", (c) => {
return c.json({ error: `kind must be one of ${ORG_KINDS.join(", ")}` }, 400);
}
const filter = kinds.length > 0 ? `AND kind IN (${marks(kinds.length)})` : "";
const ids = (c.req.query("ids") ?? "").split(",").map((id) => id.trim()).filter(Boolean).slice(0, 100);
const [where, params] =
ids.length > 0
? [`id IN (${marks(ids.length)})`, ids]
: kinds.length > 0
? [`is_listed = 1 AND kind IN (${marks(kinds.length)})`, kinds]
: [`is_listed = 1 AND kind <> 'ministry'`, []];
const rows = db
.prepare(
`SELECT * FROM organizations
WHERE is_published = 1 AND is_listed = 1 AND kind <> 'ministry' ${filter}
ORDER BY kind, sort_order, name`,
)
.all(...kinds);
.prepare(`SELECT * FROM organizations WHERE is_published = 1 AND ${where} ORDER BY kind, sort_order, name`)
.all(...params);
const ids = rows.map((row) => row.id);
const links = loadLinks(db, "organization", ids);
const cards = loadBlocks(db, "organization", ids, "card");
const found = rows.map((row) => row.id);
const links = loadLinks(db, "organization", found);
const cards = loadBlocks(db, "organization", found, "card");
// No body blocks or leadership: they grow with every organization
// and only a group's own detail panel or page shows them, which

View file

@ -37,11 +37,21 @@ sitePages.get("/site-pages/:id", (c) => {
const rows = db
.prepare(
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view, tag_id
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view, tag_id, org_kinds
FROM page_sections WHERE page_id = ? ORDER BY sort_order, id`,
)
.all(id);
const blocks = loadBlocks(db, "page_section", rows.map((row) => String(row.id)));
const picked = new Map();
for (const { section_id, org_id } of db
.prepare(
`SELECT o.section_id, o.org_id FROM page_section_orgs o
JOIN page_sections s ON s.id = o.section_id
WHERE s.page_id = ? ORDER BY o.section_id, o.sort_order, o.id`,
)
.all(id)) {
picked.set(section_id, [...(picked.get(section_id) ?? []), org_id]);
}
return json(c, {
page: {
@ -49,6 +59,7 @@ sitePages.get("/site-pages/:id", (c) => {
sections: rows.map(({ id: sectionId, ...section }) => ({
...section,
blocks: blocks.get(String(sectionId)) ?? [],
org_ids: picked.get(sectionId) ?? [],
})),
},
});