Skip to content

Commit

Permalink
fix: include program id for TE dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott committed Jan 4, 2024
1 parent 7986d43 commit 71eaded
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/modules/layout/axisGetDimensionIds.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AXIS } from './axis.js'
import { dimensionGetId } from './dimensionGetId.js'

export const axisGetDimensionIds = (axis) =>
export const axisGetDimensionIds = (axis, outputType) =>
AXIS.isValid(axis)
? axis.map((dimension) => dimensionGetId(dimension))
? axis.map((dimension) => dimensionGetId(dimension, outputType))
: AXIS.defaultValue
20 changes: 13 additions & 7 deletions src/modules/layout/dimensionGetId.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { DIMENSION_PROP_ID, DIMENSION_PROP_PROGRAM_STAGE } from './dimension.js'
import { formatDimension } from '../../api/analytics/utils.js'
import {
DIMENSION_PROP_ID,
DIMENSION_PROP_PROGRAM_STAGE,
DIMENSION_PROP_PROGRAM,
} from './dimension.js'

export const dimensionGetId = (dimension) =>
dimension[DIMENSION_PROP_PROGRAM_STAGE.name]?.id
? `${dimension[DIMENSION_PROP_PROGRAM_STAGE.name].id}.${
dimension[DIMENSION_PROP_ID.name]
}`
: dimension[DIMENSION_PROP_ID.name]
export const dimensionGetId = (dimension, outputType) =>
formatDimension({
dimension: dimension[DIMENSION_PROP_ID.name],
programId: dimension[DIMENSION_PROP_PROGRAM.name]?.id,
programStageId: dimension[DIMENSION_PROP_PROGRAM_STAGE.name]?.id,
outputType,
})
5 changes: 4 additions & 1 deletion src/modules/layout/layoutFilterDimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export const layoutFilterDimensions = (layout, dimensionIds) => {
DEFAULT_AXIS_IDS.forEach((axisId) => {
if (AXIS.isValid(filteredLayout[axisId])) {
filteredLayout[axisId] = filteredLayout[axisId].filter(
(dimension) => !idArray.includes(dimensionGetId(dimension))
(dimension) =>
!idArray.includes(
dimensionGetId(dimension, layout.outputType)
)
)
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/modules/layout/layoutGetAxisIdDimensionIdsObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { axisGetDimensionIds } from './axisGetDimensionIds.js'
export const layoutGetAxisIdDimensionIdsObject = (layout) =>
DEFAULT_AXIS_IDS.reduce((obj, axisId) => {
if (AXIS.isValid(layout[axisId])) {
obj[axisId] = axisGetDimensionIds(layout[axisId])
obj[axisId] = axisGetDimensionIds(layout[axisId], layout.outputType)
}

return obj
Expand Down
5 changes: 4 additions & 1 deletion src/modules/layout/layoutGetDimensionIdItemIdsObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { layoutGetAllDimensions } from './layoutGetAllDimensions.js'

export const layoutGetDimensionIdItemIdsObject = (layout) =>
layoutGetAllDimensions(layout).reduce((obj, dimension) => {
obj[dimensionGetId(dimension)] = dimensionGetItemIds(dimension)
obj[dimensionGetId(dimension)] = dimensionGetItemIds(
dimension,
layout.outputType
)
return obj
}, {})
3 changes: 2 additions & 1 deletion src/modules/layout/layoutHasDynamicDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const layoutHasDynamicDimension = (layout) => {

return Boolean(
layoutGetAllDimensions(layout).find(
(dimension) => !fixedIds.includes(dimensionGetId(dimension))
(dimension) =>
!fixedIds.includes(dimensionGetId(dimension, layout.outputType))
)
)
}

0 comments on commit 71eaded

Please sign in to comment.