@dhis2/analytics 24.10.12 → 24.10.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [24.10.13](https://github.com/dhis2/analytics/compare/v24.10.12...v24.10.13) (2024-06-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * apply legend to all numeric and boolean types (DHIS2-17611) [24.x] ([#1687](https://github.com/dhis2/analytics/issues/1687)) ([9e3f166](https://github.com/dhis2/analytics/commit/9e3f1668aaef693393e5a7a46dc839f9aad5bce5))
7
+
1
8
  ## [24.10.12](https://github.com/dhis2/analytics/compare/v24.10.11...v24.10.12) (2024-06-25)
2
9
 
3
10
 
@@ -56,10 +56,9 @@ const PivotTableValueCell = _ref => {
56
56
  ref: cellRef,
57
57
  classes: [cellContent.cellType, isClickable && 'clickable']
58
58
  });
59
- } // TODO: Add support for 'INTEGER' type (requires server changes)
59
+ }
60
60
 
61
-
62
- const legendStyle = cellContent.cellType === _pivotTableConstants.CELL_TYPE_VALUE && cellContent.valueType === _valueTypes.VALUE_TYPE_NUMBER ? (0, _applyLegendSet.applyLegendSet)(cellContent.rawValue, cellContent.dxDimension, engine) : undefined;
61
+ const legendStyle = cellContent.cellType === _pivotTableConstants.CELL_TYPE_VALUE && ((0, _valueTypes.isNumericValueType)(cellContent.valueType) || (0, _valueTypes.isBooleanValueType)(cellContent.valueType)) ? (0, _applyLegendSet.applyLegendSet)(cellContent.rawValue, cellContent.dxDimension, engine) : undefined;
63
62
  const width = engine.adaptiveClippingController.columns.sizes[engine.columnMap[column]].size;
64
63
  const height = engine.adaptiveClippingController.rows.sizes[engine.rowMap[row]].size;
