Renames every .js module under src/ to .ts (api, useResource, adminSchema, navConfig, adminNav and src/data/*) and points imports, comments and the seed script's module paths at the new names. Their types now come from inference; no .d.ts files and no shape interfaces. tsc stays strict (noImplicitAny off). The errors inference leaves behind get the lightest fix that clears them: `any` on empty state, contexts and list defaults, `: any` on components with optional or spread props, class fields on ApiError, and option shapes on get/useResource. Kept as real types, since they belong to modules that were already TypeScript and later features import them: PageShell's ShellSection and props, useContent's corrected record types (website/email/ instagram are bare strings) and EventListItem, and TimelineRef's orgKind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1150 lines
37 KiB
TypeScript
1150 lines
37 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
|
ADMIN FORM MANIFESTS
|
|
|
|
The presentation half of server/src/admin-schema.js: labels,
|
|
widgets, grouping, and which select pulls from which option
|
|
list. The server decides what's storable; this decides what the
|
|
form looks like. Paths here must match column names there, and
|
|
nested paths ('region.scope') match the side-table keys.
|
|
|
|
Adding a field is one entry. Adding an entity is one object here
|
|
plus one descriptor on the server — no new page component.
|
|
|
|
A value seeded in a repeater's `blank` must also be declared as
|
|
a default: on the matching server column, or a row the user adds
|
|
and never fills in reads as real input instead of being skipped.
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
const PLACE_FIELDS = [
|
|
{ path: "venue", label: "Venue" },
|
|
{ path: "address", label: "Address", full: true },
|
|
{ path: "locality", label: "City" },
|
|
{ path: "state_code", label: "State", help: "Two letters, US only" },
|
|
{ path: "country", label: "Country", help: "Defaults to US" },
|
|
{ path: "location_label", label: "Display location", help: "Overrides the line built from city and state" },
|
|
{ path: "latitude", label: "Latitude", widget: "number" },
|
|
{ path: "longitude", label: "Longitude", widget: "number" },
|
|
{ path: "is_online", label: "Online", widget: "checkbox" },
|
|
];
|
|
|
|
const PUBLISH_FIELDS = [
|
|
{ path: "is_published", label: "Published", widget: "checkbox" },
|
|
{ path: "sort_order", label: "Sort order", widget: "number" },
|
|
];
|
|
|
|
/* The parts of an affiliation that read the same from either end —
|
|
the person's list of roles, and the team's list of members. */
|
|
const AFFILIATION_ROLE_FIELDS = [
|
|
{ path: "title", label: "Title", help: "Board Chair, Chapter Lead" },
|
|
{
|
|
path: "role",
|
|
label: "Role",
|
|
widget: "select",
|
|
options: ["lead", "board", "staff", "volunteer", "member"],
|
|
},
|
|
{ path: "is_owner", label: "Owner", widget: "checkbox", help: "Listed first" },
|
|
{ path: "started_on", label: "Started", widget: "date" },
|
|
{ path: "ended_on", label: "Ended", widget: "date", help: "Blank means current" },
|
|
{ path: "is_public", label: "Public", widget: "checkbox" },
|
|
];
|
|
|
|
/* The timeline panel that appears on an event or organization once the
|
|
box is ticked. Paths are prefixed with the extension key, exactly as
|
|
'region.scope' and 'private.notes' are.
|
|
|
|
Everything here is an override. Left blank, the history page falls
|
|
back to the record's own title, date and logo through v_timeline —
|
|
which is the point of referencing rather than copying. */
|
|
const timelineExtensionFields = (noun) => [
|
|
{
|
|
path: "timeline.occurred_on",
|
|
label: "Date on the timeline",
|
|
help: `Blank uses the ${noun}'s own date. Partial dates are fine: 2012, 2012-06`,
|
|
},
|
|
{
|
|
path: "timeline.precision",
|
|
label: "Date precision",
|
|
widget: "select",
|
|
options: ["year", "month", "day"],
|
|
help: "How much of the date to trust. 'year' files it under 'Elsewhere in 2012'",
|
|
},
|
|
{
|
|
path: "timeline.title",
|
|
label: "Title override",
|
|
full: true,
|
|
help: `Blank uses the ${noun}'s name`,
|
|
},
|
|
{
|
|
path: "timeline.blurb",
|
|
label: "Blurb override",
|
|
widget: "textarea",
|
|
full: true,
|
|
help: `Blank uses the ${noun}'s tagline`,
|
|
},
|
|
{ path: "timeline.meta", label: "Secondary line", help: "Region, venue, recipient" },
|
|
{
|
|
path: "timeline.link_url",
|
|
label: "Link override",
|
|
help: `Blank links to the ${noun}'s own page`,
|
|
},
|
|
{
|
|
path: "timeline.is_featured",
|
|
label: "Featured",
|
|
widget: "checkbox",
|
|
help: "Shown large, above the month list for its year",
|
|
},
|
|
{ path: "timeline.is_published", label: "Visible on the history page", widget: "checkbox" },
|
|
{ path: "timeline.sort_order", label: "Sort order", widget: "number" },
|
|
];
|
|
|
|
/* The checkbox itself, plus the panel it gates. One entry in `groups`. */
|
|
const timelineGroup = (noun) => ({
|
|
legend: "Timeline",
|
|
note:
|
|
`Adds this ${noun} to the history page. Nothing is copied — the entry ` +
|
|
`reads this record, so editing it here updates the timeline too.`,
|
|
fields: [
|
|
{
|
|
path: "in_timeline",
|
|
label: "On the timeline",
|
|
widget: "checkbox",
|
|
help: "Show this on the history page",
|
|
},
|
|
],
|
|
});
|
|
|
|
const timelineDetailGroup = (noun) => ({
|
|
legend: "Timeline entry",
|
|
when: { path: "in_timeline", value: 1 },
|
|
note: "Every field here is optional. Blank means \u201cuse the record's own value\u201d.",
|
|
fields: timelineExtensionFields(noun),
|
|
});
|
|
|
|
/* The two collections every entity carries. */
|
|
const linksChild = {
|
|
key: "links",
|
|
label: "Links and socials",
|
|
addLabel: "Add link",
|
|
title: (row) => row.label || row.url || "New link",
|
|
blank: { kind: "action", label: "", url: "", is_primary: 0 },
|
|
fields: [
|
|
{
|
|
path: "kind",
|
|
label: "Kind",
|
|
widget: "select",
|
|
options: ["action", "social", "website", "email"],
|
|
},
|
|
{ path: "platform", label: "Platform", help: "instagram, discord…" },
|
|
{ path: "label", label: "Label", required: true },
|
|
{ path: "url", label: "URL", required: true, full: true },
|
|
{ path: "is_primary", label: "Primary", widget: "checkbox" },
|
|
],
|
|
};
|
|
|
|
/* Hosts. One row is one host, ordered, and each is either an
|
|
organization or a person — never both, which the CHECK on
|
|
event_hosts enforces and this form can only ask nicely about.
|
|
|
|
The first row supplies the logo and colour when the event sets
|
|
neither, so the order here is data rather than a display choice.
|
|
A person supplies neither: there is no colour on a person and a
|
|
headshot is not a logo, so a person-hosted event with no colour
|
|
of its own falls through to the section default. */
|
|
const hostsChild = {
|
|
key: "event_hosts",
|
|
label: "Hosts",
|
|
addLabel: "Add host",
|
|
title: (row, options) =>
|
|
options?.organizations?.find((o) => o.id === row.org_id)?.label ??
|
|
options?.people?.find((p) => p.id === row.person_id)?.label ??
|
|
"New host",
|
|
blank: { org_id: "", person_id: "" },
|
|
fields: [
|
|
{
|
|
path: "org_id",
|
|
label: "Organization",
|
|
widget: "select",
|
|
optionsFrom: "organizations",
|
|
blankLabel: "— none —",
|
|
},
|
|
{
|
|
path: "person_id",
|
|
label: "Person",
|
|
widget: "select",
|
|
optionsFrom: "people",
|
|
blankLabel: "— none —",
|
|
help: "One or the other, not both. First host supplies the logo and colour.",
|
|
},
|
|
],
|
|
};
|
|
|
|
const blocksChild = {
|
|
key: "content_blocks",
|
|
label: "Content blocks",
|
|
addLabel: "Add block",
|
|
title: (row) => `${row.type ?? "block"} — ${(row.text ?? "").slice(0, 40) || "empty"}`,
|
|
blank: { slot: "body", type: "paragraph", text: "" },
|
|
fields: [
|
|
{ path: "slot", label: "Slot", widget: "select", options: ["card", "body"] },
|
|
{
|
|
path: "type",
|
|
label: "Type",
|
|
widget: "select",
|
|
options: [
|
|
"heading",
|
|
"subheading",
|
|
"paragraph",
|
|
"list",
|
|
"links",
|
|
"quote",
|
|
"image",
|
|
"divider",
|
|
],
|
|
},
|
|
{ path: "text", label: "Text", widget: "textarea", full: true },
|
|
{ path: "media", label: "Media", help: "Filename or URL" },
|
|
{ path: "href", label: "Link" },
|
|
],
|
|
children: [
|
|
{
|
|
key: "items",
|
|
label: "Items",
|
|
addLabel: "Add item",
|
|
title: (row) => row.text || "New item",
|
|
blank: { text: "" },
|
|
fields: [
|
|
{ path: "text", label: "Text", required: true },
|
|
{ path: "detail", label: "Detail" },
|
|
{ path: "url", label: "URL", help: "Blank for a plain list item" },
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
/* ── Organizations ───────────────────────────────────────────── */
|
|
|
|
const organizations = {
|
|
key: "organizations",
|
|
label: "Organizations",
|
|
singular: "organization",
|
|
idLabel: "Slug",
|
|
slugFrom: "name",
|
|
|
|
list: {
|
|
columns: [
|
|
{ key: "name", label: "Name", primary: true },
|
|
{ key: "kind", label: "Kind" },
|
|
{ key: "locality", label: "City" },
|
|
{ key: "state_code", label: "State" },
|
|
{ key: "is_published", label: "Live", widget: "bool" },
|
|
],
|
|
filters: [
|
|
{ key: "kind", label: "Kind", options: ["national", "region", "chapter", "partner"] },
|
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
|
],
|
|
},
|
|
|
|
groups: [
|
|
{
|
|
legend: "Identity",
|
|
fields: [
|
|
{
|
|
path: "kind",
|
|
label: "Kind",
|
|
widget: "select",
|
|
options: ["national", "region", "chapter", "partner"],
|
|
required: true,
|
|
help: "Changing this swaps which extra fields apply",
|
|
},
|
|
{ path: "name", label: "Name", required: true },
|
|
{ path: "short_name", label: "Short name" },
|
|
{ path: "tagline", label: "Tagline", full: true },
|
|
{ path: "color", label: "Colour", widget: "color" },
|
|
{ path: "logo", label: "Logo", help: "Filename in public/org-logos/" },
|
|
],
|
|
},
|
|
{
|
|
legend: "Region",
|
|
when: { path: "kind", value: "region" },
|
|
fields: [
|
|
{
|
|
path: "region.scope",
|
|
label: "Scope",
|
|
widget: "select",
|
|
options: ["domestic", "international", "virtual"],
|
|
required: true,
|
|
},
|
|
{ path: "region.map_note", label: "Map note", full: true },
|
|
],
|
|
},
|
|
{
|
|
legend: "Chapter",
|
|
when: { path: "kind", value: "chapter" },
|
|
fields: [
|
|
{
|
|
path: "chapter.region_id",
|
|
label: "Region",
|
|
widget: "select",
|
|
optionsFrom: "regions",
|
|
blankLabel: "— none —",
|
|
},
|
|
{ path: "chapter.meets", label: "Meets", help: "2nd Sundays, 6:00pm" },
|
|
{ path: "chapter.started", label: "Started", help: "Since 2021" },
|
|
],
|
|
},
|
|
{ legend: "Place", fields: PLACE_FIELDS },
|
|
timelineGroup("organization"),
|
|
timelineDetailGroup("organization"),
|
|
{ legend: "Publishing", fields: PUBLISH_FIELDS },
|
|
],
|
|
|
|
children: [
|
|
{
|
|
key: "region_areas",
|
|
label: "Map areas",
|
|
when: { path: "kind", value: "region" },
|
|
addLabel: "Add area",
|
|
title: (row) => row.area_code || "New area",
|
|
blank: { area_code: "", share: 1 },
|
|
fields: [
|
|
{ path: "area_code", label: "Area code", required: true, help: "WA, CA, CANADA" },
|
|
{ path: "share", label: "Share", widget: "number", help: "1 for the whole tile, 0.5 for half" },
|
|
{
|
|
path: "edge",
|
|
label: "Edge",
|
|
widget: "select",
|
|
options: ["top", "bottom"],
|
|
blankLabel: "— whole tile —",
|
|
},
|
|
{ path: "note", label: "Note", help: "north, Salt Lake City area" },
|
|
],
|
|
},
|
|
linksChild,
|
|
blocksChild,
|
|
],
|
|
};
|
|
|
|
/* ── Events ──────────────────────────────────────────────────── */
|
|
|
|
/* The panel the Series checkbox opens. Starts and Ends above stay
|
|
the series' bounds — the first meeting and the last day it can
|
|
meet — so nothing here repeats them. */
|
|
const SERIES_WEEKDAYS = [
|
|
["sun", "Sunday"],
|
|
["mon", "Monday"],
|
|
["tue", "Tuesday"],
|
|
["wed", "Wednesday"],
|
|
["thu", "Thursday"],
|
|
["fri", "Friday"],
|
|
["sat", "Saturday"],
|
|
];
|
|
|
|
const seriesGroup = {
|
|
legend: "Series",
|
|
when: { path: "is_series", value: 1 },
|
|
note:
|
|
"Starts is the first meeting and anchors the schedule; Ends, if set, is the last " +
|
|
"day it can meet. The weekdays only apply to a weekly series; with none ticked it " +
|
|
"meets on the start date's day. Leave Date label blank and the site describes " +
|
|
"the schedule itself.",
|
|
fields: [
|
|
{
|
|
path: "series_frequency",
|
|
label: "Repeats",
|
|
widget: "select",
|
|
options: [
|
|
["weekly", "Weekly, on the days ticked below"],
|
|
["monthly_date", "Monthly, on the start date's day (the 13th)"],
|
|
["monthly_weekday", "Monthly, on the start date's weekday (2nd Tuesday)"],
|
|
],
|
|
blankLabel: "— weekly —",
|
|
},
|
|
{
|
|
path: "series_interval",
|
|
label: "Every",
|
|
widget: "number",
|
|
help: "1 for every week or month, 2 for every other, and so on",
|
|
},
|
|
{ path: "series_start_time", label: "Start time", widget: "time" },
|
|
{ path: "series_end_time", label: "End time", widget: "time" },
|
|
{
|
|
path: "series_count",
|
|
label: "Number of meetings",
|
|
widget: "number",
|
|
help: "Stops after this many. Blank to run until Ends, or indefinitely",
|
|
},
|
|
...SERIES_WEEKDAYS.map(([day, name]) => ({
|
|
path: `series_${day}`,
|
|
label: name,
|
|
widget: "checkbox",
|
|
help: `Meets on ${name}s`,
|
|
})),
|
|
],
|
|
};
|
|
|
|
const events = {
|
|
key: "events",
|
|
label: "Events",
|
|
singular: "event",
|
|
idLabel: "Slug",
|
|
slugFrom: "title",
|
|
|
|
list: {
|
|
columns: [
|
|
{ key: "title", label: "Title", primary: true },
|
|
{ key: "section_id", label: "Scope" },
|
|
{ key: "event_type", label: "Type" },
|
|
{ key: "date_label", label: "Dates" },
|
|
{ key: "status", label: "Status" },
|
|
{ key: "is_published", label: "Live", widget: "bool" },
|
|
],
|
|
filters: [
|
|
{ key: "section_id", label: "Scope", optionsFrom: "event_sections" },
|
|
{
|
|
key: "event_type",
|
|
label: "Type",
|
|
options: ["retreat", "class", "workshop", "meeting", "other"],
|
|
},
|
|
{ key: "status", label: "Status", options: ["upcoming", "past", "cancelled"] },
|
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
|
],
|
|
},
|
|
|
|
groups: [
|
|
{
|
|
legend: "Identity",
|
|
fields: [
|
|
// The column is still section_id — the rows in event_sections
|
|
// are what changed, not the schema. Only the label moved,
|
|
// because "scope" is what the field has always meant and
|
|
// "section" described where it happened to be rendered.
|
|
{
|
|
path: "section_id",
|
|
label: "Scope",
|
|
widget: "select",
|
|
optionsFrom: "event_sections",
|
|
required: true,
|
|
help: "Whose gathering this is. Only national, regional and partner appear on the Retreats page",
|
|
},
|
|
{
|
|
path: "event_type",
|
|
label: "Type",
|
|
widget: "select",
|
|
options: ["retreat", "class", "workshop", "meeting", "other"],
|
|
required: true,
|
|
help: "What kind of gathering. Independent of the scope",
|
|
},
|
|
{ path: "title", label: "Title", required: true },
|
|
{ path: "theme", label: "Theme" },
|
|
{ path: "tagline", label: "Tagline", full: true },
|
|
],
|
|
},
|
|
{
|
|
legend: "When",
|
|
fields: [
|
|
{ path: "starts_on", label: "Starts", widget: "date" },
|
|
{ path: "ends_on", label: "Ends", widget: "date" },
|
|
{
|
|
path: "date_label",
|
|
label: "Date label",
|
|
help: "What the card shows — 'March/April 2026' is fine here",
|
|
},
|
|
{
|
|
path: "status",
|
|
label: "Status",
|
|
widget: "select",
|
|
options: ["upcoming", "past", "cancelled"],
|
|
blankLabel: "— derive from end date —",
|
|
},
|
|
{
|
|
path: "is_series",
|
|
label: "Series",
|
|
widget: "checkbox",
|
|
help: "Repeats on a schedule — a weekly class, a monthly meeting",
|
|
},
|
|
],
|
|
},
|
|
seriesGroup,
|
|
{ legend: "Where", fields: PLACE_FIELDS },
|
|
{
|
|
legend: "Appearance",
|
|
fields: [
|
|
{ path: "event_logo", label: "Event logo", help: "Filename in public/event-logos/" },
|
|
{ path: "org_logo", label: "Org logo override" },
|
|
{ path: "color", label: "Colour", widget: "color" },
|
|
{ path: "gradient", label: "Gradient", full: true },
|
|
],
|
|
},
|
|
timelineGroup("event"),
|
|
timelineDetailGroup("event"),
|
|
{ legend: "Publishing", fields: PUBLISH_FIELDS },
|
|
],
|
|
|
|
children: [
|
|
hostsChild,
|
|
{
|
|
key: "event_people",
|
|
label: "People at this event",
|
|
addLabel: "Add person",
|
|
title: (row, options) =>
|
|
options?.people?.find((p) => p.id === row.person_id)?.label ?? "New person",
|
|
blank: { person_id: "", role: "speaker", is_public: 1 },
|
|
fields: [
|
|
{
|
|
path: "person_id",
|
|
label: "Person",
|
|
widget: "select",
|
|
optionsFrom: "people",
|
|
required: true,
|
|
},
|
|
{
|
|
path: "role",
|
|
label: "Role",
|
|
widget: "select",
|
|
options: [
|
|
"speaker",
|
|
"leader",
|
|
"facilitator",
|
|
"host",
|
|
"musician",
|
|
"volunteer",
|
|
"attendee",
|
|
],
|
|
},
|
|
{ path: "title", label: "Title", help: "Keynote Speaker" },
|
|
{ path: "is_public", label: "Show on the site", widget: "checkbox" },
|
|
],
|
|
},
|
|
linksChild,
|
|
blocksChild,
|
|
],
|
|
};
|
|
|
|
/* ── People ──────────────────────────────────────────────────── */
|
|
|
|
const people = {
|
|
key: "people",
|
|
label: "People",
|
|
singular: "person",
|
|
idLabel: "Slug",
|
|
slugFrom: "display_name",
|
|
|
|
list: {
|
|
columns: [
|
|
{ key: "display_name", label: "Name", primary: true },
|
|
{ key: "tagline", label: "Tagline" },
|
|
{ key: "locality", label: "City" },
|
|
{ key: "is_published", label: "Live", widget: "bool" },
|
|
],
|
|
filters: [
|
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
|
],
|
|
},
|
|
|
|
groups: [
|
|
{
|
|
legend: "Identity",
|
|
fields: [
|
|
{ path: "display_name", label: "Display name", required: true },
|
|
{ path: "sort_name", label: "Sort name", help: "Doe, Jane" },
|
|
{ path: "pronouns", label: "Pronouns" },
|
|
{ path: "tagline", label: "Tagline", full: true },
|
|
{ path: "photo", label: "Photo", help: "Filename in public/people/" },
|
|
{
|
|
path: "primary_org_id",
|
|
label: "Home organization",
|
|
widget: "select",
|
|
optionsFrom: "organizations",
|
|
blankLabel: "— none —",
|
|
help: "Optional. Shown above their bio",
|
|
},
|
|
{
|
|
path: "bio",
|
|
label: "Bio",
|
|
widget: "textarea",
|
|
full: true,
|
|
help: "Leave a blank line between paragraphs",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
legend: "Public contact",
|
|
fields: [
|
|
{ path: "public_email", label: "Email", help: "Printed on the site" },
|
|
{ path: "public_phone", label: "Phone" },
|
|
{ path: "locality", label: "City" },
|
|
{ path: "state_code", label: "State" },
|
|
{ path: "country", label: "Country" },
|
|
{ path: "location_label", label: "Display location" },
|
|
],
|
|
},
|
|
{
|
|
legend: "Private",
|
|
note: "Never sent to the public site. Only admins see this.",
|
|
fields: [
|
|
{ path: "private.birth_date", label: "Birth date", widget: "date" },
|
|
{ path: "private.private_email", label: "Email" },
|
|
{ path: "private.private_phone", label: "Phone" },
|
|
{ path: "private.address", label: "Address", full: true },
|
|
{ path: "private.notes", label: "Notes", widget: "textarea", full: true },
|
|
],
|
|
},
|
|
{
|
|
legend: "Publishing",
|
|
note: "Unpublished people are invisible everywhere, including as chapter leads.",
|
|
fields: PUBLISH_FIELDS,
|
|
},
|
|
],
|
|
|
|
children: [
|
|
{
|
|
key: "affiliations",
|
|
label: "Roles and organizations",
|
|
addLabel: "Add role",
|
|
note:
|
|
"Where someone appears within a team is set on that team's page, " +
|
|
"not by the order of this list.",
|
|
title: (row, options) =>
|
|
[row.title, options?.organizations?.find((o) => o.id === row.org_id)?.label]
|
|
.filter(Boolean)
|
|
.join(" · ") || "New role",
|
|
blank: { org_id: "", role: "member", is_public: 1, is_owner: 0 },
|
|
fields: [
|
|
{
|
|
path: "org_id",
|
|
label: "Organization",
|
|
widget: "select",
|
|
optionsFrom: "organizations",
|
|
required: true,
|
|
},
|
|
{
|
|
path: "team_id",
|
|
label: "Team",
|
|
widget: "select",
|
|
optionsFrom: "teams",
|
|
blankLabel: "— none —",
|
|
// A team belongs to an org; offering one from another
|
|
// org would fail the composite foreign key on save.
|
|
filterBy: (option, row) => option.org_id === row.org_id,
|
|
help: "Only teams of the chosen organization",
|
|
},
|
|
...AFFILIATION_ROLE_FIELDS,
|
|
],
|
|
},
|
|
{
|
|
key: "person_awards",
|
|
label: "Awards",
|
|
addLabel: "Add award",
|
|
title: (row, options) =>
|
|
options?.awards?.find((a) => a.id === row.award_id)?.label ?? "New award",
|
|
blank: { award_id: "", is_public: 1 },
|
|
fields: [
|
|
{
|
|
path: "award_id",
|
|
label: "Award",
|
|
widget: "select",
|
|
optionsFrom: "awards",
|
|
required: true,
|
|
help: "Labelled with the organization that gives it",
|
|
},
|
|
{
|
|
path: "event_id",
|
|
label: "Presented at",
|
|
widget: "select",
|
|
optionsFrom: "events",
|
|
blankLabel: "— none —",
|
|
},
|
|
{ path: "awarded_on", label: "Date", widget: "date" },
|
|
{ path: "citation", label: "Citation", widget: "textarea", full: true },
|
|
{ path: "is_public", label: "Public", widget: "checkbox" },
|
|
],
|
|
},
|
|
linksChild,
|
|
blocksChild,
|
|
],
|
|
};
|
|
|
|
/* ── Teams ───────────────────────────────────────────────────── */
|
|
|
|
const teams = {
|
|
key: "teams",
|
|
label: "Teams",
|
|
singular: "team",
|
|
idLabel: "Slug",
|
|
// teams.id is a global primary key, not scoped to the org, so
|
|
// 'board' can only exist once across the whole site. Composing
|
|
// the slug from both fields is what keeps NGU's board and the
|
|
// Northwest's board from colliding.
|
|
slugFrom: ["org_id", "name"],
|
|
|
|
list: {
|
|
columns: [
|
|
{ key: "name", label: "Name", primary: true },
|
|
{ key: "org_id", label: "Organization" },
|
|
{ key: "tagline", label: "Tagline" },
|
|
{ key: "is_published", label: "Live", widget: "bool" },
|
|
],
|
|
filters: [
|
|
{ key: "org_id", label: "Organization", optionsFrom: "organizations" },
|
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
|
],
|
|
},
|
|
|
|
groups: [
|
|
{
|
|
legend: "Identity",
|
|
note:
|
|
"Pick the organization first: the slug is built from it, " +
|
|
"and it can't be changed once anyone is filed under this team.",
|
|
fields: [
|
|
{
|
|
path: "org_id",
|
|
label: "Organization",
|
|
widget: "select",
|
|
optionsFrom: "organizations",
|
|
required: true,
|
|
help: "Who this team belongs to",
|
|
},
|
|
{ path: "name", label: "Name", required: true, help: "Board, Leadership Team" },
|
|
{ path: "tagline", label: "Tagline", full: true },
|
|
{ path: "color", label: "Colour", widget: "color" },
|
|
{ path: "logo", label: "Logo", help: "Filename in public/org-logos/" },
|
|
],
|
|
},
|
|
{ legend: "Publishing", fields: PUBLISH_FIELDS },
|
|
],
|
|
|
|
children: [
|
|
{
|
|
key: "members",
|
|
label: "Members",
|
|
addLabel: "Add member",
|
|
note:
|
|
"This order is the order they appear on the site. Owners are " +
|
|
"still listed first, in this order among themselves.",
|
|
title: (row, options) =>
|
|
[options?.people?.find((p) => p.id === row.person_id)?.label, row.title]
|
|
.filter(Boolean)
|
|
.join(" · ") || "New member",
|
|
blank: { person_id: "", role: "member", is_public: 1, is_owner: 0 },
|
|
fields: [
|
|
{
|
|
path: "person_id",
|
|
label: "Person",
|
|
widget: "select",
|
|
optionsFrom: "people",
|
|
required: true,
|
|
},
|
|
...AFFILIATION_ROLE_FIELDS,
|
|
],
|
|
},
|
|
linksChild,
|
|
blocksChild,
|
|
],
|
|
};
|
|
|
|
/* ── Awards ──────────────────────────────────────────────────── */
|
|
|
|
const awards = {
|
|
key: "awards",
|
|
label: "Awards",
|
|
singular: "award",
|
|
idLabel: "Slug",
|
|
slugFrom: "name",
|
|
|
|
list: {
|
|
columns: [
|
|
{ key: "name", label: "Name", primary: true },
|
|
{ key: "org_id", label: "Awarded by" },
|
|
{ key: "description", label: "Description" },
|
|
{ key: "sort_order", label: "Order" },
|
|
],
|
|
filters: [
|
|
{ key: "org_id", label: "Awarded by", optionsFrom: "organizations" },
|
|
],
|
|
},
|
|
|
|
groups: [
|
|
{
|
|
legend: "Identity",
|
|
note:
|
|
"An award exists whether or not anyone has received it. " +
|
|
"Who received it is edited on the person.",
|
|
fields: [
|
|
{
|
|
path: "org_id",
|
|
label: "Awarded by",
|
|
widget: "select",
|
|
optionsFrom: "organizations",
|
|
blankLabel: "— unattributed —",
|
|
help: "The organization that gives this award",
|
|
},
|
|
{ path: "name", label: "Name", required: true },
|
|
{ path: "description", label: "Description", widget: "textarea", full: true },
|
|
{ path: "logo", label: "Logo", help: "Filename in public/org-logos/" },
|
|
{ path: "sort_order", label: "Sort order", widget: "number" },
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
/* ── Timeline ─────────────────────────────────────────── */
|
|
|
|
// The only entity with no slug: the table assigns the id, because an
|
|
// entry referencing an event has no name of its own and one gets
|
|
// created every time somebody ticks a checkbox. `idKind: "auto"` tells
|
|
// EntityEdit to show the id rather than ask for it.
|
|
//
|
|
// Most rows here are created from an event or organization page, not
|
|
// this one. What this page is for: hand-authored milestones with no
|
|
// record behind them, 'people' entries about a team forming, and fixing
|
|
// up the entries the checkboxes made.
|
|
const timeline = {
|
|
key: "timeline",
|
|
label: "Timeline",
|
|
singular: "entry",
|
|
idLabel: "Entry",
|
|
idKind: "auto",
|
|
titleFrom: "title",
|
|
|
|
list: {
|
|
columns: [
|
|
{ key: "title", label: "Title", primary: true },
|
|
{ key: "occurred_on", label: "Date" },
|
|
{ key: "kind", label: "Kind" },
|
|
{ key: "ref_id", label: "References" },
|
|
{ key: "is_featured", label: "Featured", widget: "bool" },
|
|
{ key: "is_published", label: "Live", widget: "bool" },
|
|
],
|
|
filters: [
|
|
{
|
|
key: "kind",
|
|
label: "Kind",
|
|
options: ["milestone", "event", "organization", "award", "people"],
|
|
},
|
|
{
|
|
key: "ref_kind",
|
|
label: "References",
|
|
options: ["event", "organization", "award", "person", "team"],
|
|
},
|
|
{ key: "is_featured", label: "Featured", options: [["1", "Featured"], ["0", "Normal"]] },
|
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
|
],
|
|
},
|
|
|
|
groups: [
|
|
{
|
|
legend: "What this is",
|
|
note:
|
|
"An entry either points at a record or stands on its own. " +
|
|
"Pointing at one means its title, date and logo come from that " +
|
|
"record \u2014 nothing is copied, so editing the record updates this.",
|
|
fields: [
|
|
{
|
|
path: "kind",
|
|
label: "Kind",
|
|
widget: "select",
|
|
options: ["milestone", "event", "organization", "award", "people"],
|
|
required: true,
|
|
help: "Drives the marker and the layout. 'people' renders a roster",
|
|
},
|
|
{
|
|
path: "ref_kind",
|
|
label: "Points at",
|
|
widget: "select",
|
|
options: ["event", "organization", "award", "person", "team"],
|
|
blankLabel: "\u2014 nothing, this stands alone \u2014",
|
|
help: "Changing this leaves the record below orphaned \u2014 pick a new one",
|
|
},
|
|
{
|
|
path: "ref_id",
|
|
label: "Record",
|
|
widget: "select",
|
|
optionsFrom: "timeline_refs",
|
|
blankLabel: "\u2014 none \u2014",
|
|
// One flat list of every referenceable row, narrowed to the
|
|
// kind chosen above. Five dropdowns of which four are always
|
|
// wrong would be worse.
|
|
filterBy: (option, row) => option.kind === row.ref_kind,
|
|
help: "Only records of the kind chosen above",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
legend: "When",
|
|
note:
|
|
"Blank takes the referenced record's own date. Precision is what " +
|
|
"says how much of the date to believe \u2014 a backfilled entry that " +
|
|
"only knows the year should say so.",
|
|
fields: [
|
|
{
|
|
path: "occurred_on",
|
|
label: "Date",
|
|
help: "2012, 2012-06 or 2012-06-14",
|
|
},
|
|
{
|
|
path: "precision",
|
|
label: "Precision",
|
|
widget: "select",
|
|
options: ["year", "month", "day"],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
legend: "Text",
|
|
note: "All optional. Blank uses the referenced record's own wording.",
|
|
fields: [
|
|
{ path: "title", label: "Title", full: true },
|
|
{ path: "blurb", label: "Blurb", widget: "textarea", full: true },
|
|
{ path: "meta", label: "Secondary line", help: "Region, venue, recipient" },
|
|
{ path: "link_url", label: "Link", help: "Blank links to the record's own page" },
|
|
],
|
|
},
|
|
{
|
|
legend: "Publishing",
|
|
fields: [
|
|
{
|
|
path: "is_featured",
|
|
label: "Featured",
|
|
widget: "checkbox",
|
|
help: "Shown large, above the month list for its year",
|
|
},
|
|
{ path: "is_published", label: "Published", widget: "checkbox" },
|
|
{ path: "sort_order", label: "Sort order", widget: "number" },
|
|
],
|
|
},
|
|
],
|
|
|
|
children: [
|
|
{
|
|
key: "people",
|
|
label: "People",
|
|
addLabel: "Add person",
|
|
note:
|
|
"For an entry about people. A 'people' entry pointing at a team " +
|
|
"already shows that team's members \u2014 this is for the cases where " +
|
|
"the list is editorial rather than structural.",
|
|
title: (row, options) =>
|
|
options?.people?.find((p) => p.id === row.person_id)?.label ?? "New person",
|
|
blank: { person_id: "" },
|
|
fields: [
|
|
{
|
|
path: "person_id",
|
|
label: "Person",
|
|
widget: "select",
|
|
optionsFrom: "people",
|
|
required: true,
|
|
},
|
|
{ path: "note", label: "Note", help: "Founding lead, first chair" },
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
/* ── Front page ──────────────────────────────────────────────────
|
|
|
|
One record (see the singleton note in server/src/admin-schema.js).
|
|
The groups are the hero; the collections below are the rest of
|
|
the page. Photos and the livestream are editable whatever the
|
|
mode, so either can be ready before the switch is flipped.
|
|
|
|
Section keys and stat sources are the CHECK lists in migrations
|
|
017 and 019. The labels here are what the admin reads; the values are
|
|
what the page and the API key on. */
|
|
|
|
const FRONT_PAGE_SECTIONS = [
|
|
["countdown", "Countdown to the next event"],
|
|
["retreats", "National Retreats carousel"],
|
|
["calendar", "Event calendar"],
|
|
["stats", "Numbers"],
|
|
["timeline", "Featured timeline"],
|
|
["connect", "Find your way in"],
|
|
];
|
|
|
|
const STAT_SOURCES = [
|
|
["manual", "Typed in — shows Value"],
|
|
["years_since", "Years since — Value is the year"],
|
|
["regions", "Count: published regions"],
|
|
["chapters", "Count: published chapters"],
|
|
["partners", "Count: published partners"],
|
|
["events_held", "Count: past events"],
|
|
["retreats_held", "Count: past retreats"],
|
|
["people", "Count: published people"],
|
|
["awards_given", "Count: public awards given"],
|
|
];
|
|
|
|
const frontPage = {
|
|
key: "front_page",
|
|
label: "Front page",
|
|
singular: "front page",
|
|
idLabel: "Page",
|
|
singleton: "home",
|
|
|
|
list: { columns: [], filters: [] },
|
|
|
|
groups: [
|
|
{
|
|
legend: "Hero",
|
|
note: "The first thing a visitor sees. Blank buttons don't render.",
|
|
fields: [
|
|
{
|
|
path: "hero_mode",
|
|
label: "Mode",
|
|
widget: "select",
|
|
options: [
|
|
["brand", "Brand — animated colour, no media"],
|
|
["photos", "Photos — cycles through the photos below"],
|
|
["livestream", "Livestream — embeds the stream with a LIVE badge"],
|
|
],
|
|
blankLabel: "— brand —",
|
|
help: "Switch to Livestream when you go live, and back when you're done",
|
|
},
|
|
{ path: "eyebrow", label: "Eyebrow", help: "Small line above the headline" },
|
|
{ path: "headline", label: "Headline", full: true },
|
|
{ path: "subhead", label: "Subhead", widget: "textarea", full: true },
|
|
{ path: "primary_label", label: "Main button label" },
|
|
{ path: "primary_url", label: "Main button link", help: "/retreats, #connect or a full URL" },
|
|
{ path: "secondary_label", label: "Second button label" },
|
|
{ path: "secondary_url", label: "Second button link" },
|
|
],
|
|
},
|
|
{
|
|
legend: "Photos and livestream",
|
|
fields: [
|
|
{
|
|
path: "slide_seconds",
|
|
label: "Seconds per photo",
|
|
widget: "number",
|
|
help: "Photos mode. 3 to 60",
|
|
},
|
|
{
|
|
path: "livestream_url",
|
|
label: "Livestream link",
|
|
full: true,
|
|
help: "A YouTube, Facebook or Vimeo link, or any embed URL",
|
|
},
|
|
{ path: "livestream_title", label: "Livestream title", full: true },
|
|
],
|
|
},
|
|
{
|
|
legend: "Countdown",
|
|
fields: [
|
|
{
|
|
path: "countdown_event_id",
|
|
label: "Count down to",
|
|
widget: "select",
|
|
optionsFrom: "events",
|
|
blankLabel: "— the next upcoming event —",
|
|
help: "Leave blank almost always. A pinned event that's over falls back to the next one",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
|
|
children: [
|
|
{
|
|
key: "sections",
|
|
label: "Page sections",
|
|
note: "Drag to reorder. Each section can appear once; leave one out to drop it.",
|
|
addLabel: "Add section",
|
|
title: (row) =>
|
|
FRONT_PAGE_SECTIONS.find(([key]) => key === row.section)?.[1] ?? "New section",
|
|
blank: { section: "", title: "", blurb: "" },
|
|
fields: [
|
|
{
|
|
path: "section",
|
|
label: "Section",
|
|
widget: "select",
|
|
options: FRONT_PAGE_SECTIONS,
|
|
required: true,
|
|
},
|
|
{ path: "title", label: "Heading", help: "Blank for the section's own" },
|
|
{ path: "blurb", label: "Blurb", full: true },
|
|
{ path: "is_hidden", label: "Hidden", widget: "checkbox", help: "Hide for now" },
|
|
],
|
|
},
|
|
{
|
|
key: "slides",
|
|
label: "Hero photos",
|
|
note: "Shown in Photos mode, in this order.",
|
|
addLabel: "Add photo",
|
|
title: (row) => row.caption || row.media || "New photo",
|
|
blank: { media: "", alt: "", caption: "" },
|
|
fields: [
|
|
{ path: "media", label: "Photo", required: true, help: "Filename in public/front-page/, or a URL" },
|
|
{ path: "alt", label: "Description", help: "For screen readers" },
|
|
{ path: "caption", label: "Caption", full: true },
|
|
{ path: "link_url", label: "Link", help: "Optional; makes the caption a link" },
|
|
],
|
|
},
|
|
{
|
|
key: "stats",
|
|
label: "Numbers",
|
|
note: "Counts update themselves. A typed-in number with no value is left out.",
|
|
addLabel: "Add number",
|
|
title: (row) => row.label || "New number",
|
|
blank: { label: "", source: "", value: "" },
|
|
fields: [
|
|
{ path: "label", label: "Label", required: true },
|
|
{
|
|
path: "source",
|
|
label: "Where it comes from",
|
|
widget: "select",
|
|
options: STAT_SOURCES,
|
|
blankLabel: "— typed in —",
|
|
},
|
|
{ path: "value", label: "Value", help: "Typed in: the number. Years since: the year" },
|
|
{ path: "suffix", label: "Suffix", help: "+, k, % …" },
|
|
{ path: "note", label: "Note", full: true },
|
|
],
|
|
},
|
|
{
|
|
key: "paths",
|
|
label: "Find your way in",
|
|
note: "Each path is a choice a visitor can pick; its actions appear when they do.",
|
|
addLabel: "Add path",
|
|
title: (row) => [row.icon, row.label].filter(Boolean).join(" ") || "New path",
|
|
blank: { label: "", icon: "", blurb: "" },
|
|
fields: [
|
|
{ path: "label", label: "Label", required: true, help: "Attend, Serve…" },
|
|
{ path: "icon", label: "Icon", help: "One emoji" },
|
|
{ path: "blurb", label: "Blurb", full: true },
|
|
],
|
|
children: [
|
|
{
|
|
key: "actions",
|
|
label: "Actions",
|
|
addLabel: "Add action",
|
|
title: (row) => row.label || "New action",
|
|
blank: { label: "", url: "" },
|
|
fields: [
|
|
{ path: "label", label: "Label", required: true },
|
|
{ path: "url", label: "Link", required: true },
|
|
{ path: "description", label: "Description", full: true },
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
|
|
export const ADMIN_ENTITIES: Record<string, any> = {
|
|
organizations,
|
|
events,
|
|
people,
|
|
teams,
|
|
awards,
|
|
timeline,
|
|
front_page: frontPage,
|
|
};
|
|
|
|
export function slugify(value) {
|
|
return String(value ?? "")
|
|
.toLowerCase()
|
|
.normalize("NFKD")
|
|
.replace(/[^\w\s-]/g, "")
|
|
.trim()
|
|
.replace(/[\s_]+/g, "-")
|
|
.replace(/-+/g, "-")
|
|
.slice(0, 64);
|
|
}
|