import { text, int, real, bool, enumeration, placeColumns, timelineExtension, linksChild, blocksChild } from "./columns.js"; import { tagsChild } from "./tags.js"; /* ── Organizations ───────────────────────────────────────────── */ export const organizations = { key: "organizations", table: "organizations", idColumn: "id", idKind: "slug", concurrency: "updated_at", list: { columns: [ "id", "kind", "name", "short_name", "locality", "state_code", "is_published", "is_listed", "sort_order", "updated_at", ], filters: ["kind", "is_published", "is_listed"], search: ["name", "id", "locality"], order: "kind, sort_order, name", }, columns: [ enumeration("kind", ["national", "region", "group", "partner", "ministry"], { required: true, }), text("name", { required: true }), text("short_name"), text("tagline"), text("color"), text("logo"), ...placeColumns, bool("is_published"), bool("is_listed"), int("sort_order"), bool("in_timeline"), ], extensions: [ timelineExtension("organization"), { key: "region", table: "regions", idColumn: "id", when: { column: "kind", value: "region" }, columns: [ enumeration("scope", ["domestic", "international", "virtual"], { required: true, }), text("map_note"), ], }, { key: "group", table: "groups", idColumn: "id", when: { column: "kind", value: "group" }, columns: [text("region_id"), text("ministry_id"), text("meets"), text("started")], }, ], children: [ tagsChild("organization_tags", "org_id"), linksChild("organization"), blocksChild("organization"), // Who to write to there, by role (064_org_contacts.sql): private, // for the Newsletter's recipient export. { key: "contacts", table: "organization_contacts", owner: { column: "org_id" }, order: "sort_order", readRole: "editor", columns: [ text("type_id", { required: true }), text("name"), text("email"), text("phone"), ], }, { key: "region_areas", table: "region_areas", owner: { column: "region_id" }, when: { column: "kind", value: "region" }, order: "area_code", columns: [ text("area_code", { required: true }), real("share"), enumeration("edge", ["top", "bottom"]), text("note"), ], }, ], };