@dhis2/analytics 24.5.0 → 24.7.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 +16 -2
- package/build/cjs/__demo__/OrgUnitDimension.stories.js +40 -1
- package/build/cjs/components/OrgUnitDimension/OrgUnitDimension.js +25 -8
- package/build/cjs/components/OrgUnitDimension/styles/OrgUnitDimension.style.js +2 -2
- package/build/cjs/components/PeriodDimension/PeriodTransfer.js +4 -16
- package/build/cjs/components/PeriodDimension/utils/fixedPeriods.js +478 -204
- package/build/cjs/locales/en/translations.json +14 -0
- package/build/cjs/visualizations/config/generators/dhis/singleValue.js +76 -23
- package/build/cjs/visualizations/config/index.js +2 -1
- package/build/es/__demo__/OrgUnitDimension.stories.js +40 -1
- package/build/es/components/OrgUnitDimension/OrgUnitDimension.js +26 -9
- package/build/es/components/OrgUnitDimension/styles/OrgUnitDimension.style.js +2 -2
- package/build/es/components/PeriodDimension/PeriodTransfer.js +4 -14
- package/build/es/components/PeriodDimension/utils/fixedPeriods.js +477 -202
- package/build/es/locales/en/translations.json +14 -0
- package/build/es/visualizations/config/generators/dhis/singleValue.js +79 -26
- package/build/es/visualizations/config/index.js +2 -1
- package/package.json +1 -7
|
@@ -182,6 +182,20 @@
|
|
|
182
182
|
"Fixed periods": "Fixed periods",
|
|
183
183
|
"Selected Periods": "Selected Periods",
|
|
184
184
|
"No periods selected": "No periods selected",
|
|
185
|
+
"January": "January",
|
|
186
|
+
"February": "February",
|
|
187
|
+
"March": "March",
|
|
188
|
+
"April": "April",
|
|
189
|
+
"May": "May",
|
|
190
|
+
"June": "June",
|
|
191
|
+
"July": "July",
|
|
192
|
+
"August": "August",
|
|
193
|
+
"September": "September",
|
|
194
|
+
"October": "October",
|
|
195
|
+
"November": "November",
|
|
196
|
+
"December": "December",
|
|
197
|
+
"Week {{weekNumber}}": "Week {{weekNumber}}",
|
|
198
|
+
"Bi-Week {{biWeekNumber}}": "Bi-Week {{biWeekNumber}}",
|
|
185
199
|
"Daily": "Daily",
|
|
186
200
|
"Weekly": "Weekly",
|
|
187
201
|
"Weekly (Start Wednesday)": "Weekly (Start Wednesday)",
|
|
@@ -15,10 +15,9 @@ const svgNS = 'http://www.w3.org/2000/svg';
|
|
|
15
15
|
|
|
16
16
|
const generateValueSVG = _ref => {
|
|
17
17
|
let {
|
|
18
|
-
value,
|
|
19
18
|
formattedValue,
|
|
20
19
|
subText,
|
|
21
|
-
|
|
20
|
+
valueColor,
|
|
22
21
|
noData,
|
|
23
22
|
y
|
|
24
23
|
} = _ref;
|
|
@@ -33,8 +32,8 @@ const generateValueSVG = _ref => {
|
|
|
33
32
|
|
|
34
33
|
let fillColor = _ui.colors.grey900;
|
|
35
34
|
|
|
36
|
-
if (
|
|
37
|
-
fillColor =
|
|
35
|
+
if (valueColor) {
|
|
36
|
+
fillColor = valueColor;
|
|
38
37
|
} else if (formattedValue === noData.text) {
|
|
39
38
|
fillColor = _ui.colors.grey600;
|
|
40
39
|
}
|
|
@@ -75,7 +74,7 @@ const generateValueSVG = _ref => {
|
|
|
75
74
|
|
|
76
75
|
const generateDashboardItem = (config, _ref2) => {
|
|
77
76
|
let {
|
|
78
|
-
|
|
77
|
+
valueColor,
|
|
79
78
|
noData
|
|
80
79
|
} = _ref2;
|
|
81
80
|
const container = document.createElement('div');
|
|
@@ -98,10 +97,9 @@ const generateDashboardItem = (config, _ref2) => {
|
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
container.appendChild(generateValueSVG({
|
|
101
|
-
value: config.value,
|
|
102
100
|
formattedValue: config.formattedValue,
|
|
103
101
|
subText: config.subText,
|
|
104
|
-
|
|
102
|
+
valueColor,
|
|
105
103
|
noData,
|
|
106
104
|
y: 40
|
|
107
105
|
}));
|
|
@@ -138,7 +136,8 @@ const getXFromTextAlign = textAlign => {
|
|
|
138
136
|
|
|
139
137
|
const generateDVItem = (config, _ref3) => {
|
|
140
138
|
let {
|
|
141
|
-
|
|
139
|
+
valueColor,
|
|
140
|
+
titleColor,
|
|
142
141
|
parentEl,
|
|
143
142
|
fontStyle,
|
|
144
143
|
noData
|
|
@@ -161,7 +160,13 @@ const generateDVItem = (config, _ref3) => {
|
|
|
161
160
|
title.setAttribute('font-size', "".concat(titleFontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE], "px"));
|
|
162
161
|
title.setAttribute('font-weight', titleFontStyle[_fontStyle.FONT_STYLE_OPTION_BOLD] ? _fontStyle.FONT_STYLE_OPTION_BOLD : 'normal');
|
|
163
162
|
title.setAttribute('font-style', titleFontStyle[_fontStyle.FONT_STYLE_OPTION_ITALIC] ? _fontStyle.FONT_STYLE_OPTION_ITALIC : 'normal');
|
|
164
|
-
|
|
163
|
+
|
|
164
|
+
if (titleColor && titleFontStyle[_fontStyle.FONT_STYLE_OPTION_TEXT_COLOR] === _fontStyle.defaultFontStyle[_fontStyle.FONT_STYLE_VISUALIZATION_TITLE][_fontStyle.FONT_STYLE_OPTION_TEXT_COLOR]) {
|
|
165
|
+
title.setAttribute('fill', titleColor);
|
|
166
|
+
} else {
|
|
167
|
+
title.setAttribute('fill', titleFontStyle[_fontStyle.FONT_STYLE_OPTION_TEXT_COLOR]);
|
|
168
|
+
}
|
|
169
|
+
|
|
165
170
|
title.setAttribute('data-test', 'visualization-title');
|
|
166
171
|
|
|
167
172
|
if (config.title) {
|
|
@@ -178,7 +183,13 @@ const generateDVItem = (config, _ref3) => {
|
|
|
178
183
|
subtitle.setAttribute('font-size', "".concat(subtitleFontStyle[_fontStyle.FONT_STYLE_OPTION_FONT_SIZE], "px"));
|
|
179
184
|
subtitle.setAttribute('font-weight', subtitleFontStyle[_fontStyle.FONT_STYLE_OPTION_BOLD] ? _fontStyle.FONT_STYLE_OPTION_BOLD : 'normal');
|
|
180
185
|
subtitle.setAttribute('font-style', subtitleFontStyle[_fontStyle.FONT_STYLE_OPTION_ITALIC] ? _fontStyle.FONT_STYLE_OPTION_ITALIC : 'normal');
|
|
181
|
-
|
|
186
|
+
|
|
187
|
+
if (titleColor && subtitleFontStyle[_fontStyle.FONT_STYLE_OPTION_TEXT_COLOR] === _fontStyle.defaultFontStyle[_fontStyle.FONT_STYLE_VISUALIZATION_SUBTITLE][_fontStyle.FONT_STYLE_OPTION_TEXT_COLOR]) {
|
|
188
|
+
subtitle.setAttribute('fill', titleColor);
|
|
189
|
+
} else {
|
|
190
|
+
subtitle.setAttribute('fill', subtitleFontStyle[_fontStyle.FONT_STYLE_OPTION_TEXT_COLOR]);
|
|
191
|
+
}
|
|
192
|
+
|
|
182
193
|
subtitle.setAttribute('data-test', 'visualization-subtitle');
|
|
183
194
|
|
|
184
195
|
if (config.subtitle) {
|
|
@@ -187,34 +198,76 @@ const generateDVItem = (config, _ref3) => {
|
|
|
187
198
|
}
|
|
188
199
|
|
|
189
200
|
svg.appendChild(generateValueSVG({
|
|
190
|
-
value: config.value,
|
|
191
201
|
formattedValue: config.formattedValue,
|
|
192
202
|
subText: config.subText,
|
|
193
|
-
|
|
203
|
+
valueColor,
|
|
194
204
|
noData,
|
|
195
205
|
y: 20
|
|
196
206
|
}));
|
|
197
207
|
return svg;
|
|
198
208
|
};
|
|
199
209
|
|
|
210
|
+
const shouldUseContrastColor = inputColor => {
|
|
211
|
+
// based on https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color
|
|
212
|
+
var color = inputColor.charAt(0) === '#' ? inputColor.substring(1, 7) : inputColor;
|
|
213
|
+
var r = parseInt(color.substring(0, 2), 16); // hexToR
|
|
214
|
+
|
|
215
|
+
var g = parseInt(color.substring(2, 4), 16); // hexToG
|
|
216
|
+
|
|
217
|
+
var b = parseInt(color.substring(4, 6), 16); // hexToB
|
|
218
|
+
|
|
219
|
+
var uicolors = [r / 255, g / 255, b / 255];
|
|
220
|
+
var c = uicolors.map(col => {
|
|
221
|
+
if (col <= 0.03928) {
|
|
222
|
+
return col / 12.92;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return Math.pow((col + 0.055) / 1.055, 2.4);
|
|
226
|
+
});
|
|
227
|
+
var L = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
|
|
228
|
+
return L <= 0.179;
|
|
229
|
+
};
|
|
230
|
+
|
|
200
231
|
function _default(config, parentEl, _ref4) {
|
|
201
232
|
let {
|
|
202
233
|
dashboard,
|
|
203
234
|
legendSets,
|
|
204
235
|
fontStyle,
|
|
205
|
-
noData
|
|
236
|
+
noData,
|
|
237
|
+
legendOptions
|
|
206
238
|
} = _ref4;
|
|
207
|
-
const legendSet = legendSets[0];
|
|
239
|
+
const legendSet = legendOptions && legendSets[0];
|
|
240
|
+
const legendColor = legendSet && (0, _legends.getColorByValueFromLegendSet)(legendSet, config.value);
|
|
241
|
+
let valueColor, titleColor;
|
|
242
|
+
|
|
243
|
+
if (legendColor) {
|
|
244
|
+
if (legendOptions.style === _legends.LEGEND_DISPLAY_STYLE_FILL) {
|
|
245
|
+
parentEl.style.background = legendColor;
|
|
246
|
+
valueColor = titleColor = shouldUseContrastColor(legendColor) && _ui.colors.white;
|
|
247
|
+
} else {
|
|
248
|
+
valueColor = legendColor;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
208
252
|
parentEl.style.overflow = 'hidden';
|
|
209
253
|
parentEl.style.display = 'flex';
|
|
210
254
|
parentEl.style.justifyContent = 'center';
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
255
|
+
parentEl.style.borderRadius = _ui.spacers.dp8;
|
|
256
|
+
|
|
257
|
+
if (dashboard) {
|
|
258
|
+
return generateDashboardItem(config, {
|
|
259
|
+
valueColor,
|
|
260
|
+
noData
|
|
261
|
+
});
|
|
262
|
+
} else {
|
|
263
|
+
parentEl.style.margin = _ui.spacers.dp8;
|
|
264
|
+
parentEl.style.height = "calc(100% - (".concat(_ui.spacers.dp8, " * 2))");
|
|
265
|
+
return generateDVItem(config, {
|
|
266
|
+
valueColor,
|
|
267
|
+
titleColor,
|
|
268
|
+
parentEl,
|
|
269
|
+
fontStyle,
|
|
270
|
+
noData
|
|
271
|
+
});
|
|
272
|
+
}
|
|
220
273
|
}
|
|
@@ -80,6 +80,7 @@ function _default(_ref) {
|
|
|
80
80
|
|
|
81
81
|
this.createVisualization = () => _generator(this.getConfig(), el, { ...extraOptions,
|
|
82
82
|
noData: DEFAULT_EXTRA_OPTIONS.noData,
|
|
83
|
-
fontStyle: layout.fontStyle
|
|
83
|
+
fontStyle: layout.fontStyle,
|
|
84
|
+
legendOptions: layout.legend
|
|
84
85
|
});
|
|
85
86
|
}
|
|
@@ -4,7 +4,7 @@ import React, { useState } from 'react';
|
|
|
4
4
|
import OrgUnitDimension from '../components/OrgUnitDimension/OrgUnitDimension.js';
|
|
5
5
|
|
|
6
6
|
const Wrapper = story => /*#__PURE__*/React.createElement(DataProvider, {
|
|
7
|
-
baseUrl: "
|
|
7
|
+
baseUrl: "https://debug.dhis2.org/analytics-dev/",
|
|
8
8
|
apiVersion: ""
|
|
9
9
|
}, story());
|
|
10
10
|
|
|
@@ -90,4 +90,43 @@ storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('Multiple roots'
|
|
|
90
90
|
roots: ['O6uvpzGd5pu', 'fdc6uOvgoji'] // Bo + Bombali
|
|
91
91
|
|
|
92
92
|
});
|
|
93
|
+
});
|
|
94
|
+
storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('Without level selector', () => {
|
|
95
|
+
const [selected, setSelected] = useState([]);
|
|
96
|
+
return /*#__PURE__*/React.createElement(OrgUnitDimension, {
|
|
97
|
+
hideLevelSelect: true,
|
|
98
|
+
selected: selected,
|
|
99
|
+
onSelect: response => setSelected(response.items),
|
|
100
|
+
roots: defaultRootOrgUnits
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('Without group selector', () => {
|
|
104
|
+
const [selected, setSelected] = useState([]);
|
|
105
|
+
return /*#__PURE__*/React.createElement(OrgUnitDimension, {
|
|
106
|
+
hideGroupSelect: true,
|
|
107
|
+
selected: selected,
|
|
108
|
+
onSelect: response => setSelected(response.items),
|
|
109
|
+
roots: defaultRootOrgUnits
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('Without level and group selector', () => {
|
|
113
|
+
const [selected, setSelected] = useState([]);
|
|
114
|
+
return /*#__PURE__*/React.createElement(OrgUnitDimension, {
|
|
115
|
+
hideLevelSelect: true,
|
|
116
|
+
hideGroupSelect: true,
|
|
117
|
+
selected: selected,
|
|
118
|
+
onSelect: response => setSelected(response.items),
|
|
119
|
+
roots: defaultRootOrgUnits
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
storiesOf('OrgUnitDimension', module).addDecorator(Wrapper).add('Without level and group selector, with warning text', () => {
|
|
123
|
+
const [selected, setSelected] = useState([]);
|
|
124
|
+
return /*#__PURE__*/React.createElement(OrgUnitDimension, {
|
|
125
|
+
hideLevelSelect: true,
|
|
126
|
+
hideGroupSelect: true,
|
|
127
|
+
selected: selected,
|
|
128
|
+
onSelect: response => setSelected(response.items),
|
|
129
|
+
roots: defaultRootOrgUnits,
|
|
130
|
+
warning: 'No org. units selected'
|
|
131
|
+
});
|
|
93
132
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
2
|
import { useDataEngine } from '@dhis2/app-runtime';
|
|
3
|
-
import { OrganisationUnitTree, Checkbox, MultiSelect, MultiSelectOption, Button } from '@dhis2/ui';
|
|
3
|
+
import { OrganisationUnitTree, Checkbox, MultiSelect, MultiSelectOption, Button, IconWarningFilled16, colors } from '@dhis2/ui';
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React, { useEffect, useState } from 'react';
|
|
@@ -16,7 +16,10 @@ const OrgUnitDimension = _ref => {
|
|
|
16
16
|
let {
|
|
17
17
|
roots,
|
|
18
18
|
selected,
|
|
19
|
-
onSelect
|
|
19
|
+
onSelect,
|
|
20
|
+
hideGroupSelect,
|
|
21
|
+
hideLevelSelect,
|
|
22
|
+
warning
|
|
20
23
|
} = _ref;
|
|
21
24
|
const [ouLevels, setOuLevels] = useState([]);
|
|
22
25
|
const [ouGroups, setOuGroups] = useState([]);
|
|
@@ -69,9 +72,9 @@ const OrgUnitDimension = _ref => {
|
|
|
69
72
|
setOuGroups(result);
|
|
70
73
|
};
|
|
71
74
|
|
|
72
|
-
doFetchOuLevels();
|
|
73
|
-
doFetchOuGroups();
|
|
74
|
-
}, [dataEngine]);
|
|
75
|
+
!hideLevelSelect && doFetchOuLevels();
|
|
76
|
+
!hideGroupSelect && doFetchOuGroups();
|
|
77
|
+
}, [dataEngine, hideLevelSelect, hideGroupSelect]);
|
|
75
78
|
|
|
76
79
|
const onLevelChange = ids => {
|
|
77
80
|
const items = ids.map(id => ({
|
|
@@ -202,9 +205,10 @@ const OrgUnitDimension = _ref => {
|
|
|
202
205
|
dataTest: 'org-unit-tree'
|
|
203
206
|
})), /*#__PURE__*/React.createElement("div", {
|
|
204
207
|
className: "jsx-".concat(styles.__hash) + " " + (cx('selectsWrapper', {
|
|
205
|
-
disabled: selected.some(item => DYNAMIC_ORG_UNITS.includes(item.id))
|
|
208
|
+
disabled: selected.some(item => DYNAMIC_ORG_UNITS.includes(item.id)),
|
|
209
|
+
hidden: hideLevelSelect && hideGroupSelect
|
|
206
210
|
}) || "")
|
|
207
|
-
}, /*#__PURE__*/React.createElement(MultiSelect, {
|
|
211
|
+
}, !hideLevelSelect && /*#__PURE__*/React.createElement(MultiSelect, {
|
|
208
212
|
selected: ouLevels.length ? selected.filter(item => ouIdHelper.hasLevelPrefix(item.id)).map(item => ouIdHelper.removePrefix(item.id)) : [],
|
|
209
213
|
onChange: _ref5 => {
|
|
210
214
|
let {
|
|
@@ -221,7 +225,7 @@ const OrgUnitDimension = _ref => {
|
|
|
221
225
|
value: level.id,
|
|
222
226
|
label: level.displayName,
|
|
223
227
|
dataTest: "org-unit-level-select-option-".concat(level.id)
|
|
224
|
-
}))), /*#__PURE__*/React.createElement(MultiSelect, {
|
|
228
|
+
}))), !hideGroupSelect && /*#__PURE__*/React.createElement(MultiSelect, {
|
|
225
229
|
selected: ouGroups.length ? selected.filter(item => ouIdHelper.hasGroupPrefix(item.id)).map(item => ouIdHelper.removePrefix(item.id)) : [],
|
|
226
230
|
onChange: _ref6 => {
|
|
227
231
|
let {
|
|
@@ -240,7 +244,13 @@ const OrgUnitDimension = _ref => {
|
|
|
240
244
|
dataTest: "org-unit-group-select-option-".concat(group.id)
|
|
241
245
|
})))), /*#__PURE__*/React.createElement("div", {
|
|
242
246
|
className: "jsx-".concat(styles.__hash) + " " + "summaryWrapper"
|
|
243
|
-
}, /*#__PURE__*/React.createElement("
|
|
247
|
+
}, warning ? /*#__PURE__*/React.createElement("div", {
|
|
248
|
+
className: "jsx-".concat(styles.__hash) + " " + "warningWrapper"
|
|
249
|
+
}, /*#__PURE__*/React.createElement(IconWarningFilled16, {
|
|
250
|
+
color: colors.red500
|
|
251
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
252
|
+
className: "jsx-".concat(styles.__hash) + " " + "warningText"
|
|
253
|
+
}, warning)) : /*#__PURE__*/React.createElement("span", {
|
|
244
254
|
className: "jsx-".concat(styles.__hash) + " " + "summaryText"
|
|
245
255
|
}, getSummary()), /*#__PURE__*/React.createElement("div", {
|
|
246
256
|
className: "jsx-".concat(styles.__hash) + " " + "deselectButton"
|
|
@@ -254,13 +264,20 @@ const OrgUnitDimension = _ref => {
|
|
|
254
264
|
}, styles));
|
|
255
265
|
};
|
|
256
266
|
|
|
267
|
+
OrgUnitDimension.defaultProps = {
|
|
268
|
+
hideGroupSelect: false,
|
|
269
|
+
hideLevelSelect: false
|
|
270
|
+
};
|
|
257
271
|
OrgUnitDimension.propTypes = {
|
|
272
|
+
hideGroupSelect: PropTypes.bool,
|
|
273
|
+
hideLevelSelect: PropTypes.bool,
|
|
258
274
|
roots: PropTypes.arrayOf(PropTypes.string),
|
|
259
275
|
selected: PropTypes.arrayOf(PropTypes.shape({
|
|
260
276
|
id: PropTypes.string.isRequired,
|
|
261
277
|
name: PropTypes.string.isRequired,
|
|
262
278
|
path: PropTypes.string
|
|
263
279
|
})),
|
|
280
|
+
warning: PropTypes.string,
|
|
264
281
|
onSelect: PropTypes.func
|
|
265
282
|
};
|
|
266
283
|
export default OrgUnitDimension;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { colors, spacers } from '@dhis2/ui';
|
|
2
|
-
const _defaultExport = [".container.jsx-
|
|
3
|
-
_defaultExport.__hash = "
|
|
2
|
+
const _defaultExport = [".container.jsx-2348205733{height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".orgUnitTreeWrapper.jsx-2348205733{height:382px;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;overflow:auto;}", ".orgUnitTreeWrapper.jsx-2348205733>*{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}", ".disabled.jsx-2348205733{cursor:not-allowed;opacity:0.5;}", ".disabled.jsx-2348205733>*{pointer-events:none;}", ".userOrgUnitsWrapper.jsx-2348205733{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;background:".concat(colors.grey200, ";padding:").concat(spacers.dp8, " ").concat(spacers.dp8, " ").concat(spacers.dp8, " ").concat(spacers.dp24, ";margin-bottom:").concat(spacers.dp12, ";}"), ".userOrgUnitsWrapper.jsx-2348205733>*{margin-right:".concat(spacers.dp48, ";}"), ".selectsWrapper.jsx-2348205733{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;gap:".concat(spacers.dp8, ";margin-top:").concat(spacers.dp12, ";}"), ".selectsWrapper.hidden.jsx-2348205733{display:none;}", ".selectsWrapper.jsx-2348205733>*{width:50%;}", ".summaryWrapper.jsx-2348205733{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-top:".concat(spacers.dp8, ";}"), ".warningWrapper.jsx-2348205733{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".warningText.jsx-2348205733{margin-left:".concat(spacers.dp8, ";font-size:14px;line-height:18px;color:").concat(colors.red600, ";}"), ".summaryText.jsx-2348205733{font-size:14px;line-height:18px;color:".concat(colors.grey700, ";}"), ".deselectButton.jsx-2348205733{display:inline-block;margin-left:".concat(spacers.dp8, ";}")];
|
|
3
|
+
_defaultExport.__hash = "2348205733";
|
|
4
4
|
export default _defaultExport;
|
|
@@ -2,8 +2,6 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
4
|
|
|
5
|
-
import { useConfig } from '@dhis2/app-runtime';
|
|
6
|
-
import { getNowInCalendar } from '@dhis2/multi-calendar-dates';
|
|
7
5
|
import { TabBar, Tab, Transfer } from '@dhis2/ui';
|
|
8
6
|
import PropTypes from 'prop-types';
|
|
9
7
|
import React, { useState } from 'react';
|
|
@@ -27,17 +25,9 @@ const PeriodTransfer = _ref => {
|
|
|
27
25
|
rightFooter,
|
|
28
26
|
excludedPeriodTypes
|
|
29
27
|
} = _ref;
|
|
30
|
-
const {
|
|
31
|
-
systemInfo = {}
|
|
32
|
-
} = useConfig();
|
|
33
|
-
const {
|
|
34
|
-
calendar = 'gregory'
|
|
35
|
-
} = systemInfo;
|
|
36
28
|
const defaultRelativePeriodType = excludedPeriodTypes.includes(MONTHLY) ? getRelativePeriodsOptionsById(QUARTERLY) : getRelativePeriodsOptionsById(MONTHLY);
|
|
37
|
-
const defaultFixedPeriodType = excludedPeriodTypes.includes(MONTHLY) ? getFixedPeriodsOptionsById(QUARTERLY
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const defaultFixedPeriodYear = getNowInCalendar(calendar).eraYear;
|
|
29
|
+
const defaultFixedPeriodType = excludedPeriodTypes.includes(MONTHLY) ? getFixedPeriodsOptionsById(QUARTERLY) : getFixedPeriodsOptionsById(MONTHLY);
|
|
30
|
+
const defaultFixedPeriodYear = new Date().getFullYear();
|
|
41
31
|
|
|
42
32
|
const fixedPeriodConfig = year => ({
|
|
43
33
|
offset: year - defaultFixedPeriodYear,
|
|
@@ -59,7 +49,7 @@ const PeriodTransfer = _ref => {
|
|
|
59
49
|
const onIsRelativeClick = state => {
|
|
60
50
|
if (state !== isRelative) {
|
|
61
51
|
setIsRelative(state);
|
|
62
|
-
setAllPeriods(state ? getRelativePeriodsOptionsById(relativeFilter.periodType).getPeriods() : getFixedPeriodsOptionsById(fixedFilter.periodType
|
|
52
|
+
setAllPeriods(state ? getRelativePeriodsOptionsById(relativeFilter.periodType).getPeriods() : getFixedPeriodsOptionsById(fixedFilter.periodType).getPeriods(fixedPeriodConfig(Number(fixedFilter.year))));
|
|
63
53
|
}
|
|
64
54
|
};
|
|
65
55
|
|
|
@@ -112,7 +102,7 @@ const PeriodTransfer = _ref => {
|
|
|
112
102
|
|
|
113
103
|
const onSelectFixedPeriods = filter => {
|
|
114
104
|
setFixedFilter(filter);
|
|
115
|
-
setAllPeriods(getFixedPeriodsOptionsById(filter.periodType
|
|
105
|
+
setAllPeriods(getFixedPeriodsOptionsById(filter.periodType).getPeriods(fixedPeriodConfig(Number(filter.year))));
|
|
116
106
|
};
|
|
117
107
|
|
|
118
108
|
const renderEmptySelection = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", {
|