/* ═══════════════════════════════════════════════════════════════ 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 file in adminSchema/ (its manifest), one line in ADMIN_ENTITIES below, and one descriptor on the server, with no new page component. Field sets and collections several entities share are in adminSchema/shared.ts. 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 { organizations } from "./adminSchema/organizations.ts"; import { events } from "./adminSchema/events.ts"; import { people } from "./adminSchema/people.ts"; import { teams } from "./adminSchema/teams.ts"; import { awards } from "./adminSchema/awards.ts"; import { timeline } from "./adminSchema/timeline.ts"; import { frontPage } from "./adminSchema/frontPage.ts"; import { blogPosts } from "./adminSchema/blog.ts"; import { siteSettings } from "./adminSchema/siteSettings.ts"; import { communityPage, retreatsPage, resourcesPage, organizationPage, historyPage, } from "./adminSchema/sitePages.ts"; export const ADMIN_ENTITIES: Record = { organizations, events, people, teams, awards, timeline, front_page: frontPage, blog_posts: blogPosts, community_page: communityPage, retreats_page: retreatsPage, resources_page: resourcesPage, organization_page: organizationPage, history_page: historyPage, site_settings: siteSettings, }; /* The /admin/options request for the option lists `part` of a manifest names (any `optionsFrom` inside it, at any depth), so a form gets only the lists its selects use. An empty request would mean every list, so a part that names none asks for nothing. */ export function optionsPath(part: any): string | null { const names = new Set(); const seen = new Set(); const walk = (value: any) => { if (!value || typeof value !== "object" || seen.has(value)) return; seen.add(value); if (typeof value.optionsFrom === "string") names.add(value.optionsFrom); for (const child of Object.values(value)) walk(child); }; walk(part); return names.size ? `/admin/options?only=${[...names].sort().join(",")}` : null; } export function slugify(value) { return String(value ?? "") .toLowerCase() .normalize("NFKD") .replace(/[^\w\s-]/g, "") .trim() .replace(/[\s_]+/g, "-") .replace(/-+/g, "-") .slice(0, 64); }