Tidy the structure the audit found
- The colour defaults have one source, server/src/themeDefaults.js, read by the server and the admin; the build stops if src/index.css disagrees with it - server/src/admin-schema.js split into admin-schema/, one file per entity plus columns.js (the registry checked identical) - loadOwned() in shape.js replaces the same three loads on four detail routes (every public route checked identical); one NO_STORE - One OrgLogo component for the org lists and the chapter map; an organization's own page now shows the same initials as the lists - One localISO() for the viewer's calendar day, in place of three - Boot refuses a descriptor dropdown value the table's CHECK doesn't allow, instead of it failing on save - Deleted the unused Other.tsx and white-background logo; chapters.ts is useCommunity.ts; isSuper() in the Panel; stale comments and docs corrected Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
048c7599ce
commit
f934b1dd93
44 changed files with 1187 additions and 1170 deletions
202
server/src/admin-schema/columns.js
Normal file
202
server/src/admin-schema/columns.js
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
/* 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, parameterised 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",
|
||||
],
|
||||
{ required: true },
|
||||
),
|
||||
text("text"),
|
||||
text("media"),
|
||||
url("href"),
|
||||
text("alt"),
|
||||
text("cite"),
|
||||
],
|
||||
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 parameterised 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 colour from. */
|
||||
export const hostsChild = {
|
||||
key: "event_hosts",
|
||||
table: "event_hosts",
|
||||
owner: { column: "event_id" },
|
||||
order: "sort_order",
|
||||
columns: [text("org_id"), text("person_id")],
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue