NGU-Web/src/lib/adminSchema/organizations.ts
Zaldimmar e4a9c96f7e 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>
2026-09-28 22:49:07 -05:00

107 lines
3.5 KiB
TypeScript

import { mediaUrl } from "../media.ts";
import { PLACE_FIELDS, PUBLISH_FIELDS, timelineGroup, timelineDetailGroup, linksChild, blocksChild } from "./shared.ts";
/* ── Organizations ───────────────────────────────────────────── */
export const organizations = {
key: "organizations",
label: "Organizations",
singular: "organization",
idLabel: "URL ID",
slugFrom: "name",
list: {
columns: [
{ key: "name", label: "Name", primary: true },
{ key: "kind", label: "Kind" },
{ key: "locality", label: "City" },
{ key: "state_code", label: "State" },
{ key: "is_published", label: "Live", widget: "bool" },
{ key: "is_listed", label: "Listed", widget: "bool" },
],
filters: [
{ key: "kind", label: "Kind", options: ["national", "region", "chapter", "partner"] },
{ 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: "kind",
label: "Kind",
widget: "select",
options: ["national", "region", "chapter", "partner"],
required: true,
help: "Changing this swaps which extra fields apply",
},
{ path: "name", label: "Name", required: true },
{ path: "short_name", label: "Short name" },
{ path: "tagline", label: "Tagline", full: true },
{ path: "color", label: "Colour", widget: "color" },
{ path: "logo", label: "Logo", widget: "image", resolve: mediaUrl, full: true },
],
},
{
legend: "Region",
when: { path: "kind", value: "region" },
fields: [
{
path: "region.scope",
label: "Scope",
widget: "select",
options: ["domestic", "international", "virtual"],
required: true,
},
{ path: "region.map_note", label: "Map note", full: true },
],
},
{
legend: "Chapter",
when: { path: "kind", value: "chapter" },
fields: [
{
path: "chapter.region_id",
label: "Region",
widget: "select",
optionsFrom: "regions",
blankLabel: "Default: none",
},
{ path: "chapter.meets", label: "Meets", help: "2nd Sundays, 6:00pm" },
{ path: "chapter.started", label: "Started", help: "Since 2021" },
],
},
{ legend: "Place", fields: PLACE_FIELDS },
timelineGroup("organization"),
timelineDetailGroup("organization"),
{ legend: "Publishing", fields: PUBLISH_FIELDS },
],
children: [
{
key: "region_areas",
label: "Map areas",
when: { path: "kind", value: "region" },
addLabel: "Add area",
title: (row) => row.area_code || "New area",
blank: { area_code: "", share: 1 },
fields: [
{ path: "area_code", label: "Area code", required: true, help: "Two letter state code or Country name" },
{ path: "share", label: "Share", widget: "number", help: "1 for the whole tile, 0.5 for half" },
{
path: "edge",
label: "Edge",
widget: "select",
options: ["top", "bottom"],
blankLabel: "Default: whole tile",
},
{ path: "note", label: "Note", help: "details to explain why it's half or other note" },
],
},
linksChild,
blocksChild,
],
};