NGU-Web/src/lib/adminSchema.ts
Zaldimmar 222c9e69a2 Third audit, UI half; side nav on top; request button colors
- Event cards: lazy -640 photo, only nearby slides drawn, a counter
  past 12 events, past grid paged with Show more
- Community map: search over list and grid, 12 per region then Show
  all, list no longer redrawn on hover
- People tiles: one clip check for the list, Show all past 30
- Person pages: 6 events and posts then Show all; excerpts load only
  the first paragraph
- Admin: filter box on long pickers and the QR select, options sent
  per form, Media thumbnails from the small copy, debounced searches
  that drop stale answers
- Pages show their last data while refreshing after the cache TTL
- Side nav stacks above page content (the carousel arrows)
- No event request button on National Retreats; request buttons take
  their section's accent
- Version v1.11.1-audit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 19:09:21 -05:00

81 lines
3.1 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 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<string, any> = {
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<string>();
const seen = new Set<any>();
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);
}