Finish the audit leftovers
- One mediaUrl in media.ts instead of 12 identical aliases and a kind map; orgPath builds on hrefs.ts's orgHref - One Logo component (hides itself or shows a fallback when the file is missing) for event cards, org lists and chapter marks - useHistory is a thin wrapper over useRecord - adminSchema.ts split into adminSchema/, one file per entity plus shared.ts; the registry is unchanged (checked by loading both) - JS smooth scrolls respect reduced motion (lib/motion.ts) - Content-Security-Policy in Report-Only, with /api/csp-report logging what it would block Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c74ad746f5
commit
e4a9c96f7e
42 changed files with 1968 additions and 2043 deletions
148
src/lib/adminSchema/people.ts
Normal file
148
src/lib/adminSchema/people.ts
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
import { mediaUrl } from "../media.ts";
|
||||
import { PUBLISHED_FIELD, LISTED_FIELD, AFFILIATION_ROLE_FIELDS, linksChild, blocksChild } from "./shared.ts";
|
||||
|
||||
/* ── People ──────────────────────────────────────────────────── */
|
||||
|
||||
export 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: mediaUrl, 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,
|
||||
],
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue