Skip to content

Commit

Permalink
fix: prefix time dimension condition with program if present
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Jan 19, 2024
1 parent 78872dd commit 2a9877b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/Dialogs/PeriodDimension/PeriodDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ import {
SYSTEM_SETTINGS_HIDE_BIMONTHLY_PERIODS,
} from '../../../modules/systemSettings.js'
import { USER_SETTINGS_UI_LOCALE } from '../../../modules/userSettings.js'
import { extractDimensionIdParts } from '../../../modules/utils.js'
import {
sGetDimensionIdsFromLayout,
sGetUiItemsByDimension,
sGetUiInputType,
} from '../../../reducers/ui.js'
import DimensionModal from '../DimensionModal.js'
import styles from './PeriodDimension.module.css'
Expand Down Expand Up @@ -118,18 +120,23 @@ export const PeriodDimension = ({ dimension, onClose }) => {
: OPTION_PRESETS
)

const inputType = useSelector(sGetUiInputType)

const { programId } = extractDimensionIdParts(dimension.id, inputType)

const updatePeriodDimensionItems = (items) => {
const { uiItems, metadata } = items.reduce(
(acc, item) => {
acc.uiItems.push(item.id)
const itemId = programId ? `${programId}.${item.id}` : item.id
acc.uiItems.push(itemId)

if (isStartEndDate(item.id)) {
acc.metadata[item.id] = {
id: item.id,
acc.metadata[itemId] = {
id: itemId,
name: formatStartEndDate(item.id),
}
} else {
acc.metadata[item.id] = item
acc.metadata[itemId] = { ...item, id: itemId }
}

return acc
Expand Down

0 comments on commit 2a9877b

Please sign in to comment.