@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
@@ -0,0 +1,103 @@
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 { DIMENSION_TYPE_PROGRAM_DATA_ELEMENT } from '../../../modules/dataTypes.js';
7
+ import { valueTypeDisplayNames } from '../../../modules/valueTypes.js';
8
+ import { getCommonFields, renderLegendSets, InfoTable } from './InfoTable.js';
9
+ import styles from './styles/InfoPopover.style.js';
10
+ const programDataElementQuery = {
11
+ programDataElement: {
12
+ resource: 'dataElements',
13
+ id: _ref => {
14
+ let {
15
+ id
16
+ } = _ref;
17
+ return id;
18
+ },
19
+ params: _ref2 => {
20
+ let {
21
+ displayNameProp
22
+ } = _ref2;
23
+ return {
24
+ fields: `${getCommonFields(displayNameProp)},aggregationType,dimensionItemType,legendSets[id,displayName],optionsSet[displayName],valueType,zeroIsSignificant`
25
+ };
26
+ }
27
+ }
28
+ };
29
+ const programAttributeQuery = {
30
+ programAttribute: {
31
+ resource: 'trackedEntityAttributes',
32
+ id: _ref3 => {
33
+ let {
34
+ id
35
+ } = _ref3;
36
+ return id;
37
+ },
38
+ params: _ref4 => {
39
+ let {
40
+ displayNameProp
41
+ } = _ref4;
42
+ return {
43
+ fields: `${getCommonFields(displayNameProp)},aggregationType,dimensionItemType,legendSets[id,displayName],optionsSet[displayName],valueType,zeroIsSignificant`
44
+ };
45
+ }
46
+ }
47
+ };
48
+ export const EventDataItemInfo = _ref5 => {
49
+ let {
50
+ type,
51
+ id,
52
+ displayNameProp
53
+ } = _ref5;
54
+ const {
55
+ loading,
56
+ error,
57
+ data
58
+ } = useDataQuery(type === DIMENSION_TYPE_PROGRAM_DATA_ELEMENT ? programDataElementQuery : programAttributeQuery, {
59
+ // strip program id (if present)
60
+ variables: {
61
+ id: id.split('.').reverse()[0],
62
+ displayNameProp
63
+ }
64
+ });
65
+ const renderInfoTable = data => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InfoTable, {
66
+ dataType: type,
67
+ data: data,
68
+ loading: loading,
69
+ error: error
70
+ }, /*#__PURE__*/React.createElement("tr", {
71
+ className: `jsx-${styles.__hash}`
72
+ }, /*#__PURE__*/React.createElement("th", {
73
+ className: `jsx-${styles.__hash}`
74
+ }, i18n.t('Type')), /*#__PURE__*/React.createElement("td", {
75
+ className: `jsx-${styles.__hash}`
76
+ }, type === DIMENSION_TYPE_PROGRAM_DATA_ELEMENT ? i18n.t('Data element') : i18n.t('Tracked entity attribute'))), /*#__PURE__*/React.createElement("tr", {
77
+ className: `jsx-${styles.__hash}`
78
+ }, /*#__PURE__*/React.createElement("th", {
79
+ className: `jsx-${styles.__hash}`
80
+ }, i18n.t('Value type')), /*#__PURE__*/React.createElement("td", {
81
+ className: `jsx-${styles.__hash}`
82
+ }, valueTypeDisplayNames[data === null || data === void 0 ? void 0 : data.valueType])), (data === null || data === void 0 ? void 0 : data.optionSet) && /*#__PURE__*/React.createElement("tr", {
83
+ className: `jsx-${styles.__hash}`
84
+ }, /*#__PURE__*/React.createElement("td", {
85
+ className: `jsx-${styles.__hash}`
86
+ }, i18n.t('Option set')), /*#__PURE__*/React.createElement("td", {
87
+ className: `jsx-${styles.__hash}`
88
+ }, data.optionSet.displayName)), Boolean(data === null || data === void 0 ? void 0 : data.legendSets.length) && /*#__PURE__*/React.createElement("tr", {
89
+ className: `jsx-${styles.__hash}`
90
+ }, /*#__PURE__*/React.createElement("th", {
91
+ className: `jsx-${styles.__hash}`
92
+ }, i18n.t('Legend set(s)')), /*#__PURE__*/React.createElement("td", {
93
+ className: `jsx-${styles.__hash}`
94
+ }, renderLegendSets(data.legendSets)))), /*#__PURE__*/React.createElement(_JSXStyle, {
95
+ id: styles.__hash
96
+ }, styles));
97
+ return type === DIMENSION_TYPE_PROGRAM_DATA_ELEMENT ? renderInfoTable(data === null || data === void 0 ? void 0 : data.programDataElement) : renderInfoTable(data === null || data === void 0 ? void 0 : data.programAttribute);
98
+ };
99
+ EventDataItemInfo.propTypes = {
100
+ displayNameProp: PropTypes.string,
101
+ id: PropTypes.string,
102
+ type: PropTypes.string
103
+ };
@@ -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
+ };