diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index 27e2f17..812b9fa 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -184,6 +184,7 @@ also in `server/src/admin-schema/` and a CHECK): | Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table, cards, people, map, events, organizations | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). | | Content blocks → Schedule items → Type | (blank: normal entry), block, break, heading | **yes**, migration 086 | `SCHEDULE_KINDS` in `src/lib/adminSchema/shared.ts`; drawn by `ScheduleBlock.tsx` and `EventPresent.tsx` (which slides each kind gets; the presentation cuts the event's page into sections at its Heading blocks). A block's sub-items are `content_block_subitems`. A schedule's own tags (087) are `content_block_tags`, rows of the block typed in the admin (not a fixed list); entries name them by `tag_key`, made in the admin as the tag is added. A schedule's Venue (088) lends its locations (Data → Venues, `venue_locations`) to its entries' Map location, named by `location_key` the same way; an entry's Event (a workshop) fills what it leaves blank in `shape.js` (`attachEvents`). | | Content blocks → List → Style | (blank: bold text, normal detail), plain (plain text, gray detail) | **yes**, migration 092 | The Style field in `src/lib/adminSchema/shared.ts`; drawn by the `list` case in `ContentBlocks.tsx`. | +| Content blocks (an event's) → Shown | (blank: the page and the presentation), page, presentation | **yes**, migration 099 | `PRESENT_BLOCK_FIELDS` in `src/lib/adminSchema/shared.ts`; `ContentBlocks.tsx` leaves out a presentation-only block on the page and a page-only one presented, `sectionsOf` in `src/pages/EventPresent.tsx` too | | Content blocks (an event's) → Map → Location slides | (blank: each marked location), picked (the Locations with a slide), none | **yes**, migration 095 | `PRESENT_BLOCK_FIELDS` in `src/lib/adminSchema/shared.ts`; read by `mapSlides` in `src/pages/EventPresent.tsx` | | Events → Presentation → Frame | (blank: the accent bar, title line and timer), border, none | **yes**, migration 095 | The `present_frame` field in `src/lib/adminSchema/events.ts`; drawn by `Player` in `src/pages/EventPresent.tsx` | | Content blocks → Organizations → List | (blank: only the picked ones), partner, region, group, ministry | **yes**, migration 093 | The `org_kind` field in `src/lib/adminSchema/shared.ts`; the `organizations` case in `ContentBlocks.tsx` passes it as the kind to `OrgListCards` (`nested`); items picked by `org_id` replace it | diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js index 9fe002b..ff4f3d1 100644 --- a/server/src/admin-schema/columns.js +++ b/server/src/admin-schema/columns.js @@ -182,7 +182,8 @@ export const blocksChild = (ownerKind) => ({ // Organizations blocks (093): the kind listed when none are picked. enumeration("org_kind", ["region", "group", "partner", "ministry"]), // How it's presented (095): EventPresent.tsx. - bool("present_hide"), + // Where it shows (099): null both, the page or the presentation. + enumeration("present_show", ["page", "presentation"]), text("present_text"), bool("present_map_split"), bool("present_map_no_list"), diff --git a/server/src/migrations/099_present_show.sql b/server/src/migrations/099_present_show.sql new file mode 100644 index 0000000..dba78f7 --- /dev/null +++ b/server/src/migrations/099_present_show.sql @@ -0,0 +1,20 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 099 WHERE A BLOCK SHOWS: THE PAGE, THE PRESENTATION OR BOTH +-- +-- present_hide (095) could only leave a block out of the +-- presentation. present_show says where it shows instead: +-- +-- null the page and the presentation +-- 'page' only on the page (was present_hide = 1) +-- 'presentation' only in the presentation (EventPresent.tsx), eg. +-- a slide's welcome line the page doesn't need +-- +-- present_hide is copied over, then dropped. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_blocks ADD COLUMN present_show TEXT + CHECK (present_show IN ('page', 'presentation')); + +UPDATE content_blocks SET present_show = 'page' WHERE present_hide = 1; + +ALTER TABLE content_blocks DROP COLUMN present_hide; diff --git a/server/src/shape.js b/server/src/shape.js index c64aa66..8c49b89 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -67,7 +67,9 @@ export function loadLinks(db, ownerKind, ids) { /* A block's presentation settings (095), or null with none set. */ function presentOf(row) { const present = { - hide: row.present_hide === 1, + // Where it shows (099). + hide: row.present_show === "page", + only: row.present_show === "presentation", text: row.present_text, map_split: row.present_map_split === 1, map_no_list: row.present_map_no_list === 1, @@ -88,7 +90,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) { .prepare( `SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id, venue_id, word_motion, word_direction, word_seconds, list_style, org_kind, - present_hide, present_text, present_map_split, present_map_no_list, + present_show, present_text, present_map_split, present_map_no_list, present_map_no_details, present_places, present_place_keys, present_list_overview, present_list_items FROM content_blocks diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx index 1e6e709..8ffd806 100644 --- a/src/components/ContentBlocks.tsx +++ b/src/components/ContentBlocks.tsx @@ -89,12 +89,15 @@ export default function ContentBlocks({ anchorPrefix?: string }) { const presenting = usePresenting() - // Presented, a block set to is left out and the rest take their - // Presentation text (095). - if (presenting && blocks) { - blocks = blocks - .filter((block) => !block.present?.hide) - .map((block) => (block.present?.text ? { ...block, text: block.present.text } : block)) + // Presented, a block shown only on the page is left out and the + // rest take their Presentation text (095, 099); on the page, a block + // shown only in the presentation is. + if (blocks) { + blocks = presenting + ? blocks + .filter((block) => !block.present?.hide) + .map((block) => (block.present?.text ? { ...block, text: block.present.text } : block)) + : blocks.filter((block) => !block.present?.only) } if (!blocks?.length) return null // Headings get ids so a post's contents (PostContents) and a shared diff --git a/src/lib/adminSchema/shared.ts b/src/lib/adminSchema/shared.ts index cba02d3..06c556e 100644 --- a/src/lib/adminSchema/shared.ts +++ b/src/lib/adminSchema/shared.ts @@ -497,10 +497,15 @@ const SUB_ITEM_FIELDS = [ /* An event's blocks' presentation fields (095), EventPresent.tsx. */ export const PRESENT_BLOCK_FIELDS = [ { - path: "present_hide", - label: "Leave out of the presentation", - widget: "checkbox", - help: "The page still shows it.", + path: "present_show", + label: "Shown", + widget: "select", + options: [ + ["page", "Only on the page"], + ["presentation", "Only in the presentation"], + ], + blankLabel: "Default: on the page and in the presentation", + help: "Only in the presentation keeps it off the page, eg. a welcome line for the screen.", }, { path: "present_text", diff --git a/src/lib/useContent.ts b/src/lib/useContent.ts index 075a319..bd2fc34 100644 --- a/src/lib/useContent.ts +++ b/src/lib/useContent.ts @@ -76,7 +76,10 @@ export type ContentBlock = { /** A block's presentation settings (095), EventPresent.tsx. */ export type BlockPresent = { + /** Only on the page: left out of the presentation (099). */ hide: boolean + /** Only in the presentation: left off the page (099). */ + only: boolean /** In place of its text, eg. a shorter heading. */ text: string | null /** A map: a slide per map section. */ diff --git a/src/pages/EventDetail.tsx b/src/pages/EventDetail.tsx index ce90497..a0ffd9b 100644 --- a/src/pages/EventDetail.tsx +++ b/src/pages/EventDetail.tsx @@ -92,7 +92,10 @@ export default function EventDetail() { const accent = event.color || BRAND const groups = peopleGroups(event.people, accent) // Two headings or more make a list worth showing, as on a post. - const contents = event.show_contents ? headingAnchors(event.blocks).entries : [] + // Not a heading shown only in the presentation (099). + const contents = event.show_contents + ? headingAnchors(event.blocks.filter((block) => !block.present?.only)).entries + : [] const withContents = contents.length >= 2 const sections: ShellSection[] = [