65
64
  const style = { ...legendStyle,
@@ -63,7 +63,7 @@ const toFixedPrecisionString = (value, skipRounding) => {
63
63
  };
64
64
 
65
65
  const renderValue = (value, valueType, visualization) => {
66
- if (!(0, _valueTypes.isNumericValueType)(valueType) || value === undefined) {
66
+ if (!((0, _valueTypes.isNumericValueType)(valueType) || (0, _valueTypes.isBooleanValueType)(valueType)) || value === undefined) {
67
67
  return String(value).replace(/[^\S\n]+/, ' ');
68
68
  }
69
69
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isNumericValueType = exports.VALUE_TYPE_USERNAME = exports.VALUE_TYPE_URL = exports.VALUE_TYPE_UNIT_INTERVAL = exports.VALUE_TYPE_TRUE_ONLY = exports.VALUE_TYPE_TIME = exports.VALUE_TYPE_TEXT = exports.VALUE_TYPE_PHONE_NUMBER = exports.VALUE_TYPE_PERCENTAGE = exports.VALUE_TYPE_ORGANISATION_UNIT = exports.VALUE_TYPE_NUMBER = exports.VALUE_TYPE_LONG_TEXT = exports.VALUE_TYPE_LETTER = exports.VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE = exports.VALUE_TYPE_INTEGER_POSITIVE = exports.VALUE_TYPE_INTEGER_NEGATIVE = exports.VALUE_TYPE_INTEGER = exports.VALUE_TYPE_EMAIL = exports.VALUE_TYPE_DATETIME = exports.VALUE_TYPE_DATE = exports.VALUE_TYPE_BOOLEAN = exports.VALUE_TYPE_AGE = void 0;
6
+ exports.isNumericValueType = exports.isBooleanValueType = exports.VALUE_TYPE_USERNAME = exports.VALUE_TYPE_URL = exports.VALUE_TYPE_UNIT_INTERVAL = exports.VALUE_TYPE_TRUE_ONLY = exports.VALUE_TYPE_TIME = exports.VALUE_TYPE_TEXT = exports.VALUE_TYPE_PHONE_NUMBER = exports.VALUE_TYPE_PERCENTAGE = exports.VALUE_TYPE_ORGANISATION_UNIT = exports.VALUE_TYPE_NUMBER = exports.VALUE_TYPE_LONG_TEXT = exports.VALUE_TYPE_LETTER = exports.VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE = exports.VALUE_TYPE_INTEGER_POSITIVE = exports.VALUE_TYPE_INTEGER_NEGATIVE = exports.VALUE_TYPE_INTEGER = exports.VALUE_TYPE_EMAIL = exports.VALUE_TYPE_DATETIME = exports.VALUE_TYPE_DATE = exports.VALUE_TYPE_BOOLEAN = exports.VALUE_TYPE_AGE = void 0;
7
7
 
8
8
  /* These types match the types in the backend
9
9
  https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java
@@ -51,7 +51,12 @@ exports.VALUE_TYPE_ORGANISATION_UNIT = VALUE_TYPE_ORGANISATION_UNIT;
51
51
  const VALUE_TYPE_AGE = 'AGE';
52
52
  exports.VALUE_TYPE_AGE = VALUE_TYPE_AGE;
53
53
  const NUMERIC_VALUE_TYPES = [VALUE_TYPE_NUMBER, VALUE_TYPE_UNIT_INTERVAL, VALUE_TYPE_PERCENTAGE, VALUE_TYPE_INTEGER, VALUE_TYPE_INTEGER_POSITIVE, VALUE_TYPE_INTEGER_NEGATIVE, VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE];
54
+ const BOOLEAN_VALUE_TYPES = [VALUE_TYPE_BOOLEAN, VALUE_TYPE_TRUE_ONLY];
54
55
 
55
56
  const isNumericValueType = type => NUMERIC_VALUE_TYPES.includes(type);
56
57
 
57
- exports.isNumericValueType = isNumericValueType;
58
+ exports.isNumericValueType = isNumericValueType;
59
+
60
+ const isBooleanValueType = type => BOOLEAN_VALUE_TYPES.includes(type);
61
+
62
+ exports.isBooleanValueType = isBooleanValueType;
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
2
2
  import React, { useRef } from 'react';
3
3
  import { applyLegendSet } from '../../modules/pivotTable/applyLegendSet.js';
4
4
  import { CELL_TYPE_VALUE } from '../../modules/pivotTable/pivotTableConstants.js';
5
- import { VALUE_TYPE_NUMBER } from '../../modules/valueTypes.js';
5
+ import { isNumericValueType, isBooleanValueType } from '../../modules/valueTypes.js';
6
6
  import { PivotTableCell } from './PivotTableCell.js';
7
7
  import { PivotTableEmptyCell } from './PivotTableEmptyCell.js';
8
8
  import { usePivotTableEngine } from './PivotTableEngineContext.js';
@@ -35,10 +35,9 @@ export const PivotTableValueCell = _ref => {
35
35
  ref: cellRef,
36
36
  classes: [cellContent.cellType, isClickable && 'clickable']
37
37
  });
38
- } // TODO: Add support for 'INTEGER' type (requires server changes)
38
+ }
39
39
 
40
-
41
- const legendStyle = cellContent.cellType === CELL_TYPE_VALUE && cellContent.valueType === VALUE_TYPE_NUMBER ? applyLegendSet(cellContent.rawValue, cellContent.dxDimension, engine) : undefined;
40
+ const legendStyle = cellContent.cellType === CELL_TYPE_VALUE && (isNumericValueType(cellContent.valueType) || isBooleanValueType(cellContent.valueType)) ? applyLegendSet(cellContent.rawValue, cellContent.dxDimension, engine) : undefined;
42
41
  const width = engine.adaptiveClippingController.columns.sizes[engine.columnMap[column]].size;
43
42
  const height = engine.adaptiveClippingController.rows.sizes[engine.rowMap[row]].size;
44
43
  const style = { ...legendStyle,
@@ -1,5 +1,5 @@
1
1
  import { NUMBER_TYPE_ROW_PERCENTAGE, NUMBER_TYPE_COLUMN_PERCENTAGE } from './pivotTable/pivotTableConstants.js';
2
- import { isNumericValueType } from './valueTypes.js';
2
+ import { isNumericValueType, isBooleanValueType } from './valueTypes.js';
3
3
 
4
4
  const trimTrailingZeros = stringValue => stringValue.replace(/\.?0+$/, '');
5
5
 
@@ -53,7 +53,7 @@ const toFixedPrecisionString = (value, skipRounding) => {
53
53
  };
54
54
 
55
55
  export const renderValue = (value, valueType, visualization) => {
56
- if (!isNumericValueType(valueType) || value === undefined) {
56
+ if (!(isNumericValueType(valueType) || isBooleanValueType(valueType)) || value === undefined) {
57
57
  return String(value).replace(/[^\S\n]+/, ' ');
58
58
  }
59
59
 
@@ -23,4 +23,6 @@ export const VALUE_TYPE_DATETIME = 'DATETIME';
23
23
  export const VALUE_TYPE_ORGANISATION_UNIT = 'ORGANISATION_UNIT';
24
24
  export const VALUE_TYPE_AGE = 'AGE';
25
25
  const NUMERIC_VALUE_TYPES = [VALUE_TYPE_NUMBER, VALUE_TYPE_UNIT_INTERVAL, VALUE_TYPE_PERCENTAGE, VALUE_TYPE_INTEGER, VALUE_TYPE_INTEGER_POSITIVE, VALUE_TYPE_INTEGER_NEGATIVE, VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE];
26
- export const isNumericValueType = type => NUMERIC_VALUE_TYPES.includes(type);
26
+ const BOOLEAN_VALUE_TYPES = [VALUE_TYPE_BOOLEAN, VALUE_TYPE_TRUE_ONLY];
27
+ export const isNumericValueType = type => NUMERIC_VALUE_TYPES.includes(type);
28
+ export const isBooleanValueType = type => BOOLEAN_VALUE_TYPES.includes(type);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2/analytics",
3
- "version": "24.10.12",
3
+ "version": "24.10.13",
4
4
  "main": "./build/cjs/index.js",
5
5
  "module": "./build/es/index.js",
6
6
  "exports": {