@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
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.WithInfoBoxMessage = exports.NoneSelected = void 0;
7
+ var _appRuntime = require("@dhis2/app-runtime");
8
+ var _appServiceConfig = require("@dhis2/app-service-config");
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _DataDimension = _interopRequireDefault(require("../components/DataDimension/DataDimension.js"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ const Wrapper = story => /*#__PURE__*/_react.default.createElement(_appServiceConfig.ConfigProvider, {
15
+ config: {
16
+ serverVersion: {
17
+ major: 2,
18
+ minor: 41
19
+ }
20
+ }
21
+ }, /*#__PURE__*/_react.default.createElement(_appRuntime.DataProvider, {
22
+ baseUrl: "https://test.e2e.dhis2.org/analytics-41dev",
23
+ apiVersion: "41"
24
+ }, story()));
25
+ var _default = exports.default = {
26
+ title: 'DataDimension',
27
+ decorators: [Wrapper]
28
+ };
29
+ const NoneSelected = () => {
30
+ const [selected, setSelected] = (0, _react.useState)([]);
31
+ return /*#__PURE__*/_react.default.createElement(_DataDimension.default, {
32
+ displayNameProp: "displayName",
33
+ selectedDimensions: selected,
34
+ onSelect: response => setSelected(response.items)
35
+ });
36
+ };
37
+ exports.NoneSelected = NoneSelected;
38
+ NoneSelected.story = {
39
+ name: 'None selected'
40
+ };
41
+ const WithInfoBoxMessage = () => {
42
+ const [selected, setSelected] = (0, _react.useState)([]);
43
+ return /*#__PURE__*/_react.default.createElement(_DataDimension.default, {
44
+ displayNameProp: "displayName",
45
+ selectedDimensions: selected,
46
+ onSelect: response => setSelected(response.items),
47
+ infoBoxMessage: 'Test message showing in the info box'
48
+ });
49
+ };
50
+ exports.WithInfoBoxMessage = WithInfoBoxMessage;
51
+ WithInfoBoxMessage.story = {
52
+ name: 'With info box message'
53
+ };
@@ -188,7 +188,7 @@ const dataElementOperandsQuery = exports.dataElementOperandsQuery = {
188
188
  page
189
189
  } = _ref10;
190
190
  const idField = (filter === null || filter === void 0 ? void 0 : filter.group) === _dataTypes.DIMENSION_TYPE_ALL ? 'id' : 'dimensionItem~rename(id)';
191
- const filters = [];
191
+ const filters = ['categoryOptionCombo.name:ne:default'];
192
192
  if (filter !== null && filter !== void 0 && filter.group && filter.group !== _dataTypes.DIMENSION_TYPE_ALL) {
193
193
  filters.push(`dataElement.dataElementGroups.id:eq:${filter.group}`);
194
194
  }
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.validateExpressionMutation = exports.updateCalculationMutation = exports.deleteCalculationMutation = exports.createCalculationMutation = void 0;
7
- const validateExpressionMutation = exports.validateExpressionMutation = {
6
+ exports.validateProgramIndicatorExpressionMutation = exports.validateIndicatorExpressionMutation = exports.updateCalculationMutation = exports.deleteCalculationMutation = exports.createCalculationMutation = void 0;
7
+ const validateIndicatorExpressionMutation = exports.validateIndicatorExpressionMutation = {
8
8
  type: 'create',
9
9
  resource: 'indicators/expression/description',
10
10
  data: _ref => {
@@ -14,14 +14,24 @@ const validateExpressionMutation = exports.validateExpressionMutation = {
14
14
  return expression;
15
15
  }
16
16
  };
17
+ const validateProgramIndicatorExpressionMutation = exports.validateProgramIndicatorExpressionMutation = {
18
+ type: 'create',
19
+ resource: 'programIndicators/expression/description',
20
+ data: _ref2 => {
21
+ let {
22
+ expression
23
+ } = _ref2;
24
+ return expression;
25
+ }
26
+ };
17
27
  const createCalculationMutation = exports.createCalculationMutation = {
18
28
  type: 'create',
19
29
  resource: 'expressionDimensionItems',
20
- data: _ref2 => {
30
+ data: _ref3 => {
21
31
  let {
22
32
  name,
23
33
  expression
24
- } = _ref2;
34
+ } = _ref3;
25
35
  return {
26
36
  name,
27
37
  shortName: name,
@@ -32,17 +42,17 @@ const createCalculationMutation = exports.createCalculationMutation = {
32
42
  const updateCalculationMutation = exports.updateCalculationMutation = {
33
43
  type: 'json-patch',
34
44
  resource: 'expressionDimensionItems',
35
- id: _ref3 => {
45
+ id: _ref4 => {
36
46
  let {
37
47
  id
38
- } = _ref3;
48
+ } = _ref4;
39
49
  return id;
40
50
  },
41
- data: _ref4 => {
51
+ data: _ref5 => {
42
52
  let {
43
53
  name,
44
54
  expression
45
- } = _ref4;
55
+ } = _ref5;
46
56
  return [{
47
57
  op: 'add',
48
58
  path: '/name',
@@ -61,10 +71,10 @@ const updateCalculationMutation = exports.updateCalculationMutation = {
61
71
  const deleteCalculationMutation = exports.deleteCalculationMutation = {
62
72
  type: 'delete',
63
73
  resource: 'expressionDimensionItems',
64
- id: _ref5 => {
74
+ id: _ref6 => {
65
75
  let {
66
76
  id
67
- } = _ref5;
77
+ } = _ref6;
68
78
  return id;
69
79
  }
70
80
  };
@@ -51,7 +51,7 @@ const CalculationModal = _ref => {
51
51
  }] = (0, _appRuntime.useDataMutation)(_expression.deleteCalculationMutation, mutationParams);
52
52
  const [doBackendValidation, {
53
53
  loading: isValidating
54
- }] = (0, _appRuntime.useDataMutation)(_expression.validateExpressionMutation, {
54
+ }] = (0, _appRuntime.useDataMutation)(_expression.validateIndicatorExpressionMutation, {
55
55
  onError: error => showError(error)
56
56
  });
57
57
  const query = {
@@ -16,6 +16,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
16
16
  const DataDimensionCtx = /*#__PURE__*/(0, _react.createContext)({});
17
17
  const DataDimension = _ref => {
18
18
  let {
19
+ currentUser,
19
20
  onSelect,
20
21
  selectedDimensions,
21
22
  displayNameProp,
@@ -49,7 +50,8 @@ const DataDimension = _ref => {
49
50
  (0, _react.useEffect)(() => enabledDataTypes && setDataTypes(filterDataTypesByVersion(enabledDataTypes)), [enabledDataTypes, filterDataTypesByVersion]);
50
51
  return /*#__PURE__*/_react.default.createElement(DataDimensionCtx.Provider, {
51
52
  value: {
52
- visType
53
+ visType,
54
+ currentUser
53
55
  }
54
56
  }, /*#__PURE__*/_react.default.createElement(_ItemSelector.default, {
55
57
  selectedItems: selectedDimensions.map(item => ({
@@ -78,6 +80,7 @@ DataDimension.propTypes = {
78
80
  type: _propTypes.default.string
79
81
  })).isRequired,
80
82
  onSelect: _propTypes.default.func.isRequired,
83
+ currentUser: _propTypes.default.object,
81
84
  enabledDataTypes: _propTypes.default.array,
82
85
  infoBoxMessage: _propTypes.default.string,
83
86
  visType: _propTypes.default.string,
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CalculationInfo = void 0;
7
+ var _style = _interopRequireDefault(require("styled-jsx/style"));
8
+ var _appRuntime = require("@dhis2/app-runtime");
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _expression = require("../../../api/expression.js");
12
+ var _index = _interopRequireDefault(require("../../../locales/index.js"));
13
+ var _InfoTable = require("./InfoTable.js");
14
+ var _InfoPopoverStyle = _interopRequireDefault(require("./styles/InfoPopover.style.js"));
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
+ const calculationQuery = {
19
+ calculation: {
20
+ resource: 'expressionDimensionItems',
21
+ id: _ref => {
22
+ let {
23
+ id
24
+ } = _ref;
25
+ return id;
26
+ },
27
+ params: _ref2 => {
28
+ let {
29
+ displayNameProp
30
+ } = _ref2;
31
+ return {
32
+ fields: `${(0, _InfoTable.getCommonFields)(displayNameProp)},expression`
33
+ };
34
+ }
35
+ }
36
+ };
37
+ const CalculationInfo = _ref3 => {
38
+ let {
39
+ type,
40
+ id,
41
+ displayNameProp
42
+ } = _ref3;
43
+ const [data, setData] = (0, _react.useState)();
44
+ const [error, setError] = (0, _react.useState)();
45
+ const [expressionError, setExpressionError] = (0, _react.useState)();
46
+ const [loading, setLoading] = (0, _react.useState)(true);
47
+ const {
48
+ baseUrl,
49
+ apiVersion
50
+ } = (0, _appRuntime.useConfig)();
51
+ const engine = (0, _appRuntime.useDataEngine)();
52
+ const [getHumanReadableExpression] = (0, _appRuntime.useDataMutation)(_expression.validateIndicatorExpressionMutation, {
53
+ onError: setExpressionError
54
+ });
55
+ const fetchData = (0, _react.useCallback)(async () => {
56
+ const {
57
+ calculation
58
+ } = await engine.query(calculationQuery, {
59
+ variables: {
60
+ id,
61
+ displayNameProp
62
+ },
63
+ onError: setError
64
+ });
65
+ if (calculation.expression) {
66
+ const result = await getHumanReadableExpression({
67
+ expression: calculation.expression
68
+ });
69
+ if (result) {
70
+ calculation.humanReadableExpression = result;
71
+ }
72
+ }
73
+
74
+ // inject href as it is not returned from the API
75
+ calculation.href = new URL(`${calculationQuery.calculation.resource}/${id}`, new URL(`api/${apiVersion}/`, baseUrl === '..' ? window.location.href.split('dhis-web-data-visualizer/')[0] : `${baseUrl}/`)).href;
76
+ setData({
77
+ calculation
78
+ });
79
+ setLoading(false);
80
+ }, [displayNameProp, engine, getHumanReadableExpression, id, apiVersion, baseUrl]);
81
+ (0, _react.useEffect)(() => {
82
+ fetchData();
83
+ }, [fetchData]);
84
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_InfoTable.InfoTable, {
85
+ dataType: type,
86
+ data: data === null || data === void 0 ? void 0 : data.calculation,
87
+ loading: loading,
88
+ error: error
89
+ }, /*#__PURE__*/_react.default.createElement("tr", {
90
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
91
+ }, /*#__PURE__*/_react.default.createElement("th", {
92
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
93
+ }, _index.default.t('Expression description')), /*#__PURE__*/_react.default.createElement("td", {
94
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
95
+ }, data !== null && data !== void 0 && data.calculation.humanReadableExpression ? (0, _InfoTable.renderHumanReadableExpression)(data.calculation.humanReadableExpression) : /*#__PURE__*/_react.default.createElement("span", {
96
+ className: `jsx-${_InfoPopoverStyle.default.__hash}` + " " + "none"
97
+ }, expressionError ? _index.default.t('Error loading value') : _index.default.t('None'))))), /*#__PURE__*/_react.default.createElement(_style.default, {
98
+ id: _InfoPopoverStyle.default.__hash
99
+ }, _InfoPopoverStyle.default));
100
+ };
101
+ exports.CalculationInfo = CalculationInfo;
102
+ CalculationInfo.propTypes = {
103
+ displayNameProp: _propTypes.default.string,
104
+ id: _propTypes.default.string,
105
+ type: _propTypes.default.string
106
+ };
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DataElementInfo = void 0;
7
+ var _style = _interopRequireDefault(require("styled-jsx/style"));
8
+ var _appRuntime = require("@dhis2/app-runtime");
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _index = _interopRequireDefault(require("../../../locales/index.js"));
12
+ var _valueTypes = require("../../../modules/valueTypes.js");
13
+ var _InfoTable = require("./InfoTable.js");
14
+ var _InfoPopoverStyle = _interopRequireDefault(require("./styles/InfoPopover.style.js"));
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ const dataElementQuery = {
17
+ dataElement: {
18
+ resource: 'dataElements',
19
+ id: _ref => {
20
+ let {
21
+ id
22
+ } = _ref;
23
+ return id;
24
+ },
25
+ params: _ref2 => {
26
+ let {
27
+ displayNameProp
28
+ } = _ref2;
29
+ return {
30
+ fields: `${(0, _InfoTable.getCommonFields)(displayNameProp)},aggregationType,categoryCombo[displayName,categories[id,displayName]],dataElementGroups[id,displayName],dataSetElements[dataSet[id,displayName]],legendSets[id,displayName],optionSet[displayName],valueType,zeroIsSignificant`
31
+ };
32
+ }
33
+ }
34
+ };
35
+ const DataElementInfo = _ref3 => {
36
+ let {
37
+ type,
38
+ id,
39
+ displayNameProp
40
+ } = _ref3;
41
+ const {
42
+ loading,
43
+ error,
44
+ data
45
+ } = (0, _appRuntime.useDataQuery)(dataElementQuery, {
46
+ variables: {
47
+ id,
48
+ displayNameProp
49
+ }
50
+ });
51
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_InfoTable.InfoTable, {
52
+ dataType: type,
53
+ data: data === null || data === void 0 ? void 0 : data.dataElement,
54
+ loading: loading,
55
+ error: error
56
+ }, /*#__PURE__*/_react.default.createElement("tr", {
57
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
58
+ }, /*#__PURE__*/_react.default.createElement("th", {
59
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
60
+ }, _index.default.t('Data set(s)')), /*#__PURE__*/_react.default.createElement("td", {
61
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
62
+ }, (data === null || data === void 0 ? void 0 : data.dataElement.dataSetElements) && (0, _InfoTable.renderDataSets)(data.dataElement.dataSetElements.map(_ref4 => {
63
+ let {
64
+ dataSet
65
+ } = _ref4;
66
+ return dataSet;
67
+ })))), /*#__PURE__*/_react.default.createElement("tr", {
68
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
69
+ }, /*#__PURE__*/_react.default.createElement("th", {
70
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
71
+ }, _index.default.t('Zero is significant')), /*#__PURE__*/_react.default.createElement("td", {
72
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
73
+ }, data !== null && data !== void 0 && data.dataElement.zeroIsSignificant ? _index.default.t('True') : _index.default.t('False'))), /*#__PURE__*/_react.default.createElement("tr", {
74
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
75
+ }, /*#__PURE__*/_react.default.createElement("th", {
76
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
77
+ }, _index.default.t('Value type')), /*#__PURE__*/_react.default.createElement("td", {
78
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
79
+ }, _valueTypes.valueTypeDisplayNames[data === null || data === void 0 ? void 0 : data.dataElement.valueType])), /*#__PURE__*/_react.default.createElement("tr", {
80
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
81
+ }, /*#__PURE__*/_react.default.createElement("th", {
82
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
83
+ }, _index.default.t('Aggregation type')), /*#__PURE__*/_react.default.createElement("td", {
84
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
85
+ }, data === null || data === void 0 ? void 0 : data.dataElement.aggregationType)), /*#__PURE__*/_react.default.createElement("tr", {
86
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
87
+ }, /*#__PURE__*/_react.default.createElement("th", {
88
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
89
+ }, _index.default.t('Category combo')), /*#__PURE__*/_react.default.createElement("td", {
90
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
91
+ }, (data === null || data === void 0 ? void 0 : data.dataElement.categoryCombo.displayName) === 'default' ? /*#__PURE__*/_react.default.createElement("span", {
92
+ className: `jsx-${_InfoPopoverStyle.default.__hash}` + " " + "none"
93
+ }, _index.default.t('None')) : /*#__PURE__*/_react.default.createElement("details", {
94
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
95
+ }, /*#__PURE__*/_react.default.createElement("summary", {
96
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
97
+ }, data === null || data === void 0 ? void 0 : data.dataElement.categoryCombo.displayName), /*#__PURE__*/_react.default.createElement("ul", {
98
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
99
+ }, data === null || data === void 0 ? void 0 : data.dataElement.categoryCombo.categories.map(_ref5 => {
100
+ let {
101
+ id,
102
+ displayName
103
+ } = _ref5;
104
+ return /*#__PURE__*/_react.default.createElement("li", {
105
+ key: id,
106
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
107
+ }, displayName);
108
+ }))))), (data === null || data === void 0 ? void 0 : data.dataElement.optionSet) && /*#__PURE__*/_react.default.createElement("tr", {
109
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
110
+ }, /*#__PURE__*/_react.default.createElement("td", {
111
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
112
+ }, _index.default.t('Option set')), /*#__PURE__*/_react.default.createElement("td", {
113
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
114
+ }, data.dataElement.optionSet.displayName)), /*#__PURE__*/_react.default.createElement("tr", {
115
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
116
+ }, /*#__PURE__*/_react.default.createElement("th", {
117
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
118
+ }, _index.default.t('Group membership')), /*#__PURE__*/_react.default.createElement("td", {
119
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
120
+ }, (data === null || data === void 0 ? void 0 : data.dataElement.dataElementGroups) && (0, _InfoTable.renderGroupMemberships)(data.dataElement.dataElementGroups))), Boolean(data === null || data === void 0 ? void 0 : data.dataElement.legendSets.length) && /*#__PURE__*/_react.default.createElement("tr", {
121
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
122
+ }, /*#__PURE__*/_react.default.createElement("th", {
123
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
124
+ }, _index.default.t('Legend set(s)')), /*#__PURE__*/_react.default.createElement("td", {
125
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
126
+ }, (0, _InfoTable.renderLegendSets)(data.dataElement.legendSets)))), /*#__PURE__*/_react.default.createElement(_style.default, {
127
+ id: _InfoPopoverStyle.default.__hash
128
+ }, _InfoPopoverStyle.default));
129
+ };
130
+ exports.DataElementInfo = DataElementInfo;
131
+ DataElementInfo.propTypes = {
132
+ displayNameProp: _propTypes.default.string,
133
+ id: _propTypes.default.string,
134
+ type: _propTypes.default.string
135
+ };
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DataElementOperandInfo = void 0;
7
+ var _style = _interopRequireDefault(require("styled-jsx/style"));
8
+ var _appRuntime = require("@dhis2/app-runtime");
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _index = _interopRequireDefault(require("../../../locales/index.js"));
12
+ var _valueTypes = require("../../../modules/valueTypes.js");
13
+ var _InfoTable = require("./InfoTable.js");
14
+ var _InfoPopoverStyle = _interopRequireDefault(require("./styles/InfoPopover.style.js"));
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
+ const dataElementOperandsQuery = {
19
+ dataElementOperands: {
20
+ resource: 'dataElementOperands',
21
+ params: _ref => {
22
+ let {
23
+ displayNameProp,
24
+ id
25
+ } = _ref;
26
+ return {
27
+ filter: `id:eq:${id}`,
28
+ fields: [`${(0, _InfoTable.getCommonFields)(displayNameProp)}`, 'categoryOptionCombo[categoryCombo[categories[displayName,id],displayName],displayName]', `dataElement[${(0, _InfoTable.getCommonFields)(displayNameProp)},aggregationType,categoryCombo[displayName,categories[id,displayName]],dataElementGroups[id,displayName],dataSetElements[dataSet[id,displayName]],legendSets[id,displayName],optionSet[displayName],valueType,zeroIsSignificant]`, 'displayName,id']
29
+ };
30
+ }
31
+ }
32
+ };
33
+ const DataElementOperandInfo = _ref2 => {
34
+ let {
35
+ type,
36
+ id,
37
+ displayNameProp
38
+ } = _ref2;
39
+ const [data, setData] = (0, _react.useState)();
40
+ const [error, setError] = (0, _react.useState)();
41
+ const [loading, setLoading] = (0, _react.useState)(true);
42
+ const {
43
+ baseUrl,
44
+ apiVersion
45
+ } = (0, _appRuntime.useConfig)();
46
+ const engine = (0, _appRuntime.useDataEngine)();
47
+ const fetchData = (0, _react.useCallback)(async () => {
48
+ const {
49
+ dataElementOperands
50
+ } = await engine.query(dataElementOperandsQuery, {
51
+ variables: {
52
+ id,
53
+ displayNameProp
54
+ },
55
+ onError: setError
56
+ });
57
+ const dataElementOperand = dataElementOperands.dataElementOperands[0]
58
+
59
+ // copy some common fields from dataElement
60
+ ;
61
+ ['code', 'created', 'createdBy', 'displayDescription', 'lastUpdated'].forEach(key => dataElementOperand[key] = dataElementOperand.dataElement[key]);
62
+
63
+ // inject href as it is not returned from the API
64
+ dataElementOperand.href = new URL(`${dataElementOperandsQuery.dataElementOperands.resource}?${new URLSearchParams({
65
+ filter: `id:eq:${id}`
66
+ })}`, new URL(`api/${apiVersion}/`, baseUrl === '..' ? window.location.href.split('dhis-web-data-visualizer/')[0] : `${baseUrl}/`)).href;
67
+ setData({
68
+ dataElementOperand
69
+ });
70
+ setLoading(false);
71
+ }, [displayNameProp, engine, id]);
72
+ (0, _react.useEffect)(() => {
73
+ fetchData();
74
+ }, [fetchData]);
75
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_InfoTable.InfoTable, {
76
+ dataType: type,
77
+ data: data === null || data === void 0 ? void 0 : data.dataElementOperand,
78
+ loading: loading,
79
+ error: error
80
+ }, /*#__PURE__*/_react.default.createElement("tr", {
81
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
82
+ }, /*#__PURE__*/_react.default.createElement("th", {
83
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
84
+ }, _index.default.t('Data set(s)')), /*#__PURE__*/_react.default.createElement("td", {
85
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
86
+ }, (data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.dataSetElements) && (0, _InfoTable.renderDataSets)(data.dataElementOperand.dataElement.dataSetElements.map(_ref3 => {
87
+ let {
88
+ dataSet
89
+ } = _ref3;
90
+ return dataSet;
91
+ })))), /*#__PURE__*/_react.default.createElement("tr", {
92
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
93
+ }, /*#__PURE__*/_react.default.createElement("th", {
94
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
95
+ }, _index.default.t('Zero is significant')), /*#__PURE__*/_react.default.createElement("td", {
96
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
97
+ }, data !== null && data !== void 0 && data.dataElementOperand.dataElement.zeroIsSignificant ? _index.default.t('True') : _index.default.t('False'))), /*#__PURE__*/_react.default.createElement("tr", {
98
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
99
+ }, /*#__PURE__*/_react.default.createElement("th", {
100
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
101
+ }, _index.default.t('Value type')), /*#__PURE__*/_react.default.createElement("td", {
102
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
103
+ }, _valueTypes.valueTypeDisplayNames[data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.valueType])), /*#__PURE__*/_react.default.createElement("tr", {
104
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
105
+ }, /*#__PURE__*/_react.default.createElement("th", {
106
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
107
+ }, _index.default.t('Aggregation type')), /*#__PURE__*/_react.default.createElement("td", {
108
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
109
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.aggregationType)), /*#__PURE__*/_react.default.createElement("tr", {
110
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
111
+ }, /*#__PURE__*/_react.default.createElement("th", {
112
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
113
+ }, _index.default.t('Category combo')), /*#__PURE__*/_react.default.createElement("td", {
114
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
115
+ }, (data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.categoryCombo.displayName) === 'default' ? /*#__PURE__*/_react.default.createElement("span", {
116
+ className: `jsx-${_InfoPopoverStyle.default.__hash}` + " " + "none"
117
+ }, _index.default.t('None')) : /*#__PURE__*/_react.default.createElement("details", {
118
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
119
+ }, /*#__PURE__*/_react.default.createElement("summary", {
120
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
121
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.categoryCombo.displayName), /*#__PURE__*/_react.default.createElement("ul", {
122
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
123
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.categoryCombo.categories.map(_ref4 => {
124
+ let {
125
+ id,
126
+ displayName
127
+ } = _ref4;
128
+ return /*#__PURE__*/_react.default.createElement("li", {
129
+ key: id,
130
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
131
+ }, displayName);
132
+ }))))), (data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.optionSet) && /*#__PURE__*/_react.default.createElement("tr", {
133
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
134
+ }, /*#__PURE__*/_react.default.createElement("td", {
135
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
136
+ }, _index.default.t('Option set')), /*#__PURE__*/_react.default.createElement("td", {
137
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
138
+ }, data.dataElementOperand.dataElement.optionSet.displayName)), /*#__PURE__*/_react.default.createElement("tr", {
139
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
140
+ }, /*#__PURE__*/_react.default.createElement("th", {
141
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
142
+ }, _index.default.t('Group membership')), /*#__PURE__*/_react.default.createElement("td", {
143
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
144
+ }, (data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.dataElementGroups) && (0, _InfoTable.renderGroupMemberships)(data.dataElementOperand.dataElement.dataElementGroups))), Boolean(data === null || data === void 0 ? void 0 : data.dataElementOperand.dataElement.legendSets.length) && /*#__PURE__*/_react.default.createElement("tr", {
145
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
146
+ }, /*#__PURE__*/_react.default.createElement("th", {
147
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
148
+ }, _index.default.t('Legend set(s)')), /*#__PURE__*/_react.default.createElement("td", {
149
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
150
+ }, (0, _InfoTable.renderLegendSets)(data.dataElementOperand.dataElement.legendSets))), /*#__PURE__*/_react.default.createElement("tr", {
151
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
152
+ }, /*#__PURE__*/_react.default.createElement("th", {
153
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
154
+ }, _index.default.t('Category option name')), /*#__PURE__*/_react.default.createElement("td", {
155
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
156
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.categoryOptionCombo.displayName)), /*#__PURE__*/_react.default.createElement("tr", {
157
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
158
+ }, /*#__PURE__*/_react.default.createElement("th", {
159
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
160
+ }, _index.default.t('Category combo name')), /*#__PURE__*/_react.default.createElement("td", {
161
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
162
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.categoryOptionCombo.categoryCombo.displayName)), /*#__PURE__*/_react.default.createElement("tr", {
163
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
164
+ }, /*#__PURE__*/_react.default.createElement("th", {
165
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
166
+ }, _index.default.t('Categories name')), /*#__PURE__*/_react.default.createElement("td", {
167
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
168
+ }, /*#__PURE__*/_react.default.createElement("ul", {
169
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
170
+ }, data === null || data === void 0 ? void 0 : data.dataElementOperand.categoryOptionCombo.categoryCombo.categories.map(_ref5 => {
171
+ let {
172
+ id,
173
+ displayName
174
+ } = _ref5;
175
+ return /*#__PURE__*/_react.default.createElement("li", {
176
+ key: id,
177
+ className: `jsx-${_InfoPopoverStyle.default.__hash}`
178
+ }, displayName);
179
+ }))))), /*#__PURE__*/_react.default.createElement(_style.default, {
180
+ id: _InfoPopoverStyle.default.__hash
181
+ }, _InfoPopoverStyle.default));
182
+ };
183
+ exports.DataElementOperandInfo = DataElementOperandInfo;
184
+ DataElementOperandInfo.propTypes = {
185
+ displayNameProp: _propTypes.default.string,
186
+ id: _propTypes.default.string,
187
+ type: _propTypes.default.string
188
+ };