Skip to content

Commit

Permalink
fix: fix a crash when row totals is enabled (DHIS2-17297) (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo authored May 6, 2024
1 parent eef1caf commit be6ea56
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/modules/pivotTable/PivotTableEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,19 @@ export class PivotTableEngine {
if (!this.data[row]) {
return undefined
}

const cellValue = this.data[row][column]

if (cellValue && !Array.isArray(cellValue)) {
if (!cellValue) {
// Empty cell
// The cell still needs to get the valueType to render correctly 0 and cumulative values
return {
valueType: VALUE_TYPE_NUMBER,
totalAggregationType: AGGREGATE_TYPE_SUM,
}
}

if (!Array.isArray(cellValue)) {
// This is a total cell
return {
valueType: cellValue.valueType,
Expand All @@ -532,6 +542,7 @@ export class PivotTableEngine {
const dxRowIndex = this.dimensionLookup.rows.findIndex(
(dim) => dim.isDxDimension
)

if (rowHeaders.length && dxRowIndex !== -1) {
return {
valueType: rowHeaders[dxRowIndex].valueType,
Expand All @@ -553,11 +564,6 @@ export class PivotTableEngine {
}
}

// Empty cell
// The cell still needs to get the valueType to render correctly 0 and cumulative values
//
// OR
//
// Data is in Filter
// TODO : This assumes the server ignores text types, we should confirm this is the case
return {
Expand Down

0 comments on commit be6ea56

Please sign in to comment.