@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.
Files changed (31) hide show
  1. package/build/cjs/components/PeriodDimension/FixedPeriodFilter.js +5 -10
  2. package/build/cjs/components/PeriodDimension/FixedPeriodSelect.js +3 -1
  3. package/build/cjs/components/PeriodDimension/PeriodDimension.js +15 -5
  4. package/build/cjs/components/PeriodDimension/PeriodTransfer.js +111 -15
  5. package/build/cjs/components/PeriodDimension/RelativePeriodFilter.js +4 -6
  6. package/build/cjs/components/PeriodDimension/__tests__/PeriodDimension.spec.js +19 -6
  7. package/build/cjs/components/PeriodDimension/__tests__/fixedPeriods.spec.js +1 -1
  8. package/build/cjs/components/PeriodDimension/__tests__/utils.spec.js +1 -1
  9. package/build/cjs/components/PeriodDimension/useDataOutputPeriodTypes.js +155 -0
  10. package/build/cjs/components/PeriodDimension/utils/enabledPeriodTypes.js +179 -0
  11. package/build/cjs/components/PeriodDimension/utils/fixedPeriods.js +58 -62
  12. package/build/cjs/components/PeriodDimension/utils/index.js +8 -4
  13. package/build/cjs/index.js +8 -0
  14. package/build/cjs/locales/en/translations.json +9 -3
  15. package/build/cjs/visualizations/util/getFilterText.js +1 -1
  16. package/build/es/components/PeriodDimension/FixedPeriodFilter.js +5 -10
  17. package/build/es/components/PeriodDimension/FixedPeriodSelect.js +4 -2
  18. package/build/es/components/PeriodDimension/PeriodDimension.js +15 -5
  19. package/build/es/components/PeriodDimension/PeriodTransfer.js +116 -20
  20. package/build/es/components/PeriodDimension/RelativePeriodFilter.js +4 -6
  21. package/build/es/components/PeriodDimension/__tests__/PeriodDimension.spec.js +19 -6
  22. package/build/es/components/PeriodDimension/__tests__/fixedPeriods.spec.js +1 -1
  23. package/build/es/components/PeriodDimension/__tests__/utils.spec.js +1 -1
  24. package/build/es/components/PeriodDimension/useDataOutputPeriodTypes.js +149 -0
  25. package/build/es/components/PeriodDimension/utils/enabledPeriodTypes.js +168 -0
  26. package/build/es/components/PeriodDimension/utils/fixedPeriods.js +59 -63
  27. package/build/es/components/PeriodDimension/utils/index.js +7 -3
  28. package/build/es/index.js +1 -0
  29. package/build/es/locales/en/translations.json +9 -3
  30. package/build/es/visualizations/util/getFilterText.js +1 -1
  31. package/package.json +1 -1
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterEnabledRelativePeriodTypes = exports.filterEnabledFixedPeriodTypes = exports.applyPeriodNameOverrides = exports.applyFixedPeriodTypeDisplayLabels = exports.applyDisplayLabelOverrides = exports.SERVER_PT_TO_MULTI_CALENDAR_PT = exports.RP_CATEGORY_TO_FP_DEPENDENCIES = void 0;
7
+ // Mapping from server period type names to multi-calendar-dates constants
8
+ const SERVER_PT_TO_MULTI_CALENDAR_PT = exports.SERVER_PT_TO_MULTI_CALENDAR_PT = {
9
+ Daily: 'DAILY',
10
+ Weekly: 'WEEKLY',
11
+ WeeklyWednesday: 'WEEKLYWED',
12
+ WeeklyThursday: 'WEEKLYTHU',
13
+ WeeklyFriday: 'WEEKLYFRI',
14
+ WeeklySaturday: 'WEEKLYSAT',
15
+ WeeklySunday: 'WEEKLYSUN',
16
+ BiWeekly: 'BIWEEKLY',
17
+ Monthly: 'MONTHLY',
18
+ BiMonthly: 'BIMONTHLY',
19
+ Quarterly: 'QUARTERLY',
20
+ QuarterlyNov: 'QUARTERLYNOV',
21
+ SixMonthly: 'SIXMONTHLY',
22
+ SixMonthlyApril: 'SIXMONTHLYAPR',
23
+ SixMonthlyNov: 'SIXMONTHLYNOV',
24
+ Yearly: 'YEARLY',
25
+ FinancialFeb: 'FYFEB',
26
+ FinancialApril: 'FYAPR',
27
+ FinancialJuly: 'FYJUL',
28
+ FinancialAug: 'FYAUG',
29
+ FinancialSep: 'FYSEP',
30
+ FinancialOct: 'FYOCT',
31
+ FinancialNov: 'FYNOV'
32
+ };
33
+
34
+ // Mapping from relative period categories to their corresponding fixed period types
35
+ const RP_CATEGORY_TO_FP_DEPENDENCIES = exports.RP_CATEGORY_TO_FP_DEPENDENCIES = {
36
+ DAILY: ['Daily'],
37
+ WEEKLY: ['Weekly', 'WeeklyWednesday', 'WeeklyThursday', 'WeeklyFriday', 'WeeklySaturday', 'WeeklySunday'],
38
+ BIWEEKLY: ['BiWeekly'],
39
+ MONTHLY: ['Monthly'],
40
+ BIMONTHLY: ['BiMonthly'],
41
+ QUARTERLY: ['Quarterly', 'QuarterlyNov'],
42
+ SIXMONTHLY: ['SixMonthly', 'SixMonthlyApril', 'SixMonthlyNov'],
43
+ YEARLY: ['Yearly']
44
+ };
45
+
46
+ /**
47
+ * Filter fixed period types based on enabled server period types
48
+ * @param {Array} allFixedPeriodOptions - All available fixed period options
49
+ * @param {Array} enabledServerPeriodTypes - Enabled period types from server
50
+ * @returns {Array} Filtered fixed period options
51
+ */
52
+ const filterEnabledFixedPeriodTypes = (allFixedPeriodOptions, enabledServerPeriodTypes) => {
53
+ if (!enabledServerPeriodTypes || enabledServerPeriodTypes.length === 0) {
54
+ return [];
55
+ }
56
+ const enabledServerPtNames = new Set(enabledServerPeriodTypes.map(pt => pt.name));
57
+ const enabledMultiCalendarPts = new Set();
58
+
59
+ // Map server PT names to multi-calendar-dates constants
60
+ enabledServerPtNames.forEach(serverPtName => {
61
+ const multiCalendarPt = SERVER_PT_TO_MULTI_CALENDAR_PT[serverPtName];
62
+ if (multiCalendarPt) {
63
+ enabledMultiCalendarPts.add(multiCalendarPt);
64
+ }
65
+ });
66
+
67
+ // Filter fixed period options to only include enabled ones
68
+ return allFixedPeriodOptions.filter(option => enabledMultiCalendarPts.has(option.id));
69
+ };
70
+
71
+ /**
72
+ * Apply displayLabel overrides to fixed period type names
73
+ * v43-only: in v44 the API provides these names directly
74
+ */
75
+ exports.filterEnabledFixedPeriodTypes = filterEnabledFixedPeriodTypes;
76
+ const applyFixedPeriodTypeDisplayLabels = (filteredFixedOptions, enabledServerPeriodTypes) => {
77
+ if (!enabledServerPeriodTypes) {
78
+ return filteredFixedOptions;
79
+ }
80
+ const displayLabelMap = new Map();
81
+ enabledServerPeriodTypes.forEach(pt => {
82
+ if (pt.displayLabel) {
83
+ const multiCalendarPt = SERVER_PT_TO_MULTI_CALENDAR_PT[pt.name];
84
+ if (multiCalendarPt) {
85
+ displayLabelMap.set(multiCalendarPt, pt.displayLabel);
86
+ }
87
+ }
88
+ });
89
+ if (displayLabelMap.size === 0) {
90
+ return filteredFixedOptions;
91
+ }
92
+ return filteredFixedOptions.map(option => {
93
+ const displayLabel = displayLabelMap.get(option.id);
94
+ return displayLabel ? {
95
+ ...option,
96
+ name: displayLabel
97
+ } : option;
98
+ });
99
+ };
100
+
101
+ /**
102
+ * Filter relative period categories based on enabled server period types
103
+ * @param {Array} allRelativePeriodOptions - All available relative period options
104
+ * @param {Array} enabledServerPeriodTypes - Enabled period types from server
105
+ * @param {string|null} financialYearStart - Financial year start setting (if enabled)
106
+ * @returns {Array} Filtered relative period options
107
+ */
108
+ /**
109
+ * Apply metaData name overrides to a list of periods
110
+ * v43-only: in v44 the API provides these names directly
111
+ */
112
+ exports.applyFixedPeriodTypeDisplayLabels = applyFixedPeriodTypeDisplayLabels;
113
+ const applyPeriodNameOverrides = (periods, metaData) => {
114
+ if (!metaData) {
115
+ return periods;
116
+ }
117
+ return periods.map(period => metaData[period.id] ? {
118
+ ...period,
119
+ name: metaData[period.id].name
120
+ } : period);
121
+ };
122
+
123
+ /**
124
+ * Apply display label overrides to relative period options
125
+ * v43-only: in v44 the API provides these names directly
126
+ */
127
+ exports.applyPeriodNameOverrides = applyPeriodNameOverrides;
128
+ const applyDisplayLabelOverrides = (filteredRelativeOptions, {
129
+ financialYearDisplayLabel,
130
+ weeklyDisplayLabel,
131
+ metaData
132
+ }) => {
133
+ const overrides = {};
134
+ if (financialYearDisplayLabel) {
135
+ overrides['FINANCIAL'] = {
136
+ name: financialYearDisplayLabel
137
+ };
138
+ }
139
+ if (weeklyDisplayLabel) {
140
+ overrides['WEEKLY'] = {
141
+ name: weeklyDisplayLabel
142
+ };
143
+ }
144
+ if (Object.keys(overrides).length === 0) {
145
+ return filteredRelativeOptions;
146
+ }
147
+ return filteredRelativeOptions.map(option => {
148
+ const override = overrides[option.id];
149
+ if (!override) {
150
+ return option;
151
+ }
152
+ return {
153
+ ...option,
154
+ name: override.name,
155
+ getPeriods: () => applyPeriodNameOverrides(option.getPeriods(), metaData)
156
+ };
157
+ });
158
+ };
159
+ exports.applyDisplayLabelOverrides = applyDisplayLabelOverrides;
160
+ const filterEnabledRelativePeriodTypes = (allRelativePeriodOptions, enabledServerPeriodTypes, financialYearStart = null) => {
161
+ if (!enabledServerPeriodTypes || enabledServerPeriodTypes.length === 0) {
162
+ return [];
163
+ }
164
+ const enabledServerPtNames = new Set(enabledServerPeriodTypes.map(pt => pt.name));
165
+ return allRelativePeriodOptions.filter(option => {
166
+ // Special handling for financial years
167
+ if (option.id === 'FINANCIAL') {
168
+ return financialYearStart !== null;
169
+ }
170
+
171
+ // Check if any of the required FP dependencies are enabled
172
+ const requiredFpTypes = RP_CATEGORY_TO_FP_DEPENDENCIES[option.id];
173
+ if (!requiredFpTypes) {
174
+ return true; // Show if no dependency mapping (shouldn't happen)
175
+ }
176
+ return requiredFpTypes.some(fpType => enabledServerPtNames.has(fpType));
177
+ });
178
+ };
179
+ exports.filterEnabledRelativePeriodTypes = filterEnabledRelativePeriodTypes;
@@ -9,40 +9,48 @@ var _index = _interopRequireDefault(require("../../../locales/index.js"));
9
9
  var _index2 = require("./index.js");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  const PERIOD_TYPE_REGEX = exports.PERIOD_TYPE_REGEX = {
12
- [_index2.DAILY]: /^([0-9]{4})([0-9]{2})([0-9]{2})$/,
12
+ [_index2.DAILY]: /^(\d{4})(\d{2})(\d{2})$/,
13
13
  // YYYYMMDD
14
- [_index2.WEEKLY]: /^([0-9]{4})()W([0-9]{1,2})$/,
14
+ [_index2.WEEKLY]: /^(\d{4})W(\d{1,2})$/,
15
15
  // YYYY"W"[1-53]
16
- [_index2.BIWEEKLY]: /^([0-9]{4})BiW([0-9]{1,2})$/,
16
+ [_index2.BIWEEKLY]: /^(\d{4})BiW(\d{1,2})$/,
17
17
  // YYYY"BiW"[1-27]
18
- [_index2.WEEKLYWED]: /^([0-9]{4})(Wed)W([0-9]{1,2})$/,
18
+ [_index2.WEEKLYWED]: /^(\d{4})(Wed)W(\d{1,2})$/,
19
19
  // YYYY"WedW"[1-53]
20
- [_index2.WEEKLYTHU]: /^([0-9]{4})(Thu)W([0-9]{1,2})$/,
20
+ [_index2.WEEKLYTHU]: /^(\d{4})(Thu)W(\d{1,2})$/,
21
21
  // YYYY"ThuW"[1-53]
22
- [_index2.WEEKLYSAT]: /^([0-9]{4})(Sat)W([0-9]{1,2})$/,
22
+ [_index2.WEEKLYFRI]: /^(\d{4})(Fri)W(\d{1,2})$/,
23
+ // YYYY"FriW"[1-53]
24
+ [_index2.WEEKLYSAT]: /^(\d{4})(Sat)W(\d{1,2})$/,
23
25
  // YYYY"SatW"[1-53]
24
- [_index2.WEEKLYSUN]: /^([0-9]{4})(Sun)W([0-9]{1,2})$/,
26
+ [_index2.WEEKLYSUN]: /^(\d{4})(Sun)W(\d{1,2})$/,
25
27
  // YYYY"SunW"[1-53]
26
- [_index2.MONTHLY]: /^([0-9]{4})([0-9]{2})$/,
28
+ [_index2.MONTHLY]: /^(\d{4})(\d{2})$/,
27
29
  // YYYYMM
28
- [_index2.BIMONTHLY]: /^([0-9]{4})([0-9]{2})B$/,
30
+ [_index2.BIMONTHLY]: /^(\d{4})(\d{2})B$/,
29
31
  // YYYY0[1-6]"B"
30
- [_index2.QUARTERLY]: /^([0-9]{4})Q([1234])$/,
32
+ [_index2.QUARTERLY]: /^(\d{4})Q([1234])$/,
31
33
  // YYYY"Q"[1-4]
32
- [_index2.SIXMONTHLY]: /^([0-9]{4})S([12])$/,
34
+ [_index2.SIXMONTHLY]: /^(\d{4})S([12])$/,
33
35
  // YYYY"S"[1/2]
34
- [_index2.SIXMONTHLYAPR]: /^([0-9]{4})AprilS([12])$/,
36
+ [_index2.SIXMONTHLYAPR]: /^(\d{4})AprilS([12])$/,
35
37
  // YYYY"AprilS"[1/2]
36
- // [SIXMONTHLYNOV]: /^([0-9]{4})NovS([12])$/, // YYYY"NovS"[1/2] Not supported?
37
- [_index2.YEARLY]: /^([0-9]{4})$/,
38
+ // [SIXMONTHLYNOV]: /^(\d{4})NovS([12])$/, // YYYY"NovS"[1/2] Not supported?
39
+ [_index2.YEARLY]: /^(\d{4})$/,
38
40
  // YYYY
39
- [_index2.FYNOV]: /^([0-9]{4})Nov$/,
40
- // YYYY"Nov"
41
- [_index2.FYOCT]: /^([0-9]{4})Oct$/,
42
- // YYYY"Oct"
43
- [_index2.FYJUL]: /^([0-9]{4})July$/,
41
+ [_index2.FYFEB]: /^(\d{4})Feb$/,
42
+ // YYYY"Feb"
43
+ [_index2.FYAPR]: /^(\d{4})April$/,
44
+ // YYYY"April"
45
+ [_index2.FYJUL]: /^(\d{4})July$/,
44
46
  // YYYY"July"
45
- [_index2.FYAPR]: /^([0-9]{4})April$/ // YYYY"April"
47
+ [_index2.FYAUG]: /^(\d{4})Aug$/,
48
+ // YYYY"Aug"
49
+ [_index2.FYSEP]: /^(\d{4})Sep$/,
50
+ // YYYY"Sep"
51
+ [_index2.FYOCT]: /^(\d{4})Oct$/,
52
+ // YYYY"Oct"
53
+ [_index2.FYNOV]: /^(\d{4})Nov$/ // YYYY"Nov"
46
54
  };
