@dhis2/analytics 26.9.5 → 26.10.0

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.
Files changed (59) hide show
  1. package/build/cjs/__demo__/DataDimension.stories.js +53 -0
  2. package/build/cjs/api/dimensions.js +1 -1
  3. package/build/cjs/api/expression.js +20 -10
  4. package/build/cjs/components/DataDimension/Calculation/CalculationModal.js +1 -1
  5. package/build/cjs/components/DataDimension/DataDimension.js +4 -1
  6. package/build/cjs/components/DataDimension/Info/CalculationInfo.js +106 -0
  7. package/build/cjs/components/DataDimension/Info/DataElementInfo.js +135 -0
  8. package/build/cjs/components/DataDimension/Info/DataElementOperandInfo.js +188 -0
  9. package/build/cjs/components/DataDimension/Info/DataSetInfo.js +115 -0
  10. package/build/cjs/components/DataDimension/Info/EventDataItemInfo.js +111 -0
  11. package/build/cjs/components/DataDimension/Info/IndicatorInfo.js +179 -0
  12. package/build/cjs/components/DataDimension/Info/InfoPopover.js +58 -0
  13. package/build/cjs/components/DataDimension/Info/InfoTable.js +219 -0
  14. package/build/cjs/components/DataDimension/Info/ProgramIndicatorInfo.js +191 -0
  15. package/build/cjs/components/DataDimension/Info/styles/InfoPopover.style.js +10 -0
  16. package/build/cjs/components/DataDimension/ItemSelector.js +22 -5
  17. package/build/cjs/components/DataDimension/TransferOption.js +117 -0
  18. package/build/cjs/components/DataDimension/styles/TransferOption.style.js +10 -0
  19. package/build/cjs/components/DimensionsPanel/List/__tests__/__snapshots__/DimensionItem.spec.js.snap +0 -20
  20. package/build/cjs/components/OrgUnitDimension/__tests__/__snapshots__/OrgUnitDimension.spec.js.snap +0 -5
  21. package/build/cjs/components/PeriodDimension/__tests__/__snapshots__/FixedPeriodSingleSelect.spec.js.snap +0 -12
  22. package/build/cjs/components/PeriodDimension/__tests__/__snapshots__/PeriodSelector.spec.js.snap +3 -10
  23. package/build/cjs/components/styles/DimensionSelector.style.js +2 -2
  24. package/build/cjs/index.js +66 -10
  25. package/build/cjs/locales/en/translations.json +73 -9
  26. package/build/cjs/locales/vi/translations.json +202 -202
  27. package/build/cjs/modules/dimensionListItem.js +3 -3
  28. package/build/cjs/modules/dimensionSelectorHelper.js +2 -2
  29. package/build/cjs/modules/valueTypes.js +50 -11
  30. package/build/es/__demo__/DataDimension.stories.js +42 -0
  31. package/build/es/api/dimensions.js +1 -1
  32. package/build/es/api/expression.js +19 -9
  33. package/build/es/components/DataDimension/Calculation/CalculationModal.js +2 -2
  34. package/build/es/components/DataDimension/DataDimension.js +4 -1
  35. package/build/es/components/DataDimension/Info/CalculationInfo.js +96 -0
  36. package/build/es/components/DataDimension/Info/DataElementInfo.js +127 -0
  37. package/build/es/components/DataDimension/Info/DataElementOperandInfo.js +178 -0
  38. package/build/es/components/DataDimension/Info/DataSetInfo.js +107 -0
  39. package/build/es/components/DataDimension/Info/EventDataItemInfo.js +103 -0
  40. package/build/es/components/DataDimension/Info/IndicatorInfo.js +169 -0
  41. package/build/es/components/DataDimension/Info/InfoPopover.js +54 -0
  42. package/build/es/components/DataDimension/Info/InfoTable.js +205 -0
  43. package/build/es/components/DataDimension/Info/ProgramIndicatorInfo.js +181 -0
  44. package/build/es/components/DataDimension/Info/styles/InfoPopover.style.js +4 -0
  45. package/build/es/components/DataDimension/ItemSelector.js +24 -7
  46. package/build/es/components/DataDimension/TransferOption.js +109 -0
  47. package/build/es/components/DataDimension/styles/TransferOption.style.js +4 -0
  48. package/build/es/components/DimensionsPanel/List/__tests__/__snapshots__/DimensionItem.spec.js.snap +0 -20
  49. package/build/es/components/OrgUnitDimension/__tests__/__snapshots__/OrgUnitDimension.spec.js.snap +0 -5
  50. package/build/es/components/PeriodDimension/__tests__/__snapshots__/FixedPeriodSingleSelect.spec.js.snap +0 -12
  51. package/build/es/components/PeriodDimension/__tests__/__snapshots__/PeriodSelector.spec.js.snap +3 -10
  52. package/build/es/components/styles/DimensionSelector.style.js +2 -2
  53. package/build/es/index.js +1 -1
  54. package/build/es/locales/en/translations.json +73 -9
  55. package/build/es/locales/vi/translations.json +202 -202
  56. package/build/es/modules/dimensionListItem.js +1 -1
  57. package/build/es/modules/dimensionSelectorHelper.js +2 -2
  58. package/build/es/modules/valueTypes.js +48 -10
  59. package/package.json +5 -5
