Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use PeriodDimension in ThematicDialog #3407

Open
wants to merge 47 commits into
base: master
Choose a base branch
from

Conversation

BRaimbault
Copy link
Collaborator

@BRaimbault BRaimbault commented Nov 18, 2024

Implement: DHIS2-15796
Linked @dhis2/analytics PR: dhis2/analytics#1735


Overview

Main changes are:

  1. Support of multiple periods selection
  2. Use new PeriodDimension period selector (transfer-style) for preset periods (in thematic dialog)
  3. Use new StartEndDate for start-end dates periods (in thematic, events and tracked entity dialogs)
  4. Update of RenderingStrategy that controls the use of single map / timeline / split-map (in thematic dialog)
  5. Use new SegmentedControl to switch between preset periods and start-end dates (in thematic dialog)
  6. Refactoring of Timeline component to support multiple periods and from class to functional component (for thematic layers)

Also improved keyboard navigation is introduced. The original object was to only to enable typing dates properly. In the end a number of files are modified to introduce consistency. Reviewing them should be quick so it might be a good idea to start here. A few other quality of life improvements included as well. All these changes are listed at the end.

1. Multiple periods selection

filename comments specific jest test specific cypress test
src/components/edit/thematic/ThematicDialog.js Update tests from !period to periods?.length === 0. Use new getPeriodsFromFilters utility function form util/analytics.js. Use new getRelativePeriodsName from @dhis2/analytics to have name for defaultPeriod. No Yes
src/constants/actionTypes.js Support LAYER_EDIT_PERIODS_SET. No No
src/loaders/thematicLoader.js Use getPeriodsFromFilters from utils/analytics.js in legend and analyticsRequest. No No
src/reducers/layerEdit.js Update LAYER_EDIT_PERIOD_SET. Support LAYER_EDIT_PERIODS_SET (new period selector). No No
src/components/interpretations/InterpretationMap.js Use new getPeriodsFromFilters utility function form util/analytics.js. Update test to detect if at least one relative period is present. No No
src/util/analytics.js New utility functions: getPeriodsFromFilters and setFiltersFromPeriods. Yes No

2. PeriodDimension

image

The new period selector used is PeriodDimension (transfer-style) is defined in @dhis2/analytics.

filename comments specific jest test specific cypress test
src/components/edit/thematic/ThematicDialog.js Use new PeriodDimension component. No Yes
src/components/edit/LayerEdit.js Switching to large modal. No No

3. StartEndDate

image

We updated and rename StartEndDates to StartEndDate to align with the Linelisting app but with an updated date picker CalendarInput from @dhis2/ui which supports multiple calendars.

EventDialog and TrackedEntityDialog are also updated to use StartEndDate.

filename comments specific jest test specific cypress test
src/components/periods/StartEndDate.js Use new CalendarInput from @dhis2/ui which support non-gregorian calendars. Correction on typing. Yes Yes
src/util/date.js StartEndDate keyboard input validation. Yes No
src/components/edit/thematic/ThematicDialog.js Use new StartEndDate component. Handle switching between period types (resets startDate endDate). Add periodError rendering div and hide periodError when period is being modified. No Yes
src/components/edit/event/EventDialog.js Use new StartEndDate component. Handle switching between period types (resets startDate endDate). Add periodError rendering div and hide periodError when period is being modified. No Yes
src/components/edit/trackedEntity/TrackedEntityDialog.js Use new StartEndDate component. Add periodError rendering div and hide periodError when period is being modified. No Yes

4. RenderingStrategy

image

We updated the logic to account for multiple periods selection.

filename comments specific jest test specific cypress test
src/components/edit/thematic/ThematicDialog.js Use updated RenderingStrategy. No Yes
src/components/periods/RenderingStrategy.js Control that selected period presets are compatible with rendering types. Yes Yes
src/components/core/RadioGroup.js Additional styling options: boldLabel and compact. Yes No
src/util/periods.js Utility functions for periods counting in RenderingStrategy. Yes No
src/util/helpers.js New sumObjectValues helper that sum all numbers in an object recursively. Yes No

5. SegmentedControl

image

filename comments specific jest test specific cypress test
src/components/edit/thematic/ThematicDialog.js Use new SegmentedControl. Handle switching between period types (resets periods/ startDate endDate). No Yes
src/components/edit/trackedEntity/PeriodTypeSelect.js Update to use updated setPeriodType action and be compatible with SegmentedControl used in ThematicDialog. No No

6. Timeline

image

filename comments specific jest test specific cypress test
src/components/periods/Timeline.js Support multiple periods. Display period types on separate y axes, periods of shortest duration are the closest to the x axis. Play by period startDate, if multiple, start with the period type with the longest duration. Refactor to functional component. Use new utility functions form util/periods.js. Resize component properly. Yes Yes
src/util/periods.js Utility functions for periods sorting, combined periods duration evaluation and checking last period in Timeline. Yes No
src/components/map/layers/ThematicLayer.js Select correct first period for Timeline. No Yes

Smaller quality of life improvements are included:

Keyboard navigation

filename comments
src/hooks/useKeyDown.js Support keyboard interactions short and long press.
src/components/periods/StartEndDate.js Proper support of 'Tab' navigation.
src/components/edit/LayerEdit.js Press "Enter" to save changes and close component. Press "Esc" to discard changes and close component.
src/components/map/Popup.js Press "Esc" to close component.
src/components/layers/overlays/AddLayerPopover.js Press "Esc" to close component.
src/components/layerSources/ManageLayerSourcesModal.js Press "Esc" to close component.
src/components/download/DownloadSettings.js Press "Esc" to close component.
src/components/orgunits/OrgUnitProfile.js Long press "Esc" to close component.
src/components/interpretations/InterpretationsToggle.js Long press "Esc" to close component.
src/components/datatable/BottomPanel.js Long press "Esc" to close component.

Added "x" close modal buttons:

filename comments
src/components/edit/LayerEdit.js "x" button to close component.
src/components/layerSources/ManageLayerSourcesModal.js "x" button to close component.

Small bug fixes

filename comments
src/components/layers/overlays/styles/AddLayerButton.module.css Remove outline.
src/components/map/layers/EventPopup.js "Not set" text should be displayed also for data item with option sets.
src/components/map/layers/TrackedEntityPopup.js "Not set" text should be displayed also for data item with option sets.
src/util/time.js Empty date should not be considered a valid date format.

Checklist:

  • Jest tests added
  • Cypress tests added
  • Manual testing complete
  • Dashboard tested
  • Update @dhis2/analytics dependency (to not point to d2-ci)

@dhis2-bot
Copy link
Contributor

dhis2-bot commented Nov 18, 2024

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

@dhis2-bot dhis2-bot temporarily deployed to netlify November 18, 2024 16:58 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify November 25, 2024 15:58 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 2, 2024 16:05 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 3, 2024 08:49 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 3, 2024 14:40 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 4, 2024 14:58 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 5, 2024 12:36 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 5, 2024 16:04 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 6, 2024 10:42 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 6, 2024 17:04 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 9, 2024 17:54 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 23, 2024 10:11 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 23, 2024 10:38 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 23, 2024 12:54 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 24, 2024 11:49 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 24, 2024 12:26 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 27, 2024 16:42 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 27, 2024 17:00 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 27, 2024 19:10 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 27, 2024 20:04 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 27, 2024 21:23 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify December 27, 2024 23:59 Inactive
@BRaimbault BRaimbault marked this pull request as ready for review December 28, 2024 01:29
@@ -10,6 +10,10 @@
height: 36px;
}

.radioGroup.compact fieldset>div>div>label {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use the same spacing as is on line 25?

/>
)}
{periodError && (
<div key="error" className={styles.error}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of the key attribute?

display: flex;
align-items: center;
line-height: 1;
gap: 8px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use spacers-dp8

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.

3 participants