Group pages: framed facts, tags for organizations and events, every website and email (migration 070)

- Email buttons went to the link's label, not its URL (splitLinks took
  the label); they use the URL now, with or without mailto:.
- Every website and email row is listed, each with its own label,
  instead of only the first.
- The facts at the top of an organization page sit in a framed card:
  City, Part of <name> Region, Ministry, Meets, Since, and its tags.
- Tags (070): Data -> Tags (Online, In-Person to start) replace the
  Online checkbox on organizations and events. Ticked records get the
  Online tag; v_events reads the "online" tag as is_online, so the
  calendar filter and place lines are unchanged. Tags show on the
  record's page and on group entries in the Community map list and
  grid. The map no longer keeps online groups off their state's tile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-06 04:58:56 -05:00
parent 07c15ce96d
commit b55b088e16
23 changed files with 344 additions and 93 deletions

View file

@ -0,0 +1,84 @@
-- ═══════════════════════════════════════════════════════════════
-- 070 TAGS
--
-- Descriptor tags for organizations and events (Data → Tags), in
-- place of the Online checkbox: Online and In-Person to start, more
-- as they're needed. A record's tags show on its page and, for
-- groups, on the Community map's list and grid.
--
-- The tag with URL ID "online" still means online to the site:
-- v_events turns it back into is_online, which the calendar's
-- online filter, the "Online" place line and an event's search data
-- read. Records ticked Online get the tag; nothing gets In-Person
-- automatically.
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE tags (
id TEXT PRIMARY KEY
CONSTRAINT "A tag's URL ID can use only lowercase letters, numbers and hyphens, eg. in-person."
CHECK (id <> '' AND id NOT GLOB '*[^a-z0-9-]*'),
name TEXT NOT NULL, -- 'In-Person', as shown
sort_order INTEGER NOT NULL DEFAULT 0
) STRICT;
INSERT INTO tags (id, name, sort_order) VALUES
('online', 'Online', 0),
('in-person', 'In-Person', 1);
CREATE TABLE organization_tags (
org_id TEXT NOT NULL REFERENCES organizations (id) ON DELETE CASCADE,
tag_id TEXT NOT NULL REFERENCES tags (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (org_id, tag_id)
) STRICT;
CREATE INDEX organization_tags_tag_idx ON organization_tags (tag_id);
CREATE TABLE event_tags (
event_id TEXT NOT NULL REFERENCES events (id) ON DELETE CASCADE,
tag_id TEXT NOT NULL REFERENCES tags (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (event_id, tag_id)
) STRICT;
CREATE INDEX event_tags_tag_idx ON event_tags (tag_id);
INSERT INTO organization_tags (org_id, tag_id) SELECT id, 'online' FROM organizations WHERE is_online = 1;
INSERT INTO event_tags (event_id, tag_id) SELECT id, 'online' FROM events WHERE is_online = 1;
-- v_events reads e.*, so it goes while the column does and comes
-- back with is_online from the tag.
DROP VIEW v_events;
ALTER TABLE organizations DROP COLUMN is_online;
ALTER TABLE events DROP COLUMN is_online;
CREATE VIEW v_events AS
SELECT
e.*,
EXISTS (SELECT 1 FROM event_tags et WHERE et.event_id = e.id AND et.tag_id = 'online')
AS is_online,
CASE WHEN eh.id IS NULL THEN NULL
WHEN eh.person_id IS NULL THEN 'organization' ELSE 'person' END
AS host_kind,
COALESCE(eh.org_id, eh.person_id) AS host_id,
COALESCE(o.name, p.display_name) AS host_name,
o.kind AS host_org_kind,
COALESCE(e.org_logo, o.logo) AS effective_org_logo,
COALESCE(e.color, o.color) AS effective_color,
COALESCE(
e.status,
CASE WHEN e.ends_on IS NOT NULL AND e.ends_on < date('now')
THEN 'past' ELSE 'upcoming' END
) AS effective_status
FROM events e
LEFT JOIN event_hosts eh
ON eh.id = (
SELECT x.id
FROM event_hosts x
LEFT JOIN organizations xo ON xo.id = x.org_id
LEFT JOIN people xp ON xp.id = x.person_id
WHERE x.event_id = e.id
AND COALESCE(xo.is_published, xp.is_published) = 1
ORDER BY x.sort_order, x.id
LIMIT 1
)
LEFT JOIN organizations o ON o.id = eh.org_id
LEFT JOIN people p ON p.id = eh.person_id;