@dhis2/analytics 23.13.13 → 24.0.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/CHANGELOG.md +12 -0
- package/build/cjs/components/AboutAOUnit/AboutAOUnit.js +15 -9
- package/build/cjs/components/AboutAOUnit/utils.js +48 -0
- package/build/cjs/locales/en/translations.json +4 -1
- package/build/es/components/AboutAOUnit/AboutAOUnit.js +14 -9
- package/build/es/components/AboutAOUnit/utils.js +31 -0
- package/build/es/locales/en/translations.json +4 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [24.0.0](https://github.com/dhis2/analytics/compare/v23.13.13...v24.0.0) (2022-08-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add support for Maps app (LIBS-339) ([#1322](https://github.com/dhis2/analytics/issues/1322)) ([b92717d](https://github.com/dhis2/analytics/commit/b92717d941d7bdb15394cecd663fa7fa9b1a57f2))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* the type prop changed from the plural version to the singular, this requires updating the apps that use the AboutAOUnit component.
|
|
12
|
+
|
|
1
13
|
## [23.13.13](https://github.com/dhis2/analytics/compare/v23.13.12...v23.13.13) (2022-08-22)
|
|
2
14
|
|
|
3
15
|
|
|
@@ -25,6 +25,8 @@ var _list = require("../../modules/list.js");
|
|
|
25
25
|
|
|
26
26
|
var _AboutAOUnitStyle = _interopRequireDefault(require("./styles/AboutAOUnit.style.js"));
|
|
27
27
|
|
|
28
|
+
var _utils = require("./utils.js");
|
|
29
|
+
|
|
28
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
31
|
|
|
30
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -36,7 +38,7 @@ const READ_AND_WRITE = 'rw';
|
|
|
36
38
|
|
|
37
39
|
const getQueries = type => ({
|
|
38
40
|
ao: {
|
|
39
|
-
resource: type,
|
|
41
|
+
resource: _utils.AOTypeMap[type].apiEndpoint,
|
|
40
42
|
id: _ref => {
|
|
41
43
|
let {
|
|
42
44
|
id
|
|
@@ -59,22 +61,24 @@ const getQueries = type => ({
|
|
|
59
61
|
});
|
|
60
62
|
|
|
61
63
|
const getSubscribeMutation = (type, id) => ({
|
|
62
|
-
resource: "".concat(type, "/").concat(id, "/subscriber"),
|
|
64
|
+
resource: "".concat(_utils.AOTypeMap[type].apiEndpoint, "/").concat(id, "/subscriber"),
|
|
63
65
|
type: 'create'
|
|
64
66
|
});
|
|
65
67
|
|
|
66
68
|
const getUnsubscribeMutation = (type, id) => ({
|
|
67
|
-
resource: "".concat(type, "/").concat(id, "/subscriber"),
|
|
69
|
+
resource: "".concat(_utils.AOTypeMap[type].apiEndpoint, "/").concat(id, "/subscriber"),
|
|
68
70
|
type: 'delete'
|
|
69
71
|
});
|
|
70
72
|
|
|
71
73
|
const AboutAOUnit = _ref3 => {
|
|
74
|
+
var _data$ao$createdBy;
|
|
75
|
+
|
|
72
76
|
let {
|
|
73
77
|
type,
|
|
74
78
|
id
|
|
75
79
|
} = _ref3;
|
|
76
80
|
const [isExpanded, setIsExpanded] = (0, _react.useState)(true);
|
|
77
|
-
const queries = (0, _react.useMemo)(() => getQueries(type), []);
|
|
81
|
+
const queries = (0, _react.useMemo)(() => getQueries(type), [type]);
|
|
78
82
|
const {
|
|
79
83
|
data,
|
|
80
84
|
loading: dataIsLoading,
|
|
@@ -82,8 +86,8 @@ const AboutAOUnit = _ref3 => {
|
|
|
82
86
|
} = (0, _appRuntime.useDataQuery)(queries, {
|
|
83
87
|
lazy: true
|
|
84
88
|
});
|
|
85
|
-
const subscribeMutation = (0, _react.useMemo)(() => getSubscribeMutation(type, id), []);
|
|
86
|
-
const unsubscribeMutation = (0, _react.useMemo)(() => getUnsubscribeMutation(type, id), []);
|
|
89
|
+
const subscribeMutation = (0, _react.useMemo)(() => getSubscribeMutation(type, id), [type, id]);
|
|
90
|
+
const unsubscribeMutation = (0, _react.useMemo)(() => getUnsubscribeMutation(type, id), [type, id]);
|
|
87
91
|
const [subscribe, {
|
|
88
92
|
loading: subscribeIsLoading
|
|
89
93
|
}] = (0, _appRuntime.useDataMutation)(subscribeMutation, {
|
|
@@ -112,7 +116,7 @@ const AboutAOUnit = _ref3 => {
|
|
|
112
116
|
id
|
|
113
117
|
});
|
|
114
118
|
}
|
|
115
|
-
}, [
|
|
119
|
+
}, [id, refetch]);
|
|
116
120
|
|
|
117
121
|
const getAccessLevelString = access => {
|
|
118
122
|
const re = new RegExp("(?<accessLevel>".concat(READ_AND_WRITE, "?)"));
|
|
@@ -159,7 +163,7 @@ const AboutAOUnit = _ref3 => {
|
|
|
159
163
|
className: "jsx-".concat(_AboutAOUnitStyle.default.__hash) + " " + "header"
|
|
160
164
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
161
165
|
className: "jsx-".concat(_AboutAOUnitStyle.default.__hash) + " " + "title"
|
|
162
|
-
},
|
|
166
|
+
}, (0, _utils.getTranslatedString)(type, 'unitTitle')), isExpanded ? /*#__PURE__*/_react.default.createElement(_ui.IconChevronUp24, {
|
|
163
167
|
color: _ui.colors.grey700
|
|
164
168
|
}) : /*#__PURE__*/_react.default.createElement(_ui.IconChevronDown24, {
|
|
165
169
|
color: _ui.colors.grey700
|
|
@@ -189,9 +193,11 @@ const AboutAOUnit = _ref3 => {
|
|
|
189
193
|
className: "jsx-".concat(_AboutAOUnitStyle.default.__hash) + " " + "detailLine"
|
|
190
194
|
}, /*#__PURE__*/_react.default.createElement(_ui.IconUser16, {
|
|
191
195
|
color: _ui.colors.grey700
|
|
192
|
-
}), _d2I18n.default.t('Created {{time}} by {{author}}', {
|
|
196
|
+
}), (_data$ao$createdBy = data.ao.createdBy) !== null && _data$ao$createdBy !== void 0 && _data$ao$createdBy.displayName ? _d2I18n.default.t('Created {{time}} by {{author}}', {
|
|
193
197
|
time: (0, _moment.default)(data.ao.created).fromNow(),
|
|
194
198
|
author: data.ao.createdBy.displayName
|
|
199
|
+
}) : _d2I18n.default.t('Created {{time}}', {
|
|
200
|
+
time: (0, _moment.default)(data.ao.created).fromNow()
|
|
195
201
|
})), /*#__PURE__*/_react.default.createElement("p", {
|
|
196
202
|
className: "jsx-".concat(_AboutAOUnitStyle.default.__hash) + " " + "detailLine"
|
|
197
203
|
}, /*#__PURE__*/_react.default.createElement(_ui.IconView16, {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTranslatedString = exports.AO_TYPE_VISUALIZATION = exports.AO_TYPE_MAP = exports.AO_TYPE_EVENT_VISUALIZATION = exports.AOTypeMap = void 0;
|
|
7
|
+
|
|
8
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const AO_TYPE_VISUALIZATION = 'visualization';
|
|
13
|
+
exports.AO_TYPE_VISUALIZATION = AO_TYPE_VISUALIZATION;
|
|
14
|
+
const AO_TYPE_MAP = 'map';
|
|
15
|
+
exports.AO_TYPE_MAP = AO_TYPE_MAP;
|
|
16
|
+
const AO_TYPE_EVENT_VISUALIZATION = 'eventVisualization';
|
|
17
|
+
exports.AO_TYPE_EVENT_VISUALIZATION = AO_TYPE_EVENT_VISUALIZATION;
|
|
18
|
+
const AOTypeMap = {
|
|
19
|
+
[AO_TYPE_VISUALIZATION]: {
|
|
20
|
+
apiEndpoint: 'visualizations'
|
|
21
|
+
},
|
|
22
|
+
[AO_TYPE_MAP]: {
|
|
23
|
+
apiEndpoint: 'maps'
|
|
24
|
+
},
|
|
25
|
+
[AO_TYPE_EVENT_VISUALIZATION]: {
|
|
26
|
+
apiEndpoint: 'eventVisualizations'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.AOTypeMap = AOTypeMap;
|
|
30
|
+
const NO_TYPE = 'NO_TYPE';
|
|
31
|
+
const texts = {
|
|
32
|
+
[AO_TYPE_MAP]: {
|
|
33
|
+
unitTitle: _d2I18n.default.t('About this map')
|
|
34
|
+
},
|
|
35
|
+
[AO_TYPE_EVENT_VISUALIZATION]: {
|
|
36
|
+
unitTitle: _d2I18n.default.t('About this line list')
|
|
37
|
+
},
|
|
38
|
+
[AO_TYPE_VISUALIZATION]: {
|
|
39
|
+
unitTitle: _d2I18n.default.t('About this visualization')
|
|
40
|
+
},
|
|
41
|
+
[NO_TYPE]: {
|
|
42
|
+
unitTitle: _d2I18n.default.t('About this visualization')
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const getTranslatedString = (type, key) => (texts[type] || texts[NO_TYPE])[key];
|
|
47
|
+
|
|
48
|
+
exports.getTranslatedString = getTranslatedString;
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
"{{userOrGroup}} ({{accessLevel}})": "{{userOrGroup}} ({{accessLevel}})",
|
|
6
6
|
"Shared with {{commaSeparatedListOfUsersAndGroups}}": "Shared with {{commaSeparatedListOfUsersAndGroups}}",
|
|
7
7
|
"Not shared with any users or groups": "Not shared with any users or groups",
|
|
8
|
-
"About this visualization": "About this visualization",
|
|
9
8
|
"No description": "No description",
|
|
10
9
|
"Last updated {{time}}": "Last updated {{time}}",
|
|
11
10
|
"Created {{time}} by {{author}}": "Created {{time}} by {{author}}",
|
|
11
|
+
"Created {{time}}": "Created {{time}}",
|
|
12
12
|
"Viewed {{count}} times": "Viewed 1 time",
|
|
13
13
|
"Viewed {{count}} times_plural": "Viewed {{count}} times",
|
|
14
14
|
"Notifications": "Notifications",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"Unsubscribe": "Unsubscribe",
|
|
17
17
|
"Subscribe to get updates about new interpretations.": "Subscribe to get updates about new interpretations.",
|
|
18
18
|
"Subscribe": "Subscribe",
|
|
19
|
+
"About this map": "About this map",
|
|
20
|
+
"About this line list": "About this line list",
|
|
21
|
+
"About this visualization": "About this visualization",
|
|
19
22
|
"This app could not retrieve required data.": "This app could not retrieve required data.",
|
|
20
23
|
"Network error": "Network error",
|
|
21
24
|
"Data Type": "Data Type",
|
|
@@ -8,12 +8,13 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
9
9
|
import { formatList } from '../../modules/list.js';
|
|
10
10
|
import styles from './styles/AboutAOUnit.style.js';
|
|
11
|
+
import { getTranslatedString, AOTypeMap } from './utils.js';
|
|
11
12
|
const READ_ONLY = 'r';
|
|
12
13
|
const READ_AND_WRITE = 'rw';
|
|
13
14
|
|
|
14
15
|
const getQueries = type => ({
|
|
15
16
|
ao: {
|
|
16
|
-
resource: type,
|
|
17
|
+
resource: AOTypeMap[type].apiEndpoint,
|
|
17
18
|
id: _ref => {
|
|
18
19
|
let {
|
|
19
20
|
id
|
|
@@ -36,22 +37,24 @@ const getQueries = type => ({
|
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
const getSubscribeMutation = (type, id) => ({
|
|
39
|
-
resource: "".concat(type, "/").concat(id, "/subscriber"),
|
|
40
|
+
resource: "".concat(AOTypeMap[type].apiEndpoint, "/").concat(id, "/subscriber"),
|
|
40
41
|
type: 'create'
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
const getUnsubscribeMutation = (type, id) => ({
|
|
44
|
-
resource: "".concat(type, "/").concat(id, "/subscriber"),
|
|
45
|
+
resource: "".concat(AOTypeMap[type].apiEndpoint, "/").concat(id, "/subscriber"),
|
|
45
46
|
type: 'delete'
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
const AboutAOUnit = _ref3 => {
|
|
50
|
+
var _data$ao$createdBy;
|
|
51
|
+
|
|
49
52
|
let {
|
|
50
53
|
type,
|
|
51
54
|
id
|
|
52
55
|
} = _ref3;
|
|
53
56
|
const [isExpanded, setIsExpanded] = useState(true);
|
|
54
|
-
const queries = useMemo(() => getQueries(type), []);
|
|
57
|
+
const queries = useMemo(() => getQueries(type), [type]);
|
|
55
58
|
const {
|
|
56
59
|
data,
|
|
57
60
|
loading: dataIsLoading,
|
|
@@ -59,8 +62,8 @@ const AboutAOUnit = _ref3 => {
|
|
|
59
62
|
} = useDataQuery(queries, {
|
|
60
63
|
lazy: true
|
|
61
64
|
});
|
|
62
|
-
const subscribeMutation = useMemo(() => getSubscribeMutation(type, id), []);
|
|
63
|
-
const unsubscribeMutation = useMemo(() => getUnsubscribeMutation(type, id), []);
|
|
65
|
+
const subscribeMutation = useMemo(() => getSubscribeMutation(type, id), [type, id]);
|
|
66
|
+
const unsubscribeMutation = useMemo(() => getUnsubscribeMutation(type, id), [type, id]);
|
|
64
67
|
const [subscribe, {
|
|
65
68
|
loading: subscribeIsLoading
|
|
66
69
|
}] = useDataMutation(subscribeMutation, {
|
|
@@ -89,7 +92,7 @@ const AboutAOUnit = _ref3 => {
|
|
|
89
92
|
id
|
|
90
93
|
});
|
|
91
94
|
}
|
|
92
|
-
}, [
|
|
95
|
+
}, [id, refetch]);
|
|
93
96
|
|
|
94
97
|
const getAccessLevelString = access => {
|
|
95
98
|
const re = new RegExp("(?<accessLevel>".concat(READ_AND_WRITE, "?)"));
|
|
@@ -136,7 +139,7 @@ const AboutAOUnit = _ref3 => {
|
|
|
136
139
|
className: "jsx-".concat(styles.__hash) + " " + "header"
|
|
137
140
|
}, /*#__PURE__*/React.createElement("span", {
|
|
138
141
|
className: "jsx-".concat(styles.__hash) + " " + "title"
|
|
139
|
-
},
|
|
142
|
+
}, getTranslatedString(type, 'unitTitle')), isExpanded ? /*#__PURE__*/React.createElement(IconChevronUp24, {
|
|
140
143
|
color: colors.grey700
|
|
141
144
|
}) : /*#__PURE__*/React.createElement(IconChevronDown24, {
|
|
142
145
|
color: colors.grey700
|
|
@@ -166,9 +169,11 @@ const AboutAOUnit = _ref3 => {
|
|
|
166
169
|
className: "jsx-".concat(styles.__hash) + " " + "detailLine"
|
|
167
170
|
}, /*#__PURE__*/React.createElement(IconUser16, {
|
|
168
171
|
color: colors.grey700
|
|
169
|
-
}), i18n.t('Created {{time}} by {{author}}', {
|
|
172
|
+
}), (_data$ao$createdBy = data.ao.createdBy) !== null && _data$ao$createdBy !== void 0 && _data$ao$createdBy.displayName ? i18n.t('Created {{time}} by {{author}}', {
|
|
170
173
|
time: moment(data.ao.created).fromNow(),
|
|
171
174
|
author: data.ao.createdBy.displayName
|
|
175
|
+
}) : i18n.t('Created {{time}}', {
|
|
176
|
+
time: moment(data.ao.created).fromNow()
|
|
172
177
|
})), /*#__PURE__*/React.createElement("p", {
|
|
173
178
|
className: "jsx-".concat(styles.__hash) + " " + "detailLine"
|
|
174
179
|
}, /*#__PURE__*/React.createElement(IconView16, {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import i18n from '@dhis2/d2-i18n';
|
|
2
|
+
export const AO_TYPE_VISUALIZATION = 'visualization';
|
|
3
|
+
export const AO_TYPE_MAP = 'map';
|
|
4
|
+
export const AO_TYPE_EVENT_VISUALIZATION = 'eventVisualization';
|
|
5
|
+
export const AOTypeMap = {
|
|
6
|
+
[AO_TYPE_VISUALIZATION]: {
|
|
7
|
+
apiEndpoint: 'visualizations'
|
|
8
|
+
},
|
|
9
|
+
[AO_TYPE_MAP]: {
|
|
10
|
+
apiEndpoint: 'maps'
|
|
11
|
+
},
|
|
12
|
+
[AO_TYPE_EVENT_VISUALIZATION]: {
|
|
13
|
+
apiEndpoint: 'eventVisualizations'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const NO_TYPE = 'NO_TYPE';
|
|
17
|
+
const texts = {
|
|
18
|
+
[AO_TYPE_MAP]: {
|
|
19
|
+
unitTitle: i18n.t('About this map')
|
|
20
|
+
},
|
|
21
|
+
[AO_TYPE_EVENT_VISUALIZATION]: {
|
|
22
|
+
unitTitle: i18n.t('About this line list')
|
|
23
|
+
},
|
|
24
|
+
[AO_TYPE_VISUALIZATION]: {
|
|
25
|
+
unitTitle: i18n.t('About this visualization')
|
|
26
|
+
},
|
|
27
|
+
[NO_TYPE]: {
|
|
28
|
+
unitTitle: i18n.t('About this visualization')
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export const getTranslatedString = (type, key) => (texts[type] || texts[NO_TYPE])[key];
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
"{{userOrGroup}} ({{accessLevel}})": "{{userOrGroup}} ({{accessLevel}})",
|
|
6
6
|
"Shared with {{commaSeparatedListOfUsersAndGroups}}": "Shared with {{commaSeparatedListOfUsersAndGroups}}",
|
|
7
7
|
"Not shared with any users or groups": "Not shared with any users or groups",
|
|
8
|
-
"About this visualization": "About this visualization",
|
|
9
8
|
"No description": "No description",
|
|
10
9
|
"Last updated {{time}}": "Last updated {{time}}",
|
|
11
10
|
"Created {{time}} by {{author}}": "Created {{time}} by {{author}}",
|
|
11
|
+
"Created {{time}}": "Created {{time}}",
|
|
12
12
|
"Viewed {{count}} times": "Viewed 1 time",
|
|
13
13
|
"Viewed {{count}} times_plural": "Viewed {{count}} times",
|
|
14
14
|
"Notifications": "Notifications",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"Unsubscribe": "Unsubscribe",
|
|
17
17
|
"Subscribe to get updates about new interpretations.": "Subscribe to get updates about new interpretations.",
|
|
18
18
|
"Subscribe": "Subscribe",
|
|
19
|
+
"About this map": "About this map",
|
|
20
|
+
"About this line list": "About this line list",
|
|
21
|
+
"About this visualization": "About this visualization",
|
|
19
22
|
"This app could not retrieve required data.": "This app could not retrieve required data.",
|
|
20
23
|
"Network error": "Network error",
|
|
21
24
|
"Data Type": "Data Type",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2/analytics",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0",
|
|
4
4
|
"main": "./build/cjs/index.js",
|
|
5
5
|
"module": "./build/es/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@dhis2/cli-app-scripts": "^9.0.1",
|
|
36
36
|
"@dhis2/cli-style": "^10.4.1",
|
|
37
37
|
"@dhis2/d2-i18n": "^1.1.0",
|
|
38
|
-
"@dhis2/ui": "^8.4.
|
|
38
|
+
"@dhis2/ui": "^8.4.9",
|
|
39
39
|
"@sambego/storybook-state": "^2.0.1",
|
|
40
40
|
"@storybook/addons": "^6.5.9",
|
|
41
41
|
"@storybook/preset-create-react-app": "^3.1.7",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"classnames": "^2.3.1",
|
|
63
63
|
"d2-utilizr": "^0.2.16",
|
|
64
64
|
"d3-color": "^1.2.3",
|
|
65
|
-
"highcharts": "^10.
|
|
65
|
+
"highcharts": "^10.2.0",
|
|
66
66
|
"lodash": "^4.17.21",
|
|
67
67
|
"mathjs": "^9.4.2",
|
|
68
68
|
"react-beautiful-dnd": "^10.1.1",
|