Call local chapters groups, everywhere
The organization kind is 'group', its side table is groups, pages live at /groups/<id> and the Community page's section is #groups. Migration 052 converts existing databases: the kind and the tables whose CHECKs name chapters are rebuilt, the front page count and request category follow, and the site's own /chapters/ and #chapters links in records are rewritten. Request files now go in Requests/Groups on the shared drive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
175a18976d
commit
38aff34c97
42 changed files with 473 additions and 254 deletions
|
|
@ -2,7 +2,7 @@
|
|||
MAP GRID
|
||||
|
||||
Pure layout. Where each tile sits, what it's called, and how to
|
||||
work out which tile a chapter belongs to. None of this is in the
|
||||
work out which tile a group belongs to. None of this is in the
|
||||
database because none of it changes, Rhode Island will not be
|
||||
moving, and no admin form should offer to move it.
|
||||
|
||||
|
|
@ -83,27 +83,27 @@ export const AREAS = Object.freeze([
|
|||
|
||||
export const AREA_BY_CODE = Object.fromEntries(AREAS.map((a) => [a.code, a]));
|
||||
|
||||
/* ── Which tile a chapter sits on ──────────────────────────────
|
||||
/* ── Which tile a group sits on ──────────────────────────────
|
||||
The database stores a real address, state_code for US, and a
|
||||
country code otherwise, rather than a tile name. This is the
|
||||
one place that translates between the two, so adding a Mexico
|
||||
band later means a line here and nothing in SQL.
|
||||
|
||||
Returns null for anything with no tile, which covers virtual
|
||||
chapters and any country not drawn.
|
||||
groups and any country not drawn.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
const COUNTRY_AREA = {
|
||||
CA: "CANADA", // ISO country code, not California
|
||||
};
|
||||
|
||||
export function areaForChapter(chapter) {
|
||||
if (!chapter) return null;
|
||||
if (chapter.is_online) return null;
|
||||
export function areaForGroup(group) {
|
||||
if (!group) return null;
|
||||
if (group.is_online) return null;
|
||||
|
||||
if (chapter.country === "US") {
|
||||
return AREA_BY_CODE[chapter.state_code] ? chapter.state_code : null;
|
||||
if (group.country === "US") {
|
||||
return AREA_BY_CODE[group.state_code] ? group.state_code : null;
|
||||
}
|
||||
return COUNTRY_AREA[chapter.country] ?? null;
|
||||
return COUNTRY_AREA[group.country] ?? null;
|
||||
}
|
||||
|
||||
/* ── Slices per tile ───────────────────────────────────────────
|
||||
|
|
@ -146,13 +146,13 @@ export function buildAreaSlices(regionAreas: any[] = [], regions: any[] = []) {
|
|||
return byArea;
|
||||
}
|
||||
|
||||
/* ── Chapter counts per tile ───────────────────────────────────
|
||||
/* ── Group counts per tile ───────────────────────────────────
|
||||
{ WA: 2, MO: 1, CANADA: 1 }
|
||||
───────────────────────────────────────────────────────────── */
|
||||
export function countChaptersByArea(chapters: any[] = []) {
|
||||
export function countGroupsByArea(groups: any[] = []) {
|
||||
const counts = {};
|
||||
for (const chapter of chapters) {
|
||||
const code = areaForChapter(chapter);
|
||||
for (const group of groups) {
|
||||
const code = areaForGroup(group);
|
||||
if (code) counts[code] = (counts[code] ?? 0) + 1;
|
||||
}
|
||||
return counts;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
CATEGORIES in server/src/routes/requests.js (and the CHECK in
|
||||
046_content_requests.sql); keep them in step.
|
||||
|
||||
A link can open the form on one: requestLink("chapter") is
|
||||
/request?type=chapter. People, teams and awards have no buttons on
|
||||
A link can open the form on one: requestLink("group") is
|
||||
/request?type=group. People, teams and awards have no buttons on
|
||||
the site, but are here to pick.
|
||||
|
||||
`fields` are the details the form asks for on top of the name and
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
name, which the admin picks by hand
|
||||
|
||||
`entity` is the admin record it becomes, `preset` the values a new
|
||||
one starts with (a chapter is an organization of kind chapter), and
|
||||
one starts with (a group is an organization of kind group), and
|
||||
`heading` the editor field the request's name fills.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
|
|
@ -91,20 +91,20 @@ export const REQUEST_TYPES: RequestType[] = [
|
|||
],
|
||||
},
|
||||
{
|
||||
id: "chapter",
|
||||
label: "Chapter",
|
||||
hint: "A local NGU chapter",
|
||||
id: "group",
|
||||
label: "Group",
|
||||
hint: "A local NGU group",
|
||||
actions: ["new", "update"],
|
||||
subject: "The chapter's name",
|
||||
subject: "The group's name",
|
||||
entity: "organizations",
|
||||
heading: "name",
|
||||
preset: { kind: "chapter" },
|
||||
preset: { kind: "group" },
|
||||
fields: [
|
||||
{ key: "region", label: "Region it's in", placeholder: "eg. Great Lakes" },
|
||||
CITY,
|
||||
STATE,
|
||||
COUNTRY,
|
||||
{ key: "meets", label: "When it meets", placeholder: "eg. 2nd Sundays, 6:00pm", to: { path: "chapter.meets" } },
|
||||
{ key: "meets", label: "When it meets", placeholder: "eg. 2nd Sundays, 6:00pm", to: { path: "group.meets" } },
|
||||
WEBSITE,
|
||||
EMAIL,
|
||||
DESCRIPTION,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue