Let the front page countdown filter by event scope and type
Admin > Front page > Countdown gains two optional dropdowns, "Only this scope" and "Only this type", each defaulting to any. They narrow which event counts as "the next one": National + Retreat counts down to the next national retreat and skips a sooner regional class. A pinned event still wins over both. When nothing matches, the countdown band doesn't render, as before. Migration 026 adds front_page.countdown_scope_id, a foreign key to event_scopes (ON DELETE SET NULL, so removing a scope returns it to "any"), and countdown_event_type, checked against the same values as events.event_type. Adding an event type now widens both CHECKs; the note in eventTypes.ts and the guide say so. Also clears the older em-dashes from home.js and eventTypes.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
54bf649b8d
commit
68f08b633c
6 changed files with 83 additions and 11 deletions
29
server/src/migrations/026_countdown_filters.sql
Normal file
29
server/src/migrations/026_countdown_filters.sql
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 026 COUNTDOWN: FILTER BY SCOPE AND TYPE
|
||||
--
|
||||
-- The countdown counts to the pinned event, or else to the next
|
||||
-- published event that hasn't ended. These two narrow "the next
|
||||
-- event": National + Retreat counts down to the next national
|
||||
-- retreat and skips a regional class that happens sooner. Either or
|
||||
-- both can be left null, meaning any. A pinned event still wins
|
||||
-- whatever they say; the admin chose it by name.
|
||||
--
|
||||
-- countdown_scope_id an event_scopes id. A real foreign key,
|
||||
-- so it can't name a scope that doesn't
|
||||
-- exist; ON DELETE SET NULL puts it back to
|
||||
-- "any" if a scope is ever removed.
|
||||
-- countdown_event_type the same values as events.event_type.
|
||||
-- Adding an event type now means widening
|
||||
-- this CHECK too.
|
||||
--
|
||||
-- Plain ADD COLUMN: a REFERENCES column is allowed when its default
|
||||
-- is NULL, and a CHECK is allowed on any. No rebuild.
|
||||
--
|
||||
-- PRAGMA user_version; -- reads 25 before this file
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
ALTER TABLE front_page ADD COLUMN countdown_scope_id TEXT
|
||||
REFERENCES event_scopes (id) ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE front_page ADD COLUMN countdown_event_type TEXT
|
||||
CHECK (countdown_event_type IN ('retreat', 'class', 'workshop', 'meeting', 'other'));
|
||||
Loading…
Add table
Add a link
Reference in a new issue