@dhis2/analytics 26.9.6 → 26.10.1

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 (129) 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/ar/translations.json +96 -22
  26. package/build/cjs/locales/ar_IQ/translations.json +141 -44
  27. package/build/cjs/locales/bn/translations.json +458 -0
  28. package/build/cjs/locales/ckb/translations.json +137 -44
  29. package/build/cjs/locales/cs/translations.json +88 -20
  30. package/build/cjs/locales/da/translations.json +102 -23
  31. package/build/cjs/locales/en/translations.json +73 -9
  32. package/build/cjs/locales/es/translations.json +75 -9
  33. package/build/cjs/locales/es_419/translations.json +77 -9
  34. package/build/cjs/locales/fr/translations.json +77 -9
  35. package/build/cjs/locales/hi_IN/translations.json +458 -0
  36. package/build/cjs/locales/id/translations.json +95 -22
  37. package/build/cjs/locales/index.js +74 -70
  38. package/build/cjs/locales/km/translations.json +100 -23
  39. package/build/cjs/locales/lo/translations.json +73 -9
  40. package/build/cjs/locales/my/translations.json +101 -23
  41. package/build/cjs/locales/nb/translations.json +88 -20
  42. package/build/cjs/locales/ne/translations.json +77 -9
  43. package/build/cjs/locales/nl/translations.json +95 -22
  44. package/build/cjs/locales/or/translations.json +137 -44
  45. package/build/cjs/locales/prs/translations.json +102 -23
  46. package/build/cjs/locales/ps/translations.json +102 -23
  47. package/build/cjs/locales/pt/translations.json +73 -9
  48. package/build/cjs/locales/pt_BR/translations.json +95 -22
  49. package/build/cjs/locales/ro/translations.json +138 -44
  50. package/build/cjs/locales/ru/translations.json +77 -9
  51. package/build/cjs/locales/si/translations.json +102 -23
  52. package/build/cjs/locales/sv/translations.json +88 -20
  53. package/build/cjs/locales/tet/translations.json +101 -23
  54. package/build/cjs/locales/tg/translations.json +102 -23
  55. package/build/cjs/locales/uk/translations.json +96 -22
  56. package/build/cjs/locales/ur/translations.json +96 -22
  57. package/build/cjs/locales/uz_UZ_Cyrl/translations.json +95 -22
  58. package/build/cjs/locales/uz_UZ_Latn/translations.json +96 -22
  59. package/build/cjs/locales/vi/translations.json +73 -9
  60. package/build/cjs/locales/zh/translations.json +73 -9
  61. package/build/cjs/locales/zh_CN/translations.json +95 -22
  62. package/build/cjs/modules/dimensionListItem.js +3 -3
  63. package/build/cjs/modules/dimensionSelectorHelper.js +2 -2
  64. package/build/cjs/modules/valueTypes.js +50 -11
  65. package/build/es/__demo__/DataDimension.stories.js +42 -0
  66. package/build/es/api/dimensions.js +1 -1
  67. package/build/es/api/expression.js +19 -9
  68. package/build/es/components/DataDimension/Calculation/CalculationModal.js +2 -2
  69. package/build/es/components/DataDimension/DataDimension.js +4 -1
  70. package/build/es/components/DataDimension/Info/CalculationInfo.js +96 -0
  71. package/build/es/components/DataDimension/Info/DataElementInfo.js +127 -0
  72. package/build/es/components/DataDimension/Info/DataElementOperandInfo.js +178 -0
  73. package/build/es/components/DataDimension/Info/DataSetInfo.js +107 -0
  74. package/build/es/components/DataDimension/Info/EventDataItemInfo.js +103 -0
  75. package/build/es/components/DataDimension/Info/IndicatorInfo.js +169 -0
  76. package/build/es/components/DataDimension/Info/InfoPopover.js +54 -0
  77. package/build/es/components/DataDimension/Info/InfoTable.js +205 -0
  78. package/build/es/components/DataDimension/Info/ProgramIndicatorInfo.js +181 -0
  79. package/build/es/components/DataDimension/Info/styles/InfoPopover.style.js +4 -0
  80. package/build/es/components/DataDimension/ItemSelector.js +24 -7
  81. package/build/es/components/DataDimension/TransferOption.js +109 -0
  82. package/build/es/components/DataDimension/styles/TransferOption.style.js +4 -0
  83. package/build/es/components/DimensionsPanel/List/__tests__/__snapshots__/DimensionItem.spec.js.snap +0 -20
  84. package/build/es/components/OrgUnitDimension/__tests__/__snapshots__/OrgUnitDimension.spec.js.snap +0 -5
  85. package/build/es/components/PeriodDimension/__tests__/__snapshots__/FixedPeriodSingleSelect.spec.js.snap +0 -12
  86. package/build/es/components/PeriodDimension/__tests__/__snapshots__/PeriodSelector.spec.js.snap +3 -10
  87. package/build/es/components/styles/DimensionSelector.style.js +2 -2
  88. package/build/es/index.js +1 -1
  89. package/build/es/locales/ar/translations.json +96 -22
  90. package/build/es/locales/ar_IQ/translations.json +141 -44
  91. package/build/es/locales/bn/translations.json +458 -0
  92. package/build/es/locales/ckb/translations.json +137 -44
  93. package/build/es/locales/cs/translations.json +88 -20
  94. package/build/es/locales/da/translations.json +102 -23
  95. package/build/es/locales/en/translations.json +73 -9
  96. package/build/es/locales/es/translations.json +75 -9
  97. package/build/es/locales/es_419/translations.json +77 -9
  98. package/build/es/locales/fr/translations.json +77 -9
  99. package/build/es/locales/hi_IN/translations.json +458 -0
  100. package/build/es/locales/id/translations.json +95 -22
  101. package/build/es/locales/index.js +4 -0
  102. package/build/es/locales/km/translations.json +100 -23
  103. package/build/es/locales/lo/translations.json +73 -9
  104. package/build/es/locales/my/translations.json +101 -23
  105. package/build/es/locales/nb/translations.json +88 -20
  106. package/build/es/locales/ne/translations.json +77 -9
  107. package/build/es/locales/nl/translations.json +95 -22
  108. package/build/es/locales/or/translations.json +137 -44
  109. package/build/es/locales/prs/translations.json +102 -23
  110. package/build/es/locales/ps/translations.json +102 -23
  111. package/build/es/locales/pt/translations.json +73 -9
  112. package/build/es/locales/pt_BR/translations.json +95 -22
  113. package/build/es/locales/ro/translations.json +138 -44
  114. package/build/es/locales/ru/translations.json +77 -9
  115. package/build/es/locales/si/translations.json +102 -23
  116. package/build/es/locales/sv/translations.json +88 -20
  117. package/build/es/locales/tet/translations.json +101 -23
  118. package/build/es/locales/tg/translations.json +102 -23
  119. package/build/es/locales/uk/translations.json +96 -22
  120. package/build/es/locales/ur/translations.json +96 -22
  121. package/build/es/locales/uz_UZ_Cyrl/translations.json +95 -22
  122. package/build/es/locales/uz_UZ_Latn/translations.json +96 -22
  123. package/build/es/locales/vi/translations.json +73 -9
  124. package/build/es/locales/zh/translations.json +73 -9
  125. package/build/es/locales/zh_CN/translations.json +95 -22
  126. package/build/es/modules/dimensionListItem.js +1 -1
  127. package/build/es/modules/dimensionSelectorHelper.js +2 -2
  128. package/build/es/modules/valueTypes.js +48 -10
  129. package/package.json +5 -5
