Skip to content

feat: period selector for events layer#3715

Draft
BRaimbault wants to merge 11 commits into
masterfrom
feat/period-selector-events
Draft

feat: period selector for events layer#3715
BRaimbault wants to merge 11 commits into
masterfrom
feat/period-selector-events

Conversation

@BRaimbault

@BRaimbault BRaimbault commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Description

Brings the Events layer dialog's Period tab in line with the Thematic layer dialog (Stage 1 of 2 — Timeline/Split view will be Stage 2):

  1. Multi-select periods, or start/end dates — the Period tab now lets you choose "Choose from presets" (select one or more fixed/relative periods, combined into one query) or "Define start-end dates", replacing the old single-period dropdown. Existing saved Event layers keep working unchanged.
  2. Shared with Thematic — the period tab's initialization, validation, and request-building logic is now shared between the Events and Thematic dialogs instead of being duplicated, so both stay in sync going forward.
  3. Cleanup — removes the old single-period selector and related code now that Events uses the same multi-period model as Thematic.

Quality checklist

Add N/A to items that are not applicable.

  • Dashboard tested
  • Cypress and/or Jest tests added/updated
  • Docs added
  • d2-ci dependencies replaced N/A
  • Tester approved (name)

Screenshots

  • Relative and Fixed periods: Before/After
    image

  • Start and End dates: Before/After
    image

BRaimbault and others added 5 commits July 7, 2026 10:54
Moves initializePeriodType/getDefaultPeriods/initializePeriods out of
initializeThematicLayer.js into components/edit/shared/initializePeriod.js
so the Events dialog can reuse them for its own period tab, without
duplicating logic. Pure extraction, no behavior change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replace the Events layer dialog's single-period RelativePeriodSelect
dropdown with the same Single-mode period tab as the Thematic dialog:
a SegmentedControl toggle between multi-select preset periods
(PeriodDimension) and start/end dates. Adds initializeEventLayer.js,
reusing the shared period-init helpers extracted in the previous
commit, so new/existing event layers get sensible period defaults.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Moves the period-tab validation rules (period type, start/end dates,
Timeline/Split min-max) out of validateThematicLayer.js into
components/edit/shared/validatePeriod.js, and reuses them in
EventDialog's own validate(), replacing its ad hoc period/date check
and adding the "Period is required" rule that multi-select presets
now need. renderingStrategy stays optional so Events (no rendering
strategy yet) simply never trigger the Timeline/Split-only rules.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Event layers can now select multiple preset periods in the Period tab,
so getAnalyticsRequest() and eventLoader's legend text need to handle
an array of periods instead of a single one. Extracts the shared
periods-or-dates request logic (already duplicated between the event
and thematic loaders) into applyPeriodFilter() in util/analytics.js,
used by both.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
setPeriod/LAYER_EDIT_PERIOD_SET, setFiltersFromPeriod,
getPeriodFromFilters and RelativePeriodSelect.jsx have no remaining
callers now that Events uses the same multi-period setPeriods/filters
flow as Thematic.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dhis2-bot

Copy link
Copy Markdown
Contributor

🚀 Deployed on https://pr-3715.maps.netlify.dhis2.org

@dhis2-bot dhis2-bot temporarily deployed to netlify July 7, 2026 11:17 Inactive
Addresses SonarCloud S7778 (avoid multiple Array#push() calls) left
over from extracting the period validation rules into a shared
module.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dhis2-bot dhis2-bot temporarily deployed to netlify July 7, 2026 12:28 Inactive
EventLayer.selectPeriodType() drove the old single-period
RelativePeriodSelect dropdown (data-test="relative-period-select-content"),
which no longer exists now that the Events dialog uses the same
SegmentedControl + PeriodDimension period tab as Thematic. Replaces it
with selectStartEndDates(), mirroring ThematicLayer's existing helper
of the same name, and updates all call sites.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dhis2-bot dhis2-bot temporarily deployed to netlify July 7, 2026 13:04 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify July 10, 2026 08:48 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify July 10, 2026 09:01 Inactive
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants