@dhis2/analytics 29.4.2 → 29.5.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.
- package/build/cjs/__demo__/AboutAOUnit.stories.js +142 -0
- package/build/cjs/__demo__/PivotTable.event.stories.js +67 -2
- package/build/cjs/__demo__/data/event/eventou.data.json +123 -0
- package/build/cjs/__demo__/data/event/eventou.visualization.json +139 -0
- package/build/cjs/__demo__/data/event/eventstatus.data.hidena.json +122 -0
- package/build/cjs/__demo__/data/event/eventstatus.data.json +132 -0
- package/build/cjs/__demo__/data/event/eventstatus.data.org.json +117 -0
- package/build/cjs/__demo__/data/event/eventstatus.visualization.json +154 -0
- package/build/cjs/__demo__/data/event/integer.data.json +225 -39
- package/build/cjs/__demo__/data/event/integer.visualization.json +3 -1
- package/build/cjs/components/AboutAOUnit/AboutAOUnit.js +15 -8
- package/build/cjs/components/AboutAOUnit/styles/AboutAOUnit.style.js +2 -2
- package/build/cjs/index.js +8 -0
- package/build/cjs/locales/en/translations.json +16 -0
- package/build/cjs/modules/dimensions.js +68 -0
- package/build/cjs/modules/eventVisualization/__tests__/eventVisualization.spec.js +42 -0
- package/build/cjs/modules/eventVisualization/eventVisualization.js +31 -0
- package/build/cjs/modules/response/event/__tests__/response.spec.js +23 -0
- package/build/cjs/modules/response/event/response.js +25 -3
- package/build/es/__demo__/AboutAOUnit.stories.js +132 -0
- package/build/es/__demo__/PivotTable.event.stories.js +63 -1
- package/build/es/__demo__/data/event/eventou.data.json +123 -0
- package/build/es/__demo__/data/event/eventou.visualization.json +139 -0
- package/build/es/__demo__/data/event/eventstatus.data.hidena.json +122 -0
- package/build/es/__demo__/data/event/eventstatus.data.json +132 -0
- package/build/es/__demo__/data/event/eventstatus.data.org.json +117 -0
- package/build/es/__demo__/data/event/eventstatus.visualization.json +154 -0
- package/build/es/__demo__/data/event/integer.data.json +225 -39
- package/build/es/__demo__/data/event/integer.visualization.json +3 -1
- package/build/es/components/AboutAOUnit/AboutAOUnit.js +16 -9
- package/build/es/components/AboutAOUnit/styles/AboutAOUnit.style.js +2 -2
- package/build/es/index.js +4 -0
- package/build/es/locales/en/translations.json +16 -0
- package/build/es/modules/dimensions.js +61 -0
- package/build/es/modules/eventVisualization/__tests__/eventVisualization.spec.js +40 -0
- package/build/es/modules/eventVisualization/eventVisualization.js +25 -0
- package/build/es/modules/response/event/__tests__/response.spec.js +24 -1
- package/build/es/modules/response/event/response.js +23 -2
- package/package.json +9 -7
|
@@ -147,8 +147,7 @@ const AboutAOUnit = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
147
147
|
})), data && /*#__PURE__*/_react.default.createElement("div", {
|
|
148
148
|
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "content"
|
|
149
149
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
150
|
-
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + ((0, _classnames.default)('
|
|
151
|
-
description: true,
|
|
150
|
+
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + ((0, _classnames.default)('description', {
|
|
152
151
|
noDescription: !data.ao.displayDescription
|
|
153
152
|
}) || "")
|
|
154
153
|
}, data.ao.displayDescription ? /*#__PURE__*/_react.default.createElement(_index.RichTextParser, null, data.ao.displayDescription) : /*#__PURE__*/_react.default.createElement("p", {
|
|
@@ -157,28 +156,36 @@ const AboutAOUnit = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
157
156
|
className: `jsx-${_AboutAOUnitStyle.default.__hash}`
|
|
158
157
|
}, /*#__PURE__*/_react.default.createElement("p", {
|
|
159
158
|
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "detailLine"
|
|
159
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
160
|
+
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "icon"
|
|
160
161
|
}, /*#__PURE__*/_react.default.createElement(_ui.IconShare16, {
|
|
161
162
|
color: _ui.colors.grey700
|
|
162
|
-
}), getSharingSummary(data.ao)), /*#__PURE__*/_react.default.createElement("p", {
|
|
163
|
+
})), getSharingSummary(data.ao)), /*#__PURE__*/_react.default.createElement("p", {
|
|
163
164
|
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "detailLine"
|
|
165
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
166
|
+
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "icon"
|
|
164
167
|
}, /*#__PURE__*/_react.default.createElement(_ui.IconClock16, {
|
|
165
168
|
color: _ui.colors.grey700
|
|
166
|
-
}), _d2I18n.default.t('Last updated {{time}}', {
|
|
169
|
+
})), _d2I18n.default.t('Last updated {{time}}', {
|
|
167
170
|
time: (0, _moment.default)(fromServerDate(data.ao.lastUpdated)).fromNow()
|
|
168
171
|
})), /*#__PURE__*/_react.default.createElement("p", {
|
|
169
172
|
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "detailLine"
|
|
173
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
174
|
+
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "icon"
|
|
170
175
|
}, /*#__PURE__*/_react.default.createElement(_ui.IconUser16, {
|
|
171
176
|
color: _ui.colors.grey700
|
|
172
|
-
}), (_data$ao$createdBy = data.ao.createdBy) !== null && _data$ao$createdBy !== void 0 && _data$ao$createdBy.displayName ? _d2I18n.default.t('Created {{time}} by {{author}}', {
|
|
177
|
+
})), (_data$ao$createdBy = data.ao.createdBy) !== null && _data$ao$createdBy !== void 0 && _data$ao$createdBy.displayName ? _d2I18n.default.t('Created {{time}} by {{author}}', {
|
|
173
178
|
time: (0, _moment.default)(fromServerDate(data.ao.created)).fromNow(),
|
|
174
179
|
author: data.ao.createdBy.displayName
|
|
175
180
|
}) : _d2I18n.default.t('Created {{time}}', {
|
|
176
181
|
time: (0, _moment.default)(fromServerDate(data.ao.created)).fromNow()
|
|
177
182
|
})), /*#__PURE__*/_react.default.createElement("p", {
|
|
178
183
|
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "detailLine"
|
|
184
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
185
|
+
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "icon"
|
|
179
186
|
}, /*#__PURE__*/_react.default.createElement(_ui.IconView16, {
|
|
180
187
|
color: _ui.colors.grey700
|
|
181
|
-
}), _d2I18n.default.t('Viewed {{count}} times', {
|
|
188
|
+
})), _d2I18n.default.t('Viewed {{count}} times', {
|
|
182
189
|
count: data.dataStatistics.views,
|
|
183
190
|
defaultValue: 'Viewed 1 time',
|
|
184
191
|
defaultValue_plural: 'Viewed {{count}} times'
|
|
@@ -189,7 +196,7 @@ const AboutAOUnit = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
189
196
|
}, _d2I18n.default.t('Notifications')), data.ao.subscribed ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
|
|
190
197
|
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "subscriptionLabel"
|
|
191
198
|
}, _d2I18n.default.t("You're subscribed and getting updates about new interpretations.")), /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
192
|
-
icon: /*#__PURE__*/_react.default.createElement(_ui.
|
|
199
|
+
icon: /*#__PURE__*/_react.default.createElement(_ui.IconSubscribeOff16, {
|
|
193
200
|
color: _ui.colors.grey700
|
|
194
201
|
}),
|
|
195
202
|
secondary: true,
|
|
@@ -199,7 +206,7 @@ const AboutAOUnit = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
199
206
|
}, _d2I18n.default.t('Unsubscribe'))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
|
|
200
207
|
className: `jsx-${_AboutAOUnitStyle.default.__hash}` + " " + "subscriptionLabel"
|
|
201
208
|
}, _d2I18n.default.t('Subscribe to get updates about new interpretations.')), /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
202
|
-
icon: /*#__PURE__*/_react.default.createElement(_ui.
|
|
209
|
+
icon: /*#__PURE__*/_react.default.createElement(_ui.IconSubscribe16, {
|
|
203
210
|
color: _ui.colors.grey700
|
|
204
211
|
}),
|
|
205
212
|
secondary: true,
|
|
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _ui = require("@dhis2/ui");
|
|
8
|
-
const _defaultExport = [`.container.jsx-
|
|
9
|
-
_defaultExport.__hash = "
|
|
8
|
+
const _defaultExport = [`.container.jsx-3783470976{position:relative;padding:${_ui.spacers.dp16};border-bottom:1px solid ${_ui.colors.grey400};background-color:${_ui.colors.white};}`, `.expanded.jsx-3783470976{padding-bottom:${_ui.spacers.dp16};}`, `.loader.jsx-3783470976{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;padding-top:${_ui.spacers.dp16};}`, ".header.jsx-3783470976{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;cursor:pointer;}", `.title.jsx-3783470976{font-size:16px;font-weight:500;line-height:21px;color:${_ui.colors.grey900};}`, `.content.jsx-3783470976{font-size:14px;line-height:20px;color:${_ui.colors.grey900};}`, `.detailLine.jsx-3783470976{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;margin:0;padding:${_ui.spacers.dp12} 0 0 0;gap:${_ui.spacers.dp8};}`, ".detailLine.jsx-3783470976 .icon.jsx-3783470976{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;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;height:20px;}", ".description.jsx-3783470976{padding:0;}", `.description.jsx-3783470976 p{margin:${_ui.spacers.dp8} 0 ${_ui.spacers.dp4} 0;white-space:pre-line;}`, `.noDescription.jsx-3783470976{color:${_ui.colors.grey500};}`, `.subsection.jsx-3783470976{margin-top:${_ui.spacers.dp24};}`, `.subsectionTitle.jsx-3783470976{color:${_ui.colors.grey800};font-weight:500;margin:0;}`, `.subscriptionLabel.jsx-3783470976{font-size:13px;line-height:18px;margin:${_ui.spacers.dp4} 0 ${_ui.spacers.dp8} 0;color:${_ui.colors.grey600};}`];
|
|
9
|
+
_defaultExport.__hash = "3783470976";
|
|
10
10
|
var _default = exports.default = _defaultExport;
|
package/build/cjs/index.js
CHANGED
|
@@ -228,6 +228,7 @@ var _exportNames = {
|
|
|
228
228
|
HIDE_EMPTY_ROW_ITEMS_ALL: true,
|
|
229
229
|
formatValue: true,
|
|
230
230
|
transformEventAggregateResponse: true,
|
|
231
|
+
transformEventVisualization: true,
|
|
231
232
|
COLOR_SET_DEFAULT: true,
|
|
232
233
|
COLOR_SET_BASIC: true,
|
|
233
234
|
COLOR_SET_EXTENDED: true,
|
|
@@ -1935,6 +1936,12 @@ Object.defineProperty(exports, "transformEventAggregateResponse", {
|
|
|
1935
1936
|
return _response.transformResponse;
|
|
1936
1937
|
}
|
|
1937
1938
|
});
|
|
1939
|
+
Object.defineProperty(exports, "transformEventVisualization", {
|
|
1940
|
+
enumerable: true,
|
|
1941
|
+
get: function () {
|
|
1942
|
+
return _eventVisualization.transformEventVisualization;
|
|
1943
|
+
}
|
|
1944
|
+
});
|
|
1938
1945
|
Object.defineProperty(exports, "useCachedDataQuery", {
|
|
1939
1946
|
enumerable: true,
|
|
1940
1947
|
get: function () {
|
|
@@ -2074,6 +2081,7 @@ var _legends = require("./modules/legends.js");
|
|
|
2074
2081
|
var _hideEmptyRowItems = require("./modules/hideEmptyRowItems.js");
|
|
2075
2082
|
var _renderValue = require("./modules/renderValue.js");
|
|
2076
2083
|
var _response = require("./modules/response/event/response.js");
|
|
2084
|
+
var _eventVisualization = require("./modules/eventVisualization/eventVisualization.js");
|
|
2077
2085
|
var _colorSets = require("./visualizations/util/colors/colorSets.js");
|
|
2078
2086
|
var _index12 = require("./components/PeriodDimension/utils/index.js");
|
|
2079
2087
|
var _relativePeriods = require("./components/PeriodDimension/utils/relativePeriods.js");
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"Last updated {{time}}": "Last updated {{time}}",
|
|
10
10
|
"Created {{time}} by {{author}}": "Created {{time}} by {{author}}",
|
|
11
11
|
"Created {{time}}": "Created {{time}}",
|
|
12
|
+
"Viewed {{count}} times": "Viewed 1 time",
|
|
13
|
+
"Viewed {{count}} times_plural": "Viewed {{count}} times",
|
|
12
14
|
"Notifications": "Notifications",
|
|
13
15
|
"You're subscribed and getting updates about new interpretations.": "You're subscribed and getting updates about new interpretations.",
|
|
14
16
|
"Unsubscribe": "Unsubscribe",
|
|
@@ -185,6 +187,8 @@
|
|
|
185
187
|
"Error loading interpretations": "Error loading interpretations",
|
|
186
188
|
"Could not load interpretations": "Could not load interpretations",
|
|
187
189
|
"Reply": "Reply",
|
|
190
|
+
"{{count}} replies": "{{count}} reply",
|
|
191
|
+
"{{count}} replies_plural": "{{count}} replies",
|
|
188
192
|
"View replies": "View replies",
|
|
189
193
|
"Unlike": "Unlike",
|
|
190
194
|
"Like": "Like",
|
|
@@ -234,6 +238,12 @@
|
|
|
234
238
|
"No line lists found. Try adjusting your search or filter options to find what you're looking for.": "No line lists found. Try adjusting your search or filter options to find what you're looking for.",
|
|
235
239
|
"New line list": "New line list",
|
|
236
240
|
"Hide": "Hide",
|
|
241
|
+
"{{count}} org units": "{{count}} org unit",
|
|
242
|
+
"{{count}} org units_plural": "{{count}} org units",
|
|
243
|
+
"{{count}} levels": "{{count}} level",
|
|
244
|
+
"{{count}} levels_plural": "{{count}} levels",
|
|
245
|
+
"{{count}} groups": "{{count}} group",
|
|
246
|
+
"{{count}} groups_plural": "{{count}} groups",
|
|
237
247
|
"Selected: {{commaSeparatedListOfOrganisationUnits}}": "Selected: {{commaSeparatedListOfOrganisationUnits}}",
|
|
238
248
|
"Nothing selected": "Nothing selected",
|
|
239
249
|
"User organisation unit": "User organisation unit",
|
|
@@ -416,6 +426,10 @@
|
|
|
416
426
|
"Organisation unit": "Organisation unit",
|
|
417
427
|
"Assigned Categories": "Assigned Categories",
|
|
418
428
|
"No value": "No value",
|
|
429
|
+
"Active": "Active",
|
|
430
|
+
"Completed": "Completed",
|
|
431
|
+
"Scheduled": "Scheduled",
|
|
432
|
+
"Cancelled": "Cancelled",
|
|
419
433
|
"Text": "Text",
|
|
420
434
|
"Long text": "Long text",
|
|
421
435
|
"Multi text": "Multi text",
|
|
@@ -468,5 +482,7 @@
|
|
|
468
482
|
"Target": "Target",
|
|
469
483
|
"Base": "Base",
|
|
470
484
|
"Axis {{axisId}}": "Axis {{axisId}}",
|
|
485
|
+
"{{count}} items": "{{count}} item",
|
|
486
|
+
"{{count}} items_plural": "{{count}} items",
|
|
471
487
|
"Reset zoom": "Reset zoom"
|
|
472
488
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getHeaderByVis = void 0;
|
|
7
|
+
// vis: 'dimension' in EventVisualization columns/rows/filters
|
|
8
|
+
// dim: tracker analytics api dimension/filter id
|
|
9
|
+
// header: tracker analytics api header name (query endpoints)
|
|
10
|
+
|
|
11
|
+
const EVENT_DIMENSIONS = [{
|
|
12
|
+
vis: 'ou',
|
|
13
|
+
dim: 'ou',
|
|
14
|
+
header: 'ouname'
|
|
15
|
+
}, {
|
|
16
|
+
vis: 'eventDate',
|
|
17
|
+
dim: 'EVENT_DATE',
|
|
18
|
+
header: 'eventdate'
|
|
19
|
+
}, {
|
|
20
|
+
vis: 'enrollmentDate',
|
|
21
|
+
dim: 'ENROLLMENT_DATE',
|
|
22
|
+
header: 'enrollmentdate'
|
|
23
|
+
}, {
|
|
24
|
+
vis: 'scheduledDate',
|
|
25
|
+
dim: 'SCHEDULED_DATE',
|
|
26
|
+
header: 'scheduleddate'
|
|
27
|
+
}, {
|
|
28
|
+
vis: 'incidentDate',
|
|
29
|
+
dim: 'INCIDENT_DATE',
|
|
30
|
+
header: 'incidentdate'
|
|
31
|
+
}, {
|
|
32
|
+
vis: 'lastUpdated',
|
|
33
|
+
dim: 'LAST_UPDATED',
|
|
34
|
+
header: 'lastupdated'
|
|
35
|
+
}, {
|
|
36
|
+
vis: 'created',
|
|
37
|
+
dim: 'CREATED',
|
|
38
|
+
header: 'created'
|
|
39
|
+
}, {
|
|
40
|
+
vis: 'completed',
|
|
41
|
+
dim: 'COMPLETED',
|
|
42
|
+
header: 'completed'
|
|
43
|
+
}, {
|
|
44
|
+
vis: 'eventStatus',
|
|
45
|
+
dim: 'EVENT_STATUS',
|
|
46
|
+
header: 'eventstatus'
|
|
47
|
+
}, {
|
|
48
|
+
vis: 'programStatus',
|
|
49
|
+
dim: 'PROGRAM_STATUS',
|
|
50
|
+
header: 'programstatus'
|
|
51
|
+
}, {
|
|
52
|
+
vis: 'enrollmentOu',
|
|
53
|
+
dim: 'ENROLLMENT_OU',
|
|
54
|
+
header: 'enrollmentouname'
|
|
55
|
+
}, {
|
|
56
|
+
vis: 'createdBy',
|
|
57
|
+
dim: '',
|
|
58
|
+
header: 'createdbydisplayname'
|
|
59
|
+
}, {
|
|
60
|
+
vis: 'lastUpdatedBy',
|
|
61
|
+
dim: '',
|
|
62
|
+
header: 'lastupdatedbydisplayname'
|
|
63
|
+
}];
|
|
64
|
+
const getHeaderByVis = vis => {
|
|
65
|
+
var _EVENT_DIMENSIONS$fin;
|
|
66
|
+
return (_EVENT_DIMENSIONS$fin = EVENT_DIMENSIONS.find(d => d.vis === vis)) === null || _EVENT_DIMENSIONS$fin === void 0 ? void 0 : _EVENT_DIMENSIONS$fin.header;
|
|
67
|
+
};
|
|
68
|
+
exports.getHeaderByVis = getHeaderByVis;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _eventVisualization = require("../eventVisualization.js");
|
|
4
|
+
const testDim1 = {
|
|
5
|
+
dimension: 'eventDate',
|
|
6
|
+
programStage: {
|
|
7
|
+
id: 'A03MvHHogjR'
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const testDim2 = {
|
|
11
|
+
dimension: 'enrollmentDate',
|
|
12
|
+
program: {
|
|
13
|
+
id: 'IpHINAT79UW'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const testDim3 = {
|
|
17
|
+
dimension: 'created'
|
|
18
|
+
};
|
|
19
|
+
const testAxis = [testDim1];
|
|
20
|
+
const testVis = {
|
|
21
|
+
columns: testAxis,
|
|
22
|
+
rows: [testDim2],
|
|
23
|
+
filters: [testDim3]
|
|
24
|
+
};
|
|
25
|
+
describe('eventVisualization', () => {
|
|
26
|
+
describe('transformEventVisualization', () => {
|
|
27
|
+
it('does not modify dimension, axis or vis', () => {
|
|
28
|
+
const newVis = (0, _eventVisualization.transformEventVisualization)(testVis);
|
|
29
|
+
expect(newVis).not.toBe(testVis);
|
|
30
|
+
expect(newVis.columns).not.toBe(testAxis);
|
|
31
|
+
expect(newVis.columns[0]).not.toBe(testDim1);
|
|
32
|
+
});
|
|
33
|
+
it('applies program stage to id', () => {
|
|
34
|
+
const newVis = (0, _eventVisualization.transformEventVisualization)(testVis);
|
|
35
|
+
expect(newVis.columns[0].dimension).toBe('A03MvHHogjR.eventdate');
|
|
36
|
+
});
|
|
37
|
+
it('applies program to id', () => {
|
|
38
|
+
const newVis = (0, _eventVisualization.transformEventVisualization)(testVis);
|
|
39
|
+
expect(newVis.rows[0].dimension).toBe('IpHINAT79UW.enrollmentdate');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformEventVisualization = void 0;
|
|
7
|
+
var _dimensions = require("../dimensions.js");
|
|
8
|
+
var _layoutGetAllDimensions = require("../layout/layoutGetAllDimensions.js");
|
|
9
|
+
// Dimensions saved with program or program stage in an EventVisualization need
|
|
10
|
+
// transformation before we can pass them to the pivot table engine
|
|
11
|
+
|
|
12
|
+
const cloneAxis = axis => axis === null || axis === void 0 ? void 0 : axis.map(dim => ({
|
|
13
|
+
...dim
|
|
14
|
+
}));
|
|
15
|
+
const transformEventVisualization = vis => {
|
|
16
|
+
// Do not modify the original visualization
|
|
17
|
+
const transformedVis = {
|
|
18
|
+
...vis,
|
|
19
|
+
columns: cloneAxis(vis.columns),
|
|
20
|
+
rows: cloneAxis(vis.rows),
|
|
21
|
+
filters: cloneAxis(vis.filters)
|
|
22
|
+
};
|
|
23
|
+
(0, _layoutGetAllDimensions.layoutGetAllDimensions)(transformedVis).forEach(dim => {
|
|
24
|
+
var _dim$program$id, _dim$program, _dim$programStage;
|
|
25
|
+
const headerName = (0, _dimensions.getHeaderByVis)(dim.dimension);
|
|
26
|
+
const prefix = (_dim$program$id = (_dim$program = dim.program) === null || _dim$program === void 0 ? void 0 : _dim$program.id) !== null && _dim$program$id !== void 0 ? _dim$program$id : (_dim$programStage = dim.programStage) === null || _dim$programStage === void 0 ? void 0 : _dim$programStage.id;
|
|
27
|
+
dim.dimension = prefix ? `${prefix}.${headerName}` : headerName;
|
|
28
|
+
});
|
|
29
|
+
return transformedVis;
|
|
30
|
+
};
|
|
31
|
+
exports.transformEventVisualization = transformEventVisualization;
|
|
@@ -12,6 +12,9 @@ var _datetimeDataOrg = _interopRequireDefault(require("../../../../__demo__/data
|
|
|
12
12
|
var _emailDataHidena = _interopRequireDefault(require("../../../../__demo__/data/event/email.data.hidena.json"));
|
|
13
13
|
var _emailData = _interopRequireDefault(require("../../../../__demo__/data/event/email.data.json"));
|
|
14
14
|
var _emailDataOrg = _interopRequireDefault(require("../../../../__demo__/data/event/email.data.org.json"));
|
|
15
|
+
var _eventstatusDataHidena = _interopRequireDefault(require("../../../../__demo__/data/event/eventstatus.data.hidena.json"));
|
|
16
|
+
var _eventstatusData = _interopRequireDefault(require("../../../../__demo__/data/event/eventstatus.data.json"));
|
|
17
|
+
var _eventstatusDataOrg = _interopRequireDefault(require("../../../../__demo__/data/event/eventstatus.data.org.json"));
|
|
15
18
|
var _integerDataHidena = _interopRequireDefault(require("../../../../__demo__/data/event/integer.data.hidena.json"));
|
|
16
19
|
var _integerData = _interopRequireDefault(require("../../../../__demo__/data/event/integer.data.json"));
|
|
17
20
|
var _integerDataOrg = _interopRequireDefault(require("../../../../__demo__/data/event/integer.data.org.json"));
|
|
@@ -28,6 +31,16 @@ var _valueTypes = require("../../../valueTypes.js");
|
|
|
28
31
|
var _response = require("../response.js");
|
|
29
32
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
30
33
|
describe('response', () => {
|
|
34
|
+
describe('getItemFormatterByHeaderName', () => {
|
|
35
|
+
it('should return the correct formatter and format correctly', () => {
|
|
36
|
+
expect((0, _response.getItemFormatterByHeaderName)('eventstatus')('ACTIVE')).toBe('Active');
|
|
37
|
+
expect((0, _response.getItemFormatterByHeaderName)('eventstatus')('COMPLETED')).toBe('Completed');
|
|
38
|
+
expect((0, _response.getItemFormatterByHeaderName)('eventstatus')('SCHEDULE')).toBe('Scheduled');
|
|
39
|
+
expect((0, _response.getItemFormatterByHeaderName)('programstatus')('ACTIVE')).toBe('Active');
|
|
40
|
+
expect((0, _response.getItemFormatterByHeaderName)('programstatus')('COMPLETED')).toBe('Completed');
|
|
41
|
+
expect((0, _response.getItemFormatterByHeaderName)('programstatus')('CANCELLED')).toBe('Cancelled');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
31
44
|
describe('getItemFormatterByValueType', () => {
|
|
32
45
|
it('should return the correct formatter and format correctly', () => {
|
|
33
46
|
expect((0, _response.getItemFormatterByValueType)(_valueTypes.VALUE_TYPE_BOOLEAN)('1')).toBe('Yes');
|
|
@@ -121,5 +134,15 @@ describe('response', () => {
|
|
|
121
134
|
})).toEqual(_yesonlyDataHidena.default);
|
|
122
135
|
});
|
|
123
136
|
});
|
|
137
|
+
describe('eventstatus', () => {
|
|
138
|
+
it('transforms response', () => {
|
|
139
|
+
expect((0, _response.transformResponse)(_eventstatusDataOrg.default)).toEqual(_eventstatusData.default);
|
|
140
|
+
});
|
|
141
|
+
it('transforms response and hides N/A data', () => {
|
|
142
|
+
expect((0, _response.transformResponse)(_eventstatusDataOrg.default, {
|
|
143
|
+
hideNaData: true
|
|
144
|
+
})).toEqual(_eventstatusDataHidena.default);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
124
147
|
});
|
|
125
148
|
});
|
|
@@ -3,13 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.transformResponse = exports.getItemFormatterByValueType = exports.UNSUPPORTED_VALUE_TYPES = exports.PREFIX_SEPARATOR = exports.NA_VALUE_ITEM = exports.NA_VALUE = void 0;
|
|
6
|
+
exports.transformResponse = exports.getItemFormatterByValueType = exports.getItemFormatterByHeaderName = exports.getItemFormatter = exports.UNSUPPORTED_VALUE_TYPES = exports.PREFIX_SEPARATOR = exports.NA_VALUE_ITEM = exports.NA_VALUE = void 0;
|
|
7
7
|
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
8
8
|
var _predefinedDimensions = require("../../predefinedDimensions.js");
|
|
9
9
|
var _valueTypes = require("../../valueTypes.js");
|
|
10
10
|
var _default = require("./default.js");
|
|
11
11
|
var _optionSet = require("./optionSet.js");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
// Responses coming from these endpoints need transformation
|
|
14
|
+
// before we can pass it to the pivot table engine:
|
|
15
|
+
// - analytics/events/aggregate
|
|
16
|
+
// - analytics/enrollments/aggregate
|
|
17
|
+
|
|
13
18
|
const PREFIX_SEPARATOR = exports.PREFIX_SEPARATOR = '_';
|
|
14
19
|
const NA_VALUE = exports.NA_VALUE = '';
|
|
15
20
|
const NA_VALUE_ITEM = exports.NA_VALUE_ITEM = {
|
|
@@ -22,6 +27,20 @@ const NA_VALUE_ITEM = exports.NA_VALUE_ITEM = {
|
|
|
22
27
|
}
|
|
23
28
|
};
|
|
24
29
|
const UNSUPPORTED_VALUE_TYPES = exports.UNSUPPORTED_VALUE_TYPES = [_valueTypes.VALUE_TYPE_COORDINATE, _valueTypes.VALUE_TYPE_GEOJSON, _valueTypes.VALUE_TYPE_FILE_RESOURCE, _valueTypes.VALUE_TYPE_IMAGE, _valueTypes.VALUE_TYPE_MULTI_TEXT, _valueTypes.VALUE_TYPE_REFERENCE];
|
|
30
|
+
const STATUSES = {
|
|
31
|
+
ACTIVE: _d2I18n.default.t('Active'),
|
|
32
|
+
COMPLETED: _d2I18n.default.t('Completed'),
|
|
33
|
+
SCHEDULE: _d2I18n.default.t('Scheduled'),
|
|
34
|
+
CANCELLED: _d2I18n.default.t('Cancelled')
|
|
35
|
+
};
|
|
36
|
+
const formatStatus = value => STATUSES[value] || value;
|
|
37
|
+
const getItemFormatter = ({
|
|
38
|
+
name,
|
|
39
|
+
valueType
|
|
40
|
+
}) => getItemFormatterByHeaderName(name) || getItemFormatterByValueType(valueType);
|
|
41
|
+
exports.getItemFormatter = getItemFormatter;
|
|
42
|
+
const getItemFormatterByHeaderName = name => name.endsWith('eventstatus') || name.endsWith('programstatus') ? formatStatus : undefined;
|
|
43
|
+
exports.getItemFormatterByHeaderName = getItemFormatterByHeaderName;
|
|
25
44
|
const getItemFormatterByValueType = valueType => {
|
|
26
45
|
switch (valueType) {
|
|
27
46
|
case _valueTypes.VALUE_TYPE_AGE:
|
|
@@ -39,6 +58,9 @@ const getItemFormatterByValueType = valueType => {
|
|
|
39
58
|
}
|
|
40
59
|
};
|
|
41
60
|
exports.getItemFormatterByValueType = getItemFormatterByValueType;
|
|
61
|
+
const EXCLUDED_HEADER_NAMES = new Set([_predefinedDimensions.DIMENSION_ID_PERIOD, _predefinedDimensions.DIMENSION_ID_ORGUNIT, 'lastupdated', 'created', 'completed']);
|
|
62
|
+
const EXCLUDED_HEADER_SUFFIXES = ['.eventdate', '.enrollmentdate', '.scheduleddate', '.incidentdate', '.ou'];
|
|
63
|
+
const isIncludedHeader = header => Boolean(header.meta) && !EXCLUDED_HEADER_NAMES.has(header.name) && !EXCLUDED_HEADER_SUFFIXES.some(suffix => header.name.endsWith(suffix));
|
|
42
64
|
const transformResponse = (response, {
|
|
43
65
|
hideNaData = false
|
|
44
66
|
} = {}) => {
|
|
@@ -62,7 +84,7 @@ const transformResponse = (response, {
|
|
|
62
84
|
const metaHeaders = response.headers.map((header, index) => ({
|
|
63
85
|
...header,
|
|
64
86
|
index
|
|
65
|
-
})).filter(
|
|
87
|
+
})).filter(isIncludedHeader);
|
|
66
88
|
|
|
67
89
|
// Legendsets use uids and do not need transformation
|
|
68
90
|
// Skip unsupported value types
|
|
@@ -74,7 +96,7 @@ const transformResponse = (response, {
|
|
|
74
96
|
transformedResponse = (0, _optionSet.applyOptionSetHandler)(transformedResponse, header.index);
|
|
75
97
|
} else {
|
|
76
98
|
transformedResponse = (0, _default.applyDefaultHandler)(transformedResponse, header.index, {
|
|
77
|
-
itemFormatter:
|
|
99
|
+
itemFormatter: getItemFormatter(header)
|
|
78
100
|
});
|
|
79
101
|
}
|
|
80
102
|
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { CustomDataProvider } from '@dhis2/app-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import AboutAOUnit from '../components/AboutAOUnit/AboutAOUnit.js';
|
|
4
|
+
const verboseData = {
|
|
5
|
+
visualizations: {
|
|
6
|
+
id: 'abc123verbose',
|
|
7
|
+
displayDescription: 'This is a comprehensive **visualization** showing district-level aggregate data across all 47 counties for the Expanded Programme on Immunization (EPI) including BCG, OPV, Pentavalent, and Measles-Rubella coverage rates disaggregated by age, sex, and facility ownership for the fiscal year 2024/2025.',
|
|
8
|
+
created: '2023-01-15T08:30:00.000',
|
|
9
|
+
createdBy: {
|
|
10
|
+
displayName: 'Dr. Alexandria Konstantinopolous-Whittington III, MD, PhD'
|
|
11
|
+
},
|
|
12
|
+
lastUpdated: '2024-11-02T14:22:00.000',
|
|
13
|
+
subscribed: true,
|
|
14
|
+
sharing: {
|
|
15
|
+
public: 'r',
|
|
16
|
+
users: {
|
|
17
|
+
u1: {
|
|
18
|
+
displayName: 'Maria-Fernanda de los Ángeles Gutiérrez-Montoya',
|
|
19
|
+
access: 'rw'
|
|
20
|
+
},
|
|
21
|
+
u2: {
|
|
22
|
+
displayName: 'Jean-Pierre Barthélémy Christophersen',
|
|
23
|
+
access: 'r'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
userGroups: {
|
|
27
|
+
g1: {
|
|
28
|
+
displayName: 'National Immunization Programme Monitoring & Evaluation Team',
|
|
29
|
+
access: 'rw'
|
|
30
|
+
},
|
|
31
|
+
g2: {
|
|
32
|
+
displayName: 'District Health Information System Administrators Group',
|
|
33
|
+
access: 'r'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
'dataStatistics/favorites': {
|
|
39
|
+
views: 14873
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const shortData = {
|
|
43
|
+
visualizations: {
|
|
44
|
+
id: 'xyz789short',
|
|
45
|
+
displayDescription: 'ANC coverage Q3',
|
|
46
|
+
created: '2025-12-01T10:00:00.000',
|
|
47
|
+
createdBy: {
|
|
48
|
+
displayName: 'Li Wei'
|
|
49
|
+
},
|
|
50
|
+
lastUpdated: '2026-04-10T09:00:00.000',
|
|
51
|
+
subscribed: false,
|
|
52
|
+
sharing: {
|
|
53
|
+
public: 'rw',
|
|
54
|
+
users: {},
|
|
55
|
+
userGroups: {
|
|
56
|
+
g1: {
|
|
57
|
+
displayName: 'HMIS',
|
|
58
|
+
access: 'r'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
'dataStatistics/favorites': {
|
|
64
|
+
views: 3
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const missingFieldsData = {
|
|
68
|
+
visualizations: {
|
|
69
|
+
id: 'missing456',
|
|
70
|
+
displayDescription: null,
|
|
71
|
+
created: '2026-03-20T12:00:00.000',
|
|
72
|
+
createdBy: null,
|
|
73
|
+
lastUpdated: '2026-04-13T06:45:00.000',
|
|
74
|
+
subscribed: false,
|
|
75
|
+
sharing: {
|
|
76
|
+
public: '',
|
|
77
|
+
users: {},
|
|
78
|
+
userGroups: {}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
'dataStatistics/favorites': {
|
|
82
|
+
views: 0
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
export default {
|
|
86
|
+
title: 'AboutAOUnit'
|
|
87
|
+
};
|
|
88
|
+
export const VerboseData = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
89
|
+
data: verboseData
|
|
90
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
91
|
+
style: {
|
|
92
|
+
width: 372,
|
|
93
|
+
padding: '16px',
|
|
94
|
+
backgroundColor: 'lightgray'
|
|
95
|
+
}
|
|
96
|
+
}, /*#__PURE__*/React.createElement(AboutAOUnit, {
|
|
97
|
+
type: "visualization",
|
|
98
|
+
id: "abc123verbose"
|
|
99
|
+
})));
|
|
100
|
+
VerboseData.story = {
|
|
101
|
+
name: 'Verbose data with long labels'
|
|
102
|
+
};
|
|
103
|
+
export const ShortLabels = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
104
|
+
data: shortData
|
|
105
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
106
|
+
style: {
|
|
107
|
+
width: 372,
|
|
108
|
+
padding: '16px',
|
|
109
|
+
backgroundColor: 'lightgray'
|
|
110
|
+
}
|
|
111
|
+
}, /*#__PURE__*/React.createElement(AboutAOUnit, {
|
|
112
|
+
type: "visualization",
|
|
113
|
+
id: "xyz789short"
|
|
114
|
+
})));
|
|
115
|
+
ShortLabels.story = {
|
|
116
|
+
name: 'Short labels'
|
|
117
|
+
};
|
|
118
|
+
export const MissingFields = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
|
|
119
|
+
data: missingFieldsData
|
|
120
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
121
|
+
style: {
|
|
122
|
+
width: 372,
|
|
123
|
+
padding: '16px',
|
|
124
|
+
backgroundColor: 'lightgray'
|
|
125
|
+
}
|
|
126
|
+
}, /*#__PURE__*/React.createElement(AboutAOUnit, {
|
|
127
|
+
type: "visualization",
|
|
128
|
+
id: "missing456"
|
|
129
|
+
})));
|
|
130
|
+
MissingFields.story = {
|
|
131
|
+
name: 'Missing fields (no description, no author, no sharing)'
|
|
132
|
+
};
|
|
@@ -13,6 +13,11 @@ import datetimeVisualization from './data/event/datetime.visualization.json';
|
|
|
13
13
|
import emailDataHideNa from './data/event/email.data.hidena.json';
|
|
14
14
|
import emailData from './data/event/email.data.json';
|
|
15
15
|
import emailVisualization from './data/event/email.visualization.json';
|
|
16
|
+
import eventouData from './data/event/eventou.data.json';
|
|
17
|
+
import eventouVisualization from './data/event/eventou.visualization.json';
|
|
18
|
+
import eventstatusDataHideNa from './data/event/eventstatus.data.hidena.json';
|
|
19
|
+
import eventstatusData from './data/event/eventstatus.data.json';
|
|
20
|
+
import eventstatusVisualization from './data/event/eventstatus.visualization.json';
|
|
16
21
|
import integerDataHideNa from './data/event/integer.data.hidena.json';
|
|
17
22
|
import integerData from './data/event/integer.data.json';
|
|
18
23
|
import integerVisualization from './data/event/integer.visualization.json';
|
|
@@ -411,4 +416,61 @@ export const Yesonly = (_, {
|
|
|
411
416
|
visualization: visualization
|
|
412
417
|
}));
|
|
413
418
|
};
|
|
414
|
-
Yesonly.storyName = 'Yesonly';
|
|
419
|
+
Yesonly.storyName = 'Yesonly';
|
|
420
|
+
export const EventstatusNA = (_, {
|
|
421
|
+
pivotTableOptions
|
|
422
|
+
}) => {
|
|
423
|
+
const visualization = {
|
|
424
|
+
...eventstatusVisualization,
|
|
425
|
+
...visualizationReset,
|
|
426
|
+
...pivotTableOptions
|
|
427
|
+
};
|
|
428
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
429
|
+
style: {
|
|
430
|
+
width: 800,
|
|
431
|
+
height: 600
|
|
432
|
+
}
|
|
433
|
+
}, /*#__PURE__*/React.createElement(PivotTable, {
|
|
434
|
+
data: eventstatusData,
|
|
435
|
+
visualization: visualization
|
|
436
|
+
}));
|
|
437
|
+
};
|
|
438
|
+
EventstatusNA.storyName = 'Eventstatus N/A';
|
|
439
|
+
export const Eventstatus = (_, {
|
|
440
|
+
pivotTableOptions
|
|
441
|
+
}) => {
|
|
442
|
+
const visualization = {
|
|
443
|
+
...eventstatusVisualization,
|
|
444
|
+
...visualizationReset,
|
|
445
|
+
...pivotTableOptions
|
|
446
|
+
};
|
|
447
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
448
|
+
style: {
|
|
449
|
+
width: 800,
|
|
450
|
+
height: 600
|
|
451
|
+
}
|
|
452
|
+
}, /*#__PURE__*/React.createElement(PivotTable, {
|
|
453
|
+
data: eventstatusDataHideNa,
|
|
454
|
+
visualization: visualization
|
|
455
|
+
}));
|
|
456
|
+
};
|
|
457
|
+
Eventstatus.storyName = 'Eventstatus';
|
|
458
|
+
export const Eventou = (_, {
|
|
459
|
+
pivotTableOptions
|
|
460
|
+
}) => {
|
|
461
|
+
const visualization = {
|
|
462
|
+
...eventouVisualization,
|
|
463
|
+
...visualizationReset,
|
|
464
|
+
...pivotTableOptions
|
|
465
|
+
};
|
|
466
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
467
|
+
style: {
|
|
468
|
+
width: 800,
|
|
469
|
+
height: 600
|
|
470
|
+
}
|
|
471
|
+
}, /*#__PURE__*/React.createElement(PivotTable, {
|
|
472
|
+
data: eventouData,
|
|
473
|
+
visualization: visualization
|
|
474
|
+
}));
|
|
475
|
+
};
|
|
476
|
+
Eventou.storyName = 'Event orgunit';
|