@@ -0,0 +1,169 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { 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, renderGroupMemberships, renderHumanReadableExpression, renderLegendSets, InfoTable } from './InfoTable.js';
8
+ import styles from './styles/InfoPopover.style.js';
9
+ const indicatorQuery = {
10
+ indicator: {
11
+ resource: 'indicators',
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)},annualized,dataSets[id,displayName],decimals,denominator,displayDenominatorDescription,displayNumeratorDescription,indicatorGroups[id,displayName],indicatorType[displayName,factor],legendSets[id,displayName],numerator`
24
+ };
25
+ }
26
+ }
27
+ };
28
+ export const IndicatorInfo = _ref3 => {
29
+ let {
30
+ type,
31
+ id,
32
+ displayNameProp
33
+ } = _ref3;
34
+ const [data, setData] = useState();
35
+ const [error, setError] = useState();
36
+ const [loading, setLoading] = useState(true);
37
+ const engine = useDataEngine();
38
+ const [getHumanReadableExpression] = useDataMutation(validateIndicatorExpressionMutation, {
39
+ onError: setError
40
+ });
41
+ const fetchData = useCallback(async () => {
42
+ const {
43
+ indicator
44
+ } = await engine.query(indicatorQuery, {
45
+ variables: {
46
+ id,
47
+ displayNameProp
48
+ },
49
+ onError: setError
50
+ });
51
+ if (indicator.denominator) {
52
+ const result = await getHumanReadableExpression({
53
+ expression: indicator.denominator
54
+ });
55
+ if (result) {
56
+ indicator.humanReadableDenominatorExpression = result;
57
+ }
58
+ }
59
+ if (indicator.numerator) {
60
+ const result = await getHumanReadableExpression({
61
+ expression: indicator.numerator
62
+ });
63
+ if (result) {
64
+ indicator.humanReadableNumeratorExpression = result;
65
+ }
66
+ }
67
+ setData({
68
+ indicator
69
+ });
70
+ setLoading(false);
71
+ }, [displayNameProp, engine, getHumanReadableExpression, id]);
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.indicator,
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('Numerator description')), /*#__PURE__*/React.createElement("td", {
85
+ className: `jsx-${styles.__hash}`
86
+ }, data !== null && data !== void 0 && data.indicator.displayNumeratorDescription ? data.indicator.displayNumeratorDescription : /*#__PURE__*/React.createElement("span", {
87
+ className: `jsx-${styles.__hash}` + " " + "none"
88
+ }, i18n.t('None')))), /*#__PURE__*/React.createElement("tr", {
89
+ className: `jsx-${styles.__hash}`
90
+ }, /*#__PURE__*/React.createElement("th", {
91
+ className: `jsx-${styles.__hash}`
92
+ }, i18n.t('Numerator expression')), /*#__PURE__*/React.createElement("td", {
93
+ className: `jsx-${styles.__hash}`
94
+ }, data !== null && data !== void 0 && data.indicator.humanReadableNumeratorExpression ? renderHumanReadableExpression(data.indicator.humanReadableNumeratorExpression) : /*#__PURE__*/React.createElement("span", {
95
+ className: `jsx-${styles.__hash}` + " " + "none"
96
+ }, i18n.t('None')))), /*#__PURE__*/React.createElement("tr", {
97
+ className: `jsx-${styles.__hash}`
98
+ }, /*#__PURE__*/React.createElement("th", {
99
+ className: `jsx-${styles.__hash}`
100
+ }, i18n.t('Denominator description')), /*#__PURE__*/React.createElement("td", {
101
+ className: `jsx-${styles.__hash}`
102
+ }, data !== null && data !== void 0 && data.indicator.displayDenominatorDescription ? data.indicator.displayDenominatorDescription : /*#__PURE__*/React.createElement("span", {
103
+ className: `jsx-${styles.__hash}` + " " + "none"
104
+ }, i18n.t('None')))), /*#__PURE__*/React.createElement("tr", {
105
+ className: `jsx-${styles.__hash}`
106
+ }, /*#__PURE__*/React.createElement("th", {
107
+ className: `jsx-${styles.__hash}`
108
+ }, i18n.t('Denominator expression')), /*#__PURE__*/React.createElement("td", {
109
+ className: `jsx-${styles.__hash}`
110
+ }, data !== null && data !== void 0 && data.indicator.humanReadableDenominatorExpression ? renderHumanReadableExpression(data.indicator.humanReadableDenominatorExpression) : /*#__PURE__*/React.createElement("span", {
111
+ className: `jsx-${styles.__hash}` + " " + "none"
112
+ }, i18n.t('None')))), /*#__PURE__*/React.createElement("tr", {
113
+ className: `jsx-${styles.__hash}`
114
+ }, /*#__PURE__*/React.createElement("th", {
115
+ className: `jsx-${styles.__hash}`
116
+ }, i18n.t('Annualized')), /*#__PURE__*/React.createElement("td", {
117
+ className: `jsx-${styles.__hash}`
118
+ }, data !== null && data !== void 0 && data.indicator.annualized ? i18n.t('Yes') : i18n.t('No'))), /*#__PURE__*/React.createElement("tr", {
119
+ className: `jsx-${styles.__hash}`
120
+ }, /*#__PURE__*/React.createElement("th", {
121
+ className: `jsx-${styles.__hash}`
122
+ }, i18n.t('Indicator type')), /*#__PURE__*/React.createElement("td", {
123
+ className: `jsx-${styles.__hash}`
124
+ }, `${data === null || data === void 0 ? void 0 : data.indicator.indicatorType.displayName}, ${data === null || data === void 0 ? void 0 : data.indicator.indicatorType.factor}`)), (data === null || data === void 0 ? void 0 : data.indicator.decimals) && /*#__PURE__*/React.createElement("tr", {
125
+ className: `jsx-${styles.__hash}`
126
+ }, /*#__PURE__*/React.createElement("th", {
127
+ className: `jsx-${styles.__hash}`
128
+ }, i18n.t('Decimals in output')), /*#__PURE__*/React.createElement("td", {
129
+ className: `jsx-${styles.__hash}`
130
+ }, data.indicator.decimals)), Boolean(data === null || data === void 0 ? void 0 : data.indicator.dataSets.length) && /*#__PURE__*/React.createElement("tr", {
131
+ className: `jsx-${styles.__hash}`
132
+ }, /*#__PURE__*/React.createElement("th", {
133
+ className: `jsx-${styles.__hash}`
134
+ }, i18n.t('Data set(s)')), /*#__PURE__*/React.createElement("td", {
135
+ className: `jsx-${styles.__hash}`
136
+ }, data.indicator.dataSets.length === 1 ? data.indicator.dataSets[0].displayName : /*#__PURE__*/React.createElement("div", {
137
+ className: `jsx-${styles.__hash}` + " " + "content-wrap"
138
+ }, /*#__PURE__*/React.createElement("ul", {
139
+ className: `jsx-${styles.__hash}`
140
+ }, data.indicator.dataSets.map(_ref4 => {
141
+ let {
142
+ id,
143
+ displayName
144
+ } = _ref4;
145
+ return /*#__PURE__*/React.createElement("li", {
146
+ key: id,
147
+ className: `jsx-${styles.__hash}`
148
+ }, displayName);
149
+ }))))), /*#__PURE__*/React.createElement("tr", {
150
+ className: `jsx-${styles.__hash}`
151
+ }, /*#__PURE__*/React.createElement("th", {
152
+ className: `jsx-${styles.__hash}`
153
+ }, i18n.t('Group membership')), /*#__PURE__*/React.createElement("td", {
154
+ className: `jsx-${styles.__hash}`
155
+ }, (data === null || data === void 0 ? void 0 : data.indicator.indicatorGroups) && renderGroupMemberships(data.indicator.indicatorGroups))), Boolean(data === null || data === void 0 ? void 0 : data.indicator.legendSets.length) && /*#__PURE__*/React.createElement("tr", {
156
+ className: `jsx-${styles.__hash}`
157
+ }, /*#__PURE__*/React.createElement("th", {
158
+ className: `jsx-${styles.__hash}`
159
+ }, i18n.t('Legend set(s)')), /*#__PURE__*/React.createElement("td", {
160
+ className: `jsx-${styles.__hash}`
161
+ }, renderLegendSets(data.indicator.legendSets)))), /*#__PURE__*/React.createElement(_JSXStyle, {
162
+ id: styles.__hash
163
+ }, styles));
164
+ };
165
+ IndicatorInfo.propTypes = {
166
+ displayNameProp: PropTypes.string,
167
+ id: PropTypes.string,
168
+ type: PropTypes.string
169
+ };
@@ -0,0 +1,54 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { Popover } from '@dhis2/ui';
3
+ import PropTypes from 'prop-types';
4
+ import React from 'react';
5
+ import { REPORTING_RATE } from '../../../modules/dataSets.js'; // data sets
6
+ import { DIMENSION_TYPE_DATA_ELEMENT, DIMENSION_TYPE_DATA_ELEMENT_OPERAND, DIMENSION_TYPE_EXPRESSION_DIMENSION_ITEM,
7
+ // calculation
8
+ DIMENSION_TYPE_INDICATOR, DIMENSION_TYPE_PROGRAM_ATTRIBUTE,
9
+ // event data items
10
+ DIMENSION_TYPE_PROGRAM_DATA_ELEMENT,
11
+ // event data items
12
+ DIMENSION_TYPE_PROGRAM_INDICATOR } from '../../../modules/dataTypes.js';
13
+ import { CalculationInfo } from './CalculationInfo.js';
14
+ import { DataElementInfo } from './DataElementInfo.js';
15
+ import { DataElementOperandInfo } from './DataElementOperandInfo.js';
16
+ import { DataSetInfo } from './DataSetInfo.js';
17
+ import { EventDataItemInfo } from './EventDataItemInfo.js';
18
+ import { IndicatorInfo } from './IndicatorInfo.js';
19
+ import { ProgramIndicatorInfo } from './ProgramIndicatorInfo.js';
20
+ import styles from './styles/InfoPopover.style.js';
21
+ export const InfoPopover = _ref => {
22
+ let {
23
+ reference,
24
+ onClose,
25
+ dataTest,
26
+ ...props
27
+ } = _ref;
28
+ const type = props.item.type;
29
+ const infoProps = {
30
+ type,
31
+ id: props.item.id,
32
+ displayNameProp: props.displayNameProp
33
+ };
34
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popover, {
35
+ placement: "bottom-end",
36
+ reference: reference,
37
+ onClickOutside: onClose,
38
+ maxWidth: 480,
39
+ arrow: false,
40
+ elevation: "rgba(0, 0, 0, 0.1) 0px 1px 5px, rgba(0, 0, 0, 0.07) 0px 3.6px 13px, rgba(0, 0, 0, 0.06) 0px 8.4px 23px, rgba(0, 0, 0, 0.05) 0px 23px 35px"
41
+ }, /*#__PURE__*/React.createElement("div", {
42
+ "data-test": `${dataTest}-table`,
43
+ className: `jsx-${styles.__hash}` + " " + "popover"
44
+ }, type === DIMENSION_TYPE_DATA_ELEMENT && /*#__PURE__*/React.createElement(DataElementInfo, infoProps), type === DIMENSION_TYPE_DATA_ELEMENT_OPERAND && /*#__PURE__*/React.createElement(DataElementOperandInfo, infoProps), type === DIMENSION_TYPE_EXPRESSION_DIMENSION_ITEM && /*#__PURE__*/React.createElement(CalculationInfo, infoProps), type === REPORTING_RATE /* TODO: verify this! */ && /*#__PURE__*/React.createElement(DataSetInfo, infoProps), type === DIMENSION_TYPE_INDICATOR && /*#__PURE__*/React.createElement(IndicatorInfo, infoProps), [DIMENSION_TYPE_PROGRAM_ATTRIBUTE, DIMENSION_TYPE_PROGRAM_DATA_ELEMENT].includes(type) && /*#__PURE__*/React.createElement(EventDataItemInfo, infoProps), type === DIMENSION_TYPE_PROGRAM_INDICATOR && /*#__PURE__*/React.createElement(ProgramIndicatorInfo, infoProps))), /*#__PURE__*/React.createElement(_JSXStyle, {
45
+ id: styles.__hash
46
+ }, styles));
47
+ };
48
+ InfoPopover.propTypes = {
49
+ dataTest: PropTypes.string,
50
+ displayNameProp: PropTypes.string,
51
+ item: PropTypes.object,
52
+ reference: PropTypes.object,
53
+ onClose: PropTypes.func
54
+ };
@@ -0,0 +1,205 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { useTimeZoneConversion } from '@dhis2/app-runtime';
3
+ import { Center, CircularLoader } from '@dhis2/ui';
4
+ import moment from 'moment';
5
+ import PropTypes from 'prop-types';
6
+ import React from 'react';
7
+ import i18n from '../../../locales/index.js';
8
+ import { DIMENSION_TYPE_EXPRESSION_DIMENSION_ITEM // calculation
9
+ } from '../../../modules/dataTypes.js';
10
+ import styles from './styles/InfoPopover.style.js';
11
+ export const getCommonFields = displayNameProp => `attributeValues[attribute[id,displayName],value],code,created,createdBy,${displayNameProp}~rename(displayName),displayDescription,href,id,lastUpdated`;
12
+ export const capitalizeText = text => text && text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
13
+ export const sentenceCaseText = text => text && capitalizeText(text.replaceAll('_', ' ').toLowerCase());
14
+ export const renderDataSets = dataSets => {
15
+ if (dataSets.length === 0) {
16
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
17
+ className: `jsx-${styles.__hash}` + " " + "none"
18
+ }, i18n.t('None')), /*#__PURE__*/React.createElement(_JSXStyle, {
19
+ id: styles.__hash
20
+ }, styles));
21
+ } else if (dataSets.length === 1) {
22
+ return dataSets[0].displayName;
23
+ } else {
24
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
25
+ className: `jsx-${styles.__hash}` + " " + "content-wrap"
26
+ }, /*#__PURE__*/React.createElement("ul", {
27
+ className: `jsx-${styles.__hash}`
28
+ }, dataSets.map(_ref => {
29
+ let {
30
+ id,
31
+ displayName
32
+ } = _ref;
33
+ return /*#__PURE__*/React.createElement("li", {
34
+ key: id,
35
+ className: `jsx-${styles.__hash}`
36
+ }, displayName);
37
+ }))), /*#__PURE__*/React.createElement(_JSXStyle, {
38
+ id: styles.__hash
39
+ }, styles));
40
+ }
41
+ };
42
+ export const renderGroupMemberships = groups => {
43
+ if (groups.length === 0) {
44
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
45
+ className: `jsx-${styles.__hash}` + " " + "none"
46
+ }, i18n.t('None')), /*#__PURE__*/React.createElement(_JSXStyle, {
47
+ id: styles.__hash
48
+ }, styles));
49
+ } else if (groups.length === 1) {
50
+ return groups[0].displayName;
51
+ } else {
52
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
53
+ className: `jsx-${styles.__hash}` + " " + "content-wrap"
54
+ }, /*#__PURE__*/React.createElement("ul", {
55
+ className: `jsx-${styles.__hash}`
56
+ }, groups.map(_ref2 => {
57
+ let {
58
+ id,
59
+ displayName
60
+ } = _ref2;
61
+ return /*#__PURE__*/React.createElement("li", {
62
+ key: id,
63
+ className: `jsx-${styles.__hash}`
64
+ }, displayName);
65
+ }))), /*#__PURE__*/React.createElement(_JSXStyle, {
66
+ id: styles.__hash
67
+ }, styles));
68
+ }
69
+ };
70
+ export const renderHumanReadableExpression = expressionData => /*#__PURE__*/React.createElement(React.Fragment, null, expressionData.status === 'ERROR' ? /*#__PURE__*/React.createElement("span", {
71
+ className: `jsx-${styles.__hash}` + " " + "none"
72
+ }, expressionData.message) : /*#__PURE__*/React.createElement("span", {
73
+ className: `jsx-${styles.__hash}` + " " + "code"
74
+ }, expressionData.description), /*#__PURE__*/React.createElement(_JSXStyle, {
75
+ id: styles.__hash
76
+ }, styles));
77
+ export const renderLegendSets = legendSets => {
78
+ return legendSets.length === 1 ? legendSets[0].displayName : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
79
+ className: `jsx-${styles.__hash}` + " " + "content-wrap"
80
+ }, /*#__PURE__*/React.createElement("ul", {
81
+ className: `jsx-${styles.__hash}`
82
+ }, legendSets.map(_ref3 => {
83
+ let {
84
+ id,
85
+ displayName
86
+ } = _ref3;
87
+ return /*#__PURE__*/React.createElement("li", {
88
+ key: id,
89
+ className: `jsx-${styles.__hash}`
90
+ }, displayName);
91
+ }))), /*#__PURE__*/React.createElement(_JSXStyle, {
92
+ id: styles.__hash
93
+ }, styles));
94
+ };
95
+ export const InfoTable = _ref4 => {
96
+ let {
97
+ dataType,
98
+ data,
99
+ error,
100
+ loading,
101
+ children
102
+ } = _ref4;
103
+ const {
104
+ fromServerDate
105
+ } = useTimeZoneConversion();
106
+ return /*#__PURE__*/React.createElement(React.Fragment, null, loading && /*#__PURE__*/React.createElement("div", {
107
+ className: `jsx-${styles.__hash}` + " " + "loader"
108
+ }, /*#__PURE__*/React.createElement(Center, null, /*#__PURE__*/React.createElement(CircularLoader, {
109
+ small: true
110
+ }))), error && /*#__PURE__*/React.createElement("div", {
111
+ className: `jsx-${styles.__hash}` + " " + "error"
112
+ }, /*#__PURE__*/React.createElement("span", {
113
+ className: `jsx-${styles.__hash}`
114
+ }, i18n.t('There was a problem loading information for this data item.'))), data && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("table", {
115
+ className: `jsx-${styles.__hash}` + " " + "data-table"
116
+ }, /*#__PURE__*/React.createElement("tbody", {
117
+ className: `jsx-${styles.__hash}`
118
+ }, /*#__PURE__*/React.createElement("tr", {
119
+ className: `jsx-${styles.__hash}`
120
+ }, /*#__PURE__*/React.createElement("th", {
121
+ className: `jsx-${styles.__hash}`
122
+ }, i18n.t('Name')), /*#__PURE__*/React.createElement("td", {
123
+ className: `jsx-${styles.__hash}`
124
+ }, data.displayName)), children, dataType !== DIMENSION_TYPE_EXPRESSION_DIMENSION_ITEM ? /*#__PURE__*/React.createElement("tr", {
125
+ className: `jsx-${styles.__hash}`
126
+ }, /*#__PURE__*/React.createElement("th", {
127
+ className: `jsx-${styles.__hash}`
128
+ }, i18n.t('Description')), /*#__PURE__*/React.createElement("td", {
129
+ className: `jsx-${styles.__hash}`
130
+ }, data.displayDescription ? /*#__PURE__*/React.createElement("div", {
131
+ className: `jsx-${styles.__hash}` + " " + "content-wrap"
132
+ }, data.displayDescription) : /*#__PURE__*/React.createElement("span", {
133
+ className: `jsx-${styles.__hash}` + " " + "none"
134
+ }, i18n.t('None')))) : data.displayDescription && /*#__PURE__*/React.createElement("tr", {
135
+ className: `jsx-${styles.__hash}`
136
+ }, /*#__PURE__*/React.createElement("th", {
137
+ className: `jsx-${styles.__hash}`
138
+ }, i18n.t('Description')), /*#__PURE__*/React.createElement("td", {
139
+ className: `jsx-${styles.__hash}`
140
+ }, /*#__PURE__*/React.createElement("div", {
141
+ className: `jsx-${styles.__hash}` + " " + "content-wrap"
142
+ }, data.displayDescription))), dataType !== DIMENSION_TYPE_EXPRESSION_DIMENSION_ITEM ? /*#__PURE__*/React.createElement("tr", {
143
+ className: `jsx-${styles.__hash}`
144
+ }, /*#__PURE__*/React.createElement("th", {
145
+ className: `jsx-${styles.__hash}`
146
+ }, i18n.t('Code')), /*#__PURE__*/React.createElement("td", {
147
+ className: `jsx-${styles.__hash}`
148
+ }, data.code ? data.code : /*#__PURE__*/React.createElement("span", {
149
+ className: `jsx-${styles.__hash}` + " " + "none"
150
+ }, i18n.t('None')))) : data.code && /*#__PURE__*/React.createElement("tr", {
151
+ className: `jsx-${styles.__hash}`
152
+ }, /*#__PURE__*/React.createElement("th", {
153
+ className: `jsx-${styles.__hash}`
154
+ }, i18n.t('Code')), /*#__PURE__*/React.createElement("td", {
155
+ className: `jsx-${styles.__hash}`
156
+ }, data.code)), /*#__PURE__*/React.createElement("tr", {
157
+ className: `jsx-${styles.__hash}`
158
+ }, /*#__PURE__*/React.createElement("th", {
159
+ className: `jsx-${styles.__hash}`
160
+ }, i18n.t('ID')), /*#__PURE__*/React.createElement("td", {
161
+ className: `jsx-${styles.__hash}`
162
+ }, /*#__PURE__*/React.createElement("span", {
163
+ className: `jsx-${styles.__hash}` + " " + "code"
164
+ }, data.id))), /*#__PURE__*/React.createElement("tr", {
165
+ className: `jsx-${styles.__hash}`
166
+ }, /*#__PURE__*/React.createElement("th", {
167
+ className: `jsx-${styles.__hash}`
168
+ }, i18n.t('Last updated date')), /*#__PURE__*/React.createElement("td", {
169
+ className: `jsx-${styles.__hash}`
170
+ }, `${moment(fromServerDate(data.lastUpdated)).fromNow()} (${moment(fromServerDate(data.lastUpdated)).format('YYYY-MM-DD')})`)), /*#__PURE__*/React.createElement("tr", {
171
+ className: `jsx-${styles.__hash}`
172
+ }, /*#__PURE__*/React.createElement("th", {
173
+ className: `jsx-${styles.__hash}`
174
+ }, i18n.t('Created date')), /*#__PURE__*/React.createElement("td", {
175
+ className: `jsx-${styles.__hash}`
176
+ }, `${moment(fromServerDate(data.created)).fromNow()} (${moment(fromServerDate(data.created)).format('YYYY-MM-DD')})`)), /*#__PURE__*/React.createElement("tr", {
177
+ className: `jsx-${styles.__hash}`
178
+ }, /*#__PURE__*/React.createElement("th", {
179
+ className: `jsx-${styles.__hash}`
180
+ }, i18n.t('Created by')), /*#__PURE__*/React.createElement("td", {
181
+ className: `jsx-${styles.__hash}`
182
+ }, `${data.createdBy.displayName}, ${data.createdBy.username}`)), data.attributeValues.map(_ref5 => {
183
+ let {
184
+ attribute,
185
+ value
186
+ } = _ref5;
187
+ return /*#__PURE__*/React.createElement("tr", {
188
+ key: attribute.id,
189
+ className: `jsx-${styles.__hash}`
190
+ }, /*#__PURE__*/React.createElement("th", {
191
+ className: `jsx-${styles.__hash}`
192
+ }, attribute.displayName), /*#__PURE__*/React.createElement("td", {
193
+ className: `jsx-${styles.__hash}`
194
+ }, value));
195
+ })))), /*#__PURE__*/React.createElement(_JSXStyle, {
196
+ id: styles.__hash
197
+ }, styles));
198
+ };
199
+ InfoTable.propTypes = {
200
+ children: PropTypes.node,
201
+ data: PropTypes.object,
202
+ dataType: PropTypes.string,
203
+ error: PropTypes.string,
204
+ loading: PropTypes.bool
205
+ };
@@ -0,0 +1,181 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { useDataMutation, useDataEngine } from '@dhis2/app-runtime';
3
+ import PropTypes from 'prop-types';
4
+ import React, { useCallback, useEffect, useState } from 'react';
5
+ import { validateProgramIndicatorExpressionMutation } from '../../../api/expression.js';
6
+ import i18n from '../../../locales/index.js';
7
+ import { getCommonFields, renderHumanReadableExpression, renderLegendSets, sentenceCaseText, InfoTable } from './InfoTable.js';
8
+ import styles from './styles/InfoPopover.style.js';
9
+ const programIndicatorQuery = {
10
+ programIndicator: {
11
+ resource: 'programIndicators',
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,analyticsPeriodBoundaries[analyticsPeriodBoundaryType,boundaryTarget,id,offsetPeriodType,offsetPeriods],analyticsType,decimals,expression,filter,legendSets[id,displayName],program[displayName]`
24
+ };
25
+ }
26
+ }
27
+ };
28
+ export const ProgramIndicatorInfo = _ref3 => {
29
+ let {
30
+ type,
31
+ id,
32
+ displayNameProp
33
+ } = _ref3;
34
+ const [data, setData] = useState();
35
+ const [error, setError] = useState();
36
+ const [loading, setLoading] = useState(true);
37
+ const engine = useDataEngine();
38
+ const [getHumanReadableExpression] = useDataMutation(validateProgramIndicatorExpressionMutation, {
39
+ onError: setError
40
+ });
41
+ const fetchData = useCallback(async () => {
42
+ const {
43
+ programIndicator
44
+ } = await engine.query(programIndicatorQuery, {
45
+ variables: {
46
+ id,
47
+ displayNameProp
48
+ },
49
+ onError: setError
50
+ });
51
+ if (programIndicator.expression) {
52
+ const result = await getHumanReadableExpression({
53
+ expression: programIndicator.expression
54
+ });
55
+ if (result) {
56
+ programIndicator.humanReadableExpression = result;
57
+ }
58
+ }
59
+ if (programIndicator.filter) {
60
+ const result = await getHumanReadableExpression({
61
+ expression: programIndicator.filter
62
+ });
63
+ if (result) {
64
+ programIndicator.humanReadableFilter = result;
65
+ }
66
+ }
67
+ programIndicator.analyticsPeriodBoundaries.forEach((_ref4, index) => {
68
+ let {
69
+ boundaryTarget
70
+ } = _ref4;
71
+ programIndicator.analyticsPeriodBoundaries[index].boundaryTarget = ['ENROLLMENT_DATE', 'EVENT_DATE', 'INCIDENT_DATE'].includes(boundaryTarget) ? sentenceCaseText(boundaryTarget) : i18n.t('Custom');
72
+ });
73
+ setData({
74
+ programIndicator
75
+ });
76
+ setLoading(false);
77
+ }, [displayNameProp, engine, id, getHumanReadableExpression]);
78
+ useEffect(() => {
79
+ fetchData();
80
+ }, [fetchData]);
81
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfoTable, {
82
+ dataType: type,
83
+ data: data === null || data === void 0 ? void 0 : data.programIndicator,
84
+ loading: loading,
85
+ error: error
86
+ }, /*#__PURE__*/React.createElement("tr", {
87
+ className: `jsx-${styles.__hash}`
88
+ }, /*#__PURE__*/React.createElement("th", {
89
+ className: `jsx-${styles.__hash}`
90
+ }, i18n.t('Program')), /*#__PURE__*/React.createElement("td", {
91
+ className: `jsx-${styles.__hash}`
92
+ }, data === null || data === void 0 ? void 0 : data.programIndicator.program.displayName)), /*#__PURE__*/React.createElement("tr", {
93
+ className: `jsx-${styles.__hash}`
94
+ }, /*#__PURE__*/React.createElement("th", {
95
+ className: `jsx-${styles.__hash}`
96
+ }, i18n.t('Analytics type')), /*#__PURE__*/React.createElement("td", {
97
+ className: `jsx-${styles.__hash}`
98
+ }, (data === null || data === void 0 ? void 0 : data.programIndicator.analyticsType) === 'ENROLLMENT' ? i18n.t('Enrollment') : i18n.t('Event'))), /*#__PURE__*/React.createElement("tr", {
99
+ className: `jsx-${styles.__hash}`
100
+ }, /*#__PURE__*/React.createElement("th", {
101
+ className: `jsx-${styles.__hash}`
102
+ }, i18n.t('Analytics period boundaries')), /*#__PURE__*/React.createElement("td", {
103
+ className: `jsx-${styles.__hash}`
104
+ }, /*#__PURE__*/React.createElement("div", {
105
+ className: `jsx-${styles.__hash}` + " " + "content-wrap"
106
+ }, /*#__PURE__*/React.createElement("ul", {
107
+ className: `jsx-${styles.__hash}`
108
+ }, data === null || data === void 0 ? void 0 : data.programIndicator.analyticsPeriodBoundaries.map(_ref5 => {
109
+ let {
110
+ analyticsPeriodBoundaryType,
111
+ boundaryTarget,
112
+ id,
113
+ offsetPeriodType,
114
+ offsetPeriods
115
+ } = _ref5;
116
+ return /*#__PURE__*/React.createElement("li", {
117
+ key: id,
118
+ className: `jsx-${styles.__hash}`
119
+ }, /*#__PURE__*/React.createElement("span", {
120
+ className: `jsx-${styles.__hash}`
121
+ }, /*#__PURE__*/React.createElement("span", {
122
+ className: `jsx-${styles.__hash}` + " " + "label"
123
+ }, i18n.t('Type:'), "\xA0"), sentenceCaseText(analyticsPeriodBoundaryType)), /*#__PURE__*/React.createElement("br", {
124
+ className: `jsx-${styles.__hash}`
125
+ }), /*#__PURE__*/React.createElement("span", {
126
+ className: `jsx-${styles.__hash}`
127
+ }, /*#__PURE__*/React.createElement("span", {
128
+ className: `jsx-${styles.__hash}` + " " + "label"
129
+ }, i18n.t('Target:'), "\xA0"), boundaryTarget), Boolean(offsetPeriods) && Boolean(offsetPeriodType) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("br", {
130
+ className: `jsx-${styles.__hash}`
131
+ }), /*#__PURE__*/React.createElement("span", {
132
+ className: `jsx-${styles.__hash}`
133
+ }, /*#__PURE__*/React.createElement("span", {
134
+ className: `jsx-${styles.__hash}` + " " + "label"
135
+ }, i18n.t('Offset:'), "\xA0"), i18n.t('{{ offsetPeriodType }} × {{ offsetPeriods }}', {
136
+ offsetPeriodType,
137
+ offsetPeriods
138
+ }))));
139
+ }))))), /*#__PURE__*/React.createElement("tr", {
140
+ className: `jsx-${styles.__hash}`
141
+ }, /*#__PURE__*/React.createElement("th", {
142
+ className: `jsx-${styles.__hash}`
143
+ }, i18n.t('Expression')), /*#__PURE__*/React.createElement("td", {
144
+ className: `jsx-${styles.__hash}`
145
+ }, data !== null && data !== void 0 && data.programIndicator.humanReadableExpression ? renderHumanReadableExpression(data.programIndicator.humanReadableExpression) : /*#__PURE__*/React.createElement("span", {
146
+ className: `jsx-${styles.__hash}` + " " + "none"
147
+ }, i18n.t('None')))), /*#__PURE__*/React.createElement("tr", {
148
+ className: `jsx-${styles.__hash}`
149
+ }, /*#__PURE__*/React.createElement("th", {
150
+ className: `jsx-${styles.__hash}`
151
+ }, i18n.t('Filter')), /*#__PURE__*/React.createElement("td", {
152
+ className: `jsx-${styles.__hash}`
153
+ }, data !== null && data !== void 0 && data.programIndicator.humanReadableFilter ? renderHumanReadableExpression(data.programIndicator.humanReadableFilter) : /*#__PURE__*/React.createElement("span", {
154
+ className: `jsx-${styles.__hash}` + " " + "none"
155
+ }, i18n.t('None')))), /*#__PURE__*/React.createElement("tr", {
156
+ className: `jsx-${styles.__hash}`
157
+ }, /*#__PURE__*/React.createElement("th", {
158
+ className: `jsx-${styles.__hash}`
159
+ }, i18n.t('Aggregation type')), /*#__PURE__*/React.createElement("td", {
160
+ className: `jsx-${styles.__hash}`
161
+ }, data === null || data === void 0 ? void 0 : data.programIndicator.aggregationType)), (data === null || data === void 0 ? void 0 : data.programIndicator) && 'decimals' in data.programIndicator && /*#__PURE__*/React.createElement("tr", {
162
+ className: `jsx-${styles.__hash}`
163
+ }, /*#__PURE__*/React.createElement("th", {
164
+ className: `jsx-${styles.__hash}`
165
+ }, i18n.t('Decimals in output')), /*#__PURE__*/React.createElement("td", {
166
+ className: `jsx-${styles.__hash}`
167
+ }, data.programIndicator.decimals)), Boolean(data === null || data === void 0 ? void 0 : data.programIndicator.legendSets.length) && /*#__PURE__*/React.createElement("tr", {
168
+ className: `jsx-${styles.__hash}`
169
+ }, /*#__PURE__*/React.createElement("th", {
170
+ className: `jsx-${styles.__hash}`
171
+ }, i18n.t('Legend set(s)')), /*#__PURE__*/React.createElement("td", {
172
+ className: `jsx-${styles.__hash}`
173
+ }, renderLegendSets(data.programIndicator.legendSets)))), /*#__PURE__*/React.createElement(_JSXStyle, {
174
+ id: styles.__hash
175
+ }, styles));
176
+ };
177
+ ProgramIndicatorInfo.propTypes = {
178
+ displayNameProp: PropTypes.string,
179
+ id: PropTypes.string,
180
+ type: PropTypes.string
181
+ };
@@ -0,0 +1,4 @@
1
+ import { colors, spacers } from '@dhis2/ui';
2
+ const _defaultExport = [`.popover.jsx-681815212{width:480px;height:360px;border:1px solid ${colors.grey400};overflow-x:hidden;overflow-y:auto;}`, ".loader.jsx-681815212{height:100%;width:100%;}", `.error.jsx-681815212{height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;font-size:14px;color:${colors.grey700};}`, `.data-table.jsx-681815212{display:table;width:100%;border-collapse:collapse;font-size:13px;line-height:17px;margin:${spacers.dp4} 0 0 0;color:${colors.grey900};}`, ".data-table.jsx-681815212 th.jsx-681815212{text-align:left;font-weight:500;padding:8px 0 8px 12px;width:128px;vertical-align:top;}", ".data-table.jsx-681815212 td.jsx-681815212{padding:8px 4px 8px 16px;vertical-align:top;}", ".data-table.jsx-681815212 .content-wrap.jsx-681815212{max-height:240px;overflow-y:auto;}", `.data-table.jsx-681815212 tr.jsx-681815212:hover{background:${colors.grey100};}`, `ul.jsx-681815212{margin:0;padding:0 0 0 ${spacers.dp16};list-style-position:outside;}`, `li.jsx-681815212+li.jsx-681815212{margin:${spacers.dp4} 0 0 0;}`, `details.jsx-681815212 ul.jsx-681815212{margin:${spacers.dp4} 0 0 ${spacers.dp16};}`, `.data-table.jsx-681815212 .code.jsx-681815212{font-size:11px;line-height:15px;display:inline-block;border-radius:2px;background-color:${colors.grey200};outline:3px solid ${colors.grey200};color:${colors.grey900};font-family:ui-monospace,'Cascadia Code','Source Code Pro',Menlo, Consolas,'DejaVu Sans Mono',monospace;font-weight:normal;}`, `.data-table.jsx-681815212 .none.jsx-681815212,.data-table.jsx-681815212 .label.jsx-681815212{color:${colors.grey600};}`];
3
+ _defaultExport.__hash = "681815212";
4
+ export default _defaultExport;