@dhis2/analytics 26.7.5 → 26.7.7

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.
@@ -42,9 +42,7 @@ const PivotTableValueCell = _ref => {
42
42
  classes: [cellContent.cellType, isClickable && 'clickable']
43
43
  });
44
44
  }
45
-
46
- // TODO: Add support for 'INTEGER' type (requires server changes)
47
- const legendStyle = cellContent.cellType === _pivotTableConstants.CELL_TYPE_VALUE && cellContent.valueType === _valueTypes.VALUE_TYPE_NUMBER ? (0, _applyLegendSet.applyLegendSet)(cellContent.rawValue, cellContent.dxDimension, engine) : undefined;
45
+ 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;
48
46
  const width = engine.adaptiveClippingController.columns.sizes[engine.columnMap[column]].size;
49
47
  const height = engine.adaptiveClippingController.rows.sizes[engine.rowMap[row]].size;
50
48
  const style = {
@@ -47,7 +47,7 @@ const toFixedPrecisionString = (value, skipRounding) => {
47
47
  return value.toFixed(precision);
48
48
  };
49
49
  const renderValue = (value, valueType, visualization) => {
50
- if (!(0, _valueTypes.isNumericValueType)(valueType) || value === undefined) {
50
+ if (!((0, _valueTypes.isNumericValueType)(valueType) || (0, _valueTypes.isBooleanValueType)(valueType)) || value === undefined) {
51
51
  return String(value).replace(/[^\S\n]+/, ' ');
52
52
  }
53
53
  if (visualization.numberType === _pivotTableConstants.NUMBER_TYPE_ROW_PERCENTAGE || visualization.numberType === _pivotTableConstants.NUMBER_TYPE_COLUMN_PERCENTAGE) {
@@ -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
  /* These types match the types in the backend
8
8
  https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java
9
9
  */
@@ -51,5 +51,8 @@ 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
  const isNumericValueType = type => NUMERIC_VALUE_TYPES.includes(type);
55
- exports.isNumericValueType = isNumericValueType;
56
+ exports.isNumericValueType = isNumericValueType;
57
+ const isBooleanValueType = type => BOOLEAN_VALUE_TYPES.includes(type);
58
+ 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';
@@ -33,9 +33,7 @@ export const PivotTableValueCell = _ref => {
33
33
  classes: [cellContent.cellType, isClickable && 'clickable']
34
34
  });
35
35
  }
36
-
37
- // TODO: Add support for 'INTEGER' type (requires server changes)
38
- const legendStyle = cellContent.cellType === CELL_TYPE_VALUE && cellContent.valueType === VALUE_TYPE_NUMBER ? applyLegendSet(cellContent.rawValue, cellContent.dxDimension, engine) : undefined;
36
+ const legendStyle = cellContent.cellType === CELL_TYPE_VALUE && (isNumericValueType(cellContent.valueType) || isBooleanValueType(cellContent.valueType)) ? applyLegendSet(cellContent.rawValue, cellContent.dxDimension, engine) : undefined;
39
37
  const width = engine.adaptiveClippingController.columns.sizes[engine.columnMap[column]].size;
40
38
  const height = engine.adaptiveClippingController.rows.sizes[engine.rowMap[row]].size;
41
39
  const style = {
@@ -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
  const trimTrailingZeros = stringValue => stringValue.replace(/\.?0+$/, '');
4
4
  export const separateDigitGroups = function (stringValue) {
5
5
  let decimalSeparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.';
@@ -40,7 +40,7 @@ const toFixedPrecisionString = (value, skipRounding) => {
40
40
  return value.toFixed(precision);
41
41
  };
42
42
  export const renderValue = (value, valueType, visualization) => {
43
- if (!isNumericValueType(valueType) || value === undefined) {
43
+ if (!(isNumericValueType(valueType) || isBooleanValueType(valueType)) || value === undefined) {
44
44
  return String(value).replace(/[^\S\n]+/, ' ');
45
45
  }
46
46
  if (visualization.numberType === NUMBER_TYPE_ROW_PERCENTAGE || visualization.numberType === NUMBER_TYPE_COLUMN_PERCENTAGE) {
@@ -24,4 +24,6 @@ export const VALUE_TYPE_DATETIME = 'DATETIME';
24
24
  export const VALUE_TYPE_ORGANISATION_UNIT = 'ORGANISATION_UNIT';
25
25
  export const VALUE_TYPE_AGE = 'AGE';
26
26
  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];
27
- export const isNumericValueType = type => NUMERIC_VALUE_TYPES.includes(type);
27
+ const BOOLEAN_VALUE_TYPES = [VALUE_TYPE_BOOLEAN, VALUE_TYPE_TRUE_ONLY];
28
+ export const isNumericValueType = type => NUMERIC_VALUE_TYPES.includes(type);
29
+ 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": "26.7.5",
3
+ "version": "26.7.7",
4
4
  "main": "./build/cjs/index.js",
5
5
  "module": "./build/es/index.js",
6
6
  "exports": {