diff --git a/cypress/integration/layoutValidation.cy.js b/cypress/integration/layoutValidation.cy.js index b686f731c..4f41b46a0 100644 --- a/cypress/integration/layoutValidation.cy.js +++ b/cypress/integration/layoutValidation.cy.js @@ -1,3 +1,4 @@ +import { DIMENSION_ID_ORGUNIT } from '@dhis2/analytics' import { E2E_PROGRAM } from '../data/index.js' import { clickAddRemoveMainDimension, @@ -8,6 +9,11 @@ import { selectTrackedEntityWithType, } from '../helpers/dimensions.js' import { clickMenubarUpdateButton } from '../helpers/menubar.js' +import { + clickOrgUnitDimensionModalUpdateButton, + deselectUserOrgUnit, + openOuDimension, +} from '../helpers/orgUnit.js' import { goToStartPage } from '../helpers/startScreen.js' import { expectTableToBeVisible } from '../helpers/table.js' @@ -107,10 +113,9 @@ describe('layout validation', () => { // add org unit to columns without any items selected clickAddRemoveMainDimension('Registration org. unit') - // FIXME: uncomment the following lines once https://dhis2.atlassian.net/browse/DHIS2-16381 is fixed - // openOuDimension(DIMENSION_ID_ORGUNIT) - // deselectUserOrgUnit('User organisation unit') - // clickOrgUnitDimensionModalUpdateButton() + openOuDimension(DIMENSION_ID_ORGUNIT) + deselectUserOrgUnit('User organisation unit') + clickOrgUnitDimensionModalUpdateButton() clickMenubarUpdateButton() diff --git a/src/components/Visualization/analyticsQueryTools.js b/src/components/Visualization/analyticsQueryTools.js index 58febf591..094246c65 100644 --- a/src/components/Visualization/analyticsQueryTools.js +++ b/src/components/Visualization/analyticsQueryTools.js @@ -2,6 +2,7 @@ import { AXIS_ID_COLUMNS, AXIS_ID_ROWS, AXIS_ID_FILTERS, + DIMENSION_ID_ORGUNIT, } from '@dhis2/analytics' import { DIMENSION_ID_PROGRAM_STATUS, @@ -13,7 +14,10 @@ import { } from '../../modules/dimensionConstants.js' import { formatDimensionId } from '../../modules/dimensionId.js' import { getRequestOptions } from '../../modules/getRequestOptions.js' -import { getHeadersMap } from '../../modules/visualization.js' +import { + OUTPUT_TYPE_TRACKED_ENTITY, + getHeadersMap, +} from '../../modules/visualization.js' const excludedDimensions = [ DIMENSION_ID_CREATED, @@ -23,7 +27,7 @@ const excludedDimensions = [ const isTimeDimension = (dimensionId) => DIMENSION_IDS_TIME.has(dimensionId) -const adaptDimensions = (dimensions, parameters) => { +const adaptDimensions = (dimensions, parameters, outputType) => { const adaptedDimensions = [] dimensions.forEach((dimensionObj) => { const dimensionId = dimensionObj.dimension @@ -32,7 +36,9 @@ const adaptDimensions = (dimensions, parameters) => { isTimeDimension(dimensionId) || dimensionId === DIMENSION_ID_EVENT_STATUS || dimensionId === DIMENSION_ID_PROGRAM_STATUS || - dimensionId === DIMENSION_ID_CREATED + dimensionId === DIMENSION_ID_CREATED || + (dimensionId === DIMENSION_ID_ORGUNIT && + outputType === OUTPUT_TYPE_TRACKED_ENTITY) ) { if (dimensionObj.items?.length) { const items = dimensionObj.items?.map((item) => item.id) @@ -42,6 +48,8 @@ const adaptDimensions = (dimensions, parameters) => { Array.isArray(parameters[dimensionId]) ) { parameters[dimensionId].push(...items) + } else if (dimensionId === DIMENSION_ID_ORGUNIT) { + adaptedDimensions.push(dimensionObj) } else { parameters[dimensionId] = items } @@ -61,12 +69,18 @@ export const getAdaptedVisualization = (visualization) => { const adaptedColumns = adaptDimensions( visualization[AXIS_ID_COLUMNS], - parameters + parameters, + outputType + ) + const adaptedRows = adaptDimensions( + visualization[AXIS_ID_ROWS], + parameters, + outputType ) - const adaptedRows = adaptDimensions(visualization[AXIS_ID_ROWS], parameters) const adaptedFilters = adaptDimensions( visualization[AXIS_ID_FILTERS], - parameters + parameters, + outputType ) const dimensionHeadersMap = getHeadersMap(visualization)