Skip to content

Commit

Permalink
fix: remove dimensions other than dx,pe,ou for Outlier table (DHIS2-1…
Browse files Browse the repository at this point in the history
…6893)
  • Loading branch information
edoardo committed Mar 5, 2024
1 parent 04e371f commit 20adf5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
7 changes: 3 additions & 4 deletions src/modules/__tests__/getAdaptedUiLayoutByType.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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(
Expand All @@ -190,8 +191,6 @@ describe('getAdaptedUiLayoutByType', () => {
DIMENSION_ID_DATA,
DIMENSION_ID_PERIOD,
DIMENSION_ID_ORGUNIT,
someId,
otherId,
],
[AXIS_ID_ROWS]: [],
[AXIS_ID_FILTERS]: [],
Expand Down
14 changes: 1 addition & 13 deletions src/modules/getAdaptedUiLayoutByType.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]: [],
Expand Down

0 comments on commit 20adf5b

Please sign in to comment.