diff --git a/i18n/en.pot b/i18n/en.pot index 84bcab976..3a5e2610e 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -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-12-05T11:28:26.227Z\n" -"PO-Revision-Date: 2024-12-05T11:28:26.227Z\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" @@ -927,11 +927,8 @@ msgstr "Period type" msgid "Start/end dates" msgstr "Start/end dates" -msgid "Select " -msgstr "Select " - -msgid " or more periods to enable timeline or split map views." -msgstr " or more periods to enable timeline or split map views." +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." @@ -939,11 +936,8 @@ 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 "Only up to " -msgstr "Only up to " - -msgid " periods can be selected to enable timeline or split map views." -msgstr " periods can be selected to enable timeline or split map views." +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 "Period display mode" msgstr "Period display mode" diff --git a/src/components/core/RadioGroup.js b/src/components/core/RadioGroup.js index 2784c4052..e16600e6f 100644 --- a/src/components/core/RadioGroup.js +++ b/src/components/core/RadioGroup.js @@ -56,11 +56,11 @@ 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, - boldLabel: PropTypes.bool, - compact: PropTypes.bool, helpText: PropTypes.string, label: PropTypes.string, value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), diff --git a/src/components/download/DownloadSettings.js b/src/components/download/DownloadSettings.js index 9a137cabc..de6567b61 100644 --- a/src/components/download/DownloadSettings.js +++ b/src/components/download/DownloadSettings.js @@ -2,8 +2,8 @@ import i18n from '@dhis2/d2-i18n' import { Button, ButtonStrip } from '@dhis2/ui' import React, { useState, useMemo, useCallback, useEffect } from 'react' import { useSelector, useDispatch } from 'react-redux' -import useKeyDown from '../../hooks/useKeyDown.js' 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' diff --git a/src/components/edit/LayerEdit.js b/src/components/edit/LayerEdit.js index e260d855a..6002491d5 100644 --- a/src/components/edit/LayerEdit.js +++ b/src/components/edit/LayerEdit.js @@ -9,12 +9,12 @@ import { ButtonStrip, } from '@dhis2/ui' import PropTypes from 'prop-types' -import React, { useState, useEffect } from 'react' +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 { useOrgUnits } from '../OrgUnitsProvider.js' import useKeyDown from '../../hooks/useKeyDown.js' +import { useOrgUnits } from '../OrgUnitsProvider.js' import EarthEngineDialog from './earthEngine/EarthEngineDialog.js' import EventDialog from './event/EventDialog.js' import FacilityDialog from './FacilityDialog.js' diff --git a/src/components/edit/event/EventDialog.js b/src/components/edit/event/EventDialog.js index 647dcee3a..41288a306 100644 --- a/src/components/edit/event/EventDialog.js +++ b/src/components/edit/event/EventDialog.js @@ -47,7 +47,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' @@ -82,6 +82,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, @@ -174,6 +175,7 @@ class EventDialog extends Component { programStage, startDate, legendSet, + periodsSettings, } = this.props const { @@ -272,10 +274,13 @@ class EventDialog extends Component { className={styles.select} /> {period && period.id === START_END_DATES && ( - )} diff --git a/src/components/edit/thematic/ThematicDialog.js b/src/components/edit/thematic/ThematicDialog.js index a40b79629..53e7ac768 100644 --- a/src/components/edit/thematic/ThematicDialog.js +++ b/src/components/edit/thematic/ThematicDialog.js @@ -29,7 +29,6 @@ import { RENDERING_STRATEGY_SINGLE, } from '../../../constants/layers.js' import { - RELATIVE_PERIODS, PREDEFINED_PERIODS, START_END_DATES, } from '../../../constants/periods.js' @@ -55,6 +54,7 @@ import IndicatorGroupSelect from '../../indicator/IndicatorGroupSelect.js' import IndicatorSelect from '../../indicator/IndicatorSelect.js' import OrgUnitSelect from '../../orgunits/OrgUnitSelect.js' import RenderingStrategy from '../../periods/RenderingStrategy.js' +import StartEndDate from '../../periods/StartEndDate.js' import ProgramIndicatorSelect from '../../program/ProgramIndicatorSelect.js' import ProgramSelect from '../../program/ProgramSelect.js' import Labels from '../shared/Labels.js' @@ -65,13 +65,13 @@ import NoDataColor from './NoDataColor.js' import RadiusSelect, { isValidRadius } from './RadiusSelect.js' import ThematicMapTypeSelect from './ThematicMapTypeSelect.js' import ValueTypeSelect from './ValueTypeSelect.js' -import StartEndDate from '../../periods/StartEndDate.js' class ThematicDialog extends Component { static propTypes = { setClassification: PropTypes.func.isRequired, setDataElementGroup: PropTypes.func.isRequired, setDataItem: PropTypes.func.isRequired, + setEndDate: PropTypes.func.isRequired, setIndicatorGroup: PropTypes.func.isRequired, setLegendSet: PropTypes.func.isRequired, setNoDataColor: PropTypes.func.isRequired, @@ -81,6 +81,7 @@ class ThematicDialog extends Component { setPeriods: PropTypes.func.isRequired, setProgram: PropTypes.func.isRequired, setRenderingStrategy: PropTypes.func.isRequired, + setStartDate: PropTypes.func.isRequired, setValueType: PropTypes.func.isRequired, validateLayer: PropTypes.bool.isRequired, onLayerValidation: PropTypes.func.isRequired, @@ -128,20 +129,8 @@ class ThematicDialog extends Component { setOrgUnits, } = this.props - console.log( - '🚀 ~ componentDidMount ~ periodType:', - this.props.periodType - ) - console.log('🚀 ~ componentDidMount ~ filters:', this.props.filters) - console.log('🚀 ~ componentDidMount ~ startDate:', startDate) - console.log('🚀 ~ componentDidMount ~ endDate:', endDate) - const dataItem = getDataItemFromColumns(columns) const periods = getPeriodsFromFilters(filters) - console.log( - '🚀 ~ ThematicDialog ~ componentDidMount ~ periods:', - periods - ) const { keyAnalysisRelativePeriod: defaultPeriod, hiddenPeriods } = systemSettings @@ -167,21 +156,11 @@ class ThematicDialog extends Component { startDate !== '' && endDate !== undefined && endDate !== '' - console.log( - '🚀 ~ ThematicDialog ~ componentDidMount ~ hasDate:', - hasDate - ) if (hasDate) { - console.log( - '🚀 ~ componentDidMount ~ setPeriodType HERE (START_END_DATES)' - ) const keepPeriod = false setPeriodType({ value: START_END_DATES }, keepPeriod) } else { - console.log( - '🚀 ~ componentDidMount ~ setPeriodType HERE (PREDEFINED_PERIODS)' - ) const keepPeriod = true setPeriodType({ value: PREDEFINED_PERIODS }, keepPeriod) } @@ -193,8 +172,6 @@ class ThematicDialog extends Component { defaultPeriod && isPeriodAvailable(defaultPeriod, hiddenPeriods) ) { - console.log('🚀 ~ componentDidMount ~ setPeriods HERE') - console.log('getRelativePeriodsName()', getRelativePeriodsName()) const defaultPeriods = [ { id: defaultPeriod, @@ -267,9 +244,6 @@ class ThematicDialog extends Component { // !TODO Backup Start-End dates // Remove Start-End dates // !TODO Restore Predefined periods backup - console.log( - '🚀 ~ ThematicDialog ~ componentDidUpdate ~ case PREDEFINED_PERIODS' - ) setStartDate('') setEndDate('') break @@ -277,9 +251,6 @@ class ThematicDialog extends Component { // !TODO Backup Predefined periods // Remove Predefined periods // !TODO Restore Start-End dates backup - console.log( - '🚀 ~ ThematicDialog ~ componentDidUpdate ~ case START_END_DATES' - ) setPeriods([]) break } @@ -338,11 +309,6 @@ class ThematicDialog extends Component { legendSetError, } = this.state - console.log('🚀 ~ render ~ periodType:', periodType) - console.log('🚀 ~ render ~ filters:', filters) - console.log('🚀 ~ render ~ startDate:', startDate) - console.log('🚀 ~ render ~ endDate:', endDate) - const periods = getPeriodsFromFilters(filters) const dataItem = getDataItemFromColumns(columns) @@ -726,18 +692,7 @@ class ThematicDialog extends Component { 'period' ) } else if (periodType === START_END_DATES) { - console.log( - '🚀 ~ ThematicDialog ~ validate ~ periodType:', - periodType - ) const error = getStartEndDateError(startDate, endDate) - console.log( - '🚀 ~ ThematicDialog ~ validate ~ startDate:', - startDate - ) - console.log('🚀 ~ ThematicDialog ~ validate ~ endDate:', endDate) - console.log('🚀 ~ ThematicDialog ~ validate ~ error:', error) - if (error) { return this.setErrorState('periodError', error, 'period') } diff --git a/src/components/edit/trackedEntity/PeriodTypeSelect.js b/src/components/edit/trackedEntity/PeriodTypeSelect.js index 937c48427..b7751d420 100644 --- a/src/components/edit/trackedEntity/PeriodTypeSelect.js +++ b/src/components/edit/trackedEntity/PeriodTypeSelect.js @@ -19,7 +19,7 @@ const PeriodTypeSelect = ({ setPeriodType({ id: type })} + onChange={(type) => setPeriodType({ value: type })} > - )} diff --git a/src/components/layerSources/ManageLayerSourcesModal.js b/src/components/layerSources/ManageLayerSourcesModal.js index d9e26337d..c382a1f29 100644 --- a/src/components/layerSources/ManageLayerSourcesModal.js +++ b/src/components/layerSources/ManageLayerSourcesModal.js @@ -10,8 +10,8 @@ import { import PropTypes from 'prop-types' import React from 'react' import earthEngineLayers from '../../constants/earthEngineLayers/index.js' -import useManagedLayerSourcesStore from '../../hooks/useManagedLayerSourcesStore.js' import useKeyDown from '../../hooks/useKeyDown.js' +import useManagedLayerSourcesStore from '../../hooks/useManagedLayerSourcesStore.js' import LayerSource from './LayerSource.js' import styles from './styles/ManageLayerSourcesModal.module.css' diff --git a/src/components/layers/overlays/AddLayerPopover.js b/src/components/layers/overlays/AddLayerPopover.js index 13db783fd..41cbeaf23 100644 --- a/src/components/layers/overlays/AddLayerPopover.js +++ b/src/components/layers/overlays/AddLayerPopover.js @@ -6,8 +6,8 @@ import { useSelector, useDispatch } from 'react-redux' import { addLayer, editLayer } from '../../../actions/layers.js' import earthEngineLayers from '../../../constants/earthEngineLayers/index.js' import { EXTERNAL_LAYER } from '../../../constants/layers.js' -import useManagedLayerSourcesStore from '../../../hooks/useManagedLayerSourcesStore.js' import useKeyDown from '../../../hooks/useKeyDown.js' +import useManagedLayerSourcesStore from '../../../hooks/useManagedLayerSourcesStore.js' import { isSplitViewMap } from '../../../util/helpers.js' import ManageLayerSourcesButton from '../../layerSources/ManageLayerSourcesButton.js' import LayerList from './LayerList.js' diff --git a/src/components/map/Map.js b/src/components/map/Map.js index b4cccb301..c999fd46e 100644 --- a/src/components/map/Map.js +++ b/src/components/map/Map.js @@ -121,7 +121,6 @@ class Map extends Component { componentDidUpdate(prevProps) { const { resizeCount, isFullscreen, isPlugin } = this.props - console.log('🚀 ~ Map ~ componentDidUpdate ~ resizeCount:', resizeCount) if (resizeCount !== prevProps.resizeCount) { this.map.resize() diff --git a/src/components/map/layers/EventPopup.js b/src/components/map/layers/EventPopup.js index 0bf677511..58ab1cb57 100644 --- a/src/components/map/layers/EventPopup.js +++ b/src/components/map/layers/EventPopup.js @@ -9,7 +9,6 @@ import Popup from '../Popup.js' // Returns true if value is not undefined or null; const hasValue = (value) => value !== undefined && value !== null - const EVENTS_QUERY = { events: { resource: 'tracker/events', @@ -40,10 +39,10 @@ const getDataRows = ({ displayElements, dataValues, styleDataItem, value }) => { if (valueType === 'COORDINATE' && value) { formattedValue = formatCoordinate(value) - } else if (options) { - formattedValue = options[value] } else if (!hasValue(value)) { formattedValue = i18n.t('Not set') + } else if (options) { + formattedValue = options[value] } dataRows.push( diff --git a/src/components/map/layers/ThematicLayer.js b/src/components/map/layers/ThematicLayer.js index e5de1eda6..d25d2d678 100644 --- a/src/components/map/layers/ThematicLayer.js +++ b/src/components/map/layers/ThematicLayer.js @@ -140,8 +140,6 @@ class ThematicLayer extends Layer { periods, renderingStrategy = RENDERING_STRATEGY_SINGLE, } = this.props - console.log('🚀 ~ ThematicLayer ~ setPeriod ~ periods:', periods) - console.log('🚀 ~ ThematicLayer ~ setPeriod ~ period:', period) if (!period && !periods) { return diff --git a/src/components/map/layers/TrackedEntityPopup.js b/src/components/map/layers/TrackedEntityPopup.js index f427b8948..ff34195b7 100644 --- a/src/components/map/layers/TrackedEntityPopup.js +++ b/src/components/map/layers/TrackedEntityPopup.js @@ -30,10 +30,10 @@ const getDataRows = ({ displayAttributes, attributes }) => { if (valueType === 'COORDINATE' && value) { formattedValue = formatCoordinate(value) - } else if (options) { - formattedValue = options[value] } else if (!hasValue(value)) { formattedValue = i18n.t('Not set') + } else if (options) { + formattedValue = options[value] } dataRows.push( diff --git a/src/components/periods/PeriodTypeSelect.js b/src/components/periods/PeriodTypeSelect.js index 815ee5c63..2122545b6 100644 --- a/src/components/periods/PeriodTypeSelect.js +++ b/src/components/periods/PeriodTypeSelect.js @@ -31,11 +31,6 @@ const PeriodTypeSelect = ({ ) if (!period || isRelativePeriod) { - console.log( - '🚀 ~ useEffect ~ isRelativePeriod:', - isRelativePeriod - ) - console.log('🚀 ~ useEffect ~ periodTypes[0]:', periodTypes[0]) // default to first period type onChange(periodTypes[0], isRelativePeriod) } diff --git a/src/components/periods/RenderingStrategy.js b/src/components/periods/RenderingStrategy.js index ba38ec722..f8aa0b2ab 100644 --- a/src/components/periods/RenderingStrategy.js +++ b/src/components/periods/RenderingStrategy.js @@ -1,3 +1,4 @@ +import { getRelativePeriodsDetails } from '@dhis2/analytics' import i18n from '@dhis2/d2-i18n' import PropTypes from 'prop-types' import React, { useEffect } from 'react' @@ -11,14 +12,12 @@ import { MULTIMAP_MIN_PERIODS, MULTIMAP_MAX_PERIODS, } from '../../constants/periods.js' -import { getPeriodsFromFilters } from '../../util/analytics.js' import usePrevious from '../../hooks/usePrevious.js' +import { getPeriodsFromFilters } from '../../util/analytics.js' import { Radio, RadioGroup } from '../core/index.js' -import { getRelativePeriodsDetails } from '@dhis2/analytics' const countPeriods = (periods) => { const periodsDetails = getRelativePeriodsDetails() - console.log('periodsDetails', periodsDetails) const total_v1 = periods.reduce( (sum, period) => @@ -30,7 +29,6 @@ const countPeriods = (periods) => { ) const durationByType = periods.reduce((acc, period) => { - console.log('🚀 ~ test ~ period:', period) const periodDetails = periodsDetails[period.id] if (acc['FIXED_PERIOD'] === undefined) { acc['FIXED_PERIOD'] = { @@ -68,8 +66,6 @@ const countPeriods = (periods) => { const total_v2 = sumObjectValues(durationByType) - console.log('total_v1', total_v1) - console.log('total_v2', total_v2) return total_v2 } @@ -91,9 +87,7 @@ const RenderingStrategy = ({ ) ) const hasTooManyPeriods = useSelector(({ layerEdit }) => { - console.log('layerEdit', layerEdit) const periods = getPeriodsFromFilters(layerEdit.filters) - console.log('periods', periods) return countPeriods(periods) > MULTIMAP_MAX_PERIODS }) @@ -119,11 +113,12 @@ const RenderingStrategy = ({ if (countPeriods(periods) < MULTIMAP_MIN_PERIODS) { helpText.push( - i18n.t('Select ') + - MULTIMAP_MIN_PERIODS + - i18n.t( - ' or more periods to enable timeline or split map views.' - ) + i18n.t( + 'Select {{number}} or more periods to enable timeline or split map views.', + { + number: MULTIMAP_MIN_PERIODS, + } + ) ) } if (hasOtherTimelineLayers) { @@ -134,9 +129,12 @@ const RenderingStrategy = ({ } if (hasTooManyPeriods) { helpText.push( - i18n.t('Only up to ') + - MULTIMAP_MAX_PERIODS + - i18n.t(' periods can be selected to enable split map views.') + i18n.t( + 'Only up to {{number}} periods can be selected to enable split map views.', + { + number: MULTIMAP_MAX_PERIODS, + } + ) ) } helpText = helpText.join(' ') diff --git a/src/components/periods/StartEndDate.js b/src/components/periods/StartEndDate.js index 5a324fd39..0c5a6fbf2 100644 --- a/src/components/periods/StartEndDate.js +++ b/src/components/periods/StartEndDate.js @@ -1,38 +1,27 @@ import i18n from '@dhis2/d2-i18n' -import { - Field, - IconArrowRight16, - InputField, - CalendarInput, - colors, -} from '@dhis2/ui' +import { Field, IconArrowRight16, CalendarInput, colors } from '@dhis2/ui' import PropTypes from 'prop-types' -import React, { useEffect, useState } from 'react' +import React, { useState } from 'react' import { connect } from 'react-redux' import { setStartDate, setEndDate } from '../../actions/layerEdit.js' -import { DEFAULT_START_DATE, DEFAULT_END_DATE } from '../../constants/layers.js' -import styles from './StartEndDate.module.css' +import styles from './styles/StartEndDate.module.css' const StartEndDate = (props) => { const { startDate, endDate, setStartDate, setEndDate, periodsSettings } = props - console.log('🚀 ~ StartEndDate ~ periodsSettings:', periodsSettings) + const [start, setStart] = useState(startDate.slice(0, 10)) + const [end, setEnd] = useState(endDate.slice(0, 10)) - const [start, setStart] = useState(startDate) - const [end, setEnd] = useState(endDate) - - console.log('🚀 ~ StartEndDate ~ startDate:', typeof startDate) - console.log('🚀 ~ StartEndDate ~ endDate:', typeof endDate) const hasDate = startDate !== undefined && endDate !== undefined const onStartDateChange = ({ calendarDateString: value }) => { - setStart(value) - setStartDate(value) + setStart(value.slice(0, 10)) + setStartDate(value.slice(0, 10)) } const onEndDateChange = ({ calendarDateString: value }) => { - setEnd(value) - setEndDate(value) + setEnd(value.slice(0, 10)) + setEndDate(value.slice(0, 10)) } return hasDate ? ( { ) : null } StartEndDate.propTypes = { - startDate: PropTypes.string, + setEndDate: PropTypes.func.isRequired, + setStartDate: PropTypes.func.isRequired, endDate: PropTypes.string, periodsSettings: PropTypes.object, + startDate: PropTypes.string, } export default connect(null, { setStartDate, setEndDate })(StartEndDate) diff --git a/src/components/periods/StartEndDates.js b/src/components/periods/StartEndDates.js deleted file mode 100644 index 58030c249..000000000 --- a/src/components/periods/StartEndDates.js +++ /dev/null @@ -1,60 +0,0 @@ -import i18n from '@dhis2/d2-i18n' -import PropTypes from 'prop-types' -import React, { Fragment, useEffect } from 'react' -import { connect } from 'react-redux' -import { setStartDate, setEndDate } from '../../actions/layerEdit.js' -import { DEFAULT_START_DATE, DEFAULT_END_DATE } from '../../constants/layers.js' -import { DatePicker } from '../core/index.js' -import styles from '../edit/styles/LayerDialog.module.css' - -const StartEndDates = (props) => { - const { - startDate, - endDate, - setStartDate, - setEndDate, - errorText, - className, - } = props - const hasDate = startDate !== undefined && endDate !== undefined - - useEffect(() => { - if (!hasDate) { - //setStartDate(DEFAULT_START_DATE) - //setEndDate(DEFAULT_END_DATE) - } - }, [hasDate, setStartDate, setEndDate]) - - return hasDate ? ( - - - - {errorText && ( -
- {errorText} -
- )} -
- ) : null -} - -StartEndDates.propTypes = { - setEndDate: PropTypes.func.isRequired, - setStartDate: PropTypes.func.isRequired, - className: PropTypes.string, - endDate: PropTypes.string, - errorText: PropTypes.string, - startDate: PropTypes.string, -} - -export default connect(null, { setStartDate, setEndDate })(StartEndDates) diff --git a/src/components/periods/Timeline.js b/src/components/periods/Timeline.js index 22421d9d8..12ec73577 100644 --- a/src/components/periods/Timeline.js +++ b/src/components/periods/Timeline.js @@ -1,3 +1,4 @@ +import { PERIOD_TYPE_REGEX } from '@dhis2/analytics' import cx from 'classnames' import { axisBottom } from 'd3-axis' import { scaleTime } from 'd3-scale' @@ -6,7 +7,6 @@ import PropTypes from 'prop-types' import React, { Component } from 'react' import timeTicks from '../../util/timeTicks.js' import styles from './styles/Timeline.module.css' -import { PERIOD_TYPE_REGEX } from '@dhis2/analytics' const paddingLeft = 40 const paddingRight = 20 @@ -74,7 +74,7 @@ const addPeriodType = (item) => { } const countUniqueRanks = (periods) => { - let periodsWithType = periods.map((item) => addPeriodType(item)) + const periodsWithType = periods.map((item) => addPeriodType(item)) const levels = [...new Set(periodsWithType.map((item) => item.level))] return levels.length } @@ -137,8 +137,10 @@ class Timeline extends Component { return ( this.onPeriodClick(item)} /> ) @@ -192,7 +194,6 @@ class Timeline extends Component { // Set time scale setTimeScale = () => { const { periods } = this.props - console.log('🚀 ~ Timeline ~ this.props:', this.props) const { width } = this.state if (!periods.length) { @@ -224,7 +225,6 @@ class Timeline extends Component { // Set timeline axis setTimeAxis = () => { const { periodId, periods } = this.props - console.log('🚀 ~ Timeline ~ this.props:', this.props) const numPeriods = periods.length * (doubleTicksPeriods.includes(periodId) ? 2 : 1) const { width } = this.state @@ -254,13 +254,8 @@ class Timeline extends Component { onPeriodClick(period) { // Switch to period if different if (period.id !== this.props.period.id) { - console.log( - '🚀 ~ Timeline ~ onPeriodClick ~ this.props:', - this.props - ) this.props.onChange(period) } - console.log('🚀 ~ Timeline ~ onPeriodClick ~ this.props:', this.props) // Stop animation if running this.stop() @@ -278,7 +273,6 @@ class Timeline extends Component { // Play animation play = () => { const { period, periods, onChange } = this.props - console.log('🚀 ~ Timeline ~ this.props:', this.props) let sortedPeriods sortedPeriods = periods.sort((a, b) => b.level - a.level) sortedPeriods = periods.sort( diff --git a/src/components/periods/__tests__/Timeline.spec.js b/src/components/periods/__tests__/Timeline.spec.js index ecba61f4b..9b74aed5f 100644 --- a/src/components/periods/__tests__/Timeline.spec.js +++ b/src/components/periods/__tests__/Timeline.spec.js @@ -69,6 +69,7 @@ describe('Timeline', () => { it('should call onChange with the period clicked', () => { const wrapper = renderWithProps(props) wrapper.find('rect').first().simulate('click') + // Update periods[0] to account for the updated sorting logic expect(onChangeSpy).toHaveBeenCalledWith(periods[0]) }) diff --git a/src/components/periods/StartEndDate.module.css b/src/components/periods/styles/StartEndDate.module.css similarity index 100% rename from src/components/periods/StartEndDate.module.css rename to src/components/periods/styles/StartEndDate.module.css diff --git a/src/constants/periods.js b/src/constants/periods.js index 148b9d57f..1e136db48 100644 --- a/src/constants/periods.js +++ b/src/constants/periods.js @@ -35,15 +35,8 @@ export const periodGroups = [ // TODO: import from @dhis2/analytics (needs to be defined) const TODAY = 'TODAY' const YESTERDAY = 'YESTERDAY' -const LAST_14_DAYS = 'LAST_14_DAYS' -const LAST_30_DAYS = 'LAST_30_DAYS' -const LAST_60_DAYS = 'LAST_60_DAYS' -const LAST_90_DAYS = 'LAST_90_DAYS' -const LAST_180_DAYS = 'LAST_180_DAYS' const THIS_WEEK = 'THIS_WEEK' const LAST_WEEK = 'LAST_WEEK' -const LAST_52_WEEKS = 'LAST_52_WEEKS' -const WEEKS_THIS_YEAR = 'WEEKS_THIS_YEAR' const THIS_BIWEEK = 'THIS_BIWEEK' const LAST_BIWEEK = 'LAST_BIWEEK' const THIS_MONTH = 'THIS_MONTH' diff --git a/src/loaders/thematicLoader.js b/src/loaders/thematicLoader.js index ccd737764..29ca6751e 100644 --- a/src/loaders/thematicLoader.js +++ b/src/loaders/thematicLoader.js @@ -24,7 +24,6 @@ import { import { getOrgUnitsFromRows, getPeriodsFromFilters, - getPeriodFromFilters, getValidDimensionsFromFilters, getDataItemFromColumns, getApiResponseNames, @@ -98,18 +97,11 @@ const thematicLoader = async ({ config, engine, nameProperty }) => { const isSingleMap = renderingStrategy === RENDERING_STRATEGY_SINGLE const isBubbleMap = thematicMapType === THEMATIC_BUBBLE const isSingleColor = config.method === CLASSIFICATION_SINGLE_COLOR - const period = getPeriodFromFilters(config.filters) - console.log('🚀 ~ thematicLoader ~ period:', period) - const periodx = getPeriodsFromFilters(config.filters) - console.log('🚀 ~ thematicLoader ~ periodx:', periodx) - console.log('🚀 ~ thematicLoader ~ data.metaData:', data.metaData) + const presetPeriods = getPeriodsFromFilters(config.filters) const periods = getPeriodsFromMetaData(data.metaData) - console.log('🚀 ~ thematicLoader ~ periods:', periods) const dimensions = getValidDimensionsFromFilters(config.filters) const names = getApiResponseNames(data) - // TODO Handle multiple maps const valuesByPeriod = !isSingleMap ? getValuesByPeriod(data) : null - console.log('🚀 ~ thematicLoader ~ valuesByPeriod:', valuesByPeriod) const valueById = getValueById(data) const valueFeatures = noDataColor ? features @@ -157,15 +149,15 @@ const thematicLoader = async ({ config, engine, nameProperty }) => { const legend = { title: name, - period: period - ? periodx.map((pe) => names[pe.id] || pe.id).join(', ') - : formatStartEndDate( - getDateArray(config.startDate), - getDateArray(config.endDate) - ), + period: + presetPeriods.length > 0 + ? presetPeriods.map((pe) => names[pe.id] || pe.id).join(', ') + : formatStartEndDate( + getDateArray(config.startDate), + getDateArray(config.endDate) + ), items: legendItems, } - console.log('🚀 ~ thematicLoader ~ names:', names) if (dimensions && dimensions.length) { legend.filters = dimensions.map( @@ -271,7 +263,6 @@ const thematicLoader = async ({ config, engine, nameProperty }) => { if (noDataColor && Array.isArray(legend.items) && !isBubbleMap) { legend.items.push({ color: noDataColor, name: i18n.t('No data') }) } - console.log('🚀 ~ thematicLoader ~ legend:', legend) return { ...config, @@ -358,13 +349,8 @@ const loadData = async (config, nameProperty) => { renderingStrategy = RENDERING_STRATEGY_SINGLE, eventStatus, } = config - console.log('🚀 ~ loadData ~ endDate:', endDate) - console.log('🚀 ~ loadData ~ startDate:', startDate) const orgUnits = getOrgUnitsFromRows(rows) - const period = getPeriodFromFilters(filters) - console.log('🚀 ~ loadData ~ period:', period) - const periodx = getPeriodsFromFilters(filters) - console.log('🚀 ~ loadData ~ periodx:', periodx) + const presetPeriods = getPeriodsFromFilters(filters) const dimensions = getValidDimensionsFromFilters(config.filters) const dataItem = getDataItemFromColumns(columns) || {} const coordinateField = getCoordinateField(config) @@ -386,15 +372,18 @@ const loadData = async (config, nameProperty) => { .withDisplayProperty(nameProperty) if (!isSingleMap) { - // TODO Handle multiple maps analyticsRequest = analyticsRequest.addPeriodDimension( - periodx.map((pe) => pe.id) + presetPeriods.map((pe) => pe.id) ) } else { analyticsRequest = - periodx.length > 0 - ? analyticsRequest.addPeriodFilter(periodx.map((pe) => pe.id)) - : analyticsRequest.withStartDate(startDate).withEndDate(endDate) + presetPeriods.length > 0 + ? analyticsRequest.addPeriodFilter( + presetPeriods.map((pe) => pe.id) + ) + : analyticsRequest + .withStartDate(startDate.slice(0, 10)) + .withEndDate(endDate.slice(0, 10)) } if (dimensions) { diff --git a/src/util/__tests__/teiRelationshipsParser.spec.js b/src/util/__tests__/teiRelationshipsParser.spec.js index 2f80aa199..ae28b69e3 100644 --- a/src/util/__tests__/teiRelationshipsParser.spec.js +++ b/src/util/__tests__/teiRelationshipsParser.spec.js @@ -570,11 +570,8 @@ describe('getDataWithRelationships', () => { expect(result).toEqual(expected) } else { expect(result).toHaveProperty('primary') - console.log('primary', result.primary) expect(result).toHaveProperty('relationships') - console.log('relationships', result.relationships) expect(result).toHaveProperty('secondary') - console.log('secondary', result.secondary) const resultPrimaryIds = result.primary.map((item) => item.id) expect(resultPrimaryIds.sort()).toEqual(expected.primary.sort()) @@ -691,11 +688,8 @@ describe('getDataWithRelationships', () => { expect(result).toEqual(expected) } else { expect(result).toHaveProperty('primary') - //console.log('primary', result.primary) expect(result).toHaveProperty('relationships') - //console.log('relationships', result.relationships) expect(result).toHaveProperty('secondary') - //console.log('secondary', result.secondary) const resultPrimaryIds = result.primary.map((item) => item.id) expect(resultPrimaryIds.sort()).toEqual(expected.primary.sort())