@dhis2/analytics 26.9.6 → 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 (57) 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/modules/dimensionListItem.js +3 -3
  27. package/build/cjs/modules/dimensionSelectorHelper.js +2 -2
  28. package/build/cjs/modules/valueTypes.js +50 -11
  29. package/build/es/__demo__/DataDimension.stories.js +42 -0
  30. package/build/es/api/dimensions.js +1 -1
  31. package/build/es/api/expression.js +19 -9
  32. package/build/es/components/DataDimension/Calculation/CalculationModal.js +2 -2
  33. package/build/es/components/DataDimension/DataDimension.js +4 -1
  34. package/build/es/components/DataDimension/Info/CalculationInfo.js +96 -0
  35. package/build/es/components/DataDimension/Info/DataElementInfo.js +127 -0
  36. package/build/es/components/DataDimension/Info/DataElementOperandInfo.js +178 -0
  37. package/build/es/components/DataDimension/Info/DataSetInfo.js +107 -0
  38. package/build/es/components/DataDimension/Info/EventDataItemInfo.js +103 -0
  39. package/build/es/components/DataDimension/Info/IndicatorInfo.js +169 -0
  40. package/build/es/components/DataDimension/Info/InfoPopover.js +54 -0
  41. package/build/es/components/DataDimension/Info/InfoTable.js +205 -0
  42. package/build/es/components/DataDimension/Info/ProgramIndicatorInfo.js +181 -0
  43. package/build/es/components/DataDimension/Info/styles/InfoPopover.style.js +4 -0
  44. package/build/es/components/DataDimension/ItemSelector.js +24 -7
  45. package/build/es/components/DataDimension/TransferOption.js +109 -0
  46. package/build/es/components/DataDimension/styles/TransferOption.style.js +4 -0
  47. package/build/es/components/DimensionsPanel/List/__tests__/__snapshots__/DimensionItem.spec.js.snap +0 -20
  48. package/build/es/components/OrgUnitDimension/__tests__/__snapshots__/OrgUnitDimension.spec.js.snap +0 -5
  49. package/build/es/components/PeriodDimension/__tests__/__snapshots__/FixedPeriodSingleSelect.spec.js.snap +0 -12
  50. package/build/es/components/PeriodDimension/__tests__/__snapshots__/PeriodSelector.spec.js.snap +3 -10
  51. package/build/es/components/styles/DimensionSelector.style.js +2 -2
  52. package/build/es/index.js +1 -1
  53. package/build/es/locales/en/translations.json +73 -9
  54. package/build/es/modules/dimensionListItem.js +1 -1
  55. package/build/es/modules/dimensionSelectorHelper.js +2 -2
  56. package/build/es/modules/valueTypes.js +48 -10
  57. package/package.json +5 -5
