@dhis2/analytics 24.4.2 → 24.5.0-alpha.2
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 +19 -0
- package/build/cjs/components/PeriodDimension/PeriodTransfer.js +17 -4
- package/build/cjs/components/PeriodDimension/__tests__/PeriodSelector.spec.js +5 -0
- package/build/cjs/components/PeriodDimension/utils/fixedPeriods.js +205 -478
- package/build/cjs/locales/en/translations.json +0 -14
- package/build/es/components/PeriodDimension/PeriodTransfer.js +15 -4
- package/build/es/components/PeriodDimension/__tests__/PeriodSelector.spec.js +5 -0
- package/build/es/components/PeriodDimension/utils/fixedPeriods.js +203 -477
- package/build/es/locales/en/translations.json +0 -14
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [24.5.0-alpha.2](https://github.com/dhis2/analytics/compare/v24.5.0-alpha.1...v24.5.0-alpha.2) (2023-02-14)
|
|
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
|
+
|
|
8
|
+
# [24.5.0-alpha.1](https://github.com/dhis2/analytics/compare/v24.4.2...v24.5.0-alpha.1) (2023-02-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* ensure date falls back to year if no eraYear present ([2a197d5](https://github.com/dhis2/analytics/commit/2a197d57be8ac2af6dbe331dd8f11ab9069afa5d))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* use multi-calendar-dates library to generate fixed periods ([acc3801](https://github.com/dhis2/analytics/commit/acc380156092f888cfa55f70b4bade1c6516d034))
|
|
19
|
+
|
|
1
20
|
## [24.4.2](https://github.com/dhis2/analytics/compare/v24.4.1...v24.4.2) (2023-01-25)
|
|
2
21
|
|
|
3
22
|
|
|
@@ -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"));
|
|
@@ -49,9 +53,18 @@ const PeriodTransfer = _ref => {
|
|
|
49
53
|
rightFooter,
|
|
50
54
|
excludedPeriodTypes
|
|
51
55
|
} = _ref;
|
|
56
|
+
const {
|
|
57
|
+
systemInfo
|
|
58
|
+
} = (0, _appRuntime.useConfig)();
|
|
59
|
+
const {
|
|
60
|
+
calendar = 'gregory'
|
|
61
|
+
} = systemInfo;
|
|
52
62
|
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
|
|
63
|
+
const defaultFixedPeriodType = excludedPeriodTypes.includes(_index2.MONTHLY) ? (0, _fixedPeriods.getFixedPeriodsOptionsById)(_index2.QUARTERLY, calendar) : (0, _fixedPeriods.getFixedPeriodsOptionsById)(_index2.MONTHLY, calendar);
|
|
64
|
+
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)
|
|
65
|
+
// 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
|
|
66
|
+
|
|
67
|
+
const defaultFixedPeriodYear = now.eraYear || now.year;
|
|
55
68
|
|
|
56
69
|
const fixedPeriodConfig = year => ({
|
|
57
70
|
offset: year - defaultFixedPeriodYear,
|
|
@@ -73,7 +86,7 @@ const PeriodTransfer = _ref => {
|
|
|
73
86
|
const onIsRelativeClick = state => {
|
|
74
87
|
if (state !== isRelative) {
|
|
75
88
|
setIsRelative(state);
|
|
76
|
-
setAllPeriods(state ? (0, _relativePeriods.getRelativePeriodsOptionsById)(relativeFilter.periodType).getPeriods() : (0, _fixedPeriods.getFixedPeriodsOptionsById)(fixedFilter.periodType).getPeriods(fixedPeriodConfig(Number(fixedFilter.year))));
|
|
89
|
+
setAllPeriods(state ? (0, _relativePeriods.getRelativePeriodsOptionsById)(relativeFilter.periodType).getPeriods() : (0, _fixedPeriods.getFixedPeriodsOptionsById)(fixedFilter.periodType, calendar).getPeriods(fixedPeriodConfig(Number(fixedFilter.year))));
|
|
77
90
|
}
|
|
78
91
|
};
|
|
79
92
|
|
|
@@ -126,7 +139,7 @@ const PeriodTransfer = _ref => {
|
|
|
126
139
|
|
|
127
140
|
const onSelectFixedPeriods = filter => {
|
|
128
141
|
setFixedFilter(filter);
|
|
129
|
-
setAllPeriods((0, _fixedPeriods.getFixedPeriodsOptionsById)(filter.periodType).getPeriods(fixedPeriodConfig(Number(filter.year))));
|
|
142
|
+
setAllPeriods((0, _fixedPeriods.getFixedPeriodsOptionsById)(filter.periodType, calendar).getPeriods(fixedPeriodConfig(Number(filter.year)), calendar));
|
|
130
143
|
};
|
|
131
144
|
|
|
132
145
|
const renderEmptySelection = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
|
|
@@ -8,6 +8,11 @@ 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
|
+
}));
|
|
11
16
|
describe('The Period Selector component', () => {
|
|
12
17
|
let props;
|
|
13
18
|
let shallowPeriodTransfer;
|