Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
360486c
feat: fetch enabled period types in 43+ (WIP)
janhenrikoverland Jan 27, 2026
7319460
fix: add missing serverVersion mock in PeriodDimension test
janhenrikoverland Jan 27, 2026
85867b1
fix: clean up
janhenrikoverland Jan 27, 2026
456dc86
fix: satisfy sonarqube
janhenrikoverland Jan 27, 2026
1425a86
chore: remove CLAUDE.md from tracking and gitignore it
janhenrikoverland Jan 27, 2026
70a1447
fix: avoid edge case crash
janhenrikoverland Jan 27, 2026
41c304e
feat: add support for all period types from @dhis2/multi-calendar-dates
janhenrikoverland Jan 29, 2026
d322db7
fix: custom relative period item names wip
janhenrikoverland Feb 13, 2026
60d94f5
refactor: use data output period types hook
janhenrikoverland Feb 16, 2026
dd22988
chore: remove log
janhenrikoverland Feb 17, 2026
1ddd9df
fix: show custom label when passing selected items
janhenrikoverland Feb 19, 2026
7719f57
fix: do not try to rescue misconfiguration in settings app
janhenrikoverland Feb 20, 2026
f565433
fix: weekly relative period names
janhenrikoverland Feb 20, 2026
02e5165
fix: use pt display label in fixed period names
janhenrikoverland Feb 20, 2026
708cd23
Merge branch 'master' into feat/use-enabled-period-types
janhenrikoverland Mar 2, 2026
861bb74
chore: linting
janhenrikoverland Mar 2, 2026
c7ee47f
Merge branch 'feat/use-enabled-period-types' of github.com:dhis2/anal…
janhenrikoverland Mar 2, 2026
ff2f667
chore: code smell
janhenrikoverland Mar 2, 2026
f7ff0de
test: remove unsupported period types
janhenrikoverland Mar 2, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ bundle.stats.json
# DHIS2 Platform
.d2
src/locales
CLAUDE.md
35 changes: 27 additions & 8 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: 2025-09-09T09:32:04.677Z\n"
"PO-Revision-Date: 2025-09-09T09:32:04.678Z\n"
"POT-Creation-Date: 2026-03-02T14:36:21.150Z\n"
"PO-Revision-Date: 2026-03-02T14:36:21.150Z\n"

msgid "view only"
msgstr "view only"
Expand Down Expand Up @@ -822,6 +822,16 @@ msgstr "Period"
msgid "Selected Periods"
msgstr "Selected Periods"

msgid "No period types available"
msgstr "No period types available"

msgid ""
"No period types are enabled in the system. Please contact your system "
"administrator."
msgstr ""
"No period types are enabled in the system. Please contact your system "
"administrator."

msgid "Relative periods"
msgstr "Relative periods"

Expand Down Expand Up @@ -870,17 +880,26 @@ msgstr "Six-monthly April"
msgid "Yearly"
msgstr "Yearly"

msgid "Financial year (Start November)"
msgstr "Financial year (Start November)"
msgid "Financial year (Start February)"
msgstr "Financial year (Start February)"

msgid "Financial year (Start October)"
msgstr "Financial year (Start October)"
msgid "Financial year (Start April)"
msgstr "Financial year (Start April)"

msgid "Financial year (Start July)"
msgstr "Financial year (Start July)"

msgid "Financial year (Start April)"
msgstr "Financial year (Start April)"
msgid "Financial year (Start August)"
msgstr "Financial year (Start August)"

msgid "Financial year (Start September)"
msgstr "Financial year (Start September)"

msgid "Financial year (Start October)"
msgstr "Financial year (Start October)"

msgid "Financial year (Start November)"
msgstr "Financial year (Start November)"

msgid "Today"
msgstr "Today"
Expand Down
27 changes: 5 additions & 22 deletions src/components/PeriodDimension/FixedPeriodFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@ import PropTypes from 'prop-types'
import React from 'react'
import i18n from '../../locales/index.js'
import styles from './styles/PeriodFilter.style.js'
import { getFixedPeriodsOptions } from './utils/fixedPeriods.js'
import { filterPeriodTypesById } from './utils/index.js'

const EXCLUDED_PERIOD_TYPES_PROP_DEFAULT = []