47
55
  const getPeriods = ({
48
56
  periodType,
@@ -164,40 +172,10 @@ const getYearlyPeriodType = (fnFilter, periodSettings) => {
164
172
  });
165
173
  };
166
174
  };
167
- const getFinancialOctoberPeriodType = (fnFilter, periodSettings) => {
168
- return config => {
169
- return getPeriods({
170
- periodType: 'FYOCT',
171
- config,
172
- fnFilter,
173
- periodSettings
174
- });
175
- };
176
- };
177
- const getFinancialNovemberPeriodType = (fnFilter, periodSettings) => {
178
- return config => {
179
- return getPeriods({
180
- periodType: 'FYNOV',
181
- config,
182
- fnFilter,
183
- periodSettings
184
- });
185
- };
186
- };
187
- const getFinancialJulyPeriodType = (fnFilter, periodSettings) => {
188
- return config => {
189
- return getPeriods({
190
- periodType: 'FYJUL',
191
- config,
192
- fnFilter,
193
- periodSettings
194
- });
195
- };
196
- };
197
- const getFinancialAprilPeriodType = (fnFilter, periodSettings) => {
175
+ const getFinancialPeriodType = (periodType, fnFilter, periodSettings) => {
198
176
  return config => {
199
177
  return getPeriods({
200
- periodType: 'FYAPR',
178
+ periodType,
201
179
  config,
202
180
  fnFilter,
203
181
  periodSettings
@@ -237,6 +215,12 @@ const getOptions = periodSettings => {
237
215
  startDay: 4
238
216
  }, filterFuturePeriods, periodSettings),
239
217
  name: _index.default.t('Weekly (Start Thursday)')
218
+ }, {
219
+ id: _index2.WEEKLYFRI,
220
+ getPeriods: getWeeklyPeriodType({
221
+ startDay: 5
222
+ }, filterFuturePeriods, periodSettings),
223
+ name: _index.default.t('Weekly (Start Friday)')
240
224
  }, {
241
225
  id: _index2.WEEKLYSAT,
242
226
  getPeriods: getWeeklyPeriodType({
@@ -278,21 +262,33 @@ const getOptions = periodSettings => {
278
262
  getPeriods: getYearlyPeriodType(filterFuturePeriods, periodSettings),
279
263
  name: _index.default.t('Yearly')
280
264
  }, {
281
- id: _index2.FYNOV,
282
- getPeriods: getFinancialNovemberPeriodType(filterFuturePeriods, periodSettings),
283
- name: _index.default.t('Financial year (Start November)')
265
+ id: _index2.FYFEB,
266
+ getPeriods: getFinancialPeriodType('FYFEB', filterFuturePeriods, periodSettings),
267
+ name: _index.default.t('Financial year (Start February)')
284
268
  }, {
285
- id: _index2.FYOCT,
286
- getPeriods: getFinancialOctoberPeriodType(filterFuturePeriods, periodSettings),
287
- name: _index.default.t('Financial year (Start October)')
269
+ id: _index2.FYAPR,
270
+ getPeriods: getFinancialPeriodType('FYAPR', filterFuturePeriods, periodSettings),
271
+ name: _index.default.t('Financial year (Start April)')
288
272
  }, {
289
273
  id: _index2.FYJUL,
290
- getPeriods: getFinancialJulyPeriodType(filterFuturePeriods, periodSettings),
274
+ getPeriods: getFinancialPeriodType('FYJUL', filterFuturePeriods, periodSettings),
291
275
  name: _index.default.t('Financial year (Start July)')
292
276
  }, {
293
- id: _index2.FYAPR,
294
- getPeriods: getFinancialAprilPeriodType(filterFuturePeriods, periodSettings),
295
- name: _index.default.t('Financial year (Start April)')
277
+ id: _index2.FYAUG,
278
+ getPeriods: getFinancialPeriodType('FYAUG', filterFuturePeriods, periodSettings),
279
+ name: _index.default.t('Financial year (Start August)')
280
+ }, {
281
+ id: _index2.FYSEP,
282
+ getPeriods: getFinancialPeriodType('FYSEP', filterFuturePeriods, periodSettings),
283
+ name: _index.default.t('Financial year (Start September)')
284
+ }, {
285
+ id: _index2.FYOCT,
286
+ getPeriods: getFinancialPeriodType('FYOCT', filterFuturePeriods, periodSettings),
287
+ name: _index.default.t('Financial year (Start October)')
288
+ }, {
289
+ id: _index2.FYNOV,
290
+ getPeriods: getFinancialPeriodType('FYNOV', filterFuturePeriods, periodSettings),
291
+ name: _index.default.t('Financial year (Start November)')
296
292
  }];
297
293
  };
298
294
  const getFixedPeriodsOptionsById = (id, periodSettings) => {
@@ -3,11 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.filterPeriodTypesById = exports.YEARLY = exports.WEEKS_THIS_YEAR = exports.WEEKLYWED = exports.WEEKLYTHU = exports.WEEKLYSUN = exports.WEEKLYSAT = exports.WEEKLY = exports.SIXMONTHLYAPR = exports.SIXMONTHLY = exports.QUARTERLY = exports.MONTHLY = exports.FYOCT = exports.FYNOV = exports.FYJUL = exports.FYAPR = exports.FINANCIAL = exports.DAILY = exports.BIWEEKLY = exports.BIMONTHLY = void 0;
6
+ exports.filterPeriodTypesById = exports.YEARLY = exports.WEEKS_THIS_YEAR = exports.WEEKLYWED = exports.WEEKLYTHU = exports.WEEKLYSUN = exports.WEEKLYSAT = exports.WEEKLYFRI = exports.WEEKLY = exports.SIXMONTHLYAPR = exports.SIXMONTHLY = exports.QUARTERLY = exports.MONTHLY = exports.FYSEP = exports.FYOCT = exports.FYNOV = exports.FYJUL = exports.FYFEB = exports.FYAUG = exports.FYAPR = exports.FINANCIAL = exports.DAILY = exports.BIWEEKLY = exports.BIMONTHLY = void 0;
7
7
  const DAILY = exports.DAILY = 'DAILY';
8
8
  const WEEKLY = exports.WEEKLY = 'WEEKLY';
9
9
  const WEEKLYWED = exports.WEEKLYWED = 'WEEKLYWED';
10
10
  const WEEKLYTHU = exports.WEEKLYTHU = 'WEEKLYTHU';
11
+ const WEEKLYFRI = exports.WEEKLYFRI = 'WEEKLYFRI';
11
12
  const WEEKLYSAT = exports.WEEKLYSAT = 'WEEKLYSAT';
12
13
  const WEEKLYSUN = exports.WEEKLYSUN = 'WEEKLYSUN';
13
14
  const WEEKS_THIS_YEAR = exports.WEEKS_THIS_YEAR = 'WEEKS_THIS_YEAR';
@@ -19,9 +20,12 @@ const SIXMONTHLY = exports.SIXMONTHLY = 'SIXMONTHLY';
19
20
  const SIXMONTHLYAPR = exports.SIXMONTHLYAPR = 'SIXMONTHLYAPR';
20
21
  const YEARLY = exports.YEARLY = 'YEARLY';
21
22
  const FINANCIAL = exports.FINANCIAL = 'FINANCIAL';
22
- const FYNOV = exports.FYNOV = 'FYNOV';
23
- const FYOCT = exports.FYOCT = 'FYOCT';
24
- const FYJUL = exports.FYJUL = 'FYJUL';
23
+ const FYFEB = exports.FYFEB = 'FYFEB';
25
24
  const FYAPR = exports.FYAPR = 'FYAPR';
25
+ const FYJUL = exports.FYJUL = 'FYJUL';
26
+ const FYAUG = exports.FYAUG = 'FYAUG';
27
+ const FYSEP = exports.FYSEP = 'FYSEP';
28
+ const FYOCT = exports.FYOCT = 'FYOCT';
29
+ const FYNOV = exports.FYNOV = 'FYNOV';
26
30
  const filterPeriodTypesById = (allPeriodTypes = [], excludedPeriodTypes = []) => allPeriodTypes.filter(period => !excludedPeriodTypes.includes(period.id));
27
31
  exports.filterPeriodTypesById = filterPeriodTypesById;
@@ -7,6 +7,7 @@ var _exportNames = {
7
7
  DataDimension: true,
8
8
  PeriodDimension: true,
9
9
  FixedPeriodSelect: true,
10
+ useDataOutputPeriodTypes: true,
10
11
  OrgUnitDimension: true,
11
12
  DynamicDimension: true,
12
13
  ALL_DYNAMIC_DIMENSION_ITEMS: true,
@@ -1912,6 +1913,12 @@ Object.defineProperty(exports, "useCachedDataQuery", {
1912
1913
  return _CachedDataQueryProvider.useCachedDataQuery;
1913
1914
  }
1914
1915
  });
1916
+ Object.defineProperty(exports, "useDataOutputPeriodTypes", {
1917
+ enumerable: true,
1918
+ get: function () {
1919
+ return _useDataOutputPeriodTypes.useDataOutputPeriodTypes;
1920
+ }
1921
+ });
1915
1922
  Object.defineProperty(exports, "valueTypeDisplayNames", {
1916
1923
  enumerable: true,
1917
1924
  get: function () {
@@ -1934,6 +1941,7 @@ require("./locales/index.js");
1934
1941
  var _DataDimension = _interopRequireDefault(require("./components/DataDimension/DataDimension.js"));
1935
1942
  var _PeriodDimension = _interopRequireDefault(require("./components/PeriodDimension/PeriodDimension.js"));
1936
1943
  var _FixedPeriodSelect = _interopRequireDefault(require("./components/PeriodDimension/FixedPeriodSelect.js"));
1944
+ var _useDataOutputPeriodTypes = require("./components/PeriodDimension/useDataOutputPeriodTypes.js");
1937
1945
  var _OrgUnitDimension = _interopRequireDefault(require("./components/OrgUnitDimension/OrgUnitDimension.js"));
1938
1946
  var _DynamicDimension = _interopRequireWildcard(require("./components/DynamicDimension/DynamicDimension.js"));
1939
1947
  var _DimensionsPanel = _interopRequireDefault(require("./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 November)": "Financial year (Start November)",
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",
@@ -28,7 +28,7 @@ function _default(filters, metaData) {
28
28
  const relativePeriodNames = (0, _relativePeriods.getRelativePeriodsName)();
29
29
  titleFragments.push((0, _dimensionGetItemIds.dimensionGetItemIds)(filter).map(id => {
30
30
  var _metaData$items$id;
31
- return relativePeriodNames[id] || ((_metaData$items$id = metaData.items[id]) === null || _metaData$items$id === void 0 ? void 0 : _metaData$items$id.name) || id;
31
+ return ((_metaData$items$id = metaData.items[id]) === null || _metaData$items$id === void 0 ? void 0 : _metaData$items$id.name) || relativePeriodNames[id] || id;
32
32
  }).join(', '));
33
33
  } else {
34
34
  const filterItems = metaData.dimensions[filter.dimension];
@@ -4,19 +4,15 @@ import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
5
  import i18n from '../../locales/index.js';
6
6
  import styles from './styles/PeriodFilter.style.js';
7
- import { getFixedPeriodsOptions } from './utils/fixedPeriods.js';
8
- import { filterPeriodTypesById } from './utils/index.js';
9
- const EXCLUDED_PERIOD_TYPES_PROP_DEFAULT = [];
10
7
  const FixedPeriodFilter = ({
11
- allowedPeriodTypes,
12
- excludedPeriodTypes = EXCLUDED_PERIOD_TYPES_PROP_DEFAULT,
8
+ availableOptions,
13
9
  currentPeriodType,
14
10
  currentYear,
15
11
  onSelectPeriodType,
16
12
  onSelectYear,
17
13
  dataTest
18
14
  }) => {
19
- const onlyAllowedTypeIsSelected = Array.isArray(allowedPeriodTypes) && allowedPeriodTypes.length === 1 && allowedPeriodTypes[0] === currentPeriodType;
15
+ const onlyAllowedTypeIsSelected = availableOptions.length === 1 && availableOptions[0].id === currentPeriodType;
20
16
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
21
17
  "data-test": dataTest,
22
18
  className: `jsx-${styles.__hash}` + " " + "leftSection"
@@ -30,7 +26,7 @@ const FixedPeriodFilter = ({
30
26
  disabled: onlyAllowedTypeIsSelected,
31
27
  className: "filterElement",
32
28
  dataTest: `${dataTest}-period-type`
33
- }, (allowedPeriodTypes ? getFixedPeriodsOptions().filter(option => allowedPeriodTypes.some(type => type === option.id)) : filterPeriodTypesById(getFixedPeriodsOptions(), excludedPeriodTypes)).map(option => /*#__PURE__*/React.createElement(SingleSelectOption, {
29
+ }, availableOptions.map(option => /*#__PURE__*/React.createElement(SingleSelectOption, {
34
30
  key: option.id,
35
31
  value: option.id,
36
32
  label: option.name,
@@ -53,12 +49,11 @@ const FixedPeriodFilter = ({
53
49
  }, styles));
54
50
  };
55
51
  FixedPeriodFilter.propTypes = {
52
+ availableOptions: PropTypes.array.isRequired,
56
53
  currentPeriodType: PropTypes.string.isRequired,
57
54
  currentYear: PropTypes.string.isRequired,
58
55
  onSelectPeriodType: PropTypes.func.isRequired,
59
56
  onSelectYear: PropTypes.func.isRequired,
60
- allowedPeriodTypes: PropTypes.arrayOf(PropTypes.string),
61
- dataTest: PropTypes.string,
62
- excludedPeriodTypes: PropTypes.arrayOf(PropTypes.string)
57
+ dataTest: PropTypes.string
63
58
  };
64
59
  export default FixedPeriodFilter;
@@ -8,7 +8,7 @@ import React, { Component } from 'react';
8
8
  import i18n from '../../locales/index.js';
9
9
  import FixedPeriodFilter from './FixedPeriodFilter.js';
10
10
  import styles from './styles/FixedPeriodSelect.style.js';
11
- import { parsePeriodCode, getFixedPeriodsOptionsById as getPeriodById, getYearOffsetFromNow } from './utils/fixedPeriods.js';
11
+ import { parsePeriodCode, getFixedPeriodsOptionsById as getPeriodById, getFixedPeriodsOptions, getYearOffsetFromNow } from './utils/fixedPeriods.js';
12
12
  class FixedPeriodSelect extends Component {
13
13
  constructor(...args) {
14
14
  super(...args);
@@ -61,13 +61,15 @@ class FixedPeriodSelect extends Component {
61
61
  });
62
62
  }
63
63
  render() {
64
+ const allOptions = getFixedPeriodsOptions();
65
+ const availableOptions = this.props.allowedPeriodTypes ? allOptions.filter(option => this.props.allowedPeriodTypes.includes(option.id)) : allOptions;
64
66
  return /*#__PURE__*/React.createElement("div", {
65
67
  "data-test": this.props.dataTest,
66
68
  className: `jsx-${styles.__hash}` + " " + (this.props.className || "")
67
69
  }, /*#__PURE__*/React.createElement("div", {
68
70
  className: `jsx-${styles.__hash}` + " " + "row"
69
71
  }, /*#__PURE__*/React.createElement(FixedPeriodFilter, {
70
- allowedPeriodTypes: this.props.allowedPeriodTypes,
72
+ availableOptions: availableOptions,
71
73
  currentPeriodType: this.state.periodType,
72
74
  currentYear: this.state.year,
73
75
  onSelectPeriodType: this.onSelectPeriodType,
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
3
3
  import React from 'react';
4
4
  import { DIMENSION_ID_PERIOD } from '../../modules/predefinedDimensions.js';
5
5
  import PeriodTransfer from './PeriodTransfer.js';
6
+ import { useDataOutputPeriodTypes } from './useDataOutputPeriodTypes.js';
7
+ import { applyPeriodNameOverrides } from './utils/enabledPeriodTypes.js';
6
8
  const userSettingsQuery = {
7
9
  userSettings: {
8
10
  resource: 'userSettings',
@@ -20,10 +22,15 @@ const PeriodDimension = ({
20
22
  infoBoxMessage,
21
23
  height
22
24
  }) => {
25
+ const config = useConfig();
23
26
  const {
24
27
  systemInfo
25
- } = useConfig();
26
- const result = useDataQuery(userSettingsQuery);
28
+ } = config;
29
+ const userSettingsResult = useDataQuery(userSettingsQuery);
30
+ const {
31
+ supportsEnabledPeriodTypes,
32
+ enabledPeriodTypesData
33
+ } = useDataOutputPeriodTypes();
27
34
  const {
28
35
  calendar = 'gregory'
29
36
  } = systemInfo;
@@ -33,7 +40,7 @@ const PeriodDimension = ({
33
40
  keyUiLocale: locale
34
41
  } = {}
35
42
  } = {}
36
- } = result;
43
+ } = userSettingsResult;
37
44
  const periodsSettings = {
38
45
  calendar,
39
46
  locale
@@ -44,15 +51,18 @@ const PeriodDimension = ({
44
51
  items: periods
45
52
  });
46
53
  };
54
+ const selectedPeriodsWithCustomDisplayNames = applyPeriodNameOverrides(selectedPeriods, enabledPeriodTypesData === null || enabledPeriodTypesData === void 0 ? void 0 : enabledPeriodTypesData.metaData);
47
55
  return /*#__PURE__*/React.createElement(PeriodTransfer, {
48
56
  onSelect: selectPeriods,
49
- selectedItems: selectedPeriods,
57
+ selectedItems: selectedPeriodsWithCustomDisplayNames,
50
58
  infoBoxMessage: infoBoxMessage,
51
59
  rightFooter: rightFooter,
52
60
  dataTest: 'period-dimension',
53
61
  excludedPeriodTypes: excludedPeriodTypes,
54
62
  periodsSettings: periodsSettings,
55
- height: height
63
+ height: height,
64
+ enabledPeriodTypesData: enabledPeriodTypesData,
65
+ supportsEnabledPeriodTypes: supportsEnabledPeriodTypes
56
66
  });
57
67
  };
58
68
  PeriodDimension.propTypes = {