- A "People" content block: a team's members as people tiles, people
picked one by one as items (each with a title), or both.
content_blocks gains team_id (migration 054 rebuilds it for the
type CHECK); a picked person rides on the item's person_id.
- An organization host can name a team (any organization's) to show
in its place: event_hosts.team_id, carried by v_event_hosts. The
event page reads "Hosted by" the team, linked to its page.
- Admin fields can show on `when: { path, filled: true }`.
- The showcase post has a people block; the past showcase event is
hosted by the region shown as its team.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
208 lines
6.5 KiB
JavaScript
208 lines
6.5 KiB
JavaScript
/* Column helpers, and the field sets and child collections several
|
|
entities share. The descriptor anatomy is in ../admin-schema.js. */
|
|
|
|
/* ── Column helpers ──────────────────────────────────────────── */
|
|
|
|
export const text = (name, opts = {}) => ({ name, type: "text", ...opts });
|
|
// Text that is a link: refuses javascript:, data: and other schemes.
|
|
export const url = (name, opts = {}) => ({ name, type: "url", ...opts });
|
|
export const int = (name, opts = {}) => ({ name, type: "int", ...opts });
|
|
export const real = (name, opts = {}) => ({ name, type: "real", ...opts });
|
|
export const bool = (name, opts = {}) => ({ name, type: "bool", ...opts });
|
|
export const date = (name, opts = {}) => ({ name, type: "date", ...opts });
|
|
export const time = (name, opts = {}) => ({ name, type: "time", ...opts });
|
|
export const enumeration = (name, values, opts = {}) => ({
|
|
name,
|
|
type: "enum",
|
|
values,
|
|
...opts,
|
|
});
|
|
|
|
/* Place columns shared by organizations and events, in schema order. */
|
|
export const placeColumns = [
|
|
text("venue"),
|
|
text("address"),
|
|
text("locality"),
|
|
text("state_code"),
|
|
text("country"),
|
|
text("location_label"),
|
|
real("latitude"),
|
|
real("longitude"),
|
|
bool("is_online"),
|
|
];
|
|
|
|
/* The affiliation's own fields, minus whichever end owns the row.
|
|
Both editors write the same shape so neither loses the other's
|
|
values on save. */
|
|
export const affiliationRole = [
|
|
text("title"),
|
|
enumeration("role", ["lead", "board", "staff", "volunteer", "member"], {
|
|
required: true,
|
|
}),
|
|
bool("is_owner"),
|
|
date("started_on"),
|
|
date("ended_on"),
|
|
bool("is_public"),
|
|
];
|
|
|
|
/* The editable half of a timeline entry, shared by the standalone
|
|
editor and by the in_timeline extension on events and organizations.
|
|
|
|
occurred_on is text, not date. "2012" and "2025-07" are legitimate
|
|
values (a backfilled entry often knows the year and nothing more),
|
|
and the date coercion would reject both. `precision` is what says how
|
|
much of it to believe. */
|
|
export const timelineFields = [
|
|
text("occurred_on"),
|
|
enumeration("precision", ["year", "month", "day"]),
|
|
text("title"),
|
|
text("blurb"),
|
|
text("meta"),
|
|
url("link_url"),
|
|
bool("is_featured"),
|
|
bool("is_published"),
|
|
int("sort_order"),
|
|
];
|
|
|
|
/* The extension that the in_timeline checkbox drives. Ticked, the row
|
|
is upserted; unticked, writeExtensions deletes it. Both happen in the
|
|
parent's transaction, so the flag and the row cannot disagree.
|
|
|
|
The conflict target is the UNIQUE (ref_kind, ref_id) constraint
|
|
on timeline_entries, which is also what stops a second save creating a
|
|
duplicate instead of updating the first. */
|
|
export const timelineExtension = (refKind) => ({
|
|
key: "timeline",
|
|
table: "timeline_entries",
|
|
owner: { column: "ref_id", kindColumn: "ref_kind", kindValue: refKind },
|
|
conflict: ["ref_kind", "ref_id"],
|
|
when: { column: "in_timeline", value: 1 },
|
|
columns: [
|
|
// Fixed for this end: an event's entry is always an event entry.
|
|
// Declared as a default rather than a form field so the column is
|
|
// written without asking.
|
|
enumeration(
|
|
"kind",
|
|
["milestone", "event", "organization", "award", "people"],
|
|
{ default: refKind === "organization" ? "organization" : refKind },
|
|
),
|
|
...timelineFields,
|
|
],
|
|
});
|
|
|
|
/* Featured cards (030_featured_cards.sql): polymorphic like links,
|
|
so the Community blog can own a set too. */
|
|
export const featuredCardsChild = (ownerKind) => ({
|
|
key: "featured_cards",
|
|
table: "featured_cards",
|
|
owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind },
|
|
order: "sort_order",
|
|
columns: [
|
|
enumeration("kind", ["record", "link", "video"], { required: true }),
|
|
enumeration("ref_kind", ["event", "organization", "person", "team", "award"]),
|
|
text("ref_id"),
|
|
url("url"),
|
|
text("eyebrow"),
|
|
text("title"),
|
|
text("blurb"),
|
|
text("image"),
|
|
],
|
|
});
|
|
|
|
/* The two polymorphic collections, parameterized by owner_kind. */
|
|
export const linksChild = (ownerKind) => ({
|
|
key: "links",
|
|
table: "links",
|
|
owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind },
|
|
order: "sort_order",
|
|
columns: [
|
|
enumeration("kind", ["action", "social", "website", "email"], {
|
|
required: true,
|
|
}),
|
|
text("platform"),
|
|
text("label", { required: true }),
|
|
url("url", { required: true }),
|
|
bool("is_primary"),
|
|
],
|
|
});
|
|
|
|
export const blocksChild = (ownerKind) => ({
|
|
key: "content_blocks",
|
|
table: "content_blocks",
|
|
owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind },
|
|
order: "sort_order",
|
|
columns: [
|
|
enumeration("slot", ["card", "body"], { required: true }),
|
|
enumeration(
|
|
"type",
|
|
[
|
|
"heading",
|
|
"subheading",
|
|
"paragraph",
|
|
"list",
|
|
"links",
|
|
"quote",
|
|
"image",
|
|
"divider",
|
|
"video",
|
|
"button",
|
|
"callout",
|
|
"schedule",
|
|
"table",
|
|
"cards",
|
|
"people",
|
|
],
|
|
{ required: true },
|
|
),
|
|
text("text"),
|
|
text("media"),
|
|
url("href"),
|
|
text("alt"),
|
|
text("cite"),
|
|
// People blocks only (054): whose team's tiles to show.
|
|
text("team_id"),
|
|
],
|
|
children: [
|
|
{
|
|
key: "items",
|
|
table: "content_block_items",
|
|
owner: { column: "block_id" },
|
|
order: "sort_order",
|
|
columns: [
|
|
text("text", { required: true }),
|
|
text("detail"),
|
|
url("url"),
|
|
// Schedule entries only (034_schedule_block.sql).
|
|
text("day"),
|
|
text("time"),
|
|
text("location"),
|
|
text("person_id"),
|
|
text("description"),
|
|
text("media"),
|
|
text("media_alt"),
|
|
text("map"),
|
|
],
|
|
},
|
|
],
|
|
});
|
|
|
|
/* Hosts. One row is one host, ordered, each either an organization
|
|
or a person. The CHECK on event_hosts rejects both and the blank
|
|
filter drops neither, so the only bad row that reaches SQLite is
|
|
one with both selects filled, and that comes back keyed to the
|
|
row like any other field error.
|
|
|
|
Not parameterized the way links and blocks are: this table is
|
|
events-only, and the owner column says so.
|
|
|
|
sort_order isn't declared. The engine writes it from the row's
|
|
position because `order` is "sort_order", which is what makes
|
|
the first row the one v_events takes the logo and color from. */
|
|
export const hostsChild = {
|
|
key: "event_hosts",
|
|
table: "event_hosts",
|
|
owner: { column: "event_id" },
|
|
order: "sort_order",
|
|
// team_id (054): an organization host's team, shown in its place.
|
|
columns: [text("org_id"), text("person_id"), text("team_id")],
|
|
};
|