@@ -3,32 +3,71 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isNumericValueType = exports.isCumulativeValueType = 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;
6
+ exports.valueTypeDisplayNames = exports.isNumericValueType = exports.isCumulativeValueType = exports.isBooleanValueType = exports.VALUE_TYPE_USERNAME = exports.VALUE_TYPE_URL = exports.VALUE_TYPE_UNIT_INTERVAL = exports.VALUE_TYPE_TRUE_ONLY = exports.VALUE_TYPE_TRACKER_ASSOCIATE = exports.VALUE_TYPE_TIME = exports.VALUE_TYPE_TEXT = exports.VALUE_TYPE_REFERENCE = exports.VALUE_TYPE_PHONE_NUMBER = exports.VALUE_TYPE_PERCENTAGE = exports.VALUE_TYPE_ORGANISATION_UNIT = exports.VALUE_TYPE_NUMBER = exports.VALUE_TYPE_MULTI_TEXT = 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_IMAGE = exports.VALUE_TYPE_GEOJSON = exports.VALUE_TYPE_FILE_RESOURCE = exports.VALUE_TYPE_EMAIL = exports.VALUE_TYPE_DATETIME = exports.VALUE_TYPE_DATE = exports.VALUE_TYPE_COORDINATE = exports.VALUE_TYPE_BOOLEAN = exports.VALUE_TYPE_AGE = void 0;
7
+ var _index = _interopRequireDefault(require("../locales/index.js"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
9
  /* These types match the types in the backend
8
10
  https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java
9
11
  */
10
12
 
11
- const VALUE_TYPE_NUMBER = exports.VALUE_TYPE_NUMBER = 'NUMBER';
12
- const VALUE_TYPE_UNIT_INTERVAL = exports.VALUE_TYPE_UNIT_INTERVAL = 'UNIT_INTERVAL';
13
- const VALUE_TYPE_PERCENTAGE = exports.VALUE_TYPE_PERCENTAGE = 'PERCENTAGE';
14
- const VALUE_TYPE_INTEGER = exports.VALUE_TYPE_INTEGER = 'INTEGER';
15
- const VALUE_TYPE_INTEGER_POSITIVE = exports.VALUE_TYPE_INTEGER_POSITIVE = 'INTEGER_POSITIVE';
16
- const VALUE_TYPE_INTEGER_NEGATIVE = exports.VALUE_TYPE_INTEGER_NEGATIVE = 'INTEGER_NEGATIVE';
17
- const VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE = exports.VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE = 'INTEGER_ZERO_OR_POSITIVE';
18
13
  const VALUE_TYPE_TEXT = exports.VALUE_TYPE_TEXT = 'TEXT';
19
14
  const VALUE_TYPE_LONG_TEXT = exports.VALUE_TYPE_LONG_TEXT = 'LONG_TEXT';
15
+ const VALUE_TYPE_MULTI_TEXT = exports.VALUE_TYPE_MULTI_TEXT = 'MULTI_TEXT';
20
16
  const VALUE_TYPE_LETTER = exports.VALUE_TYPE_LETTER = 'LETTER';
21
17
  const VALUE_TYPE_PHONE_NUMBER = exports.VALUE_TYPE_PHONE_NUMBER = 'PHONE_NUMBER';
22
18
  const VALUE_TYPE_EMAIL = exports.VALUE_TYPE_EMAIL = 'EMAIL';
23
- const VALUE_TYPE_USERNAME = exports.VALUE_TYPE_USERNAME = 'USERNAME';
24
- const VALUE_TYPE_URL = exports.VALUE_TYPE_URL = 'URL';
25
19
  const VALUE_TYPE_BOOLEAN = exports.VALUE_TYPE_BOOLEAN = 'BOOLEAN';
26
20
  const VALUE_TYPE_TRUE_ONLY = exports.VALUE_TYPE_TRUE_ONLY = 'TRUE_ONLY';
27
21
  const VALUE_TYPE_DATE = exports.VALUE_TYPE_DATE = 'DATE';
28
- const VALUE_TYPE_TIME = exports.VALUE_TYPE_TIME = 'TIME';
29
22
  const VALUE_TYPE_DATETIME = exports.VALUE_TYPE_DATETIME = 'DATETIME';
23
+ const VALUE_TYPE_TIME = exports.VALUE_TYPE_TIME = 'TIME';
24
+ const VALUE_TYPE_NUMBER = exports.VALUE_TYPE_NUMBER = 'NUMBER';
25
+ const VALUE_TYPE_UNIT_INTERVAL = exports.VALUE_TYPE_UNIT_INTERVAL = 'UNIT_INTERVAL';
26
+ const VALUE_TYPE_PERCENTAGE = exports.VALUE_TYPE_PERCENTAGE = 'PERCENTAGE';
27
+ const VALUE_TYPE_INTEGER = exports.VALUE_TYPE_INTEGER = 'INTEGER';
28
+ const VALUE_TYPE_INTEGER_POSITIVE = exports.VALUE_TYPE_INTEGER_POSITIVE = 'INTEGER_POSITIVE';
29
+ const VALUE_TYPE_INTEGER_NEGATIVE = exports.VALUE_TYPE_INTEGER_NEGATIVE = 'INTEGER_NEGATIVE';
30
+ const VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE = exports.VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE = 'INTEGER_ZERO_OR_POSITIVE';
31
+ const VALUE_TYPE_TRACKER_ASSOCIATE = exports.VALUE_TYPE_TRACKER_ASSOCIATE = 'TRACKER_ASSOCIATE';
32
+ const VALUE_TYPE_USERNAME = exports.VALUE_TYPE_USERNAME = 'USERNAME';
33
+ const VALUE_TYPE_COORDINATE = exports.VALUE_TYPE_COORDINATE = 'COORDINATE';
30
34
  const VALUE_TYPE_ORGANISATION_UNIT = exports.VALUE_TYPE_ORGANISATION_UNIT = 'ORGANISATION_UNIT';
35
+ const VALUE_TYPE_REFERENCE = exports.VALUE_TYPE_REFERENCE = 'REFERENCE';
31
36
  const VALUE_TYPE_AGE = exports.VALUE_TYPE_AGE = 'AGE';
37
+ const VALUE_TYPE_URL = exports.VALUE_TYPE_URL = 'URL';
38
+ const VALUE_TYPE_FILE_RESOURCE = exports.VALUE_TYPE_FILE_RESOURCE = 'FILE_RESOURCE';
39
+ const VALUE_TYPE_IMAGE = exports.VALUE_TYPE_IMAGE = 'IMAGE';
40
+ const VALUE_TYPE_GEOJSON = exports.VALUE_TYPE_GEOJSON = 'GEOJSON';
41
+ const valueTypeDisplayNames = exports.valueTypeDisplayNames = {
42
+ [VALUE_TYPE_TEXT]: _index.default.t('Text'),
43
+ [VALUE_TYPE_LONG_TEXT]: _index.default.t('Long text'),
44
+ [VALUE_TYPE_MULTI_TEXT]: _index.default.t('Multi text'),
45
+ [VALUE_TYPE_LETTER]: _index.default.t('Letter'),
46
+ [VALUE_TYPE_PHONE_NUMBER]: _index.default.t('Phone number'),
47
+ [VALUE_TYPE_EMAIL]: _index.default.t('Email'),
48
+ [VALUE_TYPE_BOOLEAN]: _index.default.t('Yes/No'),
49
+ [VALUE_TYPE_TRUE_ONLY]: _index.default.t('Yes Only'),
50
+ [VALUE_TYPE_DATE]: _index.default.t('Date'),
51
+ [VALUE_TYPE_DATETIME]: _index.default.t('Date & Time'),
52
+ [VALUE_TYPE_TIME]: _index.default.t('Time'),
53
+ [VALUE_TYPE_NUMBER]: _index.default.t('Number'),
54
+ [VALUE_TYPE_UNIT_INTERVAL]: _index.default.t('Unit interval'),
55
+ [VALUE_TYPE_PERCENTAGE]: _index.default.t('Percentage'),
56
+ [VALUE_TYPE_INTEGER]: _index.default.t('Integer'),
57
+ [VALUE_TYPE_INTEGER_POSITIVE]: _index.default.t('Positive Integer'),
58
+ [VALUE_TYPE_INTEGER_NEGATIVE]: _index.default.t('Negative Integer'),
59
+ [VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE]: _index.default.t('Positive or Zero Integer'),
60
+ [VALUE_TYPE_TRACKER_ASSOCIATE]: _index.default.t('Tracker Associate'),
61
+ [VALUE_TYPE_USERNAME]: _index.default.t('Username'),
62
+ [VALUE_TYPE_COORDINATE]: _index.default.t('Coordinate'),
63
+ [VALUE_TYPE_ORGANISATION_UNIT]: _index.default.t('Organisation unit'),
64
+ [VALUE_TYPE_REFERENCE]: _index.default.t('Reference'),
65
+ [VALUE_TYPE_AGE]: _index.default.t('Age'),
66
+ [VALUE_TYPE_URL]: _index.default.t('URL'),
67
+ [VALUE_TYPE_FILE_RESOURCE]: _index.default.t('File'),
68
+ [VALUE_TYPE_IMAGE]: _index.default.t('Image'),
69
+ [VALUE_TYPE_GEOJSON]: _index.default.t('GeoJSON')
70
+ };
32
71
  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];
33
72
  const BOOLEAN_VALUE_TYPES = [VALUE_TYPE_BOOLEAN, VALUE_TYPE_TRUE_ONLY];
34
73
  const CUMULATIVE_VALUE_TYPES = [VALUE_TYPE_NUMBER, VALUE_TYPE_INTEGER, VALUE_TYPE_INTEGER_POSITIVE, VALUE_TYPE_INTEGER_NEGATIVE, VALUE_TYPE_INTEGER_ZERO_OR_POSITIVE, ...BOOLEAN_VALUE_TYPES];
@@ -0,0 +1,42 @@
1
+ import { DataProvider } from '@dhis2/app-runtime';
2
+ import { ConfigProvider } from '@dhis2/app-service-config';
3
+ import React, { useState } from 'react';
4
+ import DataDimension from '../components/DataDimension/DataDimension.js';
5
+ const Wrapper = story => /*#__PURE__*/React.createElement(ConfigProvider, {
6
+ config: {
7
+ serverVersion: {
8
+ major: 2,
9
+ minor: 41
10
+ }
11
+ }
12
+ }, /*#__PURE__*/React.createElement(DataProvider, {
13
+ baseUrl: "https://test.e2e.dhis2.org/analytics-41dev",
14
+ apiVersion: "41"
15
+ }, story()));
16
+ export default {
17
+ title: 'DataDimension',
18
+ decorators: [Wrapper]
19
+ };
20
+ export const NoneSelected = () => {
21
+ const [selected, setSelected] = useState([]);
22
+ return /*#__PURE__*/React.createElement(DataDimension, {
23
+ displayNameProp: "displayName",
24
+ selectedDimensions: selected,
25
+ onSelect: response => setSelected(response.items)
26
+ });
27
+ };
28
+ NoneSelected.story = {
29
+ name: 'None selected'
30
+ };
31
+ export const WithInfoBoxMessage = () => {
32
+ const [selected, setSelected] = useState([]);
33
+ return /*#__PURE__*/React.createElement(DataDimension, {
34
+ displayNameProp: "displayName",
35
+ selectedDimensions: selected,
36
+ onSelect: response => setSelected(response.items),
37
+ infoBoxMessage: 'Test message showing in the info box'
38
+ });
39
+ };
40
+ WithInfoBoxMessage.story = {
41
+ name: 'With info box message'
42
+ };
@@ -182,7 +182,7 @@ export const dataElementOperandsQuery = {
182
182
  page
183
183
  } = _ref10;
184
184
  const idField = (filter === null || filter === void 0 ? void 0 : filter.group) === DIMENSION_TYPE_ALL ? 'id' : 'dimensionItem~rename(id)';
185
- const filters = [];
185
+ const filters = ['categoryOptionCombo.name:ne:default'];
186
186
  if (filter !== null && filter !== void 0 && filter.group && filter.group !== DIMENSION_TYPE_ALL) {
187
187
  filters.push(`dataElement.dataElementGroups.id:eq:${filter.group}`);
188
188
  }
@@ -1,4 +1,4 @@
1
- export const validateExpressionMutation = {
1
+ export const validateIndicatorExpressionMutation = {
2
2
  type: 'create',
3
3
  resource: 'indicators/expression/description',
4
4
  data: _ref => {
@@ -8,14 +8,24 @@ export const validateExpressionMutation = {
8
8
  return expression;
9
9
  }
10
10
  };
11
+ export const validateProgramIndicatorExpressionMutation = {
12
+ type: 'create',
13
+ resource: 'programIndicators/expression/description',
14
+ data: _ref2 => {
15
+ let {
16
+ expression
17
+ } = _ref2;
18
+ return expression;
19
+ }
20
+ };
11
21
  export const createCalculationMutation = {
12
22
  type: 'create',
13
23
  resource: 'expressionDimensionItems',
14
- data: _ref2 => {
24
+ data: _ref3 => {
15
25
  let {
16
26
  name,
17
27
  expression
18
- } = _ref2;
28
+ } = _ref3;
19
29
  return {
20
30
  name,
21
31
  shortName: name,
@@ -26,17 +36,17 @@ export const createCalculationMutation = {
26
36
  export const updateCalculationMutation = {
27
37
  type: 'json-patch',
28
38
  resource: 'expressionDimensionItems',
29
- id: _ref3 => {
39
+ id: _ref4 => {
30
40
  let {
31
41
  id
32
- } = _ref3;
42
+ } = _ref4;
33
43
  return id;
34
44
  },
35
- data: _ref4 => {
45
+ data: _ref5 => {
36
46
  let {
37
47
  name,
38
48
  expression
39
- } = _ref4;
49
+ } = _ref5;
40
50
  return [{
41
51
  op: 'add',
42
52
  path: '/name',
@@ -55,10 +65,10 @@ export const updateCalculationMutation = {
55
65
  export const deleteCalculationMutation = {
56
66
  type: 'delete',
57
67
  resource: 'expressionDimensionItems',
58
- id: _ref5 => {
68
+ id: _ref6 => {
59
69
  let {
60
70
  id
61
- } = _ref5;
71
+ } = _ref6;
62
72
  return id;
63
73
  }
64
74
  };
@@ -4,7 +4,7 @@ import { Button, Modal, ModalTitle, ModalContent, ModalActions, ButtonStrip, Inp
4
4
  import cx from 'classnames';
5
5
  import PropTypes from 'prop-types';
6
6
  import React, { useEffect, useState } from 'react';
7
- import { createCalculationMutation, deleteCalculationMutation, updateCalculationMutation, validateExpressionMutation } from '../../../api/expression.js';
7
+ import { createCalculationMutation, deleteCalculationMutation, updateCalculationMutation, validateIndicatorExpressionMutation } from '../../../api/expression.js';
8
8
  import i18n from '../../../locales/index.js';
9
9
  import { parseExpressionToArray, parseArrayToExpression, validateExpression, EXPRESSION_TYPE_DATA, EXPRESSION_TYPE_NUMBER, INVALID_EXPRESSION, VALID_EXPRESSION, getItemIdsFromExpression } from '../../../modules/expressions.js';
10
10
  import { OfflineTooltip as Tooltip } from '../../OfflineTooltip.js';
@@ -42,7 +42,7 @@ const CalculationModal = _ref => {
42
42
  }] = useDataMutation(deleteCalculationMutation, mutationParams);
43
43
  const [doBackendValidation, {
44
44
  loading: isValidating
45
- }] = useDataMutation(validateExpressionMutation, {
45
+ }] = useDataMutation(validateIndicatorExpressionMutation, {
46
46
  onError: error => showError(error)
47
47
  });
48
48
  const query = {
@@ -7,6 +7,7 @@ import ItemSelector from './ItemSelector.js';
7
7
  const DataDimensionCtx = /*#__PURE__*/createContext({});
8
8
  const DataDimension = _ref => {
9
9
  let {
10
+ currentUser,
10
11
  onSelect,
11
12
  selectedDimensions,
12
13
  displayNameProp,
@@ -40,7 +41,8 @@ const DataDimension = _ref => {
40
41
  useEffect(() => enabledDataTypes && setDataTypes(filterDataTypesByVersion(enabledDataTypes)), [enabledDataTypes, filterDataTypesByVersion]);
41
42
  return /*#__PURE__*/React.createElement(DataDimensionCtx.Provider, {
42
43
  value: {
43
- visType
44
+ visType,
45
+ currentUser
44
46
  }
45
47
  }, /*#__PURE__*/React.createElement(ItemSelector, {
46
48
  selectedItems: selectedDimensions.map(item => ({
@@ -69,6 +71,7 @@ DataDimension.propTypes = {
69
71
  type: PropTypes.string
70
72
  })).isRequired,
71
73
  onSelect: PropTypes.func.isRequired,
74
+ currentUser: PropTypes.object,
72
75
  enabledDataTypes: PropTypes.array,
73
76
  infoBoxMessage: PropTypes.string,
74
77
  visType: PropTypes.string,
@@ -0,0 +1,96 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { useConfig, useDataMutation, useDataEngine } from '@dhis2/app-runtime';
3
+ import PropTypes from 'prop-types';
4
+ import React, { useCallback, useEffect, useState } from 'react';
5
+ import { validateIndicatorExpressionMutation } from '../../../api/expression.js';
6
+ import i18n from '../../../locales/index.js';
7
+ import { getCommonFields, renderHumanReadableExpression, InfoTable } from './InfoTable.js';
8
+ import styles from './styles/InfoPopover.style.js';
9
+ const calculationQuery = {
10
+ calculation: {
11
+ resource: 'expressionDimensionItems',
12
+ id: _ref => {
13
+ let {
14
+ id
15
+ } = _ref;
16
+ return id;
17
+ },
18
+ params: _ref2 => {
19
+ let {
20
+ displayNameProp
21
+ } = _ref2;
22
+ return {
23
+ fields: `${getCommonFields(displayNameProp)},expression`
24
+ };
25
+ }
26
+ }
27
+ };
28
+ export const CalculationInfo = _ref3 => {
29
+ let {
30
+ type,
31
+ id,
32
+ displayNameProp
33
+ } = _ref3;
34
+ const [data, setData] = useState();
35
+ const [error, setError] = useState();
36
+ const [expressionError, setExpressionError] = useState();
37
+ const [loading, setLoading] = useState(true);
38
+ const {
39
+ baseUrl,
40
+ apiVersion
41
+ } = useConfig();
42
+ const engine = useDataEngine();
43
+ const [getHumanReadableExpression] = useDataMutation(validateIndicatorExpressionMutation, {
44
+ onError: setExpressionError
45
+ });
46
+ const fetchData = useCallback(async () => {
47
+ const {
48
+ calculation
49
+ } = await engine.query(calculationQuery, {
50
+ variables: {
51
+ id,
52
+ displayNameProp
53
+ },
54
+ onError: setError
55
+ });
56
+ if (calculation.expression) {
57
+ const result = await getHumanReadableExpression({
58
+ expression: calculation.expression
59
+ });
60
+ if (result) {
61
+ calculation.humanReadableExpression = result;
62
+ }
63
+ }
64
+
65
+ // inject href as it is not returned from the API
66
+ calculation.href = new URL(`${calculationQuery.calculation.resource}/${id}`, new URL(`api/${apiVersion}/`, baseUrl === '..' ? window.location.href.split('dhis-web-data-visualizer/')[0] : `${baseUrl}/`)).href;
67
+ setData({
68
+ calculation
69
+ });
70
+ setLoading(false);
71
+ }, [displayNameProp, engine, getHumanReadableExpression, id, apiVersion, baseUrl]);
72
+ useEffect(() => {
73
+ fetchData();
74
+ }, [fetchData]);
75
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfoTable, {
76
+ dataType: type,
77
+ data: data === null || data === void 0 ? void 0 : data.calculation,
78
+ loading: loading,
79
+ error: error
80
+ }, /*#__PURE__*/React.createElement("tr", {
81
+ className: `jsx-${styles.__hash}`
82
+ }, /*#__PURE__*/React.createElement("th", {
83
+ className: `jsx-${styles.__hash}`
84
+ }, i18n.t('Expression description')), /*#__PURE__*/React.createElement("td", {
85
+ className: `jsx-${styles.__hash}`
86
+ }, data !== null && data !== void 0 && data.calculation.humanReadableExpression ? renderHumanReadableExpression(data.calculation.humanReadableExpression) : /*#__PURE__*/React.createElement("span", {
87
+ className: `jsx-${styles.__hash}` + " " + "none"
88
+ }, expressionError ? i18n.t('Error loading value') : i18n.t('None'))))), /*#__PURE__*/React.createElement(_JSXStyle, {
89
+ id: styles.__hash
90
+ }, styles));
91
+ };
92
+ CalculationInfo.propTypes = {
93
+ displayNameProp: PropTypes.string,
94
+ id: PropTypes.string,
95
+ type: PropTypes.string
96
+ };
@@ -0,0 +1,127 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { useDataQuery } from '@dhis2/app-runtime';
3
+ import PropTypes from 'prop-types';
4
+ import React from 'react';
5
+ import i18n from '../../../locales/index.js';
6
+ import { valueTypeDisplayNames } from '../../../modules/valueTypes.js';
7
+ import { getCommonFields, renderDataSets, renderLegendSets, renderGroupMemberships, InfoTable } from './InfoTable.js';
8
+ import styles from './styles/InfoPopover.style.js';
9
+ const dataElementQuery = {
10
+ dataElement: {
11
+ resource: 'dataElements',
12
+ id: _ref => {
13
+ let {
14
+ id
15
+ } = _ref;
16
+ return id;
17
+ },
18
+ params: _ref2 => {
19
+ let {
20
+ displayNameProp
21
+ } = _ref2;
22
+ return {
23
+ fields: `${getCommonFields(displayNameProp)},aggregationType,categoryCombo[displayName,categories[id,displayName]],dataElementGroups[id,displayName],dataSetElements[dataSet[id,displayName]],legendSets[id,displayName],optionSet[displayName],valueType,zeroIsSignificant`
24
+ };
25
+ }
26
+ }
27
+ };
28
+ export const DataElementInfo = _ref3 => {
29
+ let {
30
+ type,
31
+ id,
32
+ displayNameProp
33
+ } = _ref3;
34
+ const {
35
+ loading,
36
+ error,
37
+ data
38
+ } = useDataQuery(dataElementQuery, {
39
+ variables: {
40
+ id,
41
+ displayNameProp
42
+ }
43
+ });
44
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfoTable, {
45
+ dataType: type,
46
+ data: data === null || data === void 0 ? void 0 : data.dataElement,
47
+ loading: loading,
48
+ error: error
49
+ }, /*#__PURE__*/React.createElement("tr", {
50
+ className: `jsx-${styles.__hash}`
51
+ }, /*#__PURE__*/React.createElement("th", {
52
+ className: `jsx-${styles.__hash}`
53
+ }, i18n.t('Data set(s)')), /*#__PURE__*/React.createElement("td", {
54
+ className: `jsx-${styles.__hash}`
55
+ }, (data === null || data === void 0 ? void 0 : data.dataElement.dataSetElements) && renderDataSets(data.dataElement.dataSetElements.map(_ref4 => {
56
+ let {
57
+ dataSet
58
+ } = _ref4;
59
+ return dataSet;
60
+ })))), /*#__PURE__*/React.createElement("tr", {
61
+ className: `jsx-${styles.__hash}`
62
+ }, /*#__PURE__*/React.createElement("th", {
63
+ className: `jsx-${styles.__hash}`
64
+ }, i18n.t('Zero is significant')), /*#__PURE__*/React.createElement("td", {
65
+ className: `jsx-${styles.__hash}`
66
+ }, data !== null && data !== void 0 && data.dataElement.zeroIsSignificant ? i18n.t('True') : i18n.t('False'))), /*#__PURE__*/React.createElement("tr", {
67
+ className: `jsx-${styles.__hash}`
68
+ }, /*#__PURE__*/React.createElement("th", {
69
+ className: `jsx-${styles.__hash}`
70
+ }, i18n.t('Value type')), /*#__PURE__*/React.createElement("td", {
71
+ className: `jsx-${styles.__hash}`
72
+ }, valueTypeDisplayNames[data === null || data === void 0 ? void 0 : data.dataElement.valueType])), /*#__PURE__*/React.createElement("tr", {
73
+ className: `jsx-${styles.__hash}`
74
+ }, /*#__PURE__*/React.createElement("th", {
75
+ className: `jsx-${styles.__hash}`
76
+ }, i18n.t('Aggregation type')), /*#__PURE__*/React.createElement("td", {
77
+ className: `jsx-${styles.__hash}`
78
+ }, data === null || data === void 0 ? void 0 : data.dataElement.aggregationType)), /*#__PURE__*/React.createElement("tr", {
79
+ className: `jsx-${styles.__hash}`
80
+ }, /*#__PURE__*/React.createElement("th", {
81
+ className: `jsx-${styles.__hash}`
82
+ }, i18n.t('Category combo')), /*#__PURE__*/React.createElement("td", {
83
+ className: `jsx-${styles.__hash}`
84
+ }, (data === null || data === void 0 ? void 0 : data.dataElement.categoryCombo.displayName) === 'default' ? /*#__PURE__*/React.createElement("span", {
85
+ className: `jsx-${styles.__hash}` + " " + "none"
86
+ }, i18n.t('None')) : /*#__PURE__*/React.createElement("details", {
87
+ className: `jsx-${styles.__hash}`
88
+ }, /*#__PURE__*/React.createElement("summary", {
89
+ className: `jsx-${styles.__hash}`
90
+ }, data === null || data === void 0 ? void 0 : data.dataElement.categoryCombo.displayName), /*#__PURE__*/React.createElement("ul", {
91
+ className: `jsx-${styles.__hash}`
92
+ }, data === null || data === void 0 ? void 0 : data.dataElement.categoryCombo.categories.map(_ref5 => {
93
+ let {
94
+ id,
95
+ displayName
96
+ } = _ref5;
97
+ return /*#__PURE__*/React.createElement("li", {
98
+ key: id,
99
+ className: `jsx-${styles.__hash}`
100
+ }, displayName);
101
+ }))))), (data === null || data === void 0 ? void 0 : data.dataElement.optionSet) && /*#__PURE__*/React.createElement("tr", {
102
+ className: `jsx-${styles.__hash}`
103
+ }, /*#__PURE__*/React.createElement("td", {
104
+ className: `jsx-${styles.__hash}`
105
+ }, i18n.t('Option set')), /*#__PURE__*/React.createElement("td", {
106
+ className: `jsx-${styles.__hash}`
107
+ }, data.dataElement.optionSet.displayName)), /*#__PURE__*/React.createElement("tr", {
108
+ className: `jsx-${styles.__hash}`
109
+ }, /*#__PURE__*/React.createElement("th", {
110
+ className: `jsx-${styles.__hash}`
111
+ }, i18n.t('Group membership')), /*#__PURE__*/React.createElement("td", {
112
+ className: `jsx-${styles.__hash}`
113
+ }, (data === null || data === void 0 ? void 0 : data.dataElement.dataElementGroups) && renderGroupMemberships(data.dataElement.dataElementGroups))), Boolean(data === null || data === void 0 ? void 0 : data.dataElement.legendSets.length) && /*#__PURE__*/React.createElement("tr", {
114
+ className: `jsx-${styles.__hash}`
115
+ }, /*#__PURE__*/React.createElement("th", {
116
+ className: `jsx-${styles.__hash}`
117
+ }, i18n.t('Legend set(s)')), /*#__PURE__*/React.createElement("td", {
118
+ className: `jsx-${styles.__hash}`
119
+ }, renderLegendSets(data.dataElement.legendSets)))), /*#__PURE__*/React.createElement(_JSXStyle, {
120
+ id: styles.__hash
121
+ }, styles));
122
+ };
123
+ DataElementInfo.propTypes = {
124
+ displayNameProp: PropTypes.string,
125
+ id: PropTypes.string,
126
+ type: PropTypes.string
127
+ };
@@ -0,0 +1,178 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { useConfig, useDataEngine } from '@dhis2/app-runtime';
3
+ import PropTypes from 'prop-types';
4
+ import React, { useCallback, useEffect, useState } from 'react';
5
+ import i18n from '../../../locales/index.js';
6
+ import { valueTypeDisplayNames } from '../../../modules/valueTypes.js';
7
+ import { getCommonFields, renderDataSets, renderGroupMemberships, renderLegendSets, InfoTable } from './InfoTable.js';
8
+ import styles from './styles/InfoPopover.style.js';
9
+ const dataElementOperandsQuery = {
10
+ dataElementOperands: {
11
+ resource: 'dataElementOperands',
12
+ params: _ref => {
13
+ let {
14
+ displayNameProp,
15
+ id
16
+ } = _ref;
17
+ return {
18
+ filter: `id:eq:${id}`,
19
+ fields: [`${getCommonFields(displayNameProp)}`, 'categoryOptionCombo[categoryCombo[categories[displayName,id],displayName],displayName]', `dataElement[${getCommonFields(displayNameProp)},aggregationType,categoryCombo[displayName,categories[id,displayName]],dataElementGroups[id,displayName],dataSetElements[dataSet[id,displayName]],legendSets[id,displayName],optionSet[displayName],valueType,zeroIsSignificant]`, 'displayName,id']
20
+ };
21
+ }
22
+ }
23
+ };
24
+ export const DataElementOperandInfo = _ref2 => {
25
+ let {
26
+ type,
27
+ id,
28
+ displayNameProp
29
+ } = _ref2;
30
+ const [data, setData] = useState();
31
+ const [error, setError] = useState();
32
+ const [loading, setLoading] = useState(true);
33
+ const {
34
+ baseUrl,
35
+ apiVersion
36
+ } = useConfig();
37
+ const engine = useDataEngine();
38
+ const fetchData = useCallback(async () => {
39
+ const {
40
+ dataElementOperands
41
+ } = await engine.query(dataElementOperandsQuery, {
42
+ variables: {
43
+ id,
44
+ displayNameProp
45
+ },
46
+ onError: setError
47
+ });
48
+ const dataElementOperand = dataElementOperands.dataElementOperands[0]
49
+
50
+ // copy some common fields from dataElement
51
+ ;
52
+ ['code', 'created', 'createdBy', 'displayDescription', 'lastUpdated'].forEach(key => dataElementOperand[key] = dataElementOperand.dataElement[key]);
53
+
54
+ // inject href as it is not returned from the API
55
+ dataElementOperand.href = new URL(`${dataElementOperandsQuery.dataElementOperands.resource}?${new URLSearchParams({
56
+ filter: `id:eq:${id}`
57
+ })}`, new URL(`api/${apiVersion}/`, baseUrl === '..' ? window.location.href.split('dhis-web-data-visualizer/')[0] : `${baseUrl}/`)).href;
58
+ setData({
59
+ dataElementOperand
60
+ });
61
+ setLoading(false);
62
+ }, [displayNameProp, engine, id]);
63
+ useEffect(() => {
64
+ fetchData();
65
+ }, [fetchData]);
66
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfoTable, {
67
+ dataType: type,
68
+ data: data === null || data === void 0 ? void 0 : data.dataElementOperand,
69
+ loading: loading,
70
+ error: error
71
+ }, /*#__PURE__*/React.createElement("tr", {
72
+ className: `jsx-${styles.__hash}`
73
+ }, /*#__PURE__*/React.createElement("th", {
74
+ className: `jsx-${styles.__hash}`
75
+ }, i18n.t('Data set(s)')), /*#__PURE__*/React.createElement("td", {
76
+ className: `jsx-${styles.__hash}`
77
+ }, (data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.dataSetElements) && renderDataSets(data.dataElementOperand.dataElement.dataSetElements.map(_ref3 => {
78
+ let {
79
+ dataSet
80
+ } = _ref3;
81
+ return dataSet;
82
+ })))), /*#__PURE__*/React.createElement("tr", {
83
+ className: `jsx-${styles.__hash}`
84
+ }, /*#__PURE__*/React.createElement("th", {
85
+ className: `jsx-${styles.__hash}`
86
+ }, i18n.t('Zero is significant')), /*#__PURE__*/React.createElement("td", {
87
+ className: `jsx-${styles.__hash}`
88
+ }, data !== null && data !== void 0 && data.dataElementOperand.dataElement.zeroIsSignificant ? i18n.t('True') : i18n.t('False'))), /*#__PURE__*/React.createElement("tr", {
89
+ className: `jsx-${styles.__hash}`
90
+ }, /*#__PURE__*/React.createElement("th", {
91
+ className: `jsx-${styles.__hash}`
92
+ }, i18n.t('Value type')), /*#__PURE__*/React.createElement("td", {
93
+ className: `jsx-${styles.__hash}`
94
+ }, valueTypeDisplayNames[data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.valueType])), /*#__PURE__*/React.createElement("tr", {
95
+ className: `jsx-${styles.__hash}`
96
+ }, /*#__PURE__*/React.createElement("th", {
97
+ className: `jsx-${styles.__hash}`
98
+ }, i18n.t('Aggregation type')), /*#__PURE__*/React.createElement("td", {
99
+ className: `jsx-${styles.__hash}`
100
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.aggregationType)), /*#__PURE__*/React.createElement("tr", {
101
+ className: `jsx-${styles.__hash}`
102
+ }, /*#__PURE__*/React.createElement("th", {
103
+ className: `jsx-${styles.__hash}`
104
+ }, i18n.t('Category combo')), /*#__PURE__*/React.createElement("td", {
105
+ className: `jsx-${styles.__hash}`
106
+ }, (data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.categoryCombo.displayName) === 'default' ? /*#__PURE__*/React.createElement("span", {
107
+ className: `jsx-${styles.__hash}` + " " + "none"
108
+ }, i18n.t('None')) : /*#__PURE__*/React.createElement("details", {
109
+ className: `jsx-${styles.__hash}`
110
+ }, /*#__PURE__*/React.createElement("summary", {
111
+ className: `jsx-${styles.__hash}`
112
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.categoryCombo.displayName), /*#__PURE__*/React.createElement("ul", {
113
+ className: `jsx-${styles.__hash}`
114
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.categoryCombo.categories.map(_ref4 => {
115
+ let {
116
+ id,
117
+ displayName
118
+ } = _ref4;
119
+ return /*#__PURE__*/React.createElement("li", {
120
+ key: id,
121
+ className: `jsx-${styles.__hash}`
122
+ }, displayName);
123
+ }))))), (data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.optionSet) && /*#__PURE__*/React.createElement("tr", {
124
+ className: `jsx-${styles.__hash}`
125
+ }, /*#__PURE__*/React.createElement("td", {
126
+ className: `jsx-${styles.__hash}`
127
+ }, i18n.t('Option set')), /*#__PURE__*/React.createElement("td", {
128
+ className: `jsx-${styles.__hash}`
129
+ }, data.dataElementOperand.dataElement.optionSet.displayName)), /*#__PURE__*/React.createElement("tr", {
130
+ className: `jsx-${styles.__hash}`
131
+ }, /*#__PURE__*/React.createElement("th", {
132
+ className: `jsx-${styles.__hash}`
133
+ }, i18n.t('Group membership')), /*#__PURE__*/React.createElement("td", {
134
+ className: `jsx-${styles.__hash}`
135
+ }, (data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.dataElementGroups) && renderGroupMemberships(data.dataElementOperand.dataElement.dataElementGroups))), Boolean(data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.legendSets.length) && /*#__PURE__*/React.createElement("tr", {
136
+ className: `jsx-${styles.__hash}`
137
+ }, /*#__PURE__*/React.createElement("th", {
138
+ className: `jsx-${styles.__hash}`
139
+ }, i18n.t('Legend set(s)')), /*#__PURE__*/React.createElement("td", {
140
+ className: `jsx-${styles.__hash}`
141
+ }, renderLegendSets(data.dataElementOperand.dataElement.legendSets))), /*#__PURE__*/React.createElement("tr", {
142
+ className: `jsx-${styles.__hash}`
143
+ }, /*#__PURE__*/React.createElement("th", {
144
+ className: `jsx-${styles.__hash}`
145
+ }, i18n.t('Category option name')), /*#__PURE__*/React.createElement("td", {
146
+ className: `jsx-${styles.__hash}`
147
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.categoryOptionCombo.displayName)), /*#__PURE__*/React.createElement("tr", {
148
+ className: `jsx-${styles.__hash}`
149
+ }, /*#__PURE__*/React.createElement("th", {
150
+ className: `jsx-${styles.__hash}`
151
+ }, i18n.t('Category combo name')), /*#__PURE__*/React.createElement("td", {
152
+ className: `jsx-${styles.__hash}`
153
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.categoryOptionCombo.categoryCombo.displayName)), /*#__PURE__*/React.createElement("tr", {
154
+ className: `jsx-${styles.__hash}`
155
+ }, /*#__PURE__*/React.createElement("th", {
156
+ className: `jsx-${styles.__hash}`
157
+ }, i18n.t('Categories name')), /*#__PURE__*/React.createElement("td", {
158
+ className: `jsx-${styles.__hash}`
159
+ }, /*#__PURE__*/React.createElement("ul", {
160
+ className: `jsx-${styles.__hash}`
161
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.categoryOptionCombo.categoryCombo.categories.map(_ref5 => {
162
+ let {
163
+ id,
164
+ displayName
165
+ } = _ref5;
166
+ return /*#__PURE__*/React.createElement("li", {
167
+ key: id,
168
+ className: `jsx-${styles.__hash}`
169
+ }, displayName);
170
+ }))))), /*#__PURE__*/React.createElement(_JSXStyle, {
171
+ id: styles.__hash
172
+ }, styles));
173
+ };
174
+ DataElementOperandInfo.propTypes = {
175
+ displayNameProp: PropTypes.string,
176
+ id: PropTypes.string,
177
+ type: PropTypes.string
178
+ };