People directories, ministries, organization contacts (migrations 062 to 064)
- People tags (062): Data → People tags (Musicians seeded); a person's Directories repeater tags them and their Specialty line shows on their tile. A People directory section preset shows a tag's first 12 and links to its full page, /directory/<tag>, with page meta and a sitemap entry. Tiles' details panels show a person's links. - Ministries (063): a new organization kind. A group picks its ministry and its page says "Ministry: <name>", linked to the ministry's website. Ministries have no public page, list, sitemap or timeline entry, and aren't offered where a record links to its organization. organizations is rebuilt for the kind CHECK. - Organization contacts (064): Data → Contact types; a private Contacts repeater on each organization (editors and up, readRole on a child collection). Tools → Newsletter → Recipients filters them by type, kind, region and published and downloads a Mailchimp CSV. - A trigger refusing a save with a sentence is shown as that message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
07e56bfd20
commit
0ed7315156
38 changed files with 1108 additions and 29 deletions
|
|
@ -28,9 +28,10 @@ what a dropdown in the admin editor says.
|
||||||
| If it's… | It lives in… | Change it by… |
|
| If it's… | It lives in… | Change it by… |
|
||||||
| ------------------------------------------------------------ | ---------------- | ------------------------------------ |
|
| ------------------------------------------------------------ | ---------------- | ------------------------------------ |
|
||||||
| A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin |
|
| A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin |
|
||||||
|
| People tags (directories, eg. Musicians, at `/directory/<tag>`) and contact types (Minister, General info), and organizations' contacts | the database | Admin → Data → People tags, Contact types; who carries a tag is set on the person, contacts on the organization |
|
||||||
| The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page |
|
| The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page |
|
||||||
| Blog posts, and the Community page's blog settings (headings, pins, feeds) | the database | Admin → Data → Blog posts, and Admin → Pages → Community |
|
| Blog posts, and the Community page's blog settings (headings, pins, feeds) | the database | Admin → Data → Blog posts, and Admin → Pages → Community |
|
||||||
| The sections of Retreats, Community, Resources, Organization and History: titles, blurbs, accents, their content blocks and presets (the blog, groups map, regions, partners, events, timeline) | the database | Admin → Pages → the page. A section title is 30 characters at most (it's listed in the side nav); a front page heading fits about 60. Preset names: `PRESETS` in `src/lib/adminSchema/sitePages.ts`, what each draws: `PRESETS` in `src/pages/SitePage.tsx` |
|
| The sections of Retreats, Community, Resources, Organization and History: titles, blurbs, accents, their content blocks and presets (the blog, groups map, regions, partners, events, timeline, a people directory) | the database | Admin → Pages → the page. A section title is 30 characters at most (it's listed in the side nav); a front page heading fits about 60. Preset names: `PRESETS` in `src/lib/adminSchema/sitePages.ts`, what each draws: `PRESETS` in `src/pages/SitePage.tsx` |
|
||||||
| The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) |
|
| The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) |
|
||||||
| The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) |
|
| The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) |
|
||||||
| Navigation, colors, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) |
|
| Navigation, colors, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) |
|
||||||
|
|
@ -166,7 +167,7 @@ also in `server/src/admin-schema/` and a CHECK):
|
||||||
|
|
||||||
| Entity → field | Stored values | Labeled? | Also used on the public site by |
|
| Entity → field | Stored values | Labeled? | Also used on the public site by |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| Organizations → Kind (+ list filter) | national, region, group, partner | no, shows values | `ORG_BASE` in `src/lib/hrefs.ts` (the route each kind uses) |
|
| Organizations → Kind (+ list filter) | national, region, group, partner, ministry | no, shows values | `ORG_BASE` in `src/lib/hrefs.ts` (the route each kind uses). A ministry has no page or list on the public site (the public routes, `pageMeta.js` and the sitemap leave it out, `ORG_KINDS` in `server/src/routes/content.js` doesn't take it); only its groups name it. `KINDS` in `src/components/admin/NewsletterRecipients.tsx` (the export's filter) lists every kind too. |
|
||||||
| Organizations → Region → Scope | domestic, international, virtual | no | the Community page groups regions by it |
|
| Organizations → Region → Scope | domestic, international, virtual | no | the Community page groups regions by it |
|
||||||
| Organizations → Region areas → Edge | top, bottom | no | the group map (`OrgList-Map.tsx`) |
|
| Organizations → Region areas → Edge | top, bottom | no | the group map (`OrgList-Map.tsx`) |
|
||||||
| Events → Type (+ list filter) | retreat, class, workshop, meeting, other | no | `EVENT_TYPES` in `src/lib/eventTypes.ts` (public labels and plurals) |
|
| Events → Type (+ list filter) | retreat, class, workshop, meeting, other | no | `EVENT_TYPES` in `src/lib/eventTypes.ts` (public labels and plurals) |
|
||||||
|
|
@ -188,6 +189,7 @@ also in `server/src/admin-schema/` and a CHECK):
|
||||||
| Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) |
|
| Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) |
|
||||||
| Front page → Featured cards → Card type (Community → Community blog: pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` |
|
| Front page → Featured cards → Card type (Community → Community blog: pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` |
|
||||||
| Front page → Featured cards → Record type | event, organization, person, team, award | no | `FEATURED_REFS` in `server/src/shape.js` (what each fills the card with); the triggers in `030_featured_cards.sql` |
|
| Front page → Featured cards → Record type | event, organization, person, team, award | no | `FEATURED_REFS` in `server/src/shape.js` (what each fills the card with); the triggers in `030_featured_cards.sql` |
|
||||||
|
| Pages → Sections → Preset | community_blog, group_map, region_list, partner_list, events, timeline, people_directory | **yes**, `PRESETS` in `src/lib/adminSchema/sitePages.ts` (which pages offer which, the list passed to each `sitePage`) | `PRESETS` in `src/pages/SitePage.tsx`. A People directory shows its tag's first `DIRECTORY_PREVIEW` people (`src/pages/sections/PeopleDirectory.tsx`), linking to `/directory/<tag>`. |
|
||||||
| Every list → Published / Listed / Featured filter | 1, 0 | **yes** | n/a |
|
| Every list → Published / Listed / Featured filter | 1, 0 | **yes** | n/a |
|
||||||
|
|
||||||
"No, shows values" means the dropdown currently shows the raw value,
|
"No, shows values" means the dropdown currently shows the raw value,
|
||||||
|
|
@ -199,11 +201,14 @@ code):
|
||||||
| Dropdown | `optionsFrom` | Comes from |
|
| Dropdown | `optionsFrom` | Comes from |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| Group → Region | `regions` | organizations of kind region |
|
| Group → Region | `regions` | organizations of kind region |
|
||||||
|
| Group → Ministry | `ministries` | organizations of kind ministry |
|
||||||
|
| People → Directories → Tag; Pages → Sections → Directory: tag | `person_tag_types` | Data → People tags |
|
||||||
|
| Organizations → Contacts → Type | `contact_types` | Data → Contact types |
|
||||||
| Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) |
|
| Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) |
|
||||||
| Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labeled by name |
|
| Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labeled by name, except ministries (they have no page to link to) |
|
||||||
| Event hosts / event people / team members / timeline people → Person | `people` | people |
|
| Event hosts / event people / team members / timeline people → Person | `people` | people |
|
||||||
| Community → Community blog: pinned posts (ours) → Post | `blog_posts` | blog posts, newest first |
|
| Community → Community blog: pinned posts (ours) → Post | `blog_posts` | blog posts, newest first |
|
||||||
| Timeline → Record; Featured cards → Record | `record_refs` | every event, organization, award, person and team, narrowed by the type picked beside it |
|
| Timeline → Record; Featured cards → Record | `record_refs` | every event, organization (but ministries), award, person and team, narrowed by the type picked beside it |
|
||||||
| Affiliations → Team | `teams` | teams, filtered to the chosen organization |
|
| Affiliations → Team | `teams` | teams, filtered to the chosen organization |
|
||||||
| Person awards → Award | `awards` | awards, labeled "Award (Organization)" |
|
| Person awards → Award | `awards` | awards, labeled "Award (Organization)" |
|
||||||
| Person awards → Presented at; Front page → Count down to; Front page → Featured event | `events` | events |
|
| Person awards → Presented at; Front page → Count down to; Front page → Featured event | `events` | events |
|
||||||
|
|
|
||||||
|
|
@ -669,6 +669,12 @@ function wrapDbErrors(fn) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A trigger that refuses with a sentence (RAISE(ABORT, 'A group's
|
||||||
|
// ministry must be a ministry.')) is its own message.
|
||||||
|
if (err.errcode === 1811 && /\s/.test(message) && /[.!?]$/.test(message)) {
|
||||||
|
throw new HttpError(422, message);
|
||||||
|
}
|
||||||
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@
|
||||||
extensions 1:1 side tables, optionally gated on a column
|
extensions 1:1 side tables, optionally gated on a column
|
||||||
value (organizations.kind decides whether a
|
value (organizations.kind decides whether a
|
||||||
regions or groups row should exist)
|
regions or groups row should exist)
|
||||||
children ordered collections, replaced wholesale on save
|
children ordered collections, replaced wholesale on save;
|
||||||
|
`readRole` on one hides it from lesser roles, as
|
||||||
|
on an extension (an organization's contacts)
|
||||||
singleton the one id this entity ever has; the engine
|
singleton the one id this entity ever has; the engine
|
||||||
refuses create and delete (see front_page)
|
refuses create and delete (see front_page)
|
||||||
check (db, id) => void, run after a save has written
|
check (db, id) => void, run after a save has written
|
||||||
|
|
@ -52,6 +54,8 @@ import { frontPage } from "./admin-schema/frontPage.js";
|
||||||
import { blogPosts } from "./admin-schema/blog.js";
|
import { blogPosts } from "./admin-schema/blog.js";
|
||||||
import { siteSettings } from "./admin-schema/siteSettings.js";
|
import { siteSettings } from "./admin-schema/siteSettings.js";
|
||||||
import { newsletters } from "./admin-schema/newsletters.js";
|
import { newsletters } from "./admin-schema/newsletters.js";
|
||||||
|
import { personTagTypes } from "./admin-schema/personTags.js";
|
||||||
|
import { contactTypes } from "./admin-schema/contactTypes.js";
|
||||||
import {
|
import {
|
||||||
communityPage,
|
communityPage,
|
||||||
retreatsPage,
|
retreatsPage,
|
||||||
|
|
@ -64,6 +68,8 @@ export const ENTITIES = {
|
||||||
organizations,
|
organizations,
|
||||||
events,
|
events,
|
||||||
people,
|
people,
|
||||||
|
person_tag_types: personTagTypes,
|
||||||
|
contact_types: contactTypes,
|
||||||
teams,
|
teams,
|
||||||
awards,
|
awards,
|
||||||
timeline,
|
timeline,
|
||||||
|
|
@ -81,13 +87,20 @@ export const ENTITIES = {
|
||||||
/* ── Options for the form's select inputs ────────────────────── */
|
/* ── Options for the form's select inputs ────────────────────── */
|
||||||
|
|
||||||
export const OPTION_QUERIES = {
|
export const OPTION_QUERIES = {
|
||||||
|
// Ministries have no public page (063_ministries.sql), so nothing
|
||||||
|
// that links to its organization can pick one; a group picks its
|
||||||
|
// ministry from `ministries`.
|
||||||
organizations:
|
organizations:
|
||||||
"SELECT id, name AS label, kind FROM organizations ORDER BY kind, name",
|
"SELECT id, name AS label, kind FROM organizations WHERE kind <> 'ministry' ORDER BY kind, name",
|
||||||
regions:
|
regions:
|
||||||
"SELECT id, name AS label FROM organizations WHERE kind = 'region' ORDER BY name",
|
"SELECT id, name AS label FROM organizations WHERE kind = 'region' ORDER BY name",
|
||||||
|
ministries:
|
||||||
|
"SELECT id, name AS label FROM organizations WHERE kind = 'ministry' ORDER BY name",
|
||||||
event_scopes: "SELECT id, name AS label FROM event_scopes ORDER BY sort_order",
|
event_scopes: "SELECT id, name AS label FROM event_scopes ORDER BY sort_order",
|
||||||
events: "SELECT id, title AS label FROM events ORDER BY starts_on DESC, title",
|
events: "SELECT id, title AS label FROM events ORDER BY starts_on DESC, title",
|
||||||
people: "SELECT id, display_name AS label FROM people ORDER BY sort_name, display_name",
|
people: "SELECT id, display_name AS label FROM people ORDER BY sort_name, display_name",
|
||||||
|
person_tag_types: "SELECT id, name AS label FROM person_tag_types ORDER BY sort_order, name",
|
||||||
|
contact_types: "SELECT id, name AS label FROM contact_types ORDER BY sort_order, name",
|
||||||
blog_posts: "SELECT id, title AS label FROM blog_posts ORDER BY published_on DESC, title",
|
blog_posts: "SELECT id, title AS label FROM blog_posts ORDER BY published_on DESC, title",
|
||||||
|
|
||||||
// org_id rides along so the affiliation row can filter the list
|
// org_id rides along so the affiliation row can filter the list
|
||||||
|
|
@ -103,7 +116,7 @@ export const OPTION_QUERIES = {
|
||||||
record_refs: `
|
record_refs: `
|
||||||
SELECT 'event' AS kind, id, title AS label FROM events
|
SELECT 'event' AS kind, id, title AS label FROM events
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT 'organization', id, name || ' (' || kind || ')' FROM organizations
|
SELECT 'organization', id, name || ' (' || kind || ')' FROM organizations WHERE kind <> 'ministry'
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT 'award', id, name FROM awards
|
SELECT 'award', id, name FROM awards
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
|
||||||
25
server/src/admin-schema/contactTypes.js
Normal file
25
server/src/admin-schema/contactTypes.js
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { text, int } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── Contact types (064_org_contacts.sql) ────────────────────────
|
||||||
|
|
||||||
|
The roles an organization's contacts hold (Minister, General
|
||||||
|
info...), made in the admin. Its own entity, not a repeater,
|
||||||
|
because organization_contacts points at it; a type still in use
|
||||||
|
can't be deleted. The contacts themselves are edited on the
|
||||||
|
organization. */
|
||||||
|
|
||||||
|
export const contactTypes = {
|
||||||
|
key: "contact_types",
|
||||||
|
table: "contact_types",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: ["id", "name", "sort_order"],
|
||||||
|
filters: [],
|
||||||
|
search: ["name", "id"],
|
||||||
|
order: "sort_order, name",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [text("name", { required: true }), int("sort_order")],
|
||||||
|
};
|
||||||
|
|
@ -28,7 +28,7 @@ export const organizations = {
|
||||||
},
|
},
|
||||||
|
|
||||||
columns: [
|
columns: [
|
||||||
enumeration("kind", ["national", "region", "group", "partner"], {
|
enumeration("kind", ["national", "region", "group", "partner", "ministry"], {
|
||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
text("name", { required: true }),
|
text("name", { required: true }),
|
||||||
|
|
@ -62,13 +62,28 @@ export const organizations = {
|
||||||
table: "groups",
|
table: "groups",
|
||||||
idColumn: "id",
|
idColumn: "id",
|
||||||
when: { column: "kind", value: "group" },
|
when: { column: "kind", value: "group" },
|
||||||
columns: [text("region_id"), text("meets"), text("started")],
|
columns: [text("region_id"), text("ministry_id"), text("meets"), text("started")],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
linksChild("organization"),
|
linksChild("organization"),
|
||||||
blocksChild("organization"),
|
blocksChild("organization"),
|
||||||
|
// Who to write to there, by role (064_org_contacts.sql): private,
|
||||||
|
// for the Newsletter's recipient export.
|
||||||
|
{
|
||||||
|
key: "contacts",
|
||||||
|
table: "organization_contacts",
|
||||||
|
owner: { column: "org_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
readRole: "editor",
|
||||||
|
columns: [
|
||||||
|
text("type_id", { required: true }),
|
||||||
|
text("name"),
|
||||||
|
text("email"),
|
||||||
|
text("phone"),
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "region_areas",
|
key: "region_areas",
|
||||||
table: "region_areas",
|
table: "region_areas",
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ export const people = {
|
||||||
text("sort_name"),
|
text("sort_name"),
|
||||||
text("pronouns"),
|
text("pronouns"),
|
||||||
text("tagline"),
|
text("tagline"),
|
||||||
|
text("specialty"),
|
||||||
text("photo"),
|
text("photo"),
|
||||||
text("bio"),
|
text("bio"),
|
||||||
text("primary_org_id"),
|
text("primary_org_id"),
|
||||||
|
|
@ -61,6 +62,14 @@ export const people = {
|
||||||
],
|
],
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
// The directories they're in (person_tag_types).
|
||||||
|
{
|
||||||
|
key: "tags",
|
||||||
|
table: "person_tags",
|
||||||
|
owner: { column: "person_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [text("tag_id", { required: true })],
|
||||||
|
},
|
||||||
linksChild("person"),
|
linksChild("person"),
|
||||||
blocksChild("person"),
|
blocksChild("person"),
|
||||||
{
|
{
|
||||||
|
|
|
||||||
24
server/src/admin-schema/personTags.js
Normal file
24
server/src/admin-schema/personTags.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { text, int } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── People tags (062_people_tags.sql) ───────────────────────────
|
||||||
|
|
||||||
|
What a person can be tagged as for a directory (Musicians first).
|
||||||
|
Its own entity, not a repeater, because person_tags points at it:
|
||||||
|
deleting a tag takes its rows on people with it (cascade). Which
|
||||||
|
people carry a tag is edited on the person. */
|
||||||
|
|
||||||
|
export const personTagTypes = {
|
||||||
|
key: "person_tag_types",
|
||||||
|
table: "person_tag_types",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: ["id", "name", "blurb", "sort_order"],
|
||||||
|
filters: [],
|
||||||
|
search: ["name", "id"],
|
||||||
|
order: "sort_order, name",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [text("name", { required: true }), text("blurb"), int("sort_order")],
|
||||||
|
};
|
||||||
|
|
@ -30,10 +30,12 @@ const sectionsChild = {
|
||||||
"partner_list",
|
"partner_list",
|
||||||
"events",
|
"events",
|
||||||
"timeline",
|
"timeline",
|
||||||
|
"people_directory",
|
||||||
]),
|
]),
|
||||||
text("scope_id"),
|
text("scope_id"),
|
||||||
enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"]),
|
enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"]),
|
||||||
enumeration("view", ["carousel", "grid", "map"]),
|
enumeration("view", ["carousel", "grid", "map"]),
|
||||||
|
text("tag_id"),
|
||||||
],
|
],
|
||||||
children: [blocksChild("page_section")],
|
children: [blocksChild("page_section")],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
89
server/src/migrations/062_people_tags.sql
Normal file
89
server/src/migrations/062_people_tags.sql
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 062 PEOPLE TAGS AND THE PEOPLE DIRECTORY
|
||||||
|
--
|
||||||
|
-- A tag marks people for a directory, rather than making a team of
|
||||||
|
-- them: Musician first, more (Speakers, Teachers) added in the admin
|
||||||
|
-- (Data → People tags) with no code.
|
||||||
|
--
|
||||||
|
-- person_tag_types the tags: a name, the full directory page's
|
||||||
|
-- intro (/directory/<id>) and their order
|
||||||
|
-- person_tags which people carry which tags; a person's
|
||||||
|
-- own repeater, so deleting a tag takes its
|
||||||
|
-- rows with it (cascade)
|
||||||
|
-- people.specialty one line shown in a directory, eg. "Vocals,
|
||||||
|
-- piano · Gospel, folk"
|
||||||
|
-- page_sections a 'people_directory' preset drawing one tag's
|
||||||
|
-- people (tag_id), a short list linking to the
|
||||||
|
-- full page; rebuilt for the preset CHECK as 058
|
||||||
|
-- did, then its index and trigger again
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
CREATE TABLE person_tag_types (
|
||||||
|
id TEXT PRIMARY KEY
|
||||||
|
CONSTRAINT "A tag's URL ID can use only lowercase letters, numbers and hyphens, eg. musician."
|
||||||
|
CHECK (id <> '' AND id NOT GLOB '*[^a-z0-9-]*'),
|
||||||
|
name TEXT NOT NULL, -- 'Musicians', the directory's title
|
||||||
|
blurb TEXT, -- the full directory page's intro
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
INSERT INTO person_tag_types (id, name, blurb, sort_order) VALUES
|
||||||
|
('musician', 'Musicians', 'Musicians in the NGU community, for services, retreats and events.', 0);
|
||||||
|
|
||||||
|
CREATE TABLE person_tags (
|
||||||
|
person_id TEXT NOT NULL REFERENCES people (id) ON DELETE CASCADE,
|
||||||
|
tag_id TEXT NOT NULL REFERENCES person_tag_types (id) ON DELETE CASCADE,
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (person_id, tag_id)
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
CREATE INDEX person_tags_tag_idx ON person_tags (tag_id);
|
||||||
|
|
||||||
|
ALTER TABLE people ADD COLUMN specialty TEXT;
|
||||||
|
|
||||||
|
|
||||||
|
-- ── page_sections: the directory preset ────────────────────────
|
||||||
|
|
||||||
|
CREATE TABLE page_sections_new (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
page_id TEXT NOT NULL REFERENCES site_pages (id) ON DELETE CASCADE,
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
anchor TEXT NOT NULL
|
||||||
|
CONSTRAINT "A section's URL ID can use only lowercase letters, numbers and hyphens, eg. leadership."
|
||||||
|
CHECK (anchor <> '' AND anchor NOT GLOB '*[^a-z0-9-]*'),
|
||||||
|
title TEXT NOT NULL
|
||||||
|
CONSTRAINT "A section title can be 30 characters at most (it's listed in the page's side nav)."
|
||||||
|
CHECK (length(title) <= 30),
|
||||||
|
blurb TEXT,
|
||||||
|
accent TEXT CHECK (accent IN ('teal', 'deep', 'green', 'amber')),
|
||||||
|
preset TEXT CHECK (preset IN ('community_blog', 'group_map', 'region_list', 'partner_list',
|
||||||
|
'events', 'timeline', 'people_directory')),
|
||||||
|
-- An events preset's filter and first view.
|
||||||
|
scope_id TEXT REFERENCES event_scopes (id) ON DELETE SET NULL,
|
||||||
|
event_type TEXT CHECK (event_type IN ('retreat', 'class', 'workshop', 'meeting', 'other')),
|
||||||
|
view TEXT CHECK (view IN ('carousel', 'grid', 'map')),
|
||||||
|
-- A people_directory preset's tag.
|
||||||
|
tag_id TEXT REFERENCES person_tag_types (id) ON DELETE SET NULL,
|
||||||
|
UNIQUE (page_id, anchor)
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
INSERT INTO page_sections_new
|
||||||
|
(id, page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view)
|
||||||
|
SELECT id, page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view
|
||||||
|
FROM page_sections;
|
||||||
|
|
||||||
|
PRAGMA legacy_alter_table = ON;
|
||||||
|
DROP TABLE page_sections;
|
||||||
|
ALTER TABLE page_sections_new RENAME TO page_sections;
|
||||||
|
PRAGMA legacy_alter_table = OFF;
|
||||||
|
|
||||||
|
CREATE INDEX page_sections_page_idx ON page_sections (page_id, sort_order);
|
||||||
|
|
||||||
|
|
||||||
|
-- ── Triggers last (see CLAUDE.md, Migrations) ──
|
||||||
|
|
||||||
|
CREATE TRIGGER page_sections_cleanup
|
||||||
|
AFTER DELETE ON page_sections
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM content_blocks WHERE owner_kind = 'page_section' AND owner_id = CAST(old.id AS TEXT);
|
||||||
|
END;
|
||||||
114
server/src/migrations/063_ministries.sql
Normal file
114
server/src/migrations/063_ministries.sql
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 063 MINISTRIES
|
||||||
|
--
|
||||||
|
-- A Unity ministry (a church) is an organization of its own kind, so
|
||||||
|
-- the list of them is kept here and an NGU group can name the one it
|
||||||
|
-- belongs to. Ministries have no page and no list on the public site:
|
||||||
|
-- a group's page says "Ministry: <name>", linked to the ministry's
|
||||||
|
-- website when it has one.
|
||||||
|
--
|
||||||
|
-- organizations.kind gains 'ministry' (the CHECK changes, so the
|
||||||
|
-- table is rebuilt as 052 did, then its indexes
|
||||||
|
-- and triggers again)
|
||||||
|
-- groups.ministry_id the group's ministry, cleared if the ministry
|
||||||
|
-- is deleted; the trigger below keeps it to
|
||||||
|
-- ministries
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
CREATE TABLE organizations_new (
|
||||||
|
id TEXT PRIMARY KEY, -- slug: 'northwest', 'lynnwood'
|
||||||
|
kind TEXT NOT NULL
|
||||||
|
CHECK (kind IN ('national', 'region', 'group', 'partner', 'ministry')),
|
||||||
|
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
short_name TEXT,
|
||||||
|
tagline TEXT, -- one line, for the card
|
||||||
|
color TEXT,
|
||||||
|
logo TEXT, -- an upload's filename
|
||||||
|
|
||||||
|
venue TEXT,
|
||||||
|
address TEXT,
|
||||||
|
locality TEXT,
|
||||||
|
state_code TEXT, -- US only
|
||||||
|
country TEXT NOT NULL DEFAULT 'US',
|
||||||
|
location_label TEXT,
|
||||||
|
latitude REAL,
|
||||||
|
longitude REAL,
|
||||||
|
is_online INTEGER NOT NULL DEFAULT 0 CHECK (is_online IN (0, 1)),
|
||||||
|
|
||||||
|
is_published INTEGER NOT NULL DEFAULT 1 CHECK (is_published IN (0, 1)),
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||||
|
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||||
|
in_timeline INTEGER NOT NULL DEFAULT 0 CHECK (in_timeline IN (0, 1)),
|
||||||
|
is_listed INTEGER NOT NULL DEFAULT 1 CHECK (is_listed IN (0, 1))
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
INSERT INTO organizations_new
|
||||||
|
(id, kind, name, short_name, tagline, color, logo,
|
||||||
|
venue, address, locality, state_code, country, location_label,
|
||||||
|
latitude, longitude, is_online,
|
||||||
|
is_published, sort_order, created_at, updated_at, in_timeline, is_listed)
|
||||||
|
SELECT id, kind, name, short_name, tagline, color, logo,
|
||||||
|
venue, address, locality, state_code, country, location_label,
|
||||||
|
latitude, longitude, is_online,
|
||||||
|
is_published, sort_order, created_at, updated_at, in_timeline, is_listed
|
||||||
|
FROM organizations;
|
||||||
|
|
||||||
|
PRAGMA legacy_alter_table = ON;
|
||||||
|
DROP TABLE organizations;
|
||||||
|
ALTER TABLE organizations_new RENAME TO organizations;
|
||||||
|
PRAGMA legacy_alter_table = OFF;
|
||||||
|
|
||||||
|
CREATE INDEX organizations_kind_idx ON organizations (kind, is_published, sort_order);
|
||||||
|
CREATE INDEX organizations_state_idx ON organizations (state_code);
|
||||||
|
|
||||||
|
|
||||||
|
-- ── groups.ministry_id ─────────────────────────────────────────
|
||||||
|
|
||||||
|
ALTER TABLE groups ADD COLUMN ministry_id TEXT REFERENCES organizations (id) ON DELETE SET NULL;
|
||||||
|
|
||||||
|
|
||||||
|
-- ── Triggers last (see CLAUDE.md, Migrations) ──
|
||||||
|
|
||||||
|
CREATE TRIGGER organizations_cleanup
|
||||||
|
AFTER DELETE ON organizations
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM content_blocks WHERE owner_kind = 'organization' AND owner_id = old.id;
|
||||||
|
DELETE FROM links WHERE owner_kind = 'organization' AND owner_id = old.id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE TRIGGER timeline_organizations_cleanup
|
||||||
|
AFTER DELETE ON organizations
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM timeline_entries WHERE ref_kind = 'organization' AND ref_id = old.id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE TRIGGER organizations_featured_cleanup
|
||||||
|
AFTER DELETE ON organizations
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM featured_cards WHERE ref_kind = 'organization' AND ref_id = old.id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE TRIGGER organizations_touch
|
||||||
|
AFTER UPDATE ON organizations
|
||||||
|
FOR EACH ROW WHEN new.updated_at = old.updated_at
|
||||||
|
BEGIN
|
||||||
|
UPDATE organizations SET updated_at = datetime('now') WHERE id = new.id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE TRIGGER groups_ministry_kind
|
||||||
|
BEFORE INSERT ON groups
|
||||||
|
FOR EACH ROW WHEN new.ministry_id IS NOT NULL
|
||||||
|
AND (SELECT kind FROM organizations WHERE id = new.ministry_id) IS NOT 'ministry'
|
||||||
|
BEGIN
|
||||||
|
SELECT RAISE(ABORT, 'A group''s ministry must be a ministry.');
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE TRIGGER groups_ministry_kind_update
|
||||||
|
BEFORE UPDATE OF ministry_id ON groups
|
||||||
|
FOR EACH ROW WHEN new.ministry_id IS NOT NULL
|
||||||
|
AND (SELECT kind FROM organizations WHERE id = new.ministry_id) IS NOT 'ministry'
|
||||||
|
BEGIN
|
||||||
|
SELECT RAISE(ABORT, 'A group''s ministry must be a ministry.');
|
||||||
|
END;
|
||||||
38
server/src/migrations/064_org_contacts.sql
Normal file
38
server/src/migrations/064_org_contacts.sql
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 064 ORGANIZATION CONTACTS
|
||||||
|
--
|
||||||
|
-- Who to write to at an organization, by role, so a mailing list can
|
||||||
|
-- be exported (Tools → Newsletter → Recipients) filtered by role,
|
||||||
|
-- kind and region. Private: never sent to the public site.
|
||||||
|
--
|
||||||
|
-- contact_types the roles, made in the admin (Data →
|
||||||
|
-- Contact types), eg. Minister, General
|
||||||
|
-- info; none are seeded
|
||||||
|
-- organization_contacts an organization's contacts, each with a
|
||||||
|
-- role; its own repeater on the organization.
|
||||||
|
-- A role still in use can't be deleted (the
|
||||||
|
-- foreign key refuses it)
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
CREATE TABLE contact_types (
|
||||||
|
id TEXT PRIMARY KEY
|
||||||
|
CONSTRAINT "A contact type's URL ID can use only lowercase letters, numbers and hyphens, eg. minister."
|
||||||
|
CHECK (id <> '' AND id NOT GLOB '*[^a-z0-9-]*'),
|
||||||
|
name TEXT NOT NULL, -- 'Minister'
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
CREATE TABLE organization_contacts (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
org_id TEXT NOT NULL REFERENCES organizations (id) ON DELETE CASCADE,
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
type_id TEXT NOT NULL REFERENCES contact_types (id),
|
||||||
|
name TEXT,
|
||||||
|
email TEXT,
|
||||||
|
phone TEXT,
|
||||||
|
CONSTRAINT "A contact needs an email or a phone number."
|
||||||
|
CHECK (email IS NOT NULL OR phone IS NOT NULL)
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
CREATE INDEX organization_contacts_org_idx ON organization_contacts (org_id, sort_order);
|
||||||
|
CREATE INDEX organization_contacts_type_idx ON organization_contacts (type_id);
|
||||||
|
|
@ -252,8 +252,9 @@ function eventMeta(site, db, id, meta) {
|
||||||
function organizationMeta(site, db, id, kind, meta) {
|
function organizationMeta(site, db, id, kind, meta) {
|
||||||
const row = db.prepare(`SELECT * FROM organizations WHERE id = ? AND is_published = 1`).get(id);
|
const row = db.prepare(`SELECT * FROM organizations WHERE id = ? AND is_published = 1`).get(id);
|
||||||
// /regions/x must be a region: the same slug under the wrong route
|
// /regions/x must be a region: the same slug under the wrong route
|
||||||
// is a page the site doesn't have.
|
// is a page the site doesn't have. A ministry has no page at all
|
||||||
if (!row || (kind && row.kind !== kind)) return notFound(meta);
|
// (063_ministries.sql).
|
||||||
|
if (!row || (kind && row.kind !== kind) || row.kind === "ministry") return notFound(meta);
|
||||||
return {
|
return {
|
||||||
...meta,
|
...meta,
|
||||||
title: titled(site, row.name),
|
title: titled(site, row.name),
|
||||||
|
|
@ -307,6 +308,17 @@ function personMeta(site, db, id, meta) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A people tag's directory (062_people_tags.sql), /directory/:id. */
|
||||||
|
function directoryMeta(site, db, id, meta) {
|
||||||
|
const row = db.prepare(`SELECT * FROM person_tag_types WHERE id = ?`).get(id);
|
||||||
|
if (!row) return notFound(meta);
|
||||||
|
return {
|
||||||
|
...meta,
|
||||||
|
title: titled(site, row.name),
|
||||||
|
description: plainText(row.blurb) ?? meta.description,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function blogMeta(site, db, id, meta) {
|
function blogMeta(site, db, id, meta) {
|
||||||
const row = db.prepare(`SELECT * FROM blog_posts WHERE id = ? AND is_published = 1`).get(id);
|
const row = db.prepare(`SELECT * FROM blog_posts WHERE id = ? AND is_published = 1`).get(id);
|
||||||
if (!row) return notFound(meta);
|
if (!row) return notFound(meta);
|
||||||
|
|
@ -388,7 +400,7 @@ export function metaFor(db, rawPath) {
|
||||||
return { ...meta, title: titled(site, page.title), description: plainText(page.description) ?? meta.description };
|
return { ...meta, title: titled(site, page.title), description: plainText(page.description) ?? meta.description };
|
||||||
}
|
}
|
||||||
|
|
||||||
const match = pathname.match(/^\/(events|regions|groups|partners|organizations|teams|awards|people|blog)\/([^/]+)$/);
|
const match = pathname.match(/^\/(events|regions|groups|partners|organizations|teams|awards|people|blog|directory)\/([^/]+)$/);
|
||||||
if (!match) return notFound(meta);
|
if (!match) return notFound(meta);
|
||||||
|
|
||||||
const [, base, rawId] = match;
|
const [, base, rawId] = match;
|
||||||
|
|
@ -418,6 +430,8 @@ export function metaFor(db, rawPath) {
|
||||||
return personMeta(site, db, id, meta);
|
return personMeta(site, db, id, meta);
|
||||||
case "blog":
|
case "blog":
|
||||||
return blogMeta(site, db, id, meta);
|
return blogMeta(site, db, id, meta);
|
||||||
|
case "directory":
|
||||||
|
return directoryMeta(site, db, id, meta);
|
||||||
}
|
}
|
||||||
return notFound(meta);
|
return notFound(meta);
|
||||||
}
|
}
|
||||||
|
|
@ -522,7 +536,10 @@ export function sitemap(db) {
|
||||||
.all()
|
.all()
|
||||||
.map((r) => ({ loc: `/events/${r.id}`, lastmod: day(r.updated_at) })),
|
.map((r) => ({ loc: `/events/${r.id}`, lastmod: day(r.updated_at) })),
|
||||||
...db
|
...db
|
||||||
.prepare(`SELECT id, kind, updated_at FROM organizations WHERE is_published = 1 AND is_listed = 1`)
|
.prepare(
|
||||||
|
`SELECT id, kind, updated_at FROM organizations
|
||||||
|
WHERE is_published = 1 AND is_listed = 1 AND kind <> 'ministry'`,
|
||||||
|
)
|
||||||
.all()
|
.all()
|
||||||
.map((r) => ({ loc: `${ORG_ROUTES[r.kind] ?? "/organizations"}/${r.id}`, lastmod: day(r.updated_at) })),
|
.map((r) => ({ loc: `${ORG_ROUTES[r.kind] ?? "/organizations"}/${r.id}`, lastmod: day(r.updated_at) })),
|
||||||
...db
|
...db
|
||||||
|
|
@ -545,6 +562,10 @@ export function sitemap(db) {
|
||||||
.prepare(`SELECT id, updated_at FROM blog_posts WHERE is_published = 1 AND is_listed = 1`)
|
.prepare(`SELECT id, updated_at FROM blog_posts WHERE is_published = 1 AND is_listed = 1`)
|
||||||
.all()
|
.all()
|
||||||
.map((r) => ({ loc: `/blog/${r.id}`, lastmod: day(r.updated_at) })),
|
.map((r) => ({ loc: `/blog/${r.id}`, lastmod: day(r.updated_at) })),
|
||||||
|
...db
|
||||||
|
.prepare(`SELECT id FROM person_tag_types`)
|
||||||
|
.all()
|
||||||
|
.map((r) => ({ loc: `/directory/${r.id}` })),
|
||||||
];
|
];
|
||||||
|
|
||||||
const xml = entries
|
const xml = entries
|
||||||
|
|
|
||||||
|
|
@ -53,13 +53,17 @@ function entityForWrite(c) {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An extension can ask for more than a sign-in to be read
|
/* An extension or a child collection can ask for more than a
|
||||||
(readRole): a person's private details need editor. Blanked on
|
sign-in to be read (readRole): a person's private details and an
|
||||||
every row sent back, so a write's reply can't leak it either. */
|
organization's contacts need editor. Blanked on every row sent
|
||||||
|
back, so a write's reply can't leak it either. */
|
||||||
function visible(c, entity, row) {
|
function visible(c, entity, row) {
|
||||||
for (const ext of entity.extensions ?? []) {
|
for (const ext of entity.extensions ?? []) {
|
||||||
if (ext.readRole && !hasRole(c.get("user"), ext.readRole)) row[ext.key] = null;
|
if (ext.readRole && !hasRole(c.get("user"), ext.readRole)) row[ext.key] = null;
|
||||||
}
|
}
|
||||||
|
for (const child of entity.children ?? []) {
|
||||||
|
if (child.readRole && !hasRole(c.get("user"), child.readRole)) row[child.key] = [];
|
||||||
|
}
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -364,4 +364,55 @@ admin.get("/request-files", async (c) => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* ── Contacts for a mailing list (064_org_contacts.sql) ──────────
|
||||||
|
GET /contacts?types=minister,info&kinds=group®ion=northwest
|
||||||
|
Every organization contact matching the filters, for the
|
||||||
|
Newsletter's recipient export (a CSV made in the browser). Each
|
||||||
|
filter is optional; a region keeps the region itself and the
|
||||||
|
groups in it. Private, so editors and up only. Unpublished
|
||||||
|
organizations are left out unless ?unpublished=1. */
|
||||||
|
const CONTACT_KINDS = ["national", "region", "group", "partner", "ministry"];
|
||||||
|
const listParam = (value) => (value ?? "").split(",").map((v) => v.trim()).filter(Boolean);
|
||||||
|
|
||||||
|
admin.get("/contacts", requireRole("editor"), (c) => {
|
||||||
|
const db = c.get("db");
|
||||||
|
const types = listParam(c.req.query("types"));
|
||||||
|
const kinds = listParam(c.req.query("kinds")).filter((k) => CONTACT_KINDS.includes(k));
|
||||||
|
const region = c.req.query("region") || null;
|
||||||
|
|
||||||
|
const where = [];
|
||||||
|
const params = [];
|
||||||
|
if (types.length) {
|
||||||
|
where.push(`oc.type_id IN (${types.map(() => "?").join(",")})`);
|
||||||
|
params.push(...types);
|
||||||
|
}
|
||||||
|
if (kinds.length) {
|
||||||
|
where.push(`o.kind IN (${kinds.map(() => "?").join(",")})`);
|
||||||
|
params.push(...kinds);
|
||||||
|
}
|
||||||
|
if (region) {
|
||||||
|
where.push(`(o.id = ? OR g.region_id = ?)`);
|
||||||
|
params.push(region, region);
|
||||||
|
}
|
||||||
|
if (c.req.query("unpublished") !== "1") where.push(`o.is_published = 1`);
|
||||||
|
|
||||||
|
const rows = db
|
||||||
|
.prepare(
|
||||||
|
`SELECT oc.name, oc.email, oc.phone,
|
||||||
|
ct.id AS type_id, ct.name AS type_name,
|
||||||
|
o.id AS org_id, o.name AS org_name, o.kind AS org_kind,
|
||||||
|
r.name AS region_name
|
||||||
|
FROM organization_contacts oc
|
||||||
|
JOIN contact_types ct ON ct.id = oc.type_id
|
||||||
|
JOIN organizations o ON o.id = oc.org_id
|
||||||
|
LEFT JOIN groups g ON g.id = o.id
|
||||||
|
LEFT JOIN organizations r ON r.id = COALESCE(g.region_id, CASE o.kind WHEN 'region' THEN o.id END)
|
||||||
|
${where.length ? `WHERE ${where.join(" AND ")}` : ""}
|
||||||
|
ORDER BY o.kind, o.name, ct.sort_order, ct.name, oc.sort_order`,
|
||||||
|
)
|
||||||
|
.all(...params);
|
||||||
|
|
||||||
|
return c.json({ contacts: rows }, 200, NO_STORE);
|
||||||
|
});
|
||||||
|
|
||||||
export default admin;
|
export default admin;
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,8 @@ const content = new Hono();
|
||||||
// anything. stale-while-revalidate keeps the page instant while the
|
// anything. stale-while-revalidate keeps the page instant while the
|
||||||
// refresh happens behind it.
|
// refresh happens behind it.
|
||||||
|
|
||||||
|
// 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"];
|
||||||
|
|
||||||
/* ── Loaders ───────────────────────────────────────────────── */
|
/* ── Loaders ───────────────────────────────────────────────── */
|
||||||
|
|
@ -327,9 +329,14 @@ function attachGroupDetails(db, orgs) {
|
||||||
const rows = db
|
const rows = db
|
||||||
.prepare(
|
.prepare(
|
||||||
`SELECT c.id, c.region_id, c.meets, c.started,
|
`SELECT c.id, c.region_id, c.meets, c.started,
|
||||||
r.name AS region_name, r.color AS region_color
|
r.name AS region_name, r.color AS region_color,
|
||||||
|
m.name AS ministry_name,
|
||||||
|
(SELECT url FROM links
|
||||||
|
WHERE owner_kind = 'organization' AND owner_id = m.id AND kind = 'website'
|
||||||
|
ORDER BY sort_order LIMIT 1) AS ministry_url
|
||||||
FROM groups c
|
FROM groups c
|
||||||
LEFT JOIN organizations r ON r.id = c.region_id
|
LEFT JOIN organizations r ON r.id = c.region_id
|
||||||
|
LEFT JOIN organizations m ON m.id = c.ministry_id AND m.is_published = 1
|
||||||
WHERE c.id IN (${marks(ids.length)})`,
|
WHERE c.id IN (${marks(ids.length)})`,
|
||||||
)
|
)
|
||||||
.all(...ids);
|
.all(...ids);
|
||||||
|
|
@ -343,6 +350,10 @@ function attachGroupDetails(db, orgs) {
|
||||||
region_id: row.region_id ?? null,
|
region_id: row.region_id ?? null,
|
||||||
region_name: row.region_name ?? null,
|
region_name: row.region_name ?? null,
|
||||||
region_color: row.region_color ?? null,
|
region_color: row.region_color ?? null,
|
||||||
|
// The Unity ministry it belongs to: a name, and its website
|
||||||
|
// when it has one (ministries have no page here).
|
||||||
|
ministry_name: row.ministry_name ?? null,
|
||||||
|
ministry_url: row.ministry_url ?? null,
|
||||||
meets: row.meets ?? null,
|
meets: row.meets ?? null,
|
||||||
started: row.started ?? null,
|
started: row.started ?? null,
|
||||||
};
|
};
|
||||||
|
|
@ -610,7 +621,7 @@ content.get("/organizations", (c) => {
|
||||||
const rows = db
|
const rows = db
|
||||||
.prepare(
|
.prepare(
|
||||||
`SELECT * FROM organizations
|
`SELECT * FROM organizations
|
||||||
WHERE is_published = 1 AND is_listed = 1 ${filter}
|
WHERE is_published = 1 AND is_listed = 1 AND kind <> 'ministry' ${filter}
|
||||||
ORDER BY kind, sort_order, name`,
|
ORDER BY kind, sort_order, name`,
|
||||||
)
|
)
|
||||||
.all(...kinds);
|
.all(...kinds);
|
||||||
|
|
@ -639,7 +650,7 @@ content.get("/organizations/:id", (c) => {
|
||||||
const id = c.req.param("id");
|
const id = c.req.param("id");
|
||||||
|
|
||||||
const row = db
|
const row = db
|
||||||
.prepare(`SELECT * FROM organizations WHERE id = ? AND is_published = 1`)
|
.prepare(`SELECT * FROM organizations WHERE id = ? AND is_published = 1 AND kind <> 'ministry'`)
|
||||||
.get(id);
|
.get(id);
|
||||||
|
|
||||||
if (!row) return c.json({ error: "No such organization" }, 404);
|
if (!row) return c.json({ error: "No such organization" }, 404);
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ directory.get("/directory", (c) => {
|
||||||
organizations: all(
|
organizations: all(
|
||||||
`SELECT id, name, kind
|
`SELECT id, name, kind
|
||||||
FROM organizations
|
FROM organizations
|
||||||
WHERE is_published = 1 AND is_listed = 1
|
WHERE is_published = 1 AND is_listed = 1 AND kind <> 'ministry'
|
||||||
ORDER BY kind, name`,
|
ORDER BY kind, name`,
|
||||||
),
|
),
|
||||||
teams: all(
|
teams: all(
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,8 @@ history.get("/history", (c) => {
|
||||||
WHERE is_published = 1
|
WHERE is_published = 1
|
||||||
-- A standalone milestone reports null here and is unaffected.
|
-- A standalone milestone reports null here and is unaffected.
|
||||||
AND (ref_is_published IS NULL OR ref_is_published = 1)
|
AND (ref_is_published IS NULL OR ref_is_published = 1)
|
||||||
|
-- A ministry has no public page (063_ministries.sql).
|
||||||
|
AND (org_kind IS NULL OR org_kind <> 'ministry')
|
||||||
AND effective_date IS NOT NULL
|
AND effective_date IS NOT NULL
|
||||||
ORDER BY effective_date DESC, sort_order, id`,
|
ORDER BY effective_date DESC, sort_order, id`,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
GET /teams/:id/people current public members of a team
|
GET /teams/:id/people current public members of a team
|
||||||
GET /people?ids=a,b,c named people, any order
|
GET /people?ids=a,b,c named people, any order
|
||||||
GET /people/:id one person's page
|
GET /people/:id one person's page
|
||||||
|
GET /directories/:tag a tag's directory: its name and
|
||||||
|
intro, and its published, listed
|
||||||
|
people with their specialty and links
|
||||||
|
|
||||||
The team route reads v_org_leadership, which already decides who
|
The team route reads v_org_leadership, which already decides who
|
||||||
counts as current and public, affiliation still open, marked
|
counts as current and public, affiliation still open, marked
|
||||||
|
|
@ -21,7 +24,7 @@
|
||||||
|
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
|
||||||
import { asBool, json, loadOwned, marks, paragraphs, splitLinks } from "../shape.js";
|
import { asBool, json, loadLinks, loadOwned, marks, paragraphs, splitLinks } from "../shape.js";
|
||||||
import { postsBy } from "./blog.js";
|
import { postsBy } from "./blog.js";
|
||||||
|
|
||||||
const people = new Hono();
|
const people = new Hono();
|
||||||
|
|
@ -136,6 +139,54 @@ people.get("/people", (c) => {
|
||||||
return json(c, { people: rows.map(shapePerson) });
|
return json(c, { people: rows.map(shapePerson) });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* ── A tag's directory ─────────────────────────────────────────
|
||||||
|
Everyone carrying the tag (062_people_tags.sql), in name order,
|
||||||
|
each as a tile wants them plus their specialty line and links
|
||||||
|
(website, music, booking email). Unlisted people stay off it, as
|
||||||
|
they stay off every list.
|
||||||
|
───────────────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
people.get("/directories/:tag", (c) => {
|
||||||
|
const db = c.get("db");
|
||||||
|
const tag = db
|
||||||
|
.prepare(`SELECT id, name, blurb FROM person_tag_types WHERE id = ?`)
|
||||||
|
.get(c.req.param("tag"));
|
||||||
|
if (!tag) return c.json({ error: "No such directory." }, 404);
|
||||||
|
|
||||||
|
const rows = db
|
||||||
|
.prepare(
|
||||||
|
`SELECT p.id,
|
||||||
|
p.display_name,
|
||||||
|
p.pronouns,
|
||||||
|
p.photo,
|
||||||
|
p.tagline,
|
||||||
|
p.specialty,
|
||||||
|
p.location_label,
|
||||||
|
p.public_email,
|
||||||
|
p.bio,
|
||||||
|
o.id AS primary_org_id,
|
||||||
|
o.name AS primary_org_name
|
||||||
|
FROM person_tags t
|
||||||
|
JOIN people p ON p.id = t.person_id AND p.is_published = 1 AND p.is_listed = 1
|
||||||
|
LEFT JOIN organizations o ON o.id = p.primary_org_id AND o.is_published = 1
|
||||||
|
WHERE t.tag_id = ?
|
||||||
|
ORDER BY COALESCE(p.sort_name, p.display_name)`,
|
||||||
|
)
|
||||||
|
.all(tag.id);
|
||||||
|
const links = loadLinks(db, "person", rows.map((row) => row.id));
|
||||||
|
|
||||||
|
return json(c, {
|
||||||
|
directory: {
|
||||||
|
...tag,
|
||||||
|
people: rows.map((row) => ({
|
||||||
|
...shapePerson(row),
|
||||||
|
specialty: row.specialty,
|
||||||
|
links: links.get(row.id) ?? [],
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
/* ── One person's page ─────────────────────────────────────────
|
/* ── One person's page ─────────────────────────────────────────
|
||||||
Everything public that points at this person, each list with
|
Everything public that points at this person, each list with
|
||||||
the same visibility rules its own page applies: a role needs a
|
the same visibility rules its own page applies: a role needs a
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ sitePages.get("/site-pages/:id", (c) => {
|
||||||
|
|
||||||
const rows = db
|
const rows = db
|
||||||
.prepare(
|
.prepare(
|
||||||
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view
|
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view, tag_id
|
||||||
FROM page_sections WHERE page_id = ? ORDER BY sort_order, id`,
|
FROM page_sections WHERE page_id = ? ORDER BY sort_order, id`,
|
||||||
)
|
)
|
||||||
.all(id);
|
.all(id);
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ const TeamDetail = lazyPage(() => import("./pages/TeamDetail.tsx"))
|
||||||
const AwardDetail = lazyPage(() => import("./pages/AwardDetail.tsx"))
|
const AwardDetail = lazyPage(() => import("./pages/AwardDetail.tsx"))
|
||||||
const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx"))
|
const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx"))
|
||||||
const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx"))
|
const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx"))
|
||||||
|
const DirectoryPage = lazyPage(() => import("./pages/DirectoryPage.tsx"))
|
||||||
|
|
||||||
/*Admin Pages*/
|
/*Admin Pages*/
|
||||||
const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx"))
|
const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx"))
|
||||||
|
|
@ -100,6 +101,7 @@ export default function App() {
|
||||||
<Route path="/awards/:id" element={<AwardDetail />} />
|
<Route path="/awards/:id" element={<AwardDetail />} />
|
||||||
<Route path="/people/:id" element={<PersonDetail />} />
|
<Route path="/people/:id" element={<PersonDetail />} />
|
||||||
<Route path="/blog/:id" element={<BlogPost />} />
|
<Route path="/blog/:id" element={<BlogPost />} />
|
||||||
|
<Route path="/directory/:id" element={<DirectoryPage />} />
|
||||||
<Route path="organization" element={<SitePage key="organization" id="organization" />} />
|
<Route path="organization" element={<SitePage key="organization" id="organization" />} />
|
||||||
<Route path="resources" element={<SitePage key="resources" id="resources" />} />
|
<Route path="resources" element={<SitePage key="resources" id="resources" />} />
|
||||||
<Route path="history" element={<SitePage key="history" id="history" />} />
|
<Route path="history" element={<SitePage key="history" id="history" />} />
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,19 @@
|
||||||
text-underline-offset: 2px;
|
text-underline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A directory person's links: one per line's worth, wrapping. */
|
||||||
|
.pl__links {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.25rem 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pl__links a {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
.pl__bio-text {
|
.pl__bio-text {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 0.9375rem;
|
font-size: 0.9375rem;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import { mediaUrl, initials } from "../lib/media.ts";
|
||||||
import { useSmallImage } from "../lib/useSmallImage.ts";
|
import { useSmallImage } from "../lib/useSmallImage.ts";
|
||||||
import { paletteFill } from "../lib/color.ts";
|
import { paletteFill } from "../lib/color.ts";
|
||||||
import { useReadingMode } from "../lib/readingMode.ts";
|
import { useReadingMode } from "../lib/readingMode.ts";
|
||||||
|
import PlatformIcon from "./PlatformIcon.tsx";
|
||||||
import "./PeopleTiles.css";
|
import "./PeopleTiles.css";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -96,6 +97,8 @@ export interface Person {
|
||||||
pronouns?: string | null;
|
pronouns?: string | null;
|
||||||
location_label?: string | null;
|
location_label?: string | null;
|
||||||
public_email?: string | null;
|
public_email?: string | null;
|
||||||
|
/** Their website, music and social links (a directory's people). */
|
||||||
|
links?: PersonLink[] | null;
|
||||||
org?: string | { id?: string; name: string; href?: string } | null;
|
org?: string | { id?: string; name: string; href?: string } | null;
|
||||||
bio?: string | string[] | null;
|
bio?: string | string[] | null;
|
||||||
accent?: string;
|
accent?: string;
|
||||||
|
|
@ -105,6 +108,13 @@ export interface Person {
|
||||||
isOwner?: boolean;
|
isOwner?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PersonLink {
|
||||||
|
kind?: string;
|
||||||
|
platform?: string | null;
|
||||||
|
label: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
/** A person named by slug. Any other field overrides the record. */
|
/** A person named by slug. Any other field overrides the record. */
|
||||||
export interface PersonRef extends Partial<Omit<Person, "name">> {
|
export interface PersonRef extends Partial<Omit<Person, "name">> {
|
||||||
peopleslug: string;
|
peopleslug: string;
|
||||||
|
|
@ -881,6 +891,19 @@ function DetailPanel({
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{person.links?.length ? (
|
||||||
|
<div className="pl__fact">
|
||||||
|
<dt>Links</dt>
|
||||||
|
<dd className="pl__links">
|
||||||
|
{person.links.map((link) => (
|
||||||
|
<a key={link.url} href={link.url} target="_blank" rel="noreferrer">
|
||||||
|
<PlatformIcon platform={link.platform} />
|
||||||
|
{link.label}
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
{paragraphs.filter(Boolean).map((paragraph, index) => (
|
{paragraphs.filter(Boolean).map((paragraph, index) => (
|
||||||
|
|
@ -931,6 +954,11 @@ function ReadingPeople({ groups, level }: { groups: PeopleGroup[]; level: 3 | 4
|
||||||
Email: <a href={`mailto:${person.public_email}`}>{person.public_email}</a>
|
Email: <a href={`mailto:${person.public_email}`}>{person.public_email}</a>
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
{person.links?.map((link) => (
|
||||||
|
<p key={link.url}>
|
||||||
|
<a href={link.url}>{link.label}</a>
|
||||||
|
</p>
|
||||||
|
))}
|
||||||
{bio.filter(Boolean).map((paragraph, i) => (
|
{bio.filter(Boolean).map((paragraph, i) => (
|
||||||
<p key={i}>{paragraph}</p>
|
<p key={i}>{paragraph}</p>
|
||||||
))}
|
))}
|
||||||
|
|
@ -1022,7 +1050,11 @@ function hasDetails(person: Person): boolean {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return Boolean(
|
return Boolean(
|
||||||
person.pronouns || resolveOrg(person.org) || person.location_label || person.public_email,
|
person.pronouns ||
|
||||||
|
resolveOrg(person.org) ||
|
||||||
|
person.location_label ||
|
||||||
|
person.public_email ||
|
||||||
|
person.links?.length,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
222
src/components/admin/NewsletterRecipients.tsx
Normal file
222
src/components/admin/NewsletterRecipients.tsx
Normal file
|
|
@ -0,0 +1,222 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
NEWSLETTER RECIPIENTS (Tools → Newsletter)
|
||||||
|
|
||||||
|
Organization contacts (064_org_contacts.sql) as a mailing list:
|
||||||
|
pick contact types, organization kinds and a region, see who
|
||||||
|
matches, and download a CSV that Mailchimp (or a spreadsheet)
|
||||||
|
imports. Contacts are added on each organization; their types are
|
||||||
|
Data → Contact types. Private, so editors and up only (the API
|
||||||
|
says no to anyone else too: GET /admin/contacts).
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { DownloadSimple } from '@phosphor-icons/react'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
import { get } from '../../lib/api.ts'
|
||||||
|
|
||||||
|
type Option = { id: string; label: string }
|
||||||
|
|
||||||
|
type Contact = {
|
||||||
|
name: string | null
|
||||||
|
email: string | null
|
||||||
|
phone: string | null
|
||||||
|
type_name: string
|
||||||
|
org_name: string
|
||||||
|
org_kind: string
|
||||||
|
region_name: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The organization kinds, as the CHECK on organizations.kind has them. */
|
||||||
|
const KINDS: Array<[string, string]> = [
|
||||||
|
['national', 'National'],
|
||||||
|
['region', 'Regions'],
|
||||||
|
['group', 'Groups'],
|
||||||
|
['partner', 'Partners'],
|
||||||
|
['ministry', 'Ministries'],
|
||||||
|
]
|
||||||
|
|
||||||
|
/* How many matches show under the filters; the CSV has them all. */
|
||||||
|
const PREVIEW_ROWS = 8
|
||||||
|
|
||||||
|
const MUTED = 'var(--color-muted)'
|
||||||
|
const input =
|
||||||
|
'border border-muted/25 bg-surface px-3 py-2 text-sm text-body outline-none focus:border-brand focus:ring-2 focus:ring-brand/25'
|
||||||
|
const button =
|
||||||
|
'btn inline-flex items-center gap-2 border border-brand px-4 py-2 text-sm text-link transition-colors hover:bg-tint disabled:opacity-50'
|
||||||
|
|
||||||
|
const toggle = (list: string[], value: string) =>
|
||||||
|
list.includes(value) ? list.filter((v) => v !== value) : [...list, value]
|
||||||
|
|
||||||
|
/* "Jane Q. Doe" → Jane, Q. Doe: Mailchimp's First and Last Name. */
|
||||||
|
function splitName(name: string | null): [string, string] {
|
||||||
|
const parts = (name ?? '').trim().split(/\s+/).filter(Boolean)
|
||||||
|
return [parts[0] ?? '', parts.slice(1).join(' ')]
|
||||||
|
}
|
||||||
|
|
||||||
|
const csvCell = (value: string | null) => {
|
||||||
|
const text = value ?? ''
|
||||||
|
return /[",\n]/.test(text) ? `"${text.replace(/"/g, '""')}"` : text
|
||||||
|
}
|
||||||
|
|
||||||
|
function toCsv(rows: Contact[]): string {
|
||||||
|
const head = ['Email', 'First Name', 'Last Name', 'Phone', 'Organization', 'Kind', 'Region', 'Contact type']
|
||||||
|
const lines = rows.map((row) => {
|
||||||
|
const [first, last] = splitName(row.name)
|
||||||
|
return [row.email, first, last, row.phone, row.org_name, row.org_kind, row.region_name, row.type_name]
|
||||||
|
.map(csvCell)
|
||||||
|
.join(',')
|
||||||
|
})
|
||||||
|
return [head.join(','), ...lines].join('\n')
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function NewsletterRecipients() {
|
||||||
|
const [types, setTypes] = useState<Option[]>([])
|
||||||
|
const [regions, setRegions] = useState<Option[]>([])
|
||||||
|
const [picked, setPicked] = useState<string[]>([])
|
||||||
|
const [kinds, setKinds] = useState<string[]>([])
|
||||||
|
const [region, setRegion] = useState('')
|
||||||
|
const [unpublished, setUnpublished] = useState(false)
|
||||||
|
const [contacts, setContacts] = useState<Contact[] | null>(null)
|
||||||
|
const [error, setError] = useState<string | null>(null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
get('/admin/options?only=contact_types,regions', { ttl: 0 })
|
||||||
|
.then((data: { options: { contact_types: Option[]; regions: Option[] } }) => {
|
||||||
|
setTypes(data.options.contact_types)
|
||||||
|
setRegions(data.options.regions)
|
||||||
|
})
|
||||||
|
.catch((err) => setError(err instanceof Error ? err.message : 'Couldn’t load the contact types.'))
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const query = new URLSearchParams()
|
||||||
|
if (picked.length) query.set('types', picked.join(','))
|
||||||
|
if (kinds.length) query.set('kinds', kinds.join(','))
|
||||||
|
if (region) query.set('region', region)
|
||||||
|
if (unpublished) query.set('unpublished', '1')
|
||||||
|
let live = true
|
||||||
|
get(`/admin/contacts?${query}`, { ttl: 0 })
|
||||||
|
.then((data: { contacts: Contact[] }) => {
|
||||||
|
if (!live) return
|
||||||
|
setContacts(data.contacts)
|
||||||
|
setError(null)
|
||||||
|
})
|
||||||
|
.catch((err) => live && setError(err instanceof Error ? err.message : 'Couldn’t load the contacts.'))
|
||||||
|
return () => {
|
||||||
|
live = false
|
||||||
|
}
|
||||||
|
}, [picked, kinds, region, unpublished])
|
||||||
|
|
||||||
|
const withEmail = contacts?.filter((row) => row.email) ?? []
|
||||||
|
|
||||||
|
function download() {
|
||||||
|
const blob = new Blob([toCsv(withEmail)], { type: 'text/csv' })
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = URL.createObjectURL(blob)
|
||||||
|
link.download = `newsletter-recipients-${new Date().toISOString().slice(0, 10)}.csv`
|
||||||
|
link.click()
|
||||||
|
URL.revokeObjectURL(link.href)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="mt-10 border-l-4 border-brand bg-raised p-5 shadow-sm">
|
||||||
|
<h2 className="text-lg font-bold text-link">Recipients</h2>
|
||||||
|
<p className="mt-1 text-sm" style={{ color: MUTED }}>
|
||||||
|
Organization contacts as a mailing list. Add contacts on each organization; make their types under Data → Contact
|
||||||
|
types. Nothing picked in a filter means all of it.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="mt-4 grid gap-5 md:grid-cols-3">
|
||||||
|
<fieldset>
|
||||||
|
<legend className="text-sm font-semibold text-body">Contact types</legend>
|
||||||
|
{types.length === 0 && (
|
||||||
|
<p className="mt-1 text-sm" style={{ color: MUTED }}>
|
||||||
|
None yet: add them under Data → Contact types.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{types.map((type) => (
|
||||||
|
<label key={type.id} className="mt-1 flex items-center gap-2 text-sm text-body">
|
||||||
|
<input type="checkbox" checked={picked.includes(type.id)} onChange={() => setPicked(toggle(picked, type.id))} />
|
||||||
|
{type.label}
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend className="text-sm font-semibold text-body">Organization kinds</legend>
|
||||||
|
{KINDS.map(([kind, label]) => (
|
||||||
|
<label key={kind} className="mt-1 flex items-center gap-2 text-sm text-body">
|
||||||
|
<input type="checkbox" checked={kinds.includes(kind)} onChange={() => setKinds(toggle(kinds, kind))} />
|
||||||
|
{label}
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-semibold text-body">
|
||||||
|
Region
|
||||||
|
<select value={region} onChange={(e) => setRegion(e.target.value)} className={`mt-1 block w-full ${input}`}>
|
||||||
|
<option value="">Default: every region</option>
|
||||||
|
{regions.map((r) => (
|
||||||
|
<option key={r.id} value={r.id}>
|
||||||
|
{r.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<p className="mt-1 text-xs" style={{ color: MUTED }}>
|
||||||
|
The region itself and the groups in it
|
||||||
|
</p>
|
||||||
|
<label className="mt-3 flex items-center gap-2 text-sm text-body">
|
||||||
|
<input type="checkbox" checked={unpublished} onChange={(e) => setUnpublished(e.target.checked)} />
|
||||||
|
Include unpublished organizations
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-5 flex flex-wrap items-center gap-3">
|
||||||
|
<button type="button" onClick={download} className={button} disabled={withEmail.length === 0}>
|
||||||
|
<DownloadSimple weight="bold" aria-hidden="true" />
|
||||||
|
Download CSV
|
||||||
|
</button>
|
||||||
|
<p role="status" className={`text-sm ${error ? 'text-danger' : ''}`} style={error ? undefined : { color: MUTED }}>
|
||||||
|
{error ??
|
||||||
|
(contacts === null
|
||||||
|
? 'Loading…'
|
||||||
|
: `${withEmail.length} with an email` +
|
||||||
|
(contacts.length > withEmail.length ? ` (${contacts.length - withEmail.length} more have only a phone, left out)` : ''))}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{withEmail.length > 0 && (
|
||||||
|
<div className="mt-4 overflow-x-auto">
|
||||||
|
<table className="w-full text-left text-sm">
|
||||||
|
<thead>
|
||||||
|
<tr className="text-xs" style={{ color: MUTED }}>
|
||||||
|
<th className="py-1 pr-4 font-semibold">Email</th>
|
||||||
|
<th className="py-1 pr-4 font-semibold">Name</th>
|
||||||
|
<th className="py-1 pr-4 font-semibold">Organization</th>
|
||||||
|
<th className="py-1 pr-4 font-semibold">Type</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{withEmail.slice(0, PREVIEW_ROWS).map((row, index) => (
|
||||||
|
<tr key={`${row.email}-${index}`} className="border-t border-muted/15 text-body">
|
||||||
|
<td className="py-1 pr-4">{row.email}</td>
|
||||||
|
<td className="py-1 pr-4">{row.name || '-'}</td>
|
||||||
|
<td className="py-1 pr-4">{row.org_name}</td>
|
||||||
|
<td className="py-1 pr-4">{row.type_name}</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{withEmail.length > PREVIEW_ROWS && (
|
||||||
|
<p className="mt-2 text-xs" style={{ color: MUTED }}>
|
||||||
|
and {withEmail.length - PREVIEW_ROWS} more in the CSV
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -27,6 +27,8 @@ import { timeline } from "./adminSchema/timeline.ts";
|
||||||
import { frontPage } from "./adminSchema/frontPage.ts";
|
import { frontPage } from "./adminSchema/frontPage.ts";
|
||||||
import { blogPosts } from "./adminSchema/blog.ts";
|
import { blogPosts } from "./adminSchema/blog.ts";
|
||||||
import { siteSettings } from "./adminSchema/siteSettings.ts";
|
import { siteSettings } from "./adminSchema/siteSettings.ts";
|
||||||
|
import { personTagTypes } from "./adminSchema/personTags.ts";
|
||||||
|
import { contactTypes } from "./adminSchema/contactTypes.ts";
|
||||||
import {
|
import {
|
||||||
communityPage,
|
communityPage,
|
||||||
retreatsPage,
|
retreatsPage,
|
||||||
|
|
@ -39,6 +41,8 @@ export const ADMIN_ENTITIES: Record<string, any> = {
|
||||||
organizations,
|
organizations,
|
||||||
events,
|
events,
|
||||||
people,
|
people,
|
||||||
|
person_tag_types: personTagTypes,
|
||||||
|
contact_types: contactTypes,
|
||||||
teams,
|
teams,
|
||||||
awards,
|
awards,
|
||||||
timeline,
|
timeline,
|
||||||
|
|
|
||||||
32
src/lib/adminSchema/contactTypes.ts
Normal file
32
src/lib/adminSchema/contactTypes.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* ── Contact types (064_org_contacts.sql) ────────────────────────
|
||||||
|
Data → Contact types: the roles an organization's contacts hold,
|
||||||
|
eg. Minister, General info. Contacts are added on each
|
||||||
|
organization; Tools → Newsletter → Recipients exports them by
|
||||||
|
type. A type still in use can't be deleted. Server side:
|
||||||
|
server/src/admin-schema/contactTypes.js. */
|
||||||
|
|
||||||
|
export const contactTypes = {
|
||||||
|
key: "contact_types",
|
||||||
|
label: "Contact types",
|
||||||
|
singular: "contact type",
|
||||||
|
idLabel: "URL ID",
|
||||||
|
slugFrom: "name",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: [
|
||||||
|
{ key: "name", label: "Name", primary: true },
|
||||||
|
{ key: "sort_order", label: "Order" },
|
||||||
|
],
|
||||||
|
filters: [],
|
||||||
|
},
|
||||||
|
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
legend: "Contact type",
|
||||||
|
fields: [
|
||||||
|
{ path: "name", label: "Name", required: true, help: "eg. Minister, General info" },
|
||||||
|
{ path: "sort_order", label: "Sort order", widget: "number" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
@ -20,7 +20,7 @@ export const organizations = {
|
||||||
{ key: "is_listed", label: "Listed", widget: "bool" },
|
{ key: "is_listed", label: "Listed", widget: "bool" },
|
||||||
],
|
],
|
||||||
filters: [
|
filters: [
|
||||||
{ key: "kind", label: "Kind", options: ["national", "region", "group", "partner"] },
|
{ key: "kind", label: "Kind", options: ["national", "region", "group", "partner", "ministry"] },
|
||||||
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
||||||
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
||||||
],
|
],
|
||||||
|
|
@ -34,9 +34,9 @@ export const organizations = {
|
||||||
path: "kind",
|
path: "kind",
|
||||||
label: "Kind",
|
label: "Kind",
|
||||||
widget: "select",
|
widget: "select",
|
||||||
options: ["national", "region", "group", "partner"],
|
options: ["national", "region", "group", "partner", "ministry"],
|
||||||
required: true,
|
required: true,
|
||||||
help: "Changing this swaps which extra fields apply",
|
help: "Changing this swaps which extra fields apply. A ministry (a Unity church) has no page; its groups name it",
|
||||||
},
|
},
|
||||||
{ path: "name", label: "Name", required: true },
|
{ path: "name", label: "Name", required: true },
|
||||||
{ path: "short_name", label: "Short name" },
|
{ path: "short_name", label: "Short name" },
|
||||||
|
|
@ -70,6 +70,14 @@ export const organizations = {
|
||||||
optionsFrom: "regions",
|
optionsFrom: "regions",
|
||||||
blankLabel: "Default: none",
|
blankLabel: "Default: none",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "group.ministry_id",
|
||||||
|
label: "Ministry",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "ministries",
|
||||||
|
blankLabel: "Default: none",
|
||||||
|
help: "The Unity ministry it belongs to, named on its page (linked to the ministry's website)",
|
||||||
|
},
|
||||||
{ path: "group.meets", label: "Meets", help: "2nd Sundays, 6:00pm" },
|
{ path: "group.meets", label: "Meets", help: "2nd Sundays, 6:00pm" },
|
||||||
{ path: "group.started", label: "Started", help: "Since 2021" },
|
{ path: "group.started", label: "Started", help: "Since 2021" },
|
||||||
],
|
],
|
||||||
|
|
@ -101,6 +109,25 @@ export const organizations = {
|
||||||
{ path: "note", label: "Note", help: "details to explain why it's half or other note" },
|
{ path: "note", label: "Note", help: "details to explain why it's half or other note" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "contacts",
|
||||||
|
label: "Contacts",
|
||||||
|
note:
|
||||||
|
"Private: never on the public site, and only editors and up see them. " +
|
||||||
|
"Tools → Newsletter → Recipients exports them. Types are made under Data → Contact types.",
|
||||||
|
addLabel: "Add contact",
|
||||||
|
title: (row, options) =>
|
||||||
|
[options?.contact_types?.find((t) => t.id === row.type_id)?.label, row.name || row.email]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" · ") || "New contact",
|
||||||
|
blank: { type_id: "", name: "", email: "", phone: "" },
|
||||||
|
fields: [
|
||||||
|
{ path: "type_id", label: "Type", widget: "select", optionsFrom: "contact_types", required: true },
|
||||||
|
{ path: "name", label: "Name" },
|
||||||
|
{ path: "email", label: "Email", help: "An email or a phone is needed" },
|
||||||
|
{ path: "phone", label: "Phone" },
|
||||||
|
],
|
||||||
|
},
|
||||||
linksChild,
|
linksChild,
|
||||||
blocksChild,
|
blocksChild,
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,12 @@ export const people = {
|
||||||
{ path: "sort_name", label: "Sort name", help: "Doe, Jane" },
|
{ path: "sort_name", label: "Sort name", help: "Doe, Jane" },
|
||||||
{ path: "pronouns", label: "Pronouns" },
|
{ path: "pronouns", label: "Pronouns" },
|
||||||
{ path: "tagline", label: "Tagline", full: true },
|
{ path: "tagline", label: "Tagline", full: true },
|
||||||
|
{
|
||||||
|
path: "specialty",
|
||||||
|
label: "Specialty",
|
||||||
|
full: true,
|
||||||
|
help: "One line shown in directories, eg. Vocals, piano · Gospel, folk",
|
||||||
|
},
|
||||||
{ path: "photo", label: "Photo", widget: "image", resolve: mediaUrl, full: true },
|
{ path: "photo", label: "Photo", widget: "image", resolve: mediaUrl, full: true },
|
||||||
{
|
{
|
||||||
path: "primary_org_id",
|
path: "primary_org_id",
|
||||||
|
|
@ -80,6 +86,24 @@ export const people = {
|
||||||
],
|
],
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
{
|
||||||
|
key: "tags",
|
||||||
|
label: "Directories",
|
||||||
|
note: "Tags that list this person in a directory, eg. Musicians. Tags are made under Data → People tags.",
|
||||||
|
addLabel: "Add tag",
|
||||||
|
title: (row, options) =>
|
||||||
|
options?.person_tag_types?.find((t) => t.id === row.tag_id)?.label ?? "New tag",
|
||||||
|
blank: { tag_id: "" },
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "tag_id",
|
||||||
|
label: "Tag",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "person_tag_types",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "affiliations",
|
key: "affiliations",
|
||||||
label: "Roles and organizations",
|
label: "Roles and organizations",
|
||||||
|
|
|
||||||
35
src/lib/adminSchema/personTags.ts
Normal file
35
src/lib/adminSchema/personTags.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
/* ── People tags (062_people_tags.sql) ───────────────────────────
|
||||||
|
Data → People tags: what a person can be tagged as for a
|
||||||
|
directory (Musicians first). Which people carry a tag is edited on
|
||||||
|
the person; a page shows a tag's people with the People directory
|
||||||
|
preset, and every tag has its full page at /directory/<URL ID>.
|
||||||
|
Server side: server/src/admin-schema/personTags.js. */
|
||||||
|
|
||||||
|
export const personTagTypes = {
|
||||||
|
key: "person_tag_types",
|
||||||
|
label: "People tags",
|
||||||
|
singular: "tag",
|
||||||
|
idLabel: "URL ID",
|
||||||
|
slugFrom: "name",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: [
|
||||||
|
{ key: "name", label: "Name", primary: true },
|
||||||
|
{ key: "blurb", label: "Intro" },
|
||||||
|
{ key: "sort_order", label: "Order" },
|
||||||
|
],
|
||||||
|
filters: [],
|
||||||
|
},
|
||||||
|
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
legend: "Tag",
|
||||||
|
note: "Its full directory is at /directory/ and its URL ID, eg. /directory/musician.",
|
||||||
|
fields: [
|
||||||
|
{ path: "name", label: "Name", required: true, help: "The directory's title, eg. Musicians" },
|
||||||
|
{ path: "blurb", label: "Intro", widget: "textarea", full: true, help: "A line under the full directory's title" },
|
||||||
|
{ path: "sort_order", label: "Sort order", widget: "number" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
@ -18,6 +18,7 @@ const PRESETS = {
|
||||||
partner_list: "Partner organization cards",
|
partner_list: "Partner organization cards",
|
||||||
events: "Event carousel or grid",
|
events: "Event carousel or grid",
|
||||||
timeline: "Timeline",
|
timeline: "Timeline",
|
||||||
|
people_directory: "People directory (a tag's people)",
|
||||||
};
|
};
|
||||||
|
|
||||||
const ACCENT_OPTIONS = [
|
const ACCENT_OPTIONS = [
|
||||||
|
|
@ -99,6 +100,19 @@ const sectionsChild = (presets: string[]) => ({
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
|
...(presets.includes("people_directory")
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
path: "tag_id",
|
||||||
|
label: "Directory: tag",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "person_tag_types",
|
||||||
|
blankLabel: "Default: none (shows nothing)",
|
||||||
|
help: "Shows the first of its people and links to the full directory",
|
||||||
|
when: { path: "preset", value: "people_directory" },
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
...(presets.includes("group_map")
|
...(presets.includes("group_map")
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
|
|
@ -139,7 +153,7 @@ const sitePage = (id: string, label: string, presets: string[], more: Record<str
|
||||||
export const communityPage = sitePage(
|
export const communityPage = sitePage(
|
||||||
"community",
|
"community",
|
||||||
"Community page",
|
"Community page",
|
||||||
["community_blog", "group_map", "region_list", "partner_list"],
|
["community_blog", "group_map", "region_list", "partner_list", "people_directory"],
|
||||||
{
|
{
|
||||||
groups: [
|
groups: [
|
||||||
{
|
{
|
||||||
|
|
@ -209,6 +223,6 @@ export const communityPage = sitePage(
|
||||||
);
|
);
|
||||||
|
|
||||||
export const retreatsPage = sitePage("retreats", "Retreats page", ["events"]);
|
export const retreatsPage = sitePage("retreats", "Retreats page", ["events"]);
|
||||||
export const resourcesPage = sitePage("resources", "Resources page", []);
|
export const resourcesPage = sitePage("resources", "Resources page", ["people_directory"]);
|
||||||
export const organizationPage = sitePage("organization", "Organization page", []);
|
export const organizationPage = sitePage("organization", "Organization page", ["people_directory"]);
|
||||||
export const historyPage = sitePage("history", "History page", ["timeline"]);
|
export const historyPage = sitePage("history", "History page", ["timeline"]);
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,9 @@ export type OrganizationRecord = {
|
||||||
region_id?: string | null
|
region_id?: string | null
|
||||||
region_name?: string | null
|
region_name?: string | null
|
||||||
region_color?: string | null
|
region_color?: string | null
|
||||||
|
/** A group's Unity ministry: no page of its own, so its website. */
|
||||||
|
ministry_name?: string | null
|
||||||
|
ministry_url?: string | null
|
||||||
meets?: string | null
|
meets?: string | null
|
||||||
started?: string | null
|
started?: string | null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
19
src/lib/useDirectory.ts
Normal file
19
src/lib/useDirectory.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* A people directory: a tag's name, intro and people (GET
|
||||||
|
/api/directories/:tag, 062_people_tags.sql), for the People
|
||||||
|
directory preset and the full page at /directory/:id. */
|
||||||
|
|
||||||
|
import type { Person } from '../components/PeopleTiles.tsx'
|
||||||
|
import { detailPath } from './hrefs.ts'
|
||||||
|
import { useRecord } from './useRecord.ts'
|
||||||
|
|
||||||
|
export type DirectoryPerson = Person & { id: string; specialty: string | null }
|
||||||
|
|
||||||
|
export type DirectoryRecord = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
blurb: string | null
|
||||||
|
people: DirectoryPerson[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useDirectory = (id: string | undefined) =>
|
||||||
|
useRecord<DirectoryRecord>(detailPath('/directories', id), 'directory')
|
||||||
|
|
@ -15,6 +15,8 @@ export type SitePageSection = {
|
||||||
scope_id?: string | null
|
scope_id?: string | null
|
||||||
event_type?: string | null
|
event_type?: string | null
|
||||||
view?: string | null
|
view?: string | null
|
||||||
|
/** A people_directory preset's tag (Data → People tags). */
|
||||||
|
tag_id?: string | null
|
||||||
blocks: ContentBlock[]
|
blocks: ContentBlock[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
50
src/pages/DirectoryPage.tsx
Normal file
50
src/pages/DirectoryPage.tsx
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
DIRECTORY PAGE: /directory/:id
|
||||||
|
|
||||||
|
A people tag's full directory (Data → People tags), eg.
|
||||||
|
/directory/musician: its name and intro, then everyone carrying
|
||||||
|
the tag (PeopleDirectory, no limit). A page section can show the
|
||||||
|
first of them with the People directory preset, linking here.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { useParams } from 'react-router-dom'
|
||||||
|
|
||||||
|
import PageShell from '../components/PageShell.tsx'
|
||||||
|
import PageState from '../components/PageState.tsx'
|
||||||
|
import PeopleDirectory from './sections/PeopleDirectory.tsx'
|
||||||
|
import { useDirectory } from '../lib/useDirectory.ts'
|
||||||
|
import { BRAND } from '../lib/color.ts'
|
||||||
|
|
||||||
|
export default function DirectoryPage() {
|
||||||
|
const { id } = useParams()
|
||||||
|
const { data: directory, loading, error, notFound, reload } = useDirectory(id)
|
||||||
|
|
||||||
|
if (!directory) {
|
||||||
|
return (
|
||||||
|
<PageState
|
||||||
|
loading={loading}
|
||||||
|
error={error}
|
||||||
|
notFound={notFound}
|
||||||
|
onRetry={reload}
|
||||||
|
noun="directory"
|
||||||
|
backTo="/community"
|
||||||
|
backLabel="Community"
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageShell
|
||||||
|
title={directory.name}
|
||||||
|
intro={directory.blurb ?? undefined}
|
||||||
|
sections={[
|
||||||
|
{
|
||||||
|
id: 'people',
|
||||||
|
title: '',
|
||||||
|
accent: BRAND,
|
||||||
|
content: <PeopleDirectory tag={directory.id} accent={BRAND} />,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -251,6 +251,25 @@ function Facts({
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{org.kind === 'group' && org.details.ministry_name && (
|
||||||
|
<span style={{ color: BODY }}>
|
||||||
|
Ministry:{' '}
|
||||||
|
{org.details.ministry_url ? (
|
||||||
|
<a
|
||||||
|
href={org.details.ministry_url}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
className="font-medium hover:underline"
|
||||||
|
style={{ color: accentText(accent) }}
|
||||||
|
>
|
||||||
|
{org.details.ministry_name}
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
org.details.ministry_name
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
|
||||||
{org.kind === 'group' && org.details.meets && (
|
{org.kind === 'group' && org.details.meets && (
|
||||||
<span style={{ color: BODY }}>Meets {org.details.meets}</span>
|
<span style={{ color: BODY }}>Meets {org.details.meets}</span>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import OrgListCards from './sections/OrgList-Card.tsx'
|
||||||
import EventListCards, { EventCardsToggle } from './sections/EventList-Cards.tsx'
|
import EventListCards, { EventCardsToggle } from './sections/EventList-Cards.tsx'
|
||||||
import CommunityBlog from './sections/CommunityBlog.tsx'
|
import CommunityBlog from './sections/CommunityBlog.tsx'
|
||||||
import HistoryTimeline from './sections/history/HistoryTimeline.tsx'
|
import HistoryTimeline from './sections/history/HistoryTimeline.tsx'
|
||||||
|
import PeopleDirectory, { DIRECTORY_PREVIEW } from './sections/PeopleDirectory.tsx'
|
||||||
|
|
||||||
/* Year the program starts: decades ending before it get the
|
/* Year the program starts: decades ending before it get the
|
||||||
pre-program look on the timeline. */
|
pre-program look on the timeline. */
|
||||||
|
|
@ -84,6 +85,10 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
timeline: () => ({ Component: Timeline }),
|
timeline: () => ({ Component: Timeline }),
|
||||||
|
people_directory: (section) => ({
|
||||||
|
Component: PeopleDirectory,
|
||||||
|
props: { tag: section.tag_id, limit: DIRECTORY_PREVIEW },
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SitePage({ id }: { id: string }) {
|
export default function SitePage({ id }: { id: string }) {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@
|
||||||
unpublished blog post: its blocks and picks as the post's body,
|
unpublished blog post: its blocks and picks as the post's body,
|
||||||
opened in the post's editor to finish.
|
opened in the post's editor to finish.
|
||||||
|
|
||||||
|
Under it, Recipients exports organization contacts as a mailing
|
||||||
|
list (NewsletterRecipients.tsx), for editors and up.
|
||||||
|
|
||||||
Picked blog posts are read from their public pages, so only a
|
Picked blog posts are read from their public pages, so only a
|
||||||
post visitors can open makes it in, with its excerpt and cover.
|
post visitors can open makes it in, with its excerpt and cover.
|
||||||
Links and images are the live site's (SITE_ORIGIN), since an
|
Links and images are the live site's (SITE_ORIGIN), since an
|
||||||
|
|
@ -30,6 +33,7 @@ import { canDelete, canWrite } from '../../lib/roles.ts'
|
||||||
import { slugify } from '../../lib/adminSchema.ts'
|
import { slugify } from '../../lib/adminSchema.ts'
|
||||||
import { blocksChild, BLOCK_TYPES } from '../../lib/adminSchema/shared.ts'
|
import { blocksChild, BLOCK_TYPES } from '../../lib/adminSchema/shared.ts'
|
||||||
import { Repeater } from '../../components/admin/fields.tsx'
|
import { Repeater } from '../../components/admin/fields.tsx'
|
||||||
|
import NewsletterRecipients from '../../components/admin/NewsletterRecipients.tsx'
|
||||||
import { useEvents } from '../../lib/eventData.ts'
|
import { useEvents } from '../../lib/eventData.ts'
|
||||||
import { useFrontPage, type FeaturedCard } from '../../lib/useFrontPage.ts'
|
import { useFrontPage, type FeaturedCard } from '../../lib/useFrontPage.ts'
|
||||||
import type { BlogPostRecord } from '../../lib/useBlog.ts'
|
import type { BlogPostRecord } from '../../lib/useBlog.ts'
|
||||||
|
|
@ -603,6 +607,8 @@ export default function AdminNewsletter() {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{canWrite(user) && <NewsletterRecipients />}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,11 @@ export const DATA_NAV = {
|
||||||
label: "Organizations",
|
label: "Organizations",
|
||||||
blurb: "The national organization, regions, groups and partners.",
|
blurb: "The national organization, regions, groups and partners.",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
to: "/admin/contact_types",
|
||||||
|
label: "Contact types",
|
||||||
|
blurb: "Roles an organization's contacts hold, eg. Minister. Contacts are added on the organization.",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
to: "/admin/teams",
|
to: "/admin/teams",
|
||||||
label: "Teams",
|
label: "Teams",
|
||||||
|
|
@ -75,6 +80,11 @@ export const DATA_NAV = {
|
||||||
label: "People",
|
label: "People",
|
||||||
blurb: "Bios, contact details, affiliations and awards received.",
|
blurb: "Bios, contact details, affiliations and awards received.",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
to: "/admin/person_tag_types",
|
||||||
|
label: "People tags",
|
||||||
|
blurb: "Directories people can be tagged into, eg. Musicians. Who carries a tag is edited on the person.",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
to: "/admin/blog_posts",
|
to: "/admin/blog_posts",
|
||||||
label: "Blog posts",
|
label: "Blog posts",
|
||||||
|
|
|
||||||
80
src/pages/sections/PeopleDirectory.tsx
Normal file
80
src/pages/sections/PeopleDirectory.tsx
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
PEOPLE DIRECTORY
|
||||||
|
|
||||||
|
A tag's people (Data → People tags, eg. Musicians) as person
|
||||||
|
tiles: the People directory preset on a page, and the whole list
|
||||||
|
on the tag's own page (DirectoryPage.tsx, /directory/:id).
|
||||||
|
|
||||||
|
<PeopleDirectory tag="musician" limit={DIRECTORY_PREVIEW} />
|
||||||
|
|
||||||
|
Each tile's line under the name is the person's specialty (eg.
|
||||||
|
"Vocals, piano · Gospel, folk"), or their tagline without one;
|
||||||
|
their details panel adds their links. With a limit, the first that
|
||||||
|
many show and a link leads to the full directory.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { ArrowRight } from '@phosphor-icons/react'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
|
||||||
|
import { PeopleTilesView } from '../../components/PeopleTiles.tsx'
|
||||||
|
import { useDirectory } from '../../lib/useDirectory.ts'
|
||||||
|
import { accentText, BRAND } from '../../lib/color.ts'
|
||||||
|
|
||||||
|
/* How many people a section shows before "See the full directory". */
|
||||||
|
export const DIRECTORY_PREVIEW = 12
|
||||||
|
|
||||||
|
export const directoryHref = (tag: string) => `/directory/${encodeURIComponent(tag)}`
|
||||||
|
|
||||||
|
type PeopleDirectoryProps = {
|
||||||
|
tag?: string | null
|
||||||
|
/** Show this many, then a link to the full directory. */
|
||||||
|
limit?: number
|
||||||
|
accent?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PeopleDirectory({ tag, limit, accent = BRAND }: PeopleDirectoryProps) {
|
||||||
|
const { data: directory, loading, error, notFound } = useDirectory(tag ?? undefined)
|
||||||
|
|
||||||
|
if (!tag || notFound) {
|
||||||
|
return (
|
||||||
|
<div className="mx-auto max-w-6xl px-6">
|
||||||
|
<p className="notice">· This directory isn’t set up yet ·</p>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!directory) {
|
||||||
|
return (
|
||||||
|
<div className="mx-auto max-w-6xl px-6">
|
||||||
|
{error ? (
|
||||||
|
<p className="text-danger">Couldn’t load the directory. {error}</p>
|
||||||
|
) : (
|
||||||
|
loading && <div className="skeleton" role="status" aria-label="Loading the directory" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const people = directory.people.map((person) => ({ ...person, title: person.specialty || person.tagline }))
|
||||||
|
const shown = limit ? people.slice(0, limit) : people
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mx-auto max-w-6xl px-6">
|
||||||
|
<PeopleTilesView
|
||||||
|
groups={[{ id: directory.id, people: shown }]}
|
||||||
|
accent={accent}
|
||||||
|
emptyMessage={`No ${directory.name.toLowerCase()} listed yet.`}
|
||||||
|
/>
|
||||||
|
{limit && people.length > 0 && (
|
||||||
|
<Link
|
||||||
|
to={directoryHref(directory.id)}
|
||||||
|
className="mt-8 inline-block btn border px-5 py-2 text-sm transition-colors hover:bg-tint"
|
||||||
|
style={{ borderColor: accent, color: accentText(accent) }}
|
||||||
|
>
|
||||||
|
{people.length > limit ? `See all ${people.length} ${directory.name.toLowerCase()}` : 'Open the full directory'}{' '}
|
||||||
|
<ArrowRight size="1em" weight="bold" className="inline align-[-0.125em]" aria-hidden="true" />
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue