From efff1c81845a974fe8c60b593e6bbe42c19682d7 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Tue, 27 Aug 2024 13:44:20 +0200 Subject: [PATCH 1/3] fix: add AO TYPE for event chart and event report (#1697) Fixes DHIS2-17943 eventCharts and eventReports were missing in the list of AO_TYPES, causing the AboutAoUnit component to break. --- i18n/en.pot | 10 ++++++++-- src/components/AboutAOUnit/utils.js | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index 7aea739a6..2e98715e2 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-06-26T14:09:30.876Z\n" -"PO-Revision-Date: 2024-06-26T14:09:30.876Z\n" +"POT-Creation-Date: 2024-08-27T11:29:09.031Z\n" +"PO-Revision-Date: 2024-08-27T11:29:09.033Z\n" msgid "view only" msgstr "view only" @@ -67,6 +67,12 @@ msgstr "About this line list" msgid "About this visualization" msgstr "About this visualization" +msgid "About this event chart" +msgstr "About this event chart" + +msgid "About this event report" +msgstr "About this event report" + msgid "This app could not retrieve required data." msgstr "This app could not retrieve required data." diff --git a/src/components/AboutAOUnit/utils.js b/src/components/AboutAOUnit/utils.js index eb0295cf6..88bae014c 100644 --- a/src/components/AboutAOUnit/utils.js +++ b/src/components/AboutAOUnit/utils.js @@ -3,6 +3,8 @@ import i18n from '@dhis2/d2-i18n' export const AO_TYPE_VISUALIZATION = 'visualization' export const AO_TYPE_MAP = 'map' export const AO_TYPE_EVENT_VISUALIZATION = 'eventVisualization' +export const AO_TYPE_EVENT_CHART = 'eventChart' +export const AO_TYPE_EVENT_REPORT = 'eventReport' export const AOTypeMap = { [AO_TYPE_VISUALIZATION]: { @@ -14,6 +16,12 @@ export const AOTypeMap = { [AO_TYPE_EVENT_VISUALIZATION]: { apiEndpoint: 'eventVisualizations', }, + [AO_TYPE_EVENT_CHART]: { + apiEndpoint: 'eventCharts', + }, + [AO_TYPE_EVENT_REPORT]: { + apiEndpoint: 'eventReports', + }, } const NO_TYPE = 'NO_TYPE' @@ -28,6 +36,12 @@ const texts = { [AO_TYPE_VISUALIZATION]: { unitTitle: i18n.t('About this visualization'), }, + [AO_TYPE_EVENT_CHART]: { + unitTitle: i18n.t('About this event chart'), + }, + [AO_TYPE_EVENT_REPORT]: { + unitTitle: i18n.t('About this event report'), + }, [NO_TYPE]: { unitTitle: i18n.t('About this visualization'), }, From e347564d4c18d4f9d026f1a312ec44a538246eca Mon Sep 17 00:00:00 2001 From: "@dhis2-bot" Date: Tue, 27 Aug 2024 11:48:25 +0000 Subject: [PATCH 2/3] chore(release): cut 26.8.2 [skip ci] ## [26.8.2](https://github.com/dhis2/analytics/compare/v26.8.1...v26.8.2) (2024-08-27) ### Bug Fixes * add AO TYPE for event chart and event report ([#1697](https://github.com/dhis2/analytics/issues/1697)) ([efff1c8](https://github.com/dhis2/analytics/commit/efff1c81845a974fe8c60b593e6bbe42c19682d7)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d56447e4..bdc7663da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [26.8.2](https://github.com/dhis2/analytics/compare/v26.8.1...v26.8.2) (2024-08-27) + + +### Bug Fixes + +* add AO TYPE for event chart and event report ([#1697](https://github.com/dhis2/analytics/issues/1697)) ([efff1c8](https://github.com/dhis2/analytics/commit/efff1c81845a974fe8c60b593e6bbe42c19682d7)) + ## [26.8.1](https://github.com/dhis2/analytics/compare/v26.8.0...v26.8.1) (2024-08-08) diff --git a/package.json b/package.json index ab86e2261..dcbaffe99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dhis2/analytics", - "version": "26.8.1", + "version": "26.8.2", "main": "./build/cjs/index.js", "module": "./build/es/index.js", "exports": { From 3392d783b51dd8715beb09b673e567580005a0a2 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Tue, 27 Aug 2024 15:12:31 +0200 Subject: [PATCH 3/3] fix: compute subtotals/totals for boolean types (DHIS2-9155) (#1696) Use 2 decimals as default This is to align with the recent change in the backend where values are returned with 2 decimals by default. --- src/modules/__tests__/renderValue.spec.js | 20 ++++++++++---------- src/modules/pivotTable/PivotTableEngine.js | 17 +++++++++++++++-- src/modules/renderValue.js | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/modules/__tests__/renderValue.spec.js b/src/modules/__tests__/renderValue.spec.js index 845629bbe..eaf3d2a7c 100644 --- a/src/modules/__tests__/renderValue.spec.js +++ b/src/modules/__tests__/renderValue.spec.js @@ -25,21 +25,21 @@ const tests = [ // Numbers { value: 1000.5, - expected: '1 000.5', + expected: '1 000.50', valueType: VALUE_TYPE_NUMBER, round: true, dgs: DGS_SPACE, }, { - value: 33777889.55, - expected: '33,777,889.5', + value: 33777889.555, + expected: '33,777,889.55', valueType: VALUE_TYPE_NUMBER, round: true, dgs: DGS_COMMA, }, { value: 33777889.556, - expected: '33 777 889.6', + expected: '33 777 889.56', valueType: VALUE_TYPE_NUMBER, round: true, dgs: DGS_SPACE, @@ -53,7 +53,7 @@ const tests = [ }, { value: 33777889.56, - expected: '33777889.6', + expected: '33777889.56', valueType: VALUE_TYPE_NUMBER, round: true, dgs: DGS_NONE, @@ -74,7 +74,7 @@ const tests = [ }, { value: 1.101, - expected: '1.1', + expected: '1.10', valueType: VALUE_TYPE_NUMBER, round: true, dgs: DGS_SPACE, @@ -135,16 +135,16 @@ const tests = [ dgs: DGS_SPACE, }, { - value: -0.0234, - expected: '-2.3%', + value: -0.02345, + expected: '-2.34%', valueType: VALUE_TYPE_NUMBER, numberType: NUMBER_TYPE_ROW_PERCENTAGE, round: true, dgs: DGS_SPACE, }, { - value: -0.0234, - expected: '-2.34%', + value: -0.02345, + expected: '-2.345%', valueType: VALUE_TYPE_NUMBER, numberType: NUMBER_TYPE_ROW_PERCENTAGE, round: false, diff --git a/src/modules/pivotTable/PivotTableEngine.js b/src/modules/pivotTable/PivotTableEngine.js index 7b90e0935..6d16a8985 100644 --- a/src/modules/pivotTable/PivotTableEngine.js +++ b/src/modules/pivotTable/PivotTableEngine.js @@ -8,7 +8,12 @@ import { } from '../dataTypes.js' import { DIMENSION_ID_ORGUNIT } from '../predefinedDimensions.js' import { renderValue } from '../renderValue.js' -import { VALUE_TYPE_NUMBER, VALUE_TYPE_TEXT } from '../valueTypes.js' +import { + VALUE_TYPE_NUMBER, + VALUE_TYPE_TEXT, + isBooleanValueType, + isNumericValueType, +} from '../valueTypes.js' import { AdaptiveClippingController } from './AdaptiveClippingController.js' import { addToTotalIfNumber } from './addToTotalIfNumber.js' import { parseValue } from './parseValue.js' @@ -744,7 +749,15 @@ export class PivotTableEngine { totalCell.valueType = currentValueType } - if (dxDimension?.valueType === VALUE_TYPE_NUMBER) { + // compute subtotals and totals for all numeric and boolean value types + // in that case, force value type of subtotal and total cells to NUMBER to format them correctly + // (see DHIS2-9155) + if ( + isNumericValueType(dxDimension?.valueType) || + isBooleanValueType(dxDimension?.valueType) + ) { + totalCell.valueType = VALUE_TYPE_NUMBER + dataFields.forEach((field) => { const headerIndex = this.dimensionLookup.dataHeaders[field] const value = parseValue(dataRow[headerIndex]) diff --git a/src/modules/renderValue.js b/src/modules/renderValue.js index 5e87629f1..9c2f1c763 100644 --- a/src/modules/renderValue.js +++ b/src/modules/renderValue.js @@ -47,7 +47,7 @@ const toFixedPrecisionString = (value, skipRounding) => { return value } - const precision = skipRounding ? 10 : value > -1 && value < 1 ? 2 : 1 + const precision = skipRounding ? 10 : 2 return value.toFixed(precision) }