@dhis2/analytics 24.7.0 → 24.9.0-alpha.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.
- package/CHANGELOG.md +40 -0
- package/build/cjs/__demo__/OrgUnitDimension.stories.js +9 -0
- package/build/cjs/components/OrgUnitDimension/OrgUnitDimension.js +5 -2
- package/build/cjs/components/PeriodDimension/PeriodTransfer.js +38 -4
- package/build/cjs/components/PeriodDimension/__tests__/PeriodSelector.spec.js +13 -0
- package/build/cjs/components/PeriodDimension/utils/fixedPeriods.js +207 -478
- package/build/cjs/locales/en/translations.json +0 -14
- package/build/es/__demo__/OrgUnitDimension.stories.js +9 -0
- package/build/es/components/OrgUnitDimension/OrgUnitDimension.js +5 -2
- package/build/es/components/PeriodDimension/PeriodTransfer.js +35 -4
- package/build/es/components/PeriodDimension/__tests__/PeriodSelector.spec.js +13 -0
- package/build/es/components/PeriodDimension/utils/fixedPeriods.js +205 -477
- package/build/es/locales/en/translations.json +0 -14
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
# [24.9.0-alpha.1](https://github.com/dhis2/analytics/compare/v24.8.0...v24.9.0-alpha.1) (2023-02-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump multi-calendar-dates to avoid jest config change ([3e5892a](https://github.com/dhis2/analytics/commit/3e5892aa88a087dde3405a518625f4c6e637d17e))
|
|
7
|
+
* ensure date falls back to year if no eraYear present ([2a197d5](https://github.com/dhis2/analytics/commit/2a197d57be8ac2af6dbe331dd8f11ab9069afa5d))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* localise fixed periods according to user settings ([c640c90](https://github.com/dhis2/analytics/commit/c640c90ce2d1944a14706507284af43c7480fa2a))
|
|
13
|
+
* use multi-calendar-dates library to generate fixed periods ([acc3801](https://github.com/dhis2/analytics/commit/acc380156092f888cfa55f70b4bade1c6516d034))
|
|
14
|
+
|
|
15
|
+
# [24.5.0-alpha.3](https://github.com/dhis2/analytics/compare/v24.5.0-alpha.2...v24.5.0-alpha.3) (2023-02-23)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* localise fixed periods according to user settings ([c640c90](https://github.com/dhis2/analytics/commit/c640c90ce2d1944a14706507284af43c7480fa2a))
|
|
21
|
+
|
|
22
|
+
# [24.5.0-alpha.2](https://github.com/dhis2/analytics/compare/v24.5.0-alpha.1...v24.5.0-alpha.2) (2023-02-14)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* bump multi-calendar-dates to avoid jest config change ([3e5892a](https://github.com/dhis2/analytics/commit/3e5892aa88a087dde3405a518625f4c6e637d17e))
|
|
28
|
+
|
|
29
|
+
# [24.5.0-alpha.1](https://github.com/dhis2/analytics/compare/v24.4.2...v24.5.0-alpha.1) (2023-02-07)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* ensure date falls back to year if no eraYear present ([2a197d5](https://github.com/dhis2/analytics/commit/2a197d57be8ac2af6dbe331dd8f11ab9069afa5d))
|
|
35
|
+
|
|
36
|
+
# [24.8.0](https://github.com/dhis2/analytics/compare/v24.7.0...v24.8.0) (2023-02-16)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
* add prop for controlling user org unit selector DHIS2-14744 ([#1430](https://github.com/dhis2/analytics/issues/1430)) ([02d3057](https://github.com/dhis2/analytics/commit/02d3057c7c090e293ba7c3057720f491e71457ec))
|
|
40
|
+
|
|
1
41
|
# [24.7.0](https://github.com/dhis2/analytics/compare/v24.6.0...v24.7.0) (2023-02-15)
|
|
2
42
|
|
|
3
43
|
|
|
@@ -102,6 +102,15 @@ const defaultRootOrgUnits = ['ImspTQPwCqd']; // Sierra Leone
|
|
|
102
102
|
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
+
(0, _react.storiesOf)('OrgUnitDimension', module).addDecorator(Wrapper).add('Without user org units selection', () => {
|
|
106
|
+
const [selected, setSelected] = (0, _react2.useState)([]);
|
|
107
|
+
return /*#__PURE__*/_react2.default.createElement(_OrgUnitDimension.default, {
|
|
108
|
+
hideUserOrgUnits: true,
|
|
109
|
+
selected: selected,
|
|
110
|
+
onSelect: response => setSelected(response.items),
|
|
111
|
+
roots: defaultRootOrgUnits
|
|
112
|
+
});
|
|
113
|
+
});
|
|
105
114
|
(0, _react.storiesOf)('OrgUnitDimension', module).addDecorator(Wrapper).add('Without level selector', () => {
|
|
106
115
|
const [selected, setSelected] = (0, _react2.useState)([]);
|
|
107
116
|
return /*#__PURE__*/_react2.default.createElement(_OrgUnitDimension.default, {
|
|
@@ -44,6 +44,7 @@ const OrgUnitDimension = _ref => {
|
|
|
44
44
|
onSelect,
|
|
45
45
|
hideGroupSelect,
|
|
46
46
|
hideLevelSelect,
|
|
47
|
+
hideUserOrgUnits,
|
|
47
48
|
warning
|
|
48
49
|
} = _ref;
|
|
49
50
|
const [ouLevels, setOuLevels] = (0, _react.useState)([]);
|
|
@@ -174,7 +175,7 @@ const OrgUnitDimension = _ref => {
|
|
|
174
175
|
|
|
175
176
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
176
177
|
className: "jsx-".concat(_OrgUnitDimensionStyle.default.__hash) + " " + "container"
|
|
177
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
178
|
+
}, !hideUserOrgUnits && /*#__PURE__*/_react.default.createElement("div", {
|
|
178
179
|
className: "jsx-".concat(_OrgUnitDimensionStyle.default.__hash) + " " + "userOrgUnitsWrapper"
|
|
179
180
|
}, /*#__PURE__*/_react.default.createElement(_ui.Checkbox, {
|
|
180
181
|
label: _index.default.t('User organisation unit'),
|
|
@@ -291,11 +292,13 @@ const OrgUnitDimension = _ref => {
|
|
|
291
292
|
|
|
292
293
|
OrgUnitDimension.defaultProps = {
|
|
293
294
|
hideGroupSelect: false,
|
|
294
|
-
hideLevelSelect: false
|
|
295
|
+
hideLevelSelect: false,
|
|
296
|
+
hideUserOrgUnits: false
|
|
295
297
|
};
|
|
296
298
|
OrgUnitDimension.propTypes = {
|
|
297
299
|
hideGroupSelect: _propTypes.default.bool,
|
|
298
300
|
hideLevelSelect: _propTypes.default.bool,
|
|
301
|
+
hideUserOrgUnits: _propTypes.default.bool,
|
|
299
302
|
roots: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
300
303
|
selected: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
301
304
|
id: _propTypes.default.string.isRequired,
|
|
@@ -7,6 +7,10 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
9
|
|
|
10
|
+
var _appRuntime = require("@dhis2/app-runtime");
|
|
11
|
+
|
|
12
|
+
var _multiCalendarDates = require("@dhis2/multi-calendar-dates");
|
|
13
|
+
|
|
10
14
|
var _ui = require("@dhis2/ui");
|
|
11
15
|
|
|
12
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -41,6 +45,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
41
45
|
|
|
42
46
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
43
47
|
|
|
48
|
+
const userSettingsQuery = {
|
|
49
|
+
userSettings: {
|
|
50
|
+
resource: 'userSettings',
|
|
51
|
+
params: {
|
|
52
|
+
key: ['keyUiLocale']
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
44
57
|
const PeriodTransfer = _ref => {
|
|
45
58
|
let {
|
|
46
59
|
onSelect,
|
|
@@ -49,9 +62,30 @@ const PeriodTransfer = _ref => {
|
|
|
49
62
|
rightFooter,
|
|
50
63
|
excludedPeriodTypes
|
|
51
64
|
} = _ref;
|
|
65
|
+
const {
|
|
66
|
+
systemInfo
|
|
67
|
+
} = (0, _appRuntime.useConfig)();
|
|
68
|
+
const result = (0, _appRuntime.useDataQuery)(userSettingsQuery);
|
|
69
|
+
const {
|
|
70
|
+
calendar = 'gregory'
|
|
71
|
+
} = systemInfo;
|
|
72
|
+
const {
|
|
73
|
+
data: {
|
|
74
|
+
userSettings: {
|
|
75
|
+
keyUiLocale: locale
|
|
76
|
+
} = {}
|
|
77
|
+
} = {}
|
|
78
|
+
} = result;
|
|
79
|
+
const periodsSettings = {
|
|
80
|
+
calendar,
|
|
81
|
+
locale
|
|
82
|
+
};
|
|
52
83
|
const defaultRelativePeriodType = excludedPeriodTypes.includes(_index2.MONTHLY) ? (0, _relativePeriods.getRelativePeriodsOptionsById)(_index2.QUARTERLY) : (0, _relativePeriods.getRelativePeriodsOptionsById)(_index2.MONTHLY);
|
|
53
|
-
const defaultFixedPeriodType = excludedPeriodTypes.includes(_index2.MONTHLY) ? (0, _fixedPeriods.getFixedPeriodsOptionsById)(_index2.QUARTERLY) : (0, _fixedPeriods.getFixedPeriodsOptionsById)(_index2.MONTHLY);
|
|
54
|
-
const
|
|
84
|
+
const defaultFixedPeriodType = excludedPeriodTypes.includes(_index2.MONTHLY) ? (0, _fixedPeriods.getFixedPeriodsOptionsById)(_index2.QUARTERLY, periodsSettings) : (0, _fixedPeriods.getFixedPeriodsOptionsById)(_index2.MONTHLY, periodsSettings);
|
|
85
|
+
const now = (0, _multiCalendarDates.getNowInCalendar)(calendar); // use ".eraYear" rather than ".year" because in Ethiopian calendar, eraYear is what our users expect to see (for other calendars, it doesn't matter)
|
|
86
|
+
// there is still a pending decision in Temporal regarding which era to use by default: https://github.com/js-temporal/temporal-polyfill/blob/9350ee7dd0d29f329fc097debf923a517c32f813/lib/calendar.ts#L1964
|
|
87
|
+
|
|
88
|
+
const defaultFixedPeriodYear = now.eraYear || now.year;
|
|
55
89
|
|
|
56
90
|
const fixedPeriodConfig = year => ({
|
|
57
91
|
offset: year - defaultFixedPeriodYear,
|
|
@@ -73,7 +107,7 @@ const PeriodTransfer = _ref => {
|
|
|
73
107
|
const onIsRelativeClick = state => {
|
|
74
108
|
if (state !== isRelative) {
|
|
75
109
|
setIsRelative(state);
|
|
76
|
-
setAllPeriods(state ? (0, _relativePeriods.getRelativePeriodsOptionsById)(relativeFilter.periodType).getPeriods() : (0, _fixedPeriods.getFixedPeriodsOptionsById)(fixedFilter.periodType).getPeriods(fixedPeriodConfig(Number(fixedFilter.year))));
|
|
110
|
+
setAllPeriods(state ? (0, _relativePeriods.getRelativePeriodsOptionsById)(relativeFilter.periodType).getPeriods() : (0, _fixedPeriods.getFixedPeriodsOptionsById)(fixedFilter.periodType, periodsSettings).getPeriods(fixedPeriodConfig(Number(fixedFilter.year))));
|
|
77
111
|
}
|
|
78
112
|
};
|
|
79
113
|
|
|
@@ -126,7 +160,7 @@ const PeriodTransfer = _ref => {
|
|
|
126
160
|
|
|
127
161
|
const onSelectFixedPeriods = filter => {
|
|
128
162
|
setFixedFilter(filter);
|
|
129
|
-
setAllPeriods((0, _fixedPeriods.getFixedPeriodsOptionsById)(filter.periodType).getPeriods(fixedPeriodConfig(Number(filter.year))));
|
|
163
|
+
setAllPeriods((0, _fixedPeriods.getFixedPeriodsOptionsById)(filter.periodType, periodsSettings).getPeriods(fixedPeriodConfig(Number(filter.year)), periodsSettings));
|
|
130
164
|
};
|
|
131
165
|
|
|
132
166
|
const renderEmptySelection = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
|
|
@@ -8,6 +8,19 @@ var _PeriodTransfer = _interopRequireDefault(require("../PeriodTransfer.js"));
|
|
|
8
8
|
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
|
|
11
|
+
jest.mock('@dhis2/app-runtime', () => ({
|
|
12
|
+
useConfig: () => ({
|
|
13
|
+
systemInfo: {}
|
|
14
|
+
}),
|
|
15
|
+
useDataQuery: () => ({
|
|
16
|
+
data: {
|
|
17
|
+
userSettings: {
|
|
18
|
+
keyUiLocale: 'en'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
}));
|
|
23
|
+
afterEach(jest.clearAllMocks);
|
|
11
24
|
describe('The Period Selector component', () => {
|
|
12
25
|
let props;
|
|
13
26
|
let shallowPeriodTransfer;
|