@@ -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
+ };
@@ -0,0 +1,107 @@
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 { getCommonFields, InfoTable } from './InfoTable.js';
7
+ import styles from './styles/InfoPopover.style.js';
8
+ const dataSetQuery = {
9
+ dataSet: {
10
+ resource: 'dataSets',
11
+ id: _ref => {
12
+ let {
13
+ id
14
+ } = _ref;
15
+ return id;
16
+ },
17
+ params: _ref2 => {
18
+ let {
19
+ displayNameProp
20
+ } = _ref2;
21
+ return {
22
+ fields: `${getCommonFields(displayNameProp)},dataSetElements[dataElement[id,displayName]],expiryDays,indicators[id,displayName],periodType,`
23
+ };
24
+ }
25
+ }
26
+ };
27
+ export const DataSetInfo = _ref3 => {
28
+ let {
29
+ type,
30
+ id,
31
+ displayNameProp
32
+ } = _ref3;
33
+ const {
34
+ loading,
35
+ error,
36
+ data
37
+ } = useDataQuery(dataSetQuery, {
38
+ variables: {
39
+ id,
40
+ displayNameProp
41
+ }
42
+ });
43
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfoTable, {
44
+ dataType: type,
45
+ data: data === null || data === void 0 ? void 0 : data.dataSet,
46
+ loading: loading,
47
+ error: error
48
+ }, /*#__PURE__*/React.createElement("tr", {
49
+ className: `jsx-${styles.__hash}`
50
+ }, /*#__PURE__*/React.createElement("th", {
51
+ className: `jsx-${styles.__hash}`
52
+ }, i18n.t('Period type')), /*#__PURE__*/React.createElement("td", {
53
+ className: `jsx-${styles.__hash}`
54
+ }, data === null || data === void 0 ? void 0 : data.dataSet.periodType)), /*#__PURE__*/React.createElement("tr", {
55
+ className: `jsx-${styles.__hash}`
56
+ }, /*#__PURE__*/React.createElement("th", {
57
+ className: `jsx-${styles.__hash}`
58
+ }, i18n.t('Data elements')), /*#__PURE__*/React.createElement("td", {
59
+ className: `jsx-${styles.__hash}`
60
+ }, (data === null || data === void 0 ? void 0 : data.dataSet.dataSetElements.length) === 1 ? data.dataSet.dataSetElements[0].dataElement.displayName : /*#__PURE__*/React.createElement("div", {
61
+ className: `jsx-${styles.__hash}` + " " + "content-wrap"
62
+ }, /*#__PURE__*/React.createElement("ul", {
63
+ className: `jsx-${styles.__hash}`
64
+ }, data === null || data === void 0 ? void 0 : data.dataSet.dataSetElements.map(_ref4 => {
65
+ let {
66
+ dataElement
67
+ } = _ref4;
68
+ return /*#__PURE__*/React.createElement("li", {
69
+ key: dataElement.id,
70
+ className: `jsx-${styles.__hash}`
71
+ }, dataElement.displayName);
72
+ }))))), /*#__PURE__*/React.createElement("tr", {
73
+ className: `jsx-${styles.__hash}`
74
+ }, /*#__PURE__*/React.createElement("th", {
75
+ className: `jsx-${styles.__hash}`
76
+ }, i18n.t('Indicators')), /*#__PURE__*/React.createElement("td", {
77
+ className: `jsx-${styles.__hash}`
78
+ }, (data === null || data === void 0 ? void 0 : data.dataSet.indicators.length) === 1 ? data.dataSet.indicators[0].displayName : (data === null || data === void 0 ? void 0 : data.dataSet.indicators.length) > 1 ? /*#__PURE__*/React.createElement("div", {
79
+ className: `jsx-${styles.__hash}` + " " + "content-wrap"
80
+ }, /*#__PURE__*/React.createElement("ul", {
81
+ className: `jsx-${styles.__hash}`
82
+ }, data.dataSet.indicators.map(_ref5 => {
83
+ let {
84
+ id,
85
+ displayName
86
+ } = _ref5;
87
+ return /*#__PURE__*/React.createElement("li", {
88
+ key: id,
89
+ className: `jsx-${styles.__hash}`
90
+ }, displayName);
91
+ }))) : /*#__PURE__*/React.createElement("span", {
92
+ className: `jsx-${styles.__hash}` + " " + "none"
93
+ }, i18n.t('None')))), /*#__PURE__*/React.createElement("tr", {
94
+ className: `jsx-${styles.__hash}`
95
+ }, /*#__PURE__*/React.createElement("th", {
96
+ className: `jsx-${styles.__hash}`
97
+ }, i18n.t('Expiry days')), /*#__PURE__*/React.createElement("td", {
98
+ className: `jsx-${styles.__hash}`
99
+ }, data === null || data === void 0 ? void 0 : data.dataSet.expiryDays))), /*#__PURE__*/React.createElement(_JSXStyle, {
100
+ id: styles.__hash
101
+ }, styles));
102
+ };
103
+ DataSetInfo.propTypes = {
104
+ displayNameProp: PropTypes.string,
105
+ id: PropTypes.string,
106
+ type: PropTypes.string
107
+ };