People blocks and host teams
- A "People" content block: a team's members as people tiles, people
picked one by one as items (each with a title), or both.
content_blocks gains team_id (migration 054 rebuilds it for the
type CHECK); a picked person rides on the item's person_id.
- An organization host can name a team (any organization's) to show
in its place: event_hosts.team_id, carried by v_event_hosts. The
event page reads "Hosted by" the team, linked to its page.
- Admin fields can show on `when: { path, filled: true }`.
- The showcase post has a people block; the past showcase event is
hosted by the region shown as its team.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6f86a113e0
commit
7c7cdaac14
10 changed files with 228 additions and 11 deletions
|
|
@ -150,6 +150,7 @@ export const blocksChild = (ownerKind) => ({
|
|||
"schedule",
|
||||
"table",
|
||||
"cards",
|
||||
"people",
|
||||
],
|
||||
{ required: true },
|
||||
),
|
||||
|
|
@ -158,6 +159,8 @@ export const blocksChild = (ownerKind) => ({
|
|||
url("href"),
|
||||
text("alt"),
|
||||
text("cite"),
|
||||
// People blocks only (054): whose team's tiles to show.
|
||||
text("team_id"),
|
||||
],
|
||||
children: [
|
||||
{
|
||||
|
|
@ -200,5 +203,6 @@ export const hostsChild = {
|
|||
table: "event_hosts",
|
||||
owner: { column: "event_id" },
|
||||
order: "sort_order",
|
||||
columns: [text("org_id"), text("person_id")],
|
||||
// team_id (054): an organization host's team, shown in its place.
|
||||
columns: [text("org_id"), text("person_id"), text("team_id")],
|
||||
};
|
||||
|
|
|
|||
140
server/src/migrations/054_people_blocks_host_teams.sql
Normal file
140
server/src/migrations/054_people_blocks_host_teams.sql
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 054 PEOPLE BLOCKS, HOST TEAMS, THE ORGANIZATION PAGE
|
||||
--
|
||||
-- A content block of type 'people': a team's people tiles, people
|
||||
-- picked one by one (items, each with a title), or both. The team
|
||||
-- is a new column, content_blocks.team_id; a picked person rides on
|
||||
-- the item's person_id, as a schedule entry's does. ContentBlocks.tsx
|
||||
-- draws it with PeopleTiles. The type CHECK changes, so the table is
|
||||
-- rebuilt as 045 did (legacy_alter_table around the rename, then its
|
||||
-- index and owner trigger again).
|
||||
--
|
||||
-- An event's organization host can name a team to show instead:
|
||||
-- event_hosts.team_id, any organization's team. The event page then
|
||||
-- reads "Hosted by <team>" linked to the team's page. v_event_hosts
|
||||
-- carries it (and v_events, which reads v_event_hosts, is made again
|
||||
-- around it, unchanged).
|
||||
--
|
||||
-- The Leadership page is now the Organization page, at /organization:
|
||||
-- a page title or intro saved for /leadership in Site settings moves
|
||||
-- with it.
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
-- ── Host teams ─────────────────────────────────────────────────
|
||||
|
||||
ALTER TABLE event_hosts ADD COLUMN team_id TEXT REFERENCES teams (id) ON DELETE SET NULL;
|
||||
|
||||
DROP VIEW v_events;
|
||||
DROP VIEW v_event_hosts;
|
||||
|
||||
CREATE VIEW v_event_hosts AS
|
||||
SELECT
|
||||
eh.id,
|
||||
eh.event_id,
|
||||
eh.sort_order,
|
||||
CASE WHEN eh.person_id IS NULL THEN 'organization' ELSE 'person' END
|
||||
AS host_kind,
|
||||
COALESCE(eh.org_id, eh.person_id) AS host_id,
|
||||
COALESCE(o.name, p.display_name) AS host_name,
|
||||
o.kind AS host_org_kind,
|
||||
o.logo AS host_logo,
|
||||
o.color AS host_color,
|
||||
p.photo AS host_photo,
|
||||
COALESCE(o.is_published, p.is_published) AS host_is_published,
|
||||
t.id AS host_team_id,
|
||||
t.name AS host_team_name
|
||||
FROM event_hosts eh
|
||||
LEFT JOIN organizations o ON o.id = eh.org_id
|
||||
LEFT JOIN people p ON p.id = eh.person_id
|
||||
LEFT JOIN teams t ON t.id = eh.team_id AND eh.org_id IS NOT NULL AND t.is_published = 1;
|
||||
|
||||
CREATE VIEW v_events AS
|
||||
SELECT
|
||||
e.*,
|
||||
h.host_kind,
|
||||
h.host_id,
|
||||
h.host_name,
|
||||
h.host_org_kind,
|
||||
COALESCE(e.org_logo, h.host_logo) AS effective_org_logo,
|
||||
COALESCE(e.color, h.host_color) AS effective_color,
|
||||
COALESCE(
|
||||
e.status,
|
||||
CASE WHEN e.ends_on IS NOT NULL AND e.ends_on < date('now')
|
||||
THEN 'past' ELSE 'upcoming' END
|
||||
) AS effective_status
|
||||
FROM events e
|
||||
LEFT JOIN v_event_hosts h
|
||||
ON h.id = (
|
||||
SELECT x.id
|
||||
FROM v_event_hosts x
|
||||
WHERE x.event_id = e.id
|
||||
ORDER BY x.sort_order, x.id
|
||||
LIMIT 1
|
||||
);
|
||||
|
||||
|
||||
-- ── People blocks ──────────────────────────────────────────────
|
||||
|
||||
CREATE TABLE content_blocks_new (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
owner_kind TEXT NOT NULL
|
||||
CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post')),
|
||||
owner_id TEXT NOT NULL,
|
||||
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body')),
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
|
||||
type TEXT NOT NULL
|
||||
CHECK (type IN ('heading', 'subheading', 'paragraph',
|
||||
'list', 'links', 'quote', 'image', 'divider',
|
||||
'video', 'button', 'callout', 'schedule', 'table', 'cards',
|
||||
'people')),
|
||||
text TEXT,
|
||||
media TEXT,
|
||||
href TEXT,
|
||||
alt TEXT,
|
||||
cite TEXT,
|
||||
team_id TEXT REFERENCES teams (id) ON DELETE SET NULL
|
||||
) STRICT;
|
||||
|
||||
INSERT INTO content_blocks_new
|
||||
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite)
|
||||
SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite
|
||||
FROM content_blocks;
|
||||
|
||||
PRAGMA legacy_alter_table = ON;
|
||||
DROP TABLE content_blocks;
|
||||
ALTER TABLE content_blocks_new RENAME TO content_blocks;
|
||||
PRAGMA legacy_alter_table = OFF;
|
||||
|
||||
CREATE INDEX content_blocks_owner_idx
|
||||
ON content_blocks (owner_kind, owner_id, slot, sort_order);
|
||||
|
||||
|
||||
-- ── The Organization page ──────────────────────────────────────
|
||||
|
||||
UPDATE site_setting_pages SET path = '/organization' WHERE path = '/leadership';
|
||||
|
||||
|
||||
-- ── Triggers last (see CLAUDE.md, Migrations) ──
|
||||
|
||||
CREATE TRIGGER content_blocks_owner_exists
|
||||
BEFORE INSERT ON content_blocks
|
||||
BEGIN
|
||||
SELECT CASE
|
||||
WHEN new.owner_kind = 'event'
|
||||
AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id)
|
||||
THEN RAISE(ABORT, 'content_blocks: no such event')
|
||||
WHEN new.owner_kind = 'organization'
|
||||
AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id)
|
||||
THEN RAISE(ABORT, 'content_blocks: no such organization')
|
||||
WHEN new.owner_kind = 'person'
|
||||
AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id)
|
||||
THEN RAISE(ABORT, 'content_blocks: no such person')
|
||||
WHEN new.owner_kind = 'team'
|
||||
AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id)
|
||||
THEN RAISE(ABORT, 'content_blocks: no such team')
|
||||
WHEN new.owner_kind = 'blog_post'
|
||||
AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id)
|
||||
THEN RAISE(ABORT, 'content_blocks: no such blog post')
|
||||
END;
|
||||
END;
|
||||
|
|
@ -88,7 +88,8 @@ function loadHosts(db, ids) {
|
|||
|
||||
const rows = db
|
||||
.prepare(
|
||||
`SELECT event_id, host_kind, host_id, host_name, host_org_kind
|
||||
`SELECT event_id, host_kind, host_id, host_name, host_org_kind,
|
||||
host_team_id, host_team_name
|
||||
FROM v_event_hosts
|
||||
WHERE event_id IN (${marks(ids.length)})
|
||||
AND host_is_published = 1
|
||||
|
|
@ -115,6 +116,9 @@ function shapeHost(row) {
|
|||
// Which of /regions, /groups, /partners the slug belongs to.
|
||||
// Null for a person, whose route needs no disambiguating.
|
||||
org_kind: row.host_org_kind,
|
||||
// The team an organization host is shown as, when one is set
|
||||
// (and published): the event page names and links it instead.
|
||||
team: row.host_team_id ? { id: row.host_team_id, name: row.host_team_name } : null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,10 @@ const ALL_BLOCKS = [
|
|||
{ text: "A card with a picture", detail: "Its description, up to three lines, under the title. The whole card is the link.", url: "/retreats", media: IMAGE },
|
||||
{ text: "An outside link, text only", detail: "The card shows the site it goes to above the title.", url: "https://example.org" },
|
||||
]],
|
||||
["subheading", { text: "People" }],
|
||||
["people", { team_id: TEAM }, [
|
||||
{ person_id: PERSON, text: "Picked as an item, with a title" },
|
||||
]],
|
||||
];
|
||||
|
||||
/* A record page's body: a handful of types, so it reads like a
|
||||
|
|
@ -426,7 +430,8 @@ tx(db, () => {
|
|||
is_published: 1,
|
||||
is_listed: LISTED,
|
||||
});
|
||||
insert("event_hosts", { event_id: PAST, org_id: REGION, sort_order: 0 });
|
||||
// Hosted by the region, shown as its team (054).
|
||||
insert("event_hosts", { event_id: PAST, org_id: REGION, team_id: TEAM, sort_order: 0 });
|
||||
insert("event_people", { event_id: PAST, person_id: PERSON, role: "host", is_public: 1, sort_order: 0 });
|
||||
blocks("event", PAST, "card", cardText("past event"));
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
|||
|
||||
const blockRows = db
|
||||
.prepare(
|
||||
`SELECT id, owner_id, type, text, media, href, alt, cite
|
||||
`SELECT id, owner_id, type, text, media, href, alt, cite, team_id
|
||||
FROM content_blocks
|
||||
WHERE owner_kind = ? AND slot = ? AND owner_id IN (${placeholders(ids.length)})
|
||||
ORDER BY owner_id, sort_order`,
|
||||
|
|
@ -85,6 +85,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
|||
href: row.href,
|
||||
alt: row.alt,
|
||||
cite: row.cite,
|
||||
team_id: row.team_id,
|
||||
items: [],
|
||||
};
|
||||
byId.set(row.id, block);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue