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

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0ee3fad
feat: use PeriodDimension in ThematicDialog
BRaimbault Nov 18, 2024
537c0f7
Merge branch 'master' into feat/DHIS2-15796
BRaimbault Nov 18, 2024
06d6d71
feat: support multiple periods
BRaimbault Nov 19, 2024
67ff60d
fix: PeriodDimension style
BRaimbault Nov 20, 2024
7b3545a
fix: get default relative periods labels
BRaimbault Nov 25, 2024
b2be0ed
feat: use PeriodDimension in ThematicDialog
BRaimbault Dec 2, 2024
748150e
Merge branch 'master' into feat/DHIS2-15796
BRaimbault Dec 2, 2024
c224835
Merge branch 'master' into feat/DHIS2-15796
BRaimbault Dec 3, 2024
fcda751
feat: use PeriodDimension in ThematicDialog
BRaimbault Dec 3, 2024
c1c8a4a
feat: use PeriodDimension in ThematicDialog
BRaimbault Dec 4, 2024
12159df
Merge branch 'master' into feat/DHIS2-15796
BRaimbault Dec 5, 2024
68ac83b
fix: correct RenderingStrategy periods count
BRaimbault Dec 5, 2024
a4322fb
fix: use CalendarInput in StartEndDate
BRaimbault Dec 6, 2024
b80c33c
feat: handle multiple periods in timeline
BRaimbault Dec 6, 2024
dbd09ba
feat: use PeriodDimension in ThematicDialog
BRaimbault Dec 9, 2024
245848a
fix: add sumObjectValues helper and test
BRaimbault Dec 10, 2024
e744748
fix: add getPeriodsDurationByType util and test
BRaimbault Dec 10, 2024
25d9700
fix: refactor RenderingStrategy and add test
BRaimbault Dec 10, 2024
86e6f18
fix: refactor Timeline
BRaimbault Dec 10, 2024
c6c6fcf
fix: refactor Timeline
BRaimbault Dec 11, 2024
170ac85
fix: refactor Timeline
BRaimbault Dec 11, 2024
cd32b22
Merge branch 'master' into feat/DHIS2-15796
BRaimbault Dec 11, 2024
709a8ba
chore: clean-up
BRaimbault Dec 12, 2024
2d74cb0
chore: clean-up
BRaimbault Dec 12, 2024
051a9bd
fix: update periodError handling
BRaimbault Dec 12, 2024
5d7c55d
fix: handle multiple periods in interpretations
BRaimbault Dec 13, 2024
9f4ad67
fix: avoid defaulting to period tab
BRaimbault Dec 13, 2024
07dd32f
feat: add closing buttons "x"
BRaimbault Dec 13, 2024
1487d0b
feat: additional keyboard controls
BRaimbault Dec 13, 2024
aff5044
fix: timeline not visible in Firefox
BRaimbault Dec 18, 2024
c0d7028
chore: fix cypress tests
BRaimbault Dec 20, 2024
91a69bb
chore: fix cypress tests
BRaimbault Dec 20, 2024
5b09c6e
chore: cypress update
BRaimbault Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-10-23T12:50:51.401Z\n"
"PO-Revision-Date: 2024-10-23T12:50:51.401Z\n"
"POT-Creation-Date: 2024-12-09T14:15:43.944Z\n"
"PO-Revision-Date: 2024-12-09T14:15:43.944Z\n"

msgid "2020"
msgstr "2020"
Expand Down Expand Up @@ -461,6 +461,12 @@ msgstr "High radius should be greater than low radius"
msgid "Radius should be between {{min}} and {{max}}"
msgstr "Radius should be between {{min}} and {{max}}"

msgid "Choose from presets"
msgstr "Choose from presets"

msgid "Define start - end dates"
msgstr "Define start - end dates"

msgid "Indicator group is required"
msgstr "Indicator group is required"

Expand Down Expand Up @@ -921,24 +927,33 @@ msgstr "Period type"
msgid "Start/end dates"
msgstr "Start/end dates"

msgid "Select {{number}} or more periods to enable timeline or split map views."
msgstr "Select {{number}} or more periods to enable timeline or split map views."

msgid "Only one timeline is allowed."
msgstr "Only one timeline is allowed."

msgid "Remove other layers to enable split map views."
msgstr "Remove other layers to enable split map views."

msgid "Display periods"
msgstr "Display periods"
msgid "Only up to {{number}} periods can be selected to enable split map views."
msgstr "Only up to {{number}} periods can be selected to enable split map views."

msgid "Single (aggregate)"
msgstr "Single (aggregate)"
msgid "Period display mode"
msgstr "Period display mode"

msgid "Single (combine periods)"
msgstr "Single (combine periods)"

msgid "Timeline"
msgstr "Timeline"

msgid "Split map views"
msgstr "Split map views"

msgid "Start and end dates are inclusive and will be included in the outputs."
msgstr "Start and end dates are inclusive and will be included in the outputs."

msgid "Start date"
msgstr "Start date"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"start-server-and-test": "^2.0.3"
},
"dependencies": {
"@dhis2/analytics": "^26.8.4",
"@dhis2/analytics": "git+https://github.com/d2-ci/analytics.git#8c539c2cee08357ef6c7daaab2521e3df6ef7801",
"@dhis2/app-runtime": "^3.11.2",
"@dhis2/app-runtime-adapter-d2": "^1.1.0",
"@dhis2/app-service-datastore": "^1.0.0-beta.3",
Expand Down
6 changes: 6 additions & 0 deletions src/actions/layerEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ export const setPeriodType = (periodType, keepPeriod) => ({
keepPeriod,
})

// Set periods (thematic)
export const setPeriods = (periods) => ({
type: types.LAYER_EDIT_PERIODS_SET,
periods,
})

// Set period (event & thematic)
export const setPeriod = (period) => ({
type: types.LAYER_EDIT_PERIOD_SET,
Expand Down
16 changes: 15 additions & 1 deletion src/components/core/RadioGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const RadioGroup = ({
helpText,
display,
onChange,
boldLabel,
compact,
children,
dataTest,
}) => {
Expand All @@ -28,10 +30,20 @@ const RadioGroup = ({
<div
className={cx(styles.radioGroup, {
[styles.row]: display === 'row',
[styles.compact]: compact,
})}
>
<FieldGroup
label={label}
label={
<span
className={cx({
[styles.boldLabel]: boldLabel,
[styles.compact]: compact,
})}
>
{label}
</span>
}
helpText={helpText}
dataTest={dataTest}
>
Expand All @@ -44,7 +56,9 @@ const RadioGroup = ({

RadioGroup.propTypes = {
onChange: PropTypes.func.isRequired,
boldLabel: PropTypes.bool,
children: PropTypes.arrayOf(PropTypes.node),
compact: PropTypes.bool,
dataTest: PropTypes.string,
display: PropTypes.string,
helpText: PropTypes.string,
Expand Down
8 changes: 8 additions & 0 deletions src/components/core/styles/RadioGroup.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
height: 36px;
}

.radioGroup.compact fieldset>div>div>label {
height: 20px;
}

.row {
margin: var(--spacers-dp8) 0;
}
Expand All @@ -21,3 +25,7 @@
.row fieldset > div > div > label {
margin-right: var(--spacers-dp16);
}

.boldLabel {
font-weight: bold;
}
3 changes: 3 additions & 0 deletions src/components/datatable/BottomPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
LAYERS_PANEL_WIDTH,
RIGHT_PANEL_WIDTH,
} from '../../constants/layout.js'
import useKeyDown from '../../hooks/useKeyDown.js'
import { useWindowDimensions } from '../WindowDimensionsProvider.js'
import DataTable from './DataTable.js'
import ErrorBoundary from './ErrorBoundary.js'
Expand Down Expand Up @@ -37,6 +38,8 @@ const BottomPanel = () => {
const tableWidth = width - layersWidth - rightPanelWidth
const dataTableControlsHeight = 20

useKeyDown('Escape', () => dispatch(closeDataTable()), true)

return (
<div
ref={panelRef}
Expand Down
2 changes: 1 addition & 1 deletion src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const Table = ({ availableHeight, availableWidth }) => {
})

useEffect(() => {
/* The combination of automtic table layout and virtual scrolling
/* The combination of automatic table layout and virtual scrolling
* causes a content shift when scrolling and filtering because the
* cells in the DOM have a different content length which causes the
* columns to have a different width. To avoid that we measure the
Expand Down
3 changes: 3 additions & 0 deletions src/components/download/DownloadSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Button, ButtonStrip } from '@dhis2/ui'
import React, { useState, useMemo, useCallback, useEffect } from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { setDownloadConfig } from '../../actions/download.js'
import useKeyDown from '../../hooks/useKeyDown.js'
import { standardizeFilename } from '../../util/dataDownload.js'
import { downloadMapImage, downloadSupport } from '../../util/export-image.js'
import { getSplitViewLayer } from '../../util/helpers.js'
Expand Down Expand Up @@ -105,6 +106,8 @@ const DownloadSettings = () => {
}
}, [isPushAnalytics])

useKeyDown('Escape', closeDownloadMode)

const isSupported = downloadSupport() && !error
const isSplitView = !!getSplitViewLayer(mapViews)
const showMarginsCheckbox = false // Not in use
Expand Down
11 changes: 10 additions & 1 deletion src/components/edit/LayerEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import React, { useState } from 'react'
import { connect } from 'react-redux'
import { addLayer, updateLayer, cancelLayer } from '../../actions/layers.js'
import { EARTH_ENGINE_LAYER } from '../../constants/layers.js'
import useKeyDown from '../../hooks/useKeyDown.js'
import { useOrgUnits } from '../OrgUnitsProvider.js'
import EarthEngineDialog from './earthEngine/EarthEngineDialog.js'
import EventDialog from './event/EventDialog.js'
Expand Down Expand Up @@ -72,6 +73,9 @@ const LayerEdit = ({ layer, addLayer, updateLayer, cancelLayer }) => {
}
}

useKeyDown('Escape', cancelLayer)
useKeyDown('Enter', onValidateLayer)

if (!layer) {
return null
}
Expand All @@ -94,7 +98,12 @@ const LayerEdit = ({ layer, addLayer, updateLayer, cancelLayer }) => {
: i18n.t('Add new {{name}} layer', { name })

return (
<Modal position="middle" dataTest="layeredit">
<Modal
position="middle"
dataTest="layeredit"
large
onClose={cancelLayer}
>
<ModalTitle>{title}</ModalTitle>
<ModalContent>
<div className={styles.content}>
Expand Down
55 changes: 40 additions & 15 deletions src/components/edit/event/EventDialog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import i18n from '@dhis2/d2-i18n'
import { NoticeBox } from '@dhis2/ui'
import { NoticeBox, IconErrorFilled24 } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import { connect } from 'react-redux'
Expand All @@ -18,8 +18,6 @@ import {
setOrgUnits,
} from '../../../actions/layerEdit.js'
import {
DEFAULT_START_DATE,
DEFAULT_END_DATE,
EVENT_COLOR,
EVENT_RADIUS,
EVENT_BUFFER,
Expand Down Expand Up @@ -47,7 +45,7 @@ import FilterGroup from '../../dataItem/filter/FilterGroup.js'
import StyleByDataItem from '../../dataItem/StyleByDataItem.js'
import OrgUnitSelect from '../../orgunits/OrgUnitSelect.js'
import RelativePeriodSelect from '../../periods/RelativePeriodSelect.js'
import StartEndDates from '../../periods/StartEndDates.js'
import StartEndDate from '../../periods/StartEndDate.js'
import ProgramSelect from '../../program/ProgramSelect.js'
import ProgramStageSelect from '../../program/ProgramStageSelect.js'
import BufferRadius from '../shared/BufferRadius.js'
Expand Down Expand Up @@ -82,6 +80,7 @@ class EventDialog extends Component {
legendSet: PropTypes.object,
method: PropTypes.number,
orgUnits: PropTypes.object,
periodsSettings: PropTypes.object,
program: PropTypes.shape({
id: PropTypes.string.isRequired,
trackedEntityType: PropTypes.object,
Expand Down Expand Up @@ -116,29 +115,25 @@ class EventDialog extends Component {
endDate,
orgUnits,
setPeriod,
setStartDate,
setEndDate,
setOrgUnits,
} = this.props

const period = getPeriodFromFilters(filters)
const { keyAnalysisRelativePeriod: defaultPeriod, hiddenPeriods } =
systemSettings

const hasDate = startDate !== undefined && endDate !== undefined

// Set default period from system settings
if (
!period &&
!startDate &&
!endDate &&
!hasDate &&
defaultPeriod &&
isPeriodAvailable(defaultPeriod, hiddenPeriods)
) {
setPeriod({
id: defaultPeriod,
})
} else if (!startDate && !endDate) {
setStartDate(DEFAULT_START_DATE)
setEndDate(DEFAULT_END_DATE)
}

// Set org unit tree roots as default
Expand All @@ -151,18 +146,38 @@ class EventDialog extends Component {
}

componentDidUpdate(prev) {
const { validateLayer, onLayerValidation } = this.props
const {
validateLayer,
onLayerValidation,
filters,
startDate,
endDate,
setStartDate,
setEndDate,
} = this.props
const { periodError } = this.state

if (validateLayer && validateLayer !== prev.validateLayer) {
onLayerValidation(this.validate())
}

const hasDate = startDate !== undefined || endDate !== undefined
if (hasDate && getPeriodFromFilters(filters) !== undefined) {
setStartDate()
setEndDate()
this.setErrorState('periodError', null, 'period')
} else if (
periodError &&
(startDate !== prev.startDate || endDate !== prev.endDate)
) {
this.setErrorState('periodError', null, 'period')
}
}

render() {
const {
// layer options
columns = [],
endDate,
eventClustering,
eventStatus,
eventCoordinateField,
Expand All @@ -173,7 +188,9 @@ class EventDialog extends Component {
program,
programStage,
startDate,
endDate,
legendSet,
periodsSettings,
} = this.props

const {
Expand Down Expand Up @@ -272,12 +289,20 @@ class EventDialog extends Component {
className={styles.select}
/>
{period && period.id === START_END_DATES && (
<StartEndDates
<StartEndDate
startDate={startDate}
endDate={endDate}
errorText={periodError}
setStartDate={setStartDate}
setEndDate={setEndDate}
periodsSettings={periodsSettings}
/>
)}
{periodError && (
<div key="error" className={styles.error}>
<IconErrorFilled24 />
{periodError}
</div>
)}
</div>
)}
{tab === 'orgunits' && (
Expand Down
12 changes: 12 additions & 0 deletions src/components/edit/styles/LayerDialog.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
.error {
margin-top: var(--spacers-dp8);
color: var(--theme-error);
font-size: 12px;
display: flex;
align-items: center;
line-height: 1;
gap: 8px;
}

.indent {
Expand Down Expand Up @@ -109,6 +114,13 @@
margin: 8px 0 0 -8px;
}

/* Thematic */

.navigation {
flex-grow: 0;
margin-bottom: 8px;
}

/* Tracked entity */

.teiCheckbox {
Expand Down
Loading
Loading