Uploads (migration 028, server/src/media.js, routes/media.js): editors and up upload JPEG, PNG, GIF, WebP or SVG. Photos are resized to 2400px and saved as WebP by default, or kept as uploaded on request. Files live in UPLOADS_DIR, served by nginx in production and by the API in dev. Admins and up delete, after seeing what still uses the file. Every image field in the editor is now an image widget: preview, the path as text, Upload and Choose from library. A new Media page lists the library. Org lists and event cards now resolve logos through media.ts, so uploaded paths work there. Events get a card_image (migration 029): a photo behind the card under a light veil so the text stays readable. The card's size is unchanged. Setup for production is in docs/media-uploads.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1248 lines
41 KiB
TypeScript
1248 lines
41 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, with 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.
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
import { preview } from "./text.ts";
|
|
import { PLATFORMS } from "./platforms.ts";
|
|
import {
|
|
awardLogo,
|
|
blockMedia,
|
|
eventBackground,
|
|
eventLogo,
|
|
heroPhoto,
|
|
orgLogo,
|
|
personPhoto,
|
|
teamLogo,
|
|
} from "./media.ts";
|
|
|
|
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 PUBLISHED_FIELD = { path: "is_published", label: "Published", widget: "checkbox" };
|
|
|
|
/* Only means anything on a published record. Unticked, its own page
|
|
still works but the site's lists, counts and the QR page leave it
|
|
out. See 027_listed.sql for exactly which. */
|
|
const LISTED_FIELD = {
|
|
path: "is_listed",
|
|
label: "Listed",
|
|
widget: "checkbox",
|
|
help: "Unticked: only reachable by its link",
|
|
};
|
|
|
|
/* For entities whose lists the site orders by hand. Events sort by
|
|
date and people by sort_name, so they take the first two alone. */
|
|
const PUBLISH_FIELDS = [
|
|
PUBLISHED_FIELD,
|
|
LISTED_FIELD,
|
|
{ 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: "eg. Board Chair, Team Lead" },
|
|
{
|
|
path: "role",
|
|
label: "Role",
|
|
widget: "select",
|
|
options: ["lead", "board", "staff", "volunteer", "member"],
|
|
},
|
|
{ path: "is_owner", label: "Owner", widget: "checkbox", help: "Listed first (can be more than one)" },
|
|
{ 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",
|
|
widget: "select",
|
|
options: PLATFORMS.map((platform) => [platform.id, platform.label]),
|
|
blankLabel: "Default: no icon",
|
|
help: "Shows the platform's icon on the button.",
|
|
},
|
|
{ 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: "Default: none",
|
|
help: "Host Organization"
|
|
},
|
|
{
|
|
path: "person_id",
|
|
label: "Person",
|
|
widget: "select",
|
|
optionsFrom: "people",
|
|
blankLabel: "Default: none",
|
|
help: "Use if the host is an individual, choose between person and org host, not both.",
|
|
},
|
|
],
|
|
};
|
|
|
|
const blocksChild = {
|
|
key: "content_blocks",
|
|
label: "Content blocks",
|
|
addLabel: "Add block",
|
|
title: (row) => `${row.type ?? "block"}: ${preview(row.text, 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", widget: "image", resolve: blockMedia, full: true },
|
|
{ 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: "URL ID",
|
|
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" },
|
|
{ key: "is_listed", label: "Listed", widget: "bool" },
|
|
],
|
|
filters: [
|
|
{ key: "kind", label: "Kind", options: ["national", "region", "chapter", "partner"] },
|
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
|
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
|
],
|
|
},
|
|
|
|
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", widget: "image", resolve: orgLogo, full: true },
|
|
],
|
|
},
|
|
{
|
|
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: "Default: 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: "Two letter state code or Country name" },
|
|
{ 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: "Default: whole tile",
|
|
},
|
|
{ path: "note", label: "Note", help: "details to explain why it's half or other note" },
|
|
],
|
|
},
|
|
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 day of the start date (eg. the 13th)"],
|
|
["monthly_weekday", "Monthly, on the weekday of the start date (eg. 2nd Tuesday)"],
|
|
],
|
|
blankLabel: "Default: 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: "URL ID",
|
|
slugFrom: "title",
|
|
|
|
list: {
|
|
columns: [
|
|
{ key: "title", label: "Title", primary: true },
|
|
{ key: "scope_id", label: "Scope" },
|
|
{ key: "event_type", label: "Type" },
|
|
{ key: "date_label", label: "Dates" },
|
|
{ key: "status", label: "Status" },
|
|
{ key: "is_published", label: "Live", widget: "bool" },
|
|
{ key: "is_listed", label: "Listed", widget: "bool" },
|
|
],
|
|
filters: [
|
|
{ key: "scope_id", label: "Scope", optionsFrom: "event_scopes" },
|
|
{
|
|
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"]] },
|
|
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
|
],
|
|
},
|
|
|
|
groups: [
|
|
{
|
|
legend: "Identity",
|
|
fields: [
|
|
{
|
|
path: "scope_id",
|
|
label: "Scope",
|
|
widget: "select",
|
|
optionsFrom: "event_scopes",
|
|
required: true,
|
|
help: "Whose gathering this is.",
|
|
},
|
|
{
|
|
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: "Text override of what the card shows (eg. March/April 2026)",
|
|
},
|
|
{
|
|
path: "status",
|
|
label: "Status",
|
|
widget: "select",
|
|
options: ["upcoming", "past", "cancelled"],
|
|
blankLabel: "Default: derive from end date",
|
|
},
|
|
{
|
|
path: "is_series",
|
|
label: "Series",
|
|
widget: "checkbox",
|
|
help: "Repeats on a schedule, such as a weekly class, a monthly meeting",
|
|
},
|
|
],
|
|
},
|
|
seriesGroup,
|
|
{ legend: "Where", fields: PLACE_FIELDS },
|
|
{
|
|
legend: "Appearance",
|
|
fields: [
|
|
{ path: "event_logo", label: "Event logo", widget: "image", resolve: eventLogo, full: true },
|
|
{ path: "org_logo", label: "Org logo override", widget: "image", resolve: orgLogo, full: true },
|
|
{ path: "color", label: "Colour", widget: "color" },
|
|
{ path: "gradient", label: "Gradient", full: true },
|
|
{
|
|
path: "card_image",
|
|
label: "Card background",
|
|
widget: "image",
|
|
resolve: eventBackground,
|
|
full: true,
|
|
help: "A photo behind the event's card, faded so the text stays readable.",
|
|
},
|
|
],
|
|
},
|
|
timelineGroup("event"),
|
|
timelineDetailGroup("event"),
|
|
{ legend: "Publishing", fields: [PUBLISHED_FIELD, LISTED_FIELD] },
|
|
],
|
|
|
|
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: "eg. Keynote Speaker" },
|
|
{ path: "is_public", label: "Show on the site", widget: "checkbox" },
|
|
],
|
|
},
|
|
linksChild,
|
|
blocksChild,
|
|
],
|
|
};
|
|
|
|
/* ── People ──────────────────────────────────────────────────── */
|
|
|
|
const people = {
|
|
key: "people",
|
|
label: "People",
|
|
singular: "person",
|
|
idLabel: "URL ID",
|
|
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" },
|
|
{ key: "is_listed", label: "Listed", widget: "bool" },
|
|
],
|
|
filters: [
|
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
|
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
|
],
|
|
},
|
|
|
|
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", widget: "image", resolve: personPhoto, full: true },
|
|
{
|
|
path: "primary_org_id",
|
|
label: "Home organization",
|
|
widget: "select",
|
|
optionsFrom: "organizations",
|
|
blankLabel: "Default: 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.",
|
|
fields: [PUBLISHED_FIELD, LISTED_FIELD],
|
|
},
|
|
],
|
|
|
|
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: "Default: 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: "Default: 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: "URL ID",
|
|
// 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" },
|
|
{ key: "is_listed", label: "Listed", widget: "bool" },
|
|
],
|
|
filters: [
|
|
{ key: "org_id", label: "Organization", optionsFrom: "organizations" },
|
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
|
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
|
],
|
|
},
|
|
|
|
groups: [
|
|
{
|
|
legend: "Identity",
|
|
note:
|
|
"Pick the organization first: the id 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", widget: "image", resolve: teamLogo, full: true },
|
|
],
|
|
},
|
|
{ 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: "URL ID",
|
|
slugFrom: "name",
|
|
|
|
list: {
|
|
columns: [
|
|
{ key: "name", label: "Name", primary: true },
|
|
{ key: "org_id", label: "Awarded by" },
|
|
{ key: "description", label: "Description" },
|
|
{ key: "is_published", label: "Live", widget: "bool" },
|
|
{ key: "is_listed", label: "Listed", widget: "bool" },
|
|
],
|
|
filters: [
|
|
{ key: "org_id", label: "Awarded by", optionsFrom: "organizations" },
|
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
|
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
|
],
|
|
},
|
|
|
|
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", widget: "image", resolve: awardLogo, full: true },
|
|
],
|
|
},
|
|
{
|
|
legend: "Publishing",
|
|
note: "An unpublished award is a draft: off the site, and a 404 at its own page.",
|
|
fields: PUBLISH_FIELDS,
|
|
},
|
|
],
|
|
};
|
|
|
|
/* ── 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 and 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: "Default: nothing",
|
|
help: "Changing this leaves the record below orphaned, pick a new one",
|
|
},
|
|
{
|
|
path: "ref_id",
|
|
label: "Record",
|
|
widget: "select",
|
|
optionsFrom: "timeline_refs",
|
|
blankLabel: "Default: none",
|
|
// 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, 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, 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, the livestream and the featured video are
|
|
editable whatever the mode, so each can be ready before the
|
|
switch is flipped.
|
|
|
|
Section keys and stat sources are the CHECK lists on
|
|
front_page_sections and front_page_stats. The labels here are what the admin reads; the values are
|
|
what the page and the API key on. */
|
|
|
|
const FRONT_PAGE_SECTIONS = [
|
|
["countdown", "Event Countdown"],
|
|
["retreats", "Events Carousel (National Retreats)"],
|
|
["calendar", "Event Calendar"],
|
|
["stats", "Stats"],
|
|
["timeline", "Featured Timeline"],
|
|
["connect", "Connect Nav"],
|
|
];
|
|
|
|
const STAT_SOURCES = [
|
|
["manual", "Print Value Field"],
|
|
["years_since", "Years Since Value"],
|
|
["regions", "Count: regions"],
|
|
["chapters", "Count: chapters"],
|
|
["partners", "Count: partners"],
|
|
["events_held", "Count: past events"],
|
|
["retreats_held", "Count: past retreats"],
|
|
["people", "Count: people in database"],
|
|
["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 - Primary Section",
|
|
note: "The first thing a visitor sees. Blank buttons don't render.",
|
|
fields: [
|
|
{
|
|
path: "hero_backdrop",
|
|
label: "Background",
|
|
widget: "select",
|
|
options: [
|
|
["brand", "Brand: animated colour and the dove"],
|
|
["photos", "Photos: cycles through the photos below"],
|
|
],
|
|
blankLabel: "Default: brand",
|
|
help: "Photos with none added shows the brand background",
|
|
},
|
|
{
|
|
path: "hero_feature",
|
|
label: "Feature",
|
|
widget: "select",
|
|
options: [
|
|
["none", "Nothing: No additional overlay"],
|
|
["livestream", "Livestream: the stream, with a LIVE badge"],
|
|
["video", "Featured video: click to play"],
|
|
],
|
|
blankLabel: "Default: nothing",
|
|
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: "/page, #section-id or a full URL" },
|
|
{ path: "secondary_label", label: "Second button label" },
|
|
{ path: "secondary_url", label: "Second button link" },
|
|
],
|
|
},
|
|
{
|
|
legend: "Photos, livestream and video",
|
|
fields: [
|
|
{
|
|
path: "slide_seconds",
|
|
label: "Seconds per photo",
|
|
widget: "number",
|
|
help: "Photos Background. Set from 3 to 60 seconds",
|
|
},
|
|
{
|
|
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 },
|
|
{
|
|
path: "video_url",
|
|
label: "Featured video",
|
|
full: true,
|
|
help:
|
|
"A YouTube, Vimeo or Facebook link, or a video file: a filename in " +
|
|
"/front-page/ or a link ending in .mp4 or .webm",
|
|
},
|
|
{ path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" },
|
|
],
|
|
},
|
|
{
|
|
legend: "Countdown",
|
|
fields: [
|
|
{
|
|
path: "countdown_event_id",
|
|
label: "Count down to",
|
|
widget: "select",
|
|
optionsFrom: "events",
|
|
blankLabel: "Default: the next upcoming event",
|
|
help: "Leave blank almost always. A pinned event that's over falls back to the next one",
|
|
},
|
|
{
|
|
path: "countdown_scope_id",
|
|
label: "Only this scope",
|
|
widget: "select",
|
|
optionsFrom: "event_scopes",
|
|
blankLabel: "Default: any scope",
|
|
help: "Narrows the next upcoming event. Ignored when an event is pinned above",
|
|
},
|
|
{
|
|
path: "countdown_event_type",
|
|
label: "Only this type",
|
|
widget: "select",
|
|
options: [
|
|
["retreat", "Retreat"],
|
|
["class", "Class"],
|
|
["workshop", "Workshop"],
|
|
["meeting", "Meeting"],
|
|
["other", "Other"],
|
|
],
|
|
blankLabel: "Default: any type",
|
|
help: "Combines with the scope: National + Retreat counts down to the next national retreat",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
|
|
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: "Heading Override" },
|
|
{ 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, widget: "image", resolve: heroPhoto, full: true },
|
|
{ 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: "Number Source",
|
|
widget: "select",
|
|
options: STAT_SOURCES,
|
|
blankLabel: "Default: Print Value",
|
|
},
|
|
{ path: "value", label: "Value", help: "The number thats printed" },
|
|
{ path: "suffix", label: "Suffix", help: "+, k, % …" },
|
|
{ path: "note", label: "Note", full: true },
|
|
],
|
|
},
|
|
{
|
|
key: "paths",
|
|
label: "Connect Nav",
|
|
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: "eg. Attend, Serve…" },
|
|
{ path: "icon", label: "Icon", help: "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);
|
|
}
|