From 20adf5b6e060dbbbcd8ceae3c4a88ed1efa80894 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Fri, 23 Feb 2024 09:58:54 +0100 Subject: [PATCH] fix: remove dimensions other than dx,pe,ou for Outlier table (DHIS2-16893) --- .../__tests__/getAdaptedUiLayoutByType.spec.js | 7 +++---- src/modules/getAdaptedUiLayoutByType.js | 14 +------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/modules/__tests__/getAdaptedUiLayoutByType.spec.js b/src/modules/__tests__/getAdaptedUiLayoutByType.spec.js index 1de6c2e5b..36fb256eb 100644 --- a/src/modules/__tests__/getAdaptedUiLayoutByType.spec.js +++ b/src/modules/__tests__/getAdaptedUiLayoutByType.spec.js @@ -20,6 +20,7 @@ import { const someId = 'someId' const otherId = 'otherId' +const thirdId = 'thirdId' describe('getAdaptedUiLayoutByType', () => { it('column: moves all extra dimensions in columns and rows to filters', () => { @@ -173,11 +174,11 @@ describe('getAdaptedUiLayoutByType', () => { expect(actualState).toEqual(expectedState) }) - it('outlier table: moves all dimensions to columns with dimension strings', () => { + it('outlier table: removes all dimensions but dx,pe,ou which are moved to columns', () => { const initialState = { [AXIS_ID_COLUMNS]: [DIMENSION_ID_DATA, someId], [AXIS_ID_ROWS]: [DIMENSION_ID_PERIOD, otherId], - [AXIS_ID_FILTERS]: [DIMENSION_ID_ORGUNIT], + [AXIS_ID_FILTERS]: [DIMENSION_ID_ORGUNIT, thirdId], } const actualState = getAdaptedUiLayoutByType( @@ -190,8 +191,6 @@ describe('getAdaptedUiLayoutByType', () => { DIMENSION_ID_DATA, DIMENSION_ID_PERIOD, DIMENSION_ID_ORGUNIT, - someId, - otherId, ], [AXIS_ID_ROWS]: [], [AXIS_ID_FILTERS]: [], diff --git a/src/modules/getAdaptedUiLayoutByType.js b/src/modules/getAdaptedUiLayoutByType.js index c57d8eac7..9f1d72028 100644 --- a/src/modules/getAdaptedUiLayoutByType.js +++ b/src/modules/getAdaptedUiLayoutByType.js @@ -144,23 +144,11 @@ const getSingleValueLayout = (layout) => { } // Transform from ui.layout to outlier table layout format -const getOutlierTableLayout = (layout) => ({ +const getOutlierTableLayout = () => ({ [AXIS_ID_COLUMNS]: [ DIMENSION_ID_DATA, DIMENSION_ID_PERIOD, DIMENSION_ID_ORGUNIT, - ...[ - ...layout[AXIS_ID_COLUMNS], - ...layout[AXIS_ID_ROWS], - ...layout[AXIS_ID_FILTERS], - ].filter( - (dim) => - ![ - DIMENSION_ID_DATA, - DIMENSION_ID_ORGUNIT, - DIMENSION_ID_PERIOD, - ].includes(getDimensionId(dim)) - ), ], [AXIS_ID_ROWS]: [], [AXIS_ID_FILTERS]: [],