From 71eaded1106978c10e873d25e540f300ba87e97b Mon Sep 17 00:00:00 2001 From: martinkrulltott Date: Thu, 4 Jan 2024 12:32:45 +0000 Subject: [PATCH] fix: include program id for TE dimensions --- src/modules/layout/axisGetDimensionIds.js | 4 ++-- src/modules/layout/dimensionGetId.js | 20 ++++++++++++------- src/modules/layout/layoutFilterDimensions.js | 5 ++++- .../layoutGetAxisIdDimensionIdsObject.js | 2 +- .../layoutGetDimensionIdItemIdsObject.js | 5 ++++- .../layout/layoutHasDynamicDimension.js | 3 ++- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/modules/layout/axisGetDimensionIds.js b/src/modules/layout/axisGetDimensionIds.js index 0c7023e45..3db877e8a 100644 --- a/src/modules/layout/axisGetDimensionIds.js +++ b/src/modules/layout/axisGetDimensionIds.js @@ -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 diff --git a/src/modules/layout/dimensionGetId.js b/src/modules/layout/dimensionGetId.js index 2354a860d..f5d63b860 100644 --- a/src/modules/layout/dimensionGetId.js +++ b/src/modules/layout/dimensionGetId.js @@ -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, + }) diff --git a/src/modules/layout/layoutFilterDimensions.js b/src/modules/layout/layoutFilterDimensions.js index 0e9cd9250..ab8f9ff65 100644 --- a/src/modules/layout/layoutFilterDimensions.js +++ b/src/modules/layout/layoutFilterDimensions.js @@ -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) + ) ) } }) diff --git a/src/modules/layout/layoutGetAxisIdDimensionIdsObject.js b/src/modules/layout/layoutGetAxisIdDimensionIdsObject.js index f7ca0c8ad..c875b0567 100644 --- a/src/modules/layout/layoutGetAxisIdDimensionIdsObject.js +++ b/src/modules/layout/layoutGetAxisIdDimensionIdsObject.js @@ -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 diff --git a/src/modules/layout/layoutGetDimensionIdItemIdsObject.js b/src/modules/layout/layoutGetDimensionIdItemIdsObject.js index c98e1650e..fd261a03a 100644 --- a/src/modules/layout/layoutGetDimensionIdItemIdsObject.js +++ b/src/modules/layout/layoutGetDimensionIdItemIdsObject.js @@ -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 }, {}) diff --git a/src/modules/layout/layoutHasDynamicDimension.js b/src/modules/layout/layoutHasDynamicDimension.js index 586abdd1f..dc02b5f94 100644 --- a/src/modules/layout/layoutHasDynamicDimension.js +++ b/src/modules/layout/layoutHasDynamicDimension.js @@ -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)) ) ) }