diff --git a/packages/app/src/modules/__tests__/layoutAdapters.spec.js b/packages/app/src/modules/__tests__/layoutAdapters.spec.js index 3379f40038..17290a1ea3 100644 --- a/packages/app/src/modules/__tests__/layoutAdapters.spec.js +++ b/packages/app/src/modules/__tests__/layoutAdapters.spec.js @@ -20,16 +20,25 @@ describe('defaultLayoutAdapter', () => { it('should move all extra dimensions in columns and rows to filters', () => { const initialState = { [AXIS_ID_COLUMNS]: [DIMENSION_ID_DATA, someId], - [AXIS_ID_ROWS]: [DIMENSION_ID_PERIOD, otherId], - [AXIS_ID_FILTERS]: [DIMENSION_ID_ORGUNIT], + [AXIS_ID_ROWS]: [], + [AXIS_ID_FILTERS]: [ + DIMENSION_ID_PERIOD, + DIMENSION_ID_ORGUNIT, + otherId, + ], } const actualState = defaultLayoutAdapter(initialState) const expectedState = { [AXIS_ID_COLUMNS]: [DIMENSION_ID_DATA], - [AXIS_ID_ROWS]: [DIMENSION_ID_PERIOD], - [AXIS_ID_FILTERS]: [DIMENSION_ID_ORGUNIT, someId, otherId], + [AXIS_ID_ROWS]: [], + [AXIS_ID_FILTERS]: [ + DIMENSION_ID_PERIOD, + DIMENSION_ID_ORGUNIT, + otherId, + someId, + ], } expect(actualState).toEqual(expectedState) diff --git a/packages/app/src/modules/layoutAdapters.js b/packages/app/src/modules/layoutAdapters.js index 8264d49280..b39e64a063 100644 --- a/packages/app/src/modules/layoutAdapters.js +++ b/packages/app/src/modules/layoutAdapters.js @@ -12,8 +12,8 @@ export const defaultLayoutAdapter = layout => { const rows = layout[AXIS_ID_ROWS].slice() return { - [AXIS_ID_COLUMNS]: [columns.shift()], - [AXIS_ID_ROWS]: [rows.shift()], + [AXIS_ID_COLUMNS]: columns.length ? [columns.shift()] : columns, + [AXIS_ID_ROWS]: rows.length ? [rows.shift()] : rows, [AXIS_ID_FILTERS]: [...layout[AXIS_ID_FILTERS], ...columns, ...rows], } } @@ -24,7 +24,11 @@ export const pieLayoutAdapter = layout => { const rows = layout[AXIS_ID_ROWS].slice() return { - [AXIS_ID_COLUMNS]: [columns.shift() || rows.shift()], + [AXIS_ID_COLUMNS]: columns.length + ? [columns.shift()] + : rows.length + ? [rows.shift()] + : [], [AXIS_ID_ROWS]: [], [AXIS_ID_FILTERS]: [...layout[AXIS_ID_FILTERS], ...columns, ...rows], }