Organization cards: list partners, ministries or a hand-picked set (migration 067)
The Partners section's preset gets "Cards: list" (partners by default, ministries, or both) and an optional hand-picked list (page_section_orgs, partners or ministries only, enforced by trigger) that replaces it in its own order. /organizations takes kind=ministry and ids=; the plain list still leaves ministries out. Ministry cards link to their website only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
635dd21083
commit
fd7e1b6fc1
11 changed files with 146 additions and 23 deletions
|
|
@ -15,7 +15,7 @@ const PRESETS = {
|
|||
community_blog: "Community blog (its settings are below)",
|
||||
group_map: "Local groups map",
|
||||
region_list: "Unity Regions list",
|
||||
partner_list: "Partner organization cards",
|
||||
partner_list: "Organization cards (partners, ministries)",
|
||||
events: "Event carousel or grid",
|
||||
timeline: "Timeline",
|
||||
people_directory: "People directory (a tag's people)",
|
||||
|
|
@ -37,6 +37,7 @@ const EVENT_TYPES = [
|
|||
];
|
||||
|
||||
const EVENTS = { path: "preset", value: "events" };
|
||||
const CARDS = { path: "preset", value: "partner_list" };
|
||||
|
||||
const sectionsChild = (presets: string[]) => ({
|
||||
key: "sections",
|
||||
|
|
@ -113,6 +114,23 @@ const sectionsChild = (presets: string[]) => ({
|
|||
},
|
||||
]
|
||||
: []),
|
||||
...(presets.includes("partner_list")
|
||||
? [
|
||||
{
|
||||
path: "org_kinds",
|
||||
label: "Cards: list",
|
||||
widget: "select",
|
||||
options: [
|
||||
["partner", "Partners"],
|
||||
["ministry", "Ministries"],
|
||||
["partner,ministry", "Partners and ministries"],
|
||||
],
|
||||
blankLabel: "Default: Partners",
|
||||
help: "Every published, listed one, by name. Organizations picked below replace this list.",
|
||||
when: CARDS,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(presets.includes("group_map")
|
||||
? [
|
||||
{
|
||||
|
|
@ -127,6 +145,16 @@ const sectionsChild = (presets: string[]) => ({
|
|||
: []),
|
||||
],
|
||||
children: [
|
||||
{
|
||||
key: "orgs",
|
||||
label: "Cards: organizations",
|
||||
note: "Picked here, these show instead of the list above, in this order: partners or ministries, published ones, listed or not.",
|
||||
addLabel: "Add organization",
|
||||
when: CARDS,
|
||||
title: (row, options) => options?.card_orgs?.find((o) => o.id === row.org_id)?.label ?? "New organization",
|
||||
blank: { org_id: "" },
|
||||
fields: [{ path: "org_id", label: "Organization", widget: "select", optionsFrom: "card_orgs", required: true }],
|
||||
},
|
||||
{
|
||||
...blocksChild,
|
||||
label: "Blocks",
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ import { isBadId, orgHref } from "./hrefs.ts";
|
|||
import { useResource } from "./useResource.ts";
|
||||
|
||||
|
||||
export function useOrganizations(kind) {
|
||||
const path = kind
|
||||
? `/organizations?kind=${encodeURIComponent(kind)}`
|
||||
: "/organizations";
|
||||
/* `ids` (a hand-picked list) wins over `kind`. */
|
||||
export function useOrganizations(kind, ids?: string[]) {
|
||||
const path = ids?.length
|
||||
? `/organizations?ids=${ids.map(encodeURIComponent).join(",")}`
|
||||
: kind
|
||||
? `/organizations?kind=${encodeURIComponent(kind)}`
|
||||
: "/organizations";
|
||||
|
||||
const { data, error, loading } = useResource(path);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ export type SitePageSection = {
|
|||
view?: string | null
|
||||
/** A people_directory preset's tag (Data → People tags). */
|
||||
tag_id?: string | null
|
||||
/** Organization cards: the kinds listed ('partner', 'ministry' or both, comma separated). */
|
||||
org_kinds?: string | null
|
||||
/** Organization cards: a hand-picked list, in order, shown instead. */
|
||||
org_ids: string[]
|
||||
blocks: ContentBlock[]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,10 +66,15 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
|
|||
],
|
||||
},
|
||||
}),
|
||||
partner_list: () => ({
|
||||
partner_list: (section) => ({
|
||||
Component: OrgListCards,
|
||||
request: { type: 'partner', label: 'Request a partner listing' },
|
||||
props: { kind: 'partner', pageLabel: 'Partner page', empty: '· Partner organizations coming soon ·' },
|
||||
props: {
|
||||
kind: section.org_kinds || 'partner',
|
||||
ids: section.org_ids,
|
||||
pageLabel: 'Partner page',
|
||||
empty: '· Organizations coming soon ·',
|
||||
},
|
||||
}),
|
||||
events: (section) => ({
|
||||
Component: EventListCards,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import { useReadingMode } from '../../lib/readingMode.ts'
|
|||
page manifest and gets no control in its heading.
|
||||
|
||||
<OrgListCards kind="partner" pageLabel="Partner page" />
|
||||
<OrgListCards ids={["unity-worldwide", "unity-of-x"]} /> in that order
|
||||
|
||||
Where the vertical list expands in place, a card links out. The
|
||||
card carries as much as fits at a glance and the organization's
|
||||
|
|
@ -152,6 +153,7 @@ function Block({ title, orgs, accent, pageLabel, siteLabel }) {
|
|||
|
||||
export default function OrgListCards({
|
||||
kind,
|
||||
ids,
|
||||
title,
|
||||
groups,
|
||||
groupBy,
|
||||
|
|
@ -161,7 +163,7 @@ export default function OrgListCards({
|
|||
sort = byName,
|
||||
empty = "Nothing to show here yet.",
|
||||
}) {
|
||||
const { organizations, loading, error } = useOrganizations(kind);
|
||||
const { organizations, loading, error } = useOrganizations(kind, ids);
|
||||
|
||||
const shell = children => (
|
||||
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: GRID_MAX }}>
|
||||
|
|
@ -191,7 +193,12 @@ export default function OrgListCards({
|
|||
);
|
||||
}
|
||||
|
||||
const sorted = sort ? [...organizations].sort(sort) : organizations;
|
||||
// A hand-picked list keeps its order; anything else is sorted.
|
||||
const sorted = ids?.length
|
||||
? ids.flatMap((id) => organizations.filter((org) => org.id === id))
|
||||
: sort
|
||||
? [...organizations].sort(sort)
|
||||
: organizations;
|
||||
|
||||
// No groups given means one undivided grid.
|
||||
if (!groups || !groupBy) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue