@dhis2/analytics 29.2.1 → 29.3.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/build/cjs/components/PeriodDimension/FixedPeriodFilter.js +5 -10
- package/build/cjs/components/PeriodDimension/FixedPeriodSelect.js +3 -1
- package/build/cjs/components/PeriodDimension/PeriodDimension.js +15 -5
- package/build/cjs/components/PeriodDimension/PeriodTransfer.js +111 -15
- package/build/cjs/components/PeriodDimension/RelativePeriodFilter.js +4 -6
- package/build/cjs/components/PeriodDimension/__tests__/PeriodDimension.spec.js +19 -6
- package/build/cjs/components/PeriodDimension/__tests__/fixedPeriods.spec.js +1 -1
- package/build/cjs/components/PeriodDimension/__tests__/utils.spec.js +1 -1
- package/build/cjs/components/PeriodDimension/useDataOutputPeriodTypes.js +155 -0
- package/build/cjs/components/PeriodDimension/utils/enabledPeriodTypes.js +179 -0
- package/build/cjs/components/PeriodDimension/utils/fixedPeriods.js +58 -62
- package/build/cjs/components/PeriodDimension/utils/index.js +8 -4
- package/build/cjs/index.js +8 -0
- package/build/cjs/locales/en/translations.json +9 -3
- package/build/cjs/visualizations/util/getFilterText.js +1 -1
- package/build/es/components/PeriodDimension/FixedPeriodFilter.js +5 -10
- package/build/es/components/PeriodDimension/FixedPeriodSelect.js +4 -2
- package/build/es/components/PeriodDimension/PeriodDimension.js +15 -5
- package/build/es/components/PeriodDimension/PeriodTransfer.js +116 -20
- package/build/es/components/PeriodDimension/RelativePeriodFilter.js +4 -6
- package/build/es/components/PeriodDimension/__tests__/PeriodDimension.spec.js +19 -6
- package/build/es/components/PeriodDimension/__tests__/fixedPeriods.spec.js +1 -1
- package/build/es/components/PeriodDimension/__tests__/utils.spec.js +1 -1
- package/build/es/components/PeriodDimension/useDataOutputPeriodTypes.js +149 -0
- package/build/es/components/PeriodDimension/utils/enabledPeriodTypes.js +168 -0
- package/build/es/components/PeriodDimension/utils/fixedPeriods.js +59 -63
- package/build/es/components/PeriodDimension/utils/index.js +7 -3
- package/build/es/index.js +1 -0
- package/build/es/locales/en/translations.json +9 -3
- package/build/es/visualizations/util/getFilterText.js +1 -1
- package/package.json +1 -1
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
import { generateFixedPeriods, getNowInCalendar } from '@dhis2/multi-calendar-dates';
|
|
2
2
|
import i18n from '../../../locales/index.js';
|
|
3
|
-
import { DAILY, WEEKLY, WEEKLYWED, WEEKLYTHU, WEEKLYSAT, WEEKLYSUN, BIWEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, SIXMONTHLY, SIXMONTHLYAPR, YEARLY,
|
|
3
|
+
import { DAILY, WEEKLY, WEEKLYWED, WEEKLYTHU, WEEKLYFRI, WEEKLYSAT, WEEKLYSUN, BIWEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, SIXMONTHLY, SIXMONTHLYAPR, YEARLY, FYFEB, FYAPR, FYJUL, FYAUG, FYSEP, FYOCT, FYNOV } from './index.js';
|
|
4
4
|
export const PERIOD_TYPE_REGEX = {
|
|
5
|
-
[DAILY]: /^(
|
|
5
|
+
[DAILY]: /^(\d{4})(\d{2})(\d{2})$/,
|
|
6
6
|
// YYYYMMDD
|
|
7
|
-
[WEEKLY]: /^(
|
|
7
|
+
[WEEKLY]: /^(\d{4})W(\d{1,2})$/,
|
|
8
8
|
// YYYY"W"[1-53]
|
|
9
|
-
[BIWEEKLY]: /^(
|
|
9
|
+
[BIWEEKLY]: /^(\d{4})BiW(\d{1,2})$/,
|
|
10
10
|
// YYYY"BiW"[1-27]
|
|
11
|
-
[WEEKLYWED]: /^(
|
|
11
|
+
[WEEKLYWED]: /^(\d{4})(Wed)W(\d{1,2})$/,
|
|
12
12
|
// YYYY"WedW"[1-53]
|
|
13
|
-
[WEEKLYTHU]: /^(
|
|
13
|
+
[WEEKLYTHU]: /^(\d{4})(Thu)W(\d{1,2})$/,
|
|
14
14
|
// YYYY"ThuW"[1-53]
|
|
15
|
-
[
|
|
15
|
+
[WEEKLYFRI]: /^(\d{4})(Fri)W(\d{1,2})$/,
|
|
16
|
+
// YYYY"FriW"[1-53]
|
|
17
|
+
[WEEKLYSAT]: /^(\d{4})(Sat)W(\d{1,2})$/,
|
|
16
18
|
// YYYY"SatW"[1-53]
|
|
17
|
-
[WEEKLYSUN]: /^(
|
|
19
|
+
[WEEKLYSUN]: /^(\d{4})(Sun)W(\d{1,2})$/,
|
|
18
20
|
// YYYY"SunW"[1-53]
|
|
19
|
-
[MONTHLY]: /^(
|
|
21
|
+
[MONTHLY]: /^(\d{4})(\d{2})$/,
|
|
20
22
|
// YYYYMM
|
|
21
|
-
[BIMONTHLY]: /^(
|
|
23
|
+
[BIMONTHLY]: /^(\d{4})(\d{2})B$/,
|
|
22
24
|
// YYYY0[1-6]"B"
|
|
23
|
-
[QUARTERLY]: /^(
|
|
25
|
+
[QUARTERLY]: /^(\d{4})Q([1234])$/,
|
|
24
26
|
// YYYY"Q"[1-4]
|
|
25
|
-
[SIXMONTHLY]: /^(
|
|
27
|
+
[SIXMONTHLY]: /^(\d{4})S([12])$/,
|
|
26
28
|
// YYYY"S"[1/2]
|
|
27
|
-
[SIXMONTHLYAPR]: /^(
|
|
29
|
+
[SIXMONTHLYAPR]: /^(\d{4})AprilS([12])$/,
|
|
28
30
|
// YYYY"AprilS"[1/2]
|
|
29
|
-
// [SIXMONTHLYNOV]: /^(
|
|
30
|
-
[YEARLY]: /^(
|
|
31
|
+
// [SIXMONTHLYNOV]: /^(\d{4})NovS([12])$/, // YYYY"NovS"[1/2] Not supported?
|
|
32
|
+
[YEARLY]: /^(\d{4})$/,
|
|
31
33
|
// YYYY
|
|
32
|
-
[
|
|
33
|
-
// YYYY"
|
|
34
|
-
[
|
|
35
|
-
// YYYY"
|
|
36
|
-
[FYJUL]: /^(
|
|
34
|
+
[FYFEB]: /^(\d{4})Feb$/,
|
|
35
|
+
// YYYY"Feb"
|
|
36
|
+
[FYAPR]: /^(\d{4})April$/,
|
|
37
|
+
// YYYY"April"
|
|
38
|
+
[FYJUL]: /^(\d{4})July$/,
|
|
37
39
|
// YYYY"July"
|
|
38
|
-
[
|
|
40
|
+
[FYAUG]: /^(\d{4})Aug$/,
|
|
41
|
+
// YYYY"Aug"
|
|
42
|
+
[FYSEP]: /^(\d{4})Sep$/,
|
|
43
|
+
// YYYY"Sep"
|
|
44
|
+
[FYOCT]: /^(\d{4})Oct$/,
|
|
45
|
+
// YYYY"Oct"
|
|
46
|
+
[FYNOV]: /^(\d{4})Nov$/ // YYYY"Nov"
|
|
39
47
|
};
|
|
40
48
|
const getPeriods = ({
|
|
41
49
|
periodType,
|
|
@@ -157,40 +165,10 @@ const getYearlyPeriodType = (fnFilter, periodSettings) => {
|
|
|
157
165
|
});
|
|
158
166
|
};
|
|
159
167
|
};
|
|
160
|
-
const
|
|
161
|
-
return config => {
|
|
162
|
-
return getPeriods({
|
|
163
|
-
periodType: 'FYOCT',
|
|
164
|
-
config,
|
|
165
|
-
fnFilter,
|
|
166
|
-
periodSettings
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
const getFinancialNovemberPeriodType = (fnFilter, periodSettings) => {
|
|
171
|
-
return config => {
|
|
172
|
-
return getPeriods({
|
|
173
|
-
periodType: 'FYNOV',
|
|
174
|
-
config,
|
|
175
|
-
fnFilter,
|
|
176
|
-
periodSettings
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
const getFinancialJulyPeriodType = (fnFilter, periodSettings) => {
|
|
181
|
-
return config => {
|
|
182
|
-
return getPeriods({
|
|
183
|
-
periodType: 'FYJUL',
|
|
184
|
-
config,
|
|
185
|
-
fnFilter,
|
|
186
|
-
periodSettings
|
|
187
|
-
});
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
const getFinancialAprilPeriodType = (fnFilter, periodSettings) => {
|
|
168
|
+
const getFinancialPeriodType = (periodType, fnFilter, periodSettings) => {
|
|
191
169
|
return config => {
|
|
192
170
|
return getPeriods({
|
|
193
|
-
periodType
|
|
171
|
+
periodType,
|
|
194
172
|
config,
|
|
195
173
|
fnFilter,
|
|
196
174
|
periodSettings
|
|
@@ -230,6 +208,12 @@ const getOptions = periodSettings => {
|
|
|
230
208
|
startDay: 4
|
|
231
209
|
}, filterFuturePeriods, periodSettings),
|
|
232
210
|
name: i18n.t('Weekly (Start Thursday)')
|
|
211
|
+
}, {
|
|
212
|
+
id: WEEKLYFRI,
|
|
213
|
+
getPeriods: getWeeklyPeriodType({
|
|
214
|
+
startDay: 5
|
|
215
|
+
}, filterFuturePeriods, periodSettings),
|
|
216
|
+
name: i18n.t('Weekly (Start Friday)')
|
|
233
217
|
}, {
|
|
234
218
|
id: WEEKLYSAT,
|
|
235
219
|
getPeriods: getWeeklyPeriodType({
|
|
@@ -271,21 +255,33 @@ const getOptions = periodSettings => {
|
|
|
271
255
|
getPeriods: getYearlyPeriodType(filterFuturePeriods, periodSettings),
|
|
272
256
|
name: i18n.t('Yearly')
|
|
273
257
|
}, {
|
|
274
|
-
id:
|
|
275
|
-
getPeriods:
|
|
276
|
-
name: i18n.t('Financial year (Start
|
|
258
|
+
id: FYFEB,
|
|
259
|
+
getPeriods: getFinancialPeriodType('FYFEB', filterFuturePeriods, periodSettings),
|
|
260
|
+
name: i18n.t('Financial year (Start February)')
|
|
277
261
|
}, {
|
|
278
|
-
id:
|
|
279
|
-
getPeriods:
|
|
280
|
-
name: i18n.t('Financial year (Start
|
|
262
|
+
id: FYAPR,
|
|
263
|
+
getPeriods: getFinancialPeriodType('FYAPR', filterFuturePeriods, periodSettings),
|
|
264
|
+
name: i18n.t('Financial year (Start April)')
|
|
281
265
|
}, {
|
|
282
266
|
id: FYJUL,
|
|
283
|
-
getPeriods:
|
|
267
|
+
getPeriods: getFinancialPeriodType('FYJUL', filterFuturePeriods, periodSettings),
|
|
284
268
|
name: i18n.t('Financial year (Start July)')
|
|
285
269
|
}, {
|
|
286
|
-
id:
|
|
287
|
-
getPeriods:
|
|
288
|
-
name: i18n.t('Financial year (Start
|
|
270
|
+
id: FYAUG,
|
|
271
|
+
getPeriods: getFinancialPeriodType('FYAUG', filterFuturePeriods, periodSettings),
|
|
272
|
+
name: i18n.t('Financial year (Start August)')
|
|
273
|
+
}, {
|
|
274
|
+
id: FYSEP,
|
|
275
|
+
getPeriods: getFinancialPeriodType('FYSEP', filterFuturePeriods, periodSettings),
|
|
276
|
+
name: i18n.t('Financial year (Start September)')
|
|
277
|
+
}, {
|
|
278
|
+
id: FYOCT,
|
|
279
|
+
getPeriods: getFinancialPeriodType('FYOCT', filterFuturePeriods, periodSettings),
|
|
280
|
+
name: i18n.t('Financial year (Start October)')
|
|
281
|
+
}, {
|
|
282
|
+
id: FYNOV,
|
|
283
|
+
getPeriods: getFinancialPeriodType('FYNOV', filterFuturePeriods, periodSettings),
|
|
284
|
+
name: i18n.t('Financial year (Start November)')
|
|
289
285
|
}];
|
|
290
286
|
};
|
|
291
287
|
export const getFixedPeriodsOptionsById = (id, periodSettings) => {
|
|
@@ -2,6 +2,7 @@ export const DAILY = 'DAILY';
|
|
|
2
2
|
export const WEEKLY = 'WEEKLY';
|
|
3
3
|
export const WEEKLYWED = 'WEEKLYWED';
|
|
4
4
|
export const WEEKLYTHU = 'WEEKLYTHU';
|
|
5
|
+
export const WEEKLYFRI = 'WEEKLYFRI';
|
|
5
6
|
export const WEEKLYSAT = 'WEEKLYSAT';
|
|
6
7
|
export const WEEKLYSUN = 'WEEKLYSUN';
|
|
7
8
|
export const WEEKS_THIS_YEAR = 'WEEKS_THIS_YEAR';
|
|
@@ -13,8 +14,11 @@ export const SIXMONTHLY = 'SIXMONTHLY';
|
|
|
13
14
|
export const SIXMONTHLYAPR = 'SIXMONTHLYAPR';
|
|
14
15
|
export const YEARLY = 'YEARLY';
|
|
15
16
|
export const FINANCIAL = 'FINANCIAL';
|
|
16
|
-
export const
|
|
17
|
-
export const FYOCT = 'FYOCT';
|
|
18
|
-
export const FYJUL = 'FYJUL';
|
|
17
|
+
export const FYFEB = 'FYFEB';
|
|
19
18
|
export const FYAPR = 'FYAPR';
|
|
19
|
+
export const FYJUL = 'FYJUL';
|
|
20
|
+
export const FYAUG = 'FYAUG';
|
|
21
|
+
export const FYSEP = 'FYSEP';
|
|
22
|
+
export const FYOCT = 'FYOCT';
|
|
23
|
+
export const FYNOV = 'FYNOV';
|
|
20
24
|
export const filterPeriodTypesById = (allPeriodTypes = [], excludedPeriodTypes = []) => allPeriodTypes.filter(period => !excludedPeriodTypes.includes(period.id));
|
package/build/es/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import './locales/index.js';
|
|
|
4
4
|
export { default as DataDimension } from './components/DataDimension/DataDimension.js';
|
|
5
5
|
export { default as PeriodDimension } from './components/PeriodDimension/PeriodDimension.js';
|
|
6
6
|
export { default as FixedPeriodSelect } from './components/PeriodDimension/FixedPeriodSelect.js';
|
|
7
|
+
export { useDataOutputPeriodTypes } from './components/PeriodDimension/useDataOutputPeriodTypes.js';
|
|
7
8
|
export { default as OrgUnitDimension } from './components/OrgUnitDimension/OrgUnitDimension.js';
|
|
8
9
|
export { default as DynamicDimension, ALL_DYNAMIC_DIMENSION_ITEMS } from './components/DynamicDimension/DynamicDimension.js';
|
|
9
10
|
export { default as DimensionsPanel } from './components/DimensionsPanel/DimensionsPanel.js';
|
|
@@ -256,6 +256,8 @@
|
|
|
256
256
|
"Select year": "Select year",
|
|
257
257
|
"Period": "Period",
|
|
258
258
|
"Selected Periods": "Selected Periods",
|
|
259
|
+
"No period types available": "No period types available",
|
|
260
|
+
"No period types are enabled in the system. Please contact your system administrator.": "No period types are enabled in the system. Please contact your system administrator.",
|
|
259
261
|
"Relative periods": "Relative periods",
|
|
260
262
|
"Fixed periods": "Fixed periods",
|
|
261
263
|
"No periods selected": "No periods selected",
|
|
@@ -263,6 +265,7 @@
|
|
|
263
265
|
"Weekly": "Weekly",
|
|
264
266
|
"Weekly (Start Wednesday)": "Weekly (Start Wednesday)",
|
|
265
267
|
"Weekly (Start Thursday)": "Weekly (Start Thursday)",
|
|
268
|
+
"Weekly (Start Friday)": "Weekly (Start Friday)",
|
|
266
269
|
"Weekly (Start Saturday)": "Weekly (Start Saturday)",
|
|
267
270
|
"Weekly (Start Sunday)": "Weekly (Start Sunday)",
|
|
268
271
|
"Bi-weekly": "Bi-weekly",
|
|
@@ -272,10 +275,13 @@
|
|
|
272
275
|
"Six-monthly": "Six-monthly",
|
|
273
276
|
"Six-monthly April": "Six-monthly April",
|
|
274
277
|
"Yearly": "Yearly",
|
|
275
|
-
"Financial year (Start
|
|
276
|
-
"Financial year (Start October)": "Financial year (Start October)",
|
|
277
|
-
"Financial year (Start July)": "Financial year (Start July)",
|
|
278
|
+
"Financial year (Start February)": "Financial year (Start February)",
|
|
278
279
|
"Financial year (Start April)": "Financial year (Start April)",
|
|
280
|
+
"Financial year (Start July)": "Financial year (Start July)",
|
|
281
|
+
"Financial year (Start August)": "Financial year (Start August)",
|
|
282
|
+
"Financial year (Start September)": "Financial year (Start September)",
|
|
283
|
+
"Financial year (Start October)": "Financial year (Start October)",
|
|
284
|
+
"Financial year (Start November)": "Financial year (Start November)",
|
|
279
285
|
"Today": "Today",
|
|
280
286
|
"Yesterday": "Yesterday",
|
|
281
287
|
"Last 3 days": "Last 3 days",
|
|
@@ -22,7 +22,7 @@ export default function (filters, metaData) {
|
|
|
22
22
|
const relativePeriodNames = getRelativePeriodsName();
|
|
23
23
|
titleFragments.push(dimensionGetItemIds(filter).map(id => {
|
|
24
24
|
var _metaData$items$id;
|
|
25
|
-
return
|
|
25
|
+
return ((_metaData$items$id = metaData.items[id]) === null || _metaData$items$id === void 0 ? void 0 : _metaData$items$id.name) || relativePeriodNames[id] || id;
|
|
26
26
|
}).join(', '));
|
|
27
27
|
} else {
|
|
28
28
|
const filterItems = metaData.dimensions[filter.dimension];
|