const FixedPeriodFilter = ({
allowedPeriodTypes,
excludedPeriodTypes = EXCLUDED_PERIOD_TYPES_PROP_DEFAULT,
availableOptions,
currentPeriodType,
currentYear,
onSelectPeriodType,
onSelectYear,
dataTest,
}) => {
const onlyAllowedTypeIsSelected =
Array.isArray(allowedPeriodTypes) &&
allowedPeriodTypes.length === 1 &&
allowedPeriodTypes[0] === currentPeriodType
availableOptions.length === 1 &&
availableOptions[0].id === currentPeriodType

return (
<>
Expand All @@ -34,17 +28,7 @@ const FixedPeriodFilter = ({
className="filterElement"
dataTest={`${dataTest}-period-type`}
>
{(allowedPeriodTypes
? getFixedPeriodsOptions().filter((option) =>
allowedPeriodTypes.some(
(type) => type === option.id
)
)
: filterPeriodTypesById(
getFixedPeriodsOptions(),
excludedPeriodTypes
)
).map((option) => (
{availableOptions.map((option) => (
<SingleSelectOption
key={option.id}
value={option.id}
Expand Down Expand Up @@ -72,13 +56,12 @@ const FixedPeriodFilter = ({
}

FixedPeriodFilter.propTypes = {
availableOptions: PropTypes.array.isRequired,
currentPeriodType: PropTypes.string.isRequired,
currentYear: PropTypes.string.isRequired,
onSelectPeriodType: PropTypes.func.isRequired,
onSelectYear: PropTypes.func.isRequired,
allowedPeriodTypes: PropTypes.arrayOf(PropTypes.string),
dataTest: PropTypes.string,
excludedPeriodTypes: PropTypes.arrayOf(PropTypes.string),
}

export default FixedPeriodFilter
10 changes: 9 additions & 1 deletion src/components/PeriodDimension/FixedPeriodSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import styles from './styles/FixedPeriodSelect.style.js'
import {
parsePeriodCode,
getFixedPeriodsOptionsById as getPeriodById,
getFixedPeriodsOptions,
getYearOffsetFromNow,
} from './utils/fixedPeriods.js'

Expand Down Expand Up @@ -63,14 +64,21 @@ class FixedPeriodSelect extends Component {
}

render() {
const allOptions = getFixedPeriodsOptions()
const availableOptions = this.props.allowedPeriodTypes
? allOptions.filter((option) =>
this.props.allowedPeriodTypes.includes(option.id)
)
: allOptions

return (
<div
data-test={this.props.dataTest}
className={this.props.className}
>
<div className="row">
<FixedPeriodFilter
allowedPeriodTypes={this.props.allowedPeriodTypes}
availableOptions={availableOptions}
currentPeriodType={this.state.periodType}
currentYear={this.state.year}
onSelectPeriodType={this.onSelectPeriodType}
Expand Down
23 changes: 19 additions & 4 deletions src/components/PeriodDimension/PeriodDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import PropTypes from 'prop-types'
import React from 'react'
import { DIMENSION_ID_PERIOD } from '../../modules/predefinedDimensions.js'
import PeriodTransfer from './PeriodTransfer.js'
import { useDataOutputPeriodTypes } from './useDataOutputPeriodTypes.js'
import { applyPeriodNameOverrides } from './utils/enabledPeriodTypes.js'

const userSettingsQuery = {
userSettings: {
Expand All @@ -23,11 +25,16 @@ const PeriodDimension = ({
infoBoxMessage,
height,
}) => {
const { systemInfo } = useConfig()
const result = useDataQuery(userSettingsQuery)
const config = useConfig()
const { systemInfo } = config
const userSettingsResult = useDataQuery(userSettingsQuery)

const { supportsEnabledPeriodTypes, enabledPeriodTypesData } =
useDataOutputPeriodTypes()

const { calendar = 'gregory' } = systemInfo
const { data: { userSettings: { keyUiLocale: locale } = {} } = {} } = result
const { data: { userSettings: { keyUiLocale: locale } = {} } = {} } =
userSettingsResult

const periodsSettings = { calendar, locale }

Expand All @@ -37,16 +44,24 @@ const PeriodDimension = ({
items: periods,
})
}

const selectedPeriodsWithCustomDisplayNames = applyPeriodNameOverrides(
selectedPeriods,
enabledPeriodTypesData?.metaData
)

return (
<PeriodTransfer
onSelect={selectPeriods}
selectedItems={selectedPeriods}
selectedItems={selectedPeriodsWithCustomDisplayNames}
infoBoxMessage={infoBoxMessage}
rightFooter={rightFooter}
dataTest={'period-dimension'}
excludedPeriodTypes={excludedPeriodTypes}
periodsSettings={periodsSettings}
height={height}
enabledPeriodTypesData={enabledPeriodTypesData}
supportsEnabledPeriodTypes={supportsEnabledPeriodTypes}
/>
)
}
Expand Down
Loading
Loading