@dhis2/analytics 21.0.0-alpha.1 → 21.0.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 +2775 -0
- package/build/cjs/__demo__/Filter.stories.js +2 -2
- package/build/cjs/__demo__/FixedPeriodSelect.stories.js +2 -2
- package/build/cjs/__demo__/OpenFileDialog.stories.js +1 -1
- package/build/cjs/__demo__/OrgUnitDimension.stories.js +17 -8
- package/build/cjs/__demo__/PivotTable.stories.js +2 -2
- package/build/cjs/api/analytics/AnalyticsBase.js +1 -1
- package/build/cjs/api/analytics/AnalyticsRequest.js +1 -1
- package/build/cjs/api/analytics/AnalyticsRequestBase.js +3 -3
- package/build/cjs/api/analytics/AnalyticsRequestPropertiesMixin.js +7 -7
- package/build/cjs/api/analytics/AnalyticsResponse.js +2 -2
- package/build/cjs/api/analytics/__tests__/AnalyticsAggregate.spec.js +1 -11
- package/build/cjs/api/analytics/__tests__/AnalyticsRequest.spec.js +9 -9
- package/build/cjs/api/analytics/__tests__/AnalyticsRequestBase.spec.js +4 -4
- package/build/cjs/api/analytics/utils.js +1 -1
- package/build/cjs/api/dimensions.js +37 -37
- package/build/cjs/api/organisationUnits.js +5 -5
- package/build/cjs/components/AboutAOUnit/AboutAOUnit.js +226 -0
- package/build/cjs/components/AboutAOUnit/styles/AboutAOUnit.style.js +13 -0
- package/build/cjs/components/DataDimension/DataTypesSelector.js +3 -3
- package/build/cjs/components/DataDimension/DetailSelector.js +2 -2
- package/build/cjs/components/DataDimension/GroupSelector.js +9 -9
- package/build/cjs/components/DataDimension/ItemSelector.js +19 -19
- package/build/cjs/components/DataDimension/MetricSelector.js +3 -3
- package/build/cjs/components/DataDimension/styles/DataTypesSelector.style.js +1 -1
- package/build/cjs/components/DataDimension/styles/DetailSelector.style.js +1 -1
- package/build/cjs/components/DataDimension/styles/GroupSelector.style.js +1 -1
- package/build/cjs/components/DataDimension/styles/MetricSelector.style.js +1 -1
- package/build/cjs/components/DimensionMenu.js +10 -10
- package/build/cjs/components/DimensionsPanel/DimensionsPanel.js +2 -2
- package/build/cjs/components/DimensionsPanel/List/DimensionItem.js +5 -5
- package/build/cjs/components/DimensionsPanel/List/DimensionLabel.js +2 -2
- package/build/cjs/components/DimensionsPanel/List/DimensionList.js +10 -10
- package/build/cjs/components/DimensionsPanel/List/styles/DimensionList.style.js +1 -1
- package/build/cjs/components/DimensionsPanel/styles/DimensionsPanel.style.js +1 -1
- package/build/cjs/components/DynamicDimension/DynamicDimension.js +4 -4
- package/build/cjs/components/DynamicDimension/ItemSelector.js +8 -8
- package/build/cjs/components/DynamicDimension/styles/DynamicDimension.style.js +1 -1
- package/build/cjs/components/FileMenu/DeleteDialog.js +4 -4
- package/build/cjs/components/FileMenu/FileMenu.js +7 -7
- package/build/cjs/components/FileMenu/FileMenu.styles.js +1 -1
- package/build/cjs/components/FileMenu/GetLinkDialog.js +3 -3
- package/build/cjs/components/FileMenu/RenameDialog.js +4 -4
- package/build/cjs/components/FileMenu/SaveAsDialog.js +4 -4
- package/build/cjs/components/FileMenu/__tests__/DeleteDialog.spec.js +1 -1
- package/build/cjs/components/FileMenu/__tests__/RenameDialog.spec.js +1 -1
- package/build/cjs/components/FileMenu/__tests__/SaveAsDialog.spec.js +1 -1
- package/build/cjs/components/FileMenu/utils.js +3 -3
- package/build/cjs/components/Filter/Filter.js +1 -1
- package/build/cjs/components/Filter/styles/Filter.style.js +1 -1
- package/build/cjs/components/LegendKey/LegendKey.js +9 -9
- package/build/cjs/components/LegendKey/styles/LegendKey.style.js +1 -1
- package/build/cjs/components/OpenFileDialog/CustomSelectOption.js +2 -2
- package/build/cjs/components/OpenFileDialog/OpenFileDialog.js +21 -21
- package/build/cjs/components/OpenFileDialog/OpenFileDialog.styles.js +1 -1
- package/build/cjs/components/OpenFileDialog/styles/CustomSelectOption.style.js +1 -1
- package/build/cjs/components/Options/VisualizationOptions.js +2 -2
- package/build/cjs/components/Options/styles/VisualizationOptions.style.js +10 -10
- package/build/cjs/components/OrgUnitDimension/OrgUnitDimension.js +90 -20
- package/build/cjs/components/OrgUnitDimension/styles/OrgUnitDimension.style.js +2 -2
- package/build/cjs/components/PeriodDimension/FixedPeriodFilter.js +5 -5
- package/build/cjs/components/PeriodDimension/FixedPeriodSelect.js +6 -6
- package/build/cjs/components/PeriodDimension/PeriodTransfer.js +11 -11
- package/build/cjs/components/PeriodDimension/RelativePeriodFilter.js +2 -2
- package/build/cjs/components/PeriodDimension/styles/FixedPeriodSelect.style.js +1 -1
- package/build/cjs/components/PeriodDimension/styles/PeriodFilter.style.js +1 -1
- package/build/cjs/components/PeriodDimension/utils/fixedPeriods.js +49 -49
- package/build/cjs/components/PivotTable/PivotTable.js +2 -2
- package/build/cjs/components/PivotTable/PivotTableCell.js +3 -3
- package/build/cjs/components/PivotTable/PivotTableColumnHeaderCell.js +2 -2
- package/build/cjs/components/PivotTable/PivotTableContainer.js +2 -2
- package/build/cjs/components/PivotTable/PivotTableEngineContext.js +2 -2
- package/build/cjs/components/PivotTable/PivotTableSortIcon.js +2 -2
- package/build/cjs/components/PivotTable/PivotTableTitleRow.js +4 -4
- package/build/cjs/components/PivotTable/PivotTableValueCell.js +2 -2
- package/build/cjs/components/PivotTable/styles/PivotTable.style.js +3 -3
- package/build/cjs/components/TransferOption.js +7 -7
- package/build/cjs/components/styles/DimensionSelector.style.js +1 -1
- package/build/cjs/components/styles/TransferOption.style.js +1 -1
- package/build/cjs/index.js +28 -2
- package/build/cjs/locales/en/translations.json +26 -0
- package/build/cjs/modules/axis.js +1 -1
- package/build/cjs/modules/layoutUiRules/rules.js +1 -1
- package/build/cjs/modules/list.js +25 -0
- package/build/cjs/modules/ouIdHelper/index.js +2 -2
- package/build/cjs/modules/pivotTable/PivotTableEngine.js +3 -3
- package/build/cjs/modules/pivotTable/measureText.js +1 -1
- package/build/cjs/modules/visTypes.js +1 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/addTrendLines.js +1 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/axis.js +2 -2
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/getAxisTitle.js +1 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/index.js +2 -2
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/legend.js +8 -19
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/legendSet.js +1 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/plotOptions.js +1 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/subtitle/index.js +1 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/title/index.js +1 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/title/scatter.js +1 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/xAxis/index.js +1 -1
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/yAxis/gauge.js +3 -3
- package/build/cjs/visualizations/config/adapters/dhis_highcharts/yAxis/index.js +2 -2
- package/build/cjs/visualizations/config/generators/dhis/singleValue.js +5 -5
- package/build/cjs/visualizations/config/index.js +3 -3
- package/build/cjs/visualizations/store/adapters/dhis_dhis/index.js +1 -1
- package/build/cjs/visualizations/store/adapters/dhis_highcharts/index.js +1 -1
- package/build/cjs/visualizations/store/adapters/dhis_highcharts/twoCategory.js +1 -1
- package/build/cjs/visualizations/store/index.js +2 -2
- package/build/cjs/visualizations/util/__tests__/getFilterText.spec.js +1 -1
- package/build/cjs/visualizations/util/axisId.js +1 -1
- package/build/cjs/visualizations/util/getFilterText.js +4 -12
- package/build/es/__demo__/OpenFileDialog.stories.js +1 -1
- package/build/es/__demo__/OrgUnitDimension.stories.js +15 -6
- package/build/es/api/analytics/AnalyticsBase.js +1 -1
- package/build/es/api/analytics/AnalyticsRequest.js +1 -1
- package/build/es/api/analytics/AnalyticsRequestBase.js +3 -3
- package/build/es/api/analytics/AnalyticsRequestPropertiesMixin.js +7 -7
- package/build/es/api/analytics/AnalyticsResponse.js +2 -2
- package/build/es/api/analytics/__tests__/AnalyticsAggregate.spec.js +1 -11
- package/build/es/api/analytics/__tests__/AnalyticsRequest.spec.js +9 -9
- package/build/es/api/analytics/__tests__/AnalyticsRequestBase.spec.js +4 -4
- package/build/es/api/analytics/utils.js +1 -1
- package/build/es/api/dimensions.js +39 -39
- package/build/es/api/organisationUnits.js +5 -5
- package/build/es/components/AboutAOUnit/AboutAOUnit.js +203 -0
- package/build/es/components/AboutAOUnit/styles/AboutAOUnit.style.js +4 -0
- package/build/es/components/DataDimension/DataTypesSelector.js +3 -3
- package/build/es/components/DataDimension/DetailSelector.js +2 -2
- package/build/es/components/DataDimension/GroupSelector.js +7 -7
- package/build/es/components/DataDimension/ItemSelector.js +17 -17
- package/build/es/components/DataDimension/MetricSelector.js +3 -3
- package/build/es/components/DataDimension/styles/DataTypesSelector.style.js +1 -1
- package/build/es/components/DataDimension/styles/DetailSelector.style.js +1 -1
- package/build/es/components/DataDimension/styles/GroupSelector.style.js +1 -1
- package/build/es/components/DataDimension/styles/MetricSelector.style.js +1 -1
- package/build/es/components/DimensionMenu.js +10 -10
- package/build/es/components/DimensionsPanel/List/DimensionItem.js +3 -3
- package/build/es/components/DimensionsPanel/List/DimensionList.js +8 -8
- package/build/es/components/DimensionsPanel/List/styles/DimensionList.style.js +1 -1
- package/build/es/components/DimensionsPanel/styles/DimensionsPanel.style.js +1 -1
- package/build/es/components/DynamicDimension/DynamicDimension.js +4 -4
- package/build/es/components/DynamicDimension/ItemSelector.js +6 -6
- package/build/es/components/DynamicDimension/styles/DynamicDimension.style.js +1 -1
- package/build/es/components/FileMenu/DeleteDialog.js +1 -1
- package/build/es/components/FileMenu/FileMenu.js +4 -4
- package/build/es/components/FileMenu/FileMenu.styles.js +1 -1
- package/build/es/components/FileMenu/GetLinkDialog.js +2 -2
- package/build/es/components/FileMenu/RenameDialog.js +1 -1
- package/build/es/components/FileMenu/SaveAsDialog.js +1 -1
- package/build/es/components/FileMenu/__tests__/DeleteDialog.spec.js +1 -1
- package/build/es/components/FileMenu/__tests__/RenameDialog.spec.js +1 -1
- package/build/es/components/FileMenu/__tests__/SaveAsDialog.spec.js +1 -1
- package/build/es/components/FileMenu/utils.js +3 -3
- package/build/es/components/Filter/Filter.js +1 -1
- package/build/es/components/Filter/styles/Filter.style.js +1 -1
- package/build/es/components/LegendKey/LegendKey.js +9 -9
- package/build/es/components/LegendKey/styles/LegendKey.style.js +1 -1
- package/build/es/components/OpenFileDialog/CustomSelectOption.js +2 -2
- package/build/es/components/OpenFileDialog/OpenFileDialog.js +19 -19
- package/build/es/components/OpenFileDialog/OpenFileDialog.styles.js +1 -1
- package/build/es/components/OpenFileDialog/styles/CustomSelectOption.style.js +1 -1
- package/build/es/components/Options/styles/VisualizationOptions.style.js +10 -10
- package/build/es/components/OrgUnitDimension/OrgUnitDimension.js +88 -19
- package/build/es/components/OrgUnitDimension/styles/OrgUnitDimension.style.js +2 -2
- package/build/es/components/PeriodDimension/FixedPeriodFilter.js +5 -5
- package/build/es/components/PeriodDimension/FixedPeriodSelect.js +8 -8
- package/build/es/components/PeriodDimension/PeriodTransfer.js +9 -9
- package/build/es/components/PeriodDimension/RelativePeriodFilter.js +2 -2
- package/build/es/components/PeriodDimension/styles/FixedPeriodSelect.style.js +1 -1
- package/build/es/components/PeriodDimension/styles/PeriodFilter.style.js +1 -1
- package/build/es/components/PeriodDimension/utils/fixedPeriods.js +49 -49
- package/build/es/components/PivotTable/PivotTableCell.js +3 -3
- package/build/es/components/PivotTable/PivotTableColumnHeaderCell.js +2 -2
- package/build/es/components/PivotTable/PivotTableContainer.js +2 -2
- package/build/es/components/PivotTable/PivotTableSortIcon.js +2 -2
- package/build/es/components/PivotTable/PivotTableTitleRow.js +2 -2
- package/build/es/components/PivotTable/styles/PivotTable.style.js +3 -3
- package/build/es/components/TransferOption.js +17 -17
- package/build/es/components/styles/DimensionSelector.style.js +1 -1
- package/build/es/components/styles/TransferOption.style.js +1 -1
- package/build/es/index.js +3 -2
- package/build/es/locales/en/translations.json +26 -0
- package/build/es/modules/axis.js +1 -1
- package/build/es/modules/layoutUiRules/rules.js +1 -1
- package/build/es/modules/list.js +13 -0
- package/build/es/modules/ouIdHelper/index.js +2 -2
- package/build/es/modules/pivotTable/PivotTableEngine.js +3 -3
- package/build/es/modules/pivotTable/measureText.js +1 -1
- package/build/es/modules/visTypes.js +1 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/addTrendLines.js +1 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/axis.js +2 -2
- package/build/es/visualizations/config/adapters/dhis_highcharts/getAxisTitle.js +1 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/legend.js +8 -19
- package/build/es/visualizations/config/adapters/dhis_highcharts/legendSet.js +1 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/plotOptions.js +1 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/subtitle/index.js +1 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/title/index.js +1 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/title/scatter.js +1 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/xAxis/index.js +1 -1
- package/build/es/visualizations/config/adapters/dhis_highcharts/yAxis/gauge.js +3 -3
- package/build/es/visualizations/config/adapters/dhis_highcharts/yAxis/index.js +2 -2
- package/build/es/visualizations/config/generators/dhis/singleValue.js +5 -5
- package/build/es/visualizations/config/index.js +3 -3
- package/build/es/visualizations/store/adapters/dhis_dhis/index.js +1 -1
- package/build/es/visualizations/store/adapters/dhis_highcharts/index.js +1 -1
- package/build/es/visualizations/store/adapters/dhis_highcharts/twoCategory.js +1 -1
- package/build/es/visualizations/store/index.js +2 -2
- package/build/es/visualizations/util/__tests__/getFilterText.spec.js +1 -1
- package/build/es/visualizations/util/axisId.js +1 -1
- package/build/es/visualizations/util/getFilterText.js +5 -13
- package/package.json +4 -4
- package/build/cjs/components/OrgUnitDimension/OrgUnitDimensionOld.js +0 -244
- package/build/es/components/OrgUnitDimension/OrgUnitDimensionOld.js +0 -220
|
@@ -14,7 +14,7 @@ const generateValueSVG = ({
|
|
|
14
14
|
const textSize = 300;
|
|
15
15
|
const svgValue = document.createElementNS(svgNS, 'svg');
|
|
16
16
|
svgValue.setAttribute('xmlns', svgNS);
|
|
17
|
-
svgValue.setAttribute('viewBox',
|
|
17
|
+
svgValue.setAttribute('viewBox', "0 -".concat(textSize + 50, " ").concat(textSize * 0.75 * formattedValue.length, " ").concat(textSize + 200));
|
|
18
18
|
|
|
19
19
|
if (y) {
|
|
20
20
|
svgValue.setAttribute('y', y);
|
|
@@ -42,7 +42,7 @@ const generateValueSVG = ({
|
|
|
42
42
|
if (subText) {
|
|
43
43
|
const svgSubText = document.createElementNS(svgNS, 'svg');
|
|
44
44
|
const subTextSize = 40;
|
|
45
|
-
svgSubText.setAttribute('viewBox',
|
|
45
|
+
svgSubText.setAttribute('viewBox', "0 -50 ".concat(textSize * 0.75 * formattedValue.length, " ").concat(textSize + 200));
|
|
46
46
|
|
|
47
47
|
if (y) {
|
|
48
48
|
svgSubText.setAttribute('y', y);
|
|
@@ -136,7 +136,7 @@ const generateDVItem = (config, {
|
|
|
136
136
|
const svgNS = 'http://www.w3.org/2000/svg';
|
|
137
137
|
const svg = document.createElementNS(svgNS, 'svg');
|
|
138
138
|
svg.setAttribute('xmlns', svgNS);
|
|
139
|
-
svg.setAttribute('viewBox',
|
|
139
|
+
svg.setAttribute('viewBox', "0 0 ".concat(width, " ").concat(height));
|
|
140
140
|
svg.setAttribute('width', '100%');
|
|
141
141
|
svg.setAttribute('height', '100%');
|
|
142
142
|
svg.setAttribute('data-test', 'visualization-container');
|
|
@@ -145,7 +145,7 @@ const generateDVItem = (config, {
|
|
|
145
145
|
title.setAttribute('x', getXFromTextAlign(titleFontStyle[FONT_STYLE_OPTION_TEXT_ALIGN]));
|
|
146
146
|
title.setAttribute('y', 28);
|
|
147
147
|
title.setAttribute('text-anchor', getTextAnchorFromTextAlign(titleFontStyle[FONT_STYLE_OPTION_TEXT_ALIGN]));
|
|
148
|
-
title.setAttribute('font-size',
|
|
148
|
+
title.setAttribute('font-size', "".concat(titleFontStyle[FONT_STYLE_OPTION_FONT_SIZE], "px"));
|
|
149
149
|
title.setAttribute('font-weight', titleFontStyle[FONT_STYLE_OPTION_BOLD] ? FONT_STYLE_OPTION_BOLD : 'normal');
|
|
150
150
|
title.setAttribute('font-style', titleFontStyle[FONT_STYLE_OPTION_ITALIC] ? FONT_STYLE_OPTION_ITALIC : 'normal');
|
|
151
151
|
title.setAttribute('fill', titleFontStyle[FONT_STYLE_OPTION_TEXT_COLOR]);
|
|
@@ -162,7 +162,7 @@ const generateDVItem = (config, {
|
|
|
162
162
|
subtitle.setAttribute('y', 28);
|
|
163
163
|
subtitle.setAttribute('dy', 22);
|
|
164
164
|
subtitle.setAttribute('text-anchor', getTextAnchorFromTextAlign(subtitleFontStyle[FONT_STYLE_OPTION_TEXT_ALIGN]));
|
|
165
|
-
subtitle.setAttribute('font-size',
|
|
165
|
+
subtitle.setAttribute('font-size', "".concat(subtitleFontStyle[FONT_STYLE_OPTION_FONT_SIZE], "px"));
|
|
166
166
|
subtitle.setAttribute('font-weight', subtitleFontStyle[FONT_STYLE_OPTION_BOLD] ? FONT_STYLE_OPTION_BOLD : 'normal');
|
|
167
167
|
subtitle.setAttribute('font-style', subtitleFontStyle[FONT_STYLE_OPTION_ITALIC] ? FONT_STYLE_OPTION_ITALIC : 'normal');
|
|
168
168
|
subtitle.setAttribute('fill', subtitleFontStyle[FONT_STYLE_OPTION_TEXT_COLOR]);
|
|
@@ -20,15 +20,15 @@ export default function ({
|
|
|
20
20
|
const _generator = generators[outputFormat];
|
|
21
21
|
|
|
22
22
|
if (_validator === validators.noValidation) {
|
|
23
|
-
onWarning(
|
|
23
|
+
onWarning("No validation implementation for config input format \"".concat(inputFormat, "\""));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (!_adapter) {
|
|
27
|
-
onError(
|
|
27
|
+
onError("No config tranformation implementation for format \"".concat(inputFormat, "\" to format \"").concat(outputFormat, "\""));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
if (!_generator) {
|
|
31
|
-
onError(
|
|
31
|
+
onError("No visualization implementation for format ".concat(outputFormat));
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const DEFAULT_EXTRA_OPTIONS = {
|
|
@@ -30,7 +30,7 @@ function getDefault(acc, seriesIds, categoryIds, idValueMap, metaData) {
|
|
|
30
30
|
seriesIds.forEach(seriesId => {
|
|
31
31
|
const serieData = [];
|
|
32
32
|
categoryIds.forEach(categoryId => {
|
|
33
|
-
const value = idValueMap.get(
|
|
33
|
+
const value = idValueMap.get("".concat(seriesId, "-").concat(categoryId)); // DHIS2-1261: 0 is a valid value
|
|
34
34
|
// undefined value means the key was not found within the rows
|
|
35
35
|
// in that case null is returned as value in the serie
|
|
36
36
|
|
|
@@ -40,7 +40,7 @@ function getDefault(acc, series, categories, idValueMap, metaData) {
|
|
|
40
40
|
series[0].forEach(serieItemId => {
|
|
41
41
|
const serieData = [];
|
|
42
42
|
categories[0].forEach(categoryItemId => {
|
|
43
|
-
const value = idValueMap.get(
|
|
43
|
+
const value = idValueMap.get("".concat(serieItemId, "-").concat(categoryItemId)); // DHIS2-1261: 0 is a valid value
|
|
44
44
|
// undefined value means the key was not found within the rows
|
|
45
45
|
// in that case null is returned as value in the serie
|
|
46
46
|
// this is to keep the correct indexes for the values within the serie array
|
|
@@ -6,7 +6,7 @@ export default function (acc, series, categories, idValueMap, metaData) {
|
|
|
6
6
|
categories[0].forEach(category1ItemId => {
|
|
7
7
|
const groupData = [];
|
|
8
8
|
categories[1].forEach(category2ItemId => {
|
|
9
|
-
const value = idValueMap.get(
|
|
9
|
+
const value = idValueMap.get("".concat(seriesItemId, "-").concat(category1ItemId, "-").concat(category2ItemId));
|
|
10
10
|
groupData.push(value === undefined ? null : parseFloat(value));
|
|
11
11
|
});
|
|
12
12
|
groupedData.push(groupData);
|
|
@@ -14,11 +14,11 @@ export default function ({
|
|
|
14
14
|
const _adapter = adapters[inputFormat + '_' + outputFormat];
|
|
15
15
|
|
|
16
16
|
if (_validator === validators.noValidation) {
|
|
17
|
-
warning(
|
|
17
|
+
warning("Validation not supported for data input format \"".concat(inputFormat, "\""));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
if (!_adapter) {
|
|
21
|
-
error(
|
|
21
|
+
error("Data tranformation from \"".concat(inputFormat, "\" to \"").concat(outputFormat, "\" is not supported"));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
this.data = data;
|
|
@@ -128,7 +128,7 @@ describe('getFilterText', () => {
|
|
|
128
128
|
name: '02 of 2018',
|
|
129
129
|
uid: '_201802_'
|
|
130
130
|
};
|
|
131
|
-
expect(getFilterText(filters, metaData)).toEqual('Clinics, Hospital -
|
|
131
|
+
expect(getFilterText(filters, metaData)).toEqual('Clinics, Hospital - 01 of 2018, 02 of 2018');
|
|
132
132
|
});
|
|
133
133
|
});
|
|
134
134
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const AXIS_ID_PREFIX = 'AXIS_';
|
|
2
|
-
export const getAxisStringFromId = id =>
|
|
2
|
+
export const getAxisStringFromId = id => "".concat(AXIS_ID_PREFIX).concat(id);
|
|
@@ -2,7 +2,7 @@ import { getOuLevelAndGroupText } from '../../modules/getOuLevelAndGroupText';
|
|
|
2
2
|
import { dimensionGetItems } from '../../modules/layout/dimensionGetItems';
|
|
3
3
|
import { dimensionIs } from '../../modules/layout/dimensionIs';
|
|
4
4
|
import { ouIdHelper } from '../../modules/ouIdHelper';
|
|
5
|
-
import { DIMENSION_ID_ORGUNIT
|
|
5
|
+
import { DIMENSION_ID_ORGUNIT } from '../../modules/predefinedDimensions';
|
|
6
6
|
export default function (filters, metaData) {
|
|
7
7
|
if (!Array.isArray(filters) || !filters.length) {
|
|
8
8
|
return '';
|
|
@@ -19,15 +19,7 @@ export default function (filters, metaData) {
|
|
|
19
19
|
}) => ouIdHelper.hasGroupPrefix(id) || ouIdHelper.hasLevelPrefix(id))) {
|
|
20
20
|
titleFragments.push(getOuLevelAndGroupText(filter, metaData));
|
|
21
21
|
} else {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (dimensionIs(filter, DIMENSION_ID_PERIOD)) {
|
|
25
|
-
filterItems = items.map(({
|
|
26
|
-
id
|
|
27
|
-
}) => id);
|
|
28
|
-
} else {
|
|
29
|
-
filterItems = metaData.dimensions[filter.dimension];
|
|
30
|
-
}
|
|
22
|
+
const filterItems = metaData.dimensions[filter.dimension];
|
|
31
23
|
|
|
32
24
|
if (Array.isArray(filterItems)) {
|
|
33
25
|
l = filterItems.length;
|
|
@@ -42,9 +34,9 @@ export default function (filters, metaData) {
|
|
|
42
34
|
} // otherwise use the values directly
|
|
43
35
|
// this is a temporary fix to avoid app crashing when using filters with data items in EV
|
|
44
36
|
else {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
sectionParts.push(metaData.items[filter.dimension].name + ': ' + filterItems.join(', '));
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
48
40
|
}
|
|
49
41
|
|
|
50
42
|
titleFragments.push(sectionParts.join(', '));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2/analytics",
|
|
3
|
-
"version": "21.0.0
|
|
3
|
+
"version": "21.0.0",
|
|
4
4
|
"main": "./build/cjs/index.js",
|
|
5
5
|
"module": "./build/es/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@dhis2/cli-app-scripts": "^6.2.0",
|
|
36
36
|
"@dhis2/cli-style": "^9.0.1",
|
|
37
37
|
"@dhis2/d2-i18n": "^1.1.0",
|
|
38
|
-
"@dhis2/ui": "^
|
|
38
|
+
"@dhis2/ui": "^7.7.3",
|
|
39
39
|
"@sambego/storybook-state": "^2.0.1",
|
|
40
40
|
"@storybook/addons": "^6.1.14",
|
|
41
41
|
"@storybook/preset-create-react-app": "^3.1.7",
|
|
@@ -44,20 +44,20 @@
|
|
|
44
44
|
"enzyme-adapter-react-16": "^1.15.6",
|
|
45
45
|
"fs-extra": "^10.0.0",
|
|
46
46
|
"jest-enzyme": "^7.0.2",
|
|
47
|
+
"prop-types": "^15",
|
|
47
48
|
"styled-jsx": "3.3.2",
|
|
48
49
|
"typeface-roboto": "^0.0.75"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"@dhis2/app-runtime": "^2",
|
|
52
53
|
"@dhis2/d2-i18n": "^1.1",
|
|
53
|
-
"@dhis2/ui": "^
|
|
54
|
+
"@dhis2/ui": "^7.7.3",
|
|
54
55
|
"prop-types": "^15",
|
|
55
56
|
"react": "^16.3",
|
|
56
57
|
"react-dom": "^16.3",
|
|
57
58
|
"styled-jsx": "^3.3.2"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
|
-
"@dhis2/d2-ui-org-unit-dialog": "^7.3.0",
|
|
61
61
|
"@dhis2/d2-ui-translation-dialog": "^7.3.1",
|
|
62
62
|
"classnames": "^2.3.1",
|
|
63
63
|
"d2-utilizr": "^0.2.16",
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.defaultState = void 0;
|
|
7
|
-
|
|
8
|
-
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
|
-
var _d2UiOrgUnitDialog = require("@dhis2/d2-ui-org-unit-dialog");
|
|
11
|
-
|
|
12
|
-
var _ui = require("@dhis2/ui");
|
|
13
|
-
|
|
14
|
-
var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
|
|
15
|
-
|
|
16
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
|
-
var _organisationUnits = require("../../api/organisationUnits");
|
|
21
|
-
|
|
22
|
-
var _ouIdHelper = require("../../modules/ouIdHelper");
|
|
23
|
-
|
|
24
|
-
var _predefinedDimensions = require("../../modules/predefinedDimensions");
|
|
25
|
-
|
|
26
|
-
var _OrgUnitDimension = _interopRequireDefault(require("./styles/OrgUnitDimension.style"));
|
|
27
|
-
|
|
28
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
-
|
|
30
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
-
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
|
-
|
|
36
|
-
const defaultState = {
|
|
37
|
-
root: undefined,
|
|
38
|
-
roots: undefined,
|
|
39
|
-
// use "selected" property for cloning org units while user org unit(s) is (are) selected
|
|
40
|
-
selected: [],
|
|
41
|
-
ouLevels: [],
|
|
42
|
-
ouGroups: [],
|
|
43
|
-
showOrgUnitsTree: true
|
|
44
|
-
};
|
|
45
|
-
exports.defaultState = defaultState;
|
|
46
|
-
|
|
47
|
-
class OrgUnitDimension extends _react.Component {
|
|
48
|
-
constructor(props) {
|
|
49
|
-
super(props);
|
|
50
|
-
|
|
51
|
-
_defineProperty(this, "showOrgUnitsTree", () => {
|
|
52
|
-
this.setState({
|
|
53
|
-
showOrgUnitsTree: true
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
_defineProperty(this, "hideOrgUnitsTree", () => {
|
|
58
|
-
this.setState({
|
|
59
|
-
showOrgUnitsTree: false
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
_defineProperty(this, "getUserOrgUnitsFromIds", ids => {
|
|
64
|
-
return _d2UiOrgUnitDialog.userOrgUnits.filter(ou => ids.includes(ou.id));
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
_defineProperty(this, "onLevelChange", event => {
|
|
68
|
-
const levelIds = event.target.value.filter(id => !!id);
|
|
69
|
-
this.props.onSelect({
|
|
70
|
-
dimensionId: _predefinedDimensions.DIMENSION_ID_ORGUNIT,
|
|
71
|
-
items: [...this.props.ouItems.filter(ou => !_ouIdHelper.ouIdHelper.hasLevelPrefix(ou.id)), ...levelIds.map(id => {
|
|
72
|
-
const levelOu = this.state.ouLevels.find(ou => ou.id === id);
|
|
73
|
-
return { ...levelOu,
|
|
74
|
-
id: _ouIdHelper.ouIdHelper.addLevelPrefix(levelOu.id)
|
|
75
|
-
};
|
|
76
|
-
})]
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
_defineProperty(this, "onGroupChange", event => {
|
|
81
|
-
const groupIds = event.target.value.filter(id => !!id);
|
|
82
|
-
this.props.onSelect({
|
|
83
|
-
dimensionId: _predefinedDimensions.DIMENSION_ID_ORGUNIT,
|
|
84
|
-
items: [...this.props.ouItems.filter(ou => !_ouIdHelper.ouIdHelper.hasGroupPrefix(ou.id)), ...groupIds.map(id => {
|
|
85
|
-
const groupOu = this.state.ouGroups.find(ou => ou.id === id);
|
|
86
|
-
return { ...groupOu,
|
|
87
|
-
id: _ouIdHelper.ouIdHelper.addGroupPrefix(id)
|
|
88
|
-
};
|
|
89
|
-
})]
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
_defineProperty(this, "onDeselectAllClick", () => this.props.onDeselect({
|
|
94
|
-
dimensionId: _predefinedDimensions.DIMENSION_ID_ORGUNIT,
|
|
95
|
-
itemIdsToRemove: this.props.ouItems.map(ou => ou.id)
|
|
96
|
-
}));
|
|
97
|
-
|
|
98
|
-
_defineProperty(this, "loadOrgUnitTree", (d2, displayNameProperty) => {
|
|
99
|
-
(0, _organisationUnits.apiFetchOrganisationUnits)(d2, displayNameProperty).then(rootLevel => rootLevel.toArray()).then(roots => {
|
|
100
|
-
this.setState({
|
|
101
|
-
roots,
|
|
102
|
-
root: roots[0]
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
_defineProperty(this, "loadOrgUnitGroups", (d2, displayNameProperty) => {
|
|
108
|
-
(0, _organisationUnits.apiFetchOrganisationUnitGroups)(d2, displayNameProperty).then(organisationUnitGroups => this.setState({
|
|
109
|
-
ouGroups: organisationUnitGroups
|
|
110
|
-
}));
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
_defineProperty(this, "loadOrgUnitLevels", d2 => {
|
|
114
|
-
(0, _organisationUnits.apiFetchOrganisationUnitLevels)(d2).then(organisationUnitLevels => this.setState({
|
|
115
|
-
ouLevels: (0, _sortBy.default)(organisationUnitLevels, ['level'])
|
|
116
|
-
}));
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
_defineProperty(this, "handleOrgUnitClick", (event, orgUnit) => {
|
|
120
|
-
const selected = this.props.ouItems;
|
|
121
|
-
|
|
122
|
-
if (selected.some(ou => ou.path === orgUnit.path)) {
|
|
123
|
-
this.props.onDeselect({
|
|
124
|
-
dimensionId: _predefinedDimensions.DIMENSION_ID_ORGUNIT,
|
|
125
|
-
itemIdsToRemove: [orgUnit.id]
|
|
126
|
-
});
|
|
127
|
-
} else {
|
|
128
|
-
this.props.onSelect({
|
|
129
|
-
dimensionId: _predefinedDimensions.DIMENSION_ID_ORGUNIT,
|
|
130
|
-
items: [...selected, { ...orgUnit,
|
|
131
|
-
name: orgUnit.name || orgUnit.displayName
|
|
132
|
-
}]
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
_defineProperty(this, "handleUserOrgUnitClick", (event, checked) => {
|
|
138
|
-
if (checked) {
|
|
139
|
-
if (!this.state.selected.length) {
|
|
140
|
-
this.setState({
|
|
141
|
-
selected: this.props.ouItems.slice()
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
this.props.onSelect({
|
|
146
|
-
dimensionId: _predefinedDimensions.DIMENSION_ID_ORGUNIT,
|
|
147
|
-
items: [...this.props.ouItems.filter(ou => this.userOrgUnitIds.includes(ou.id)), _d2UiOrgUnitDialog.userOrgUnits.find(ou => ou.id === event.target.name)]
|
|
148
|
-
});
|
|
149
|
-
} else {
|
|
150
|
-
if (this.props.ouItems.length === 1 && this.state.selected.length > 0) {
|
|
151
|
-
this.props.onSelect({
|
|
152
|
-
dimensionId: _predefinedDimensions.DIMENSION_ID_ORGUNIT,
|
|
153
|
-
items: this.state.selected
|
|
154
|
-
});
|
|
155
|
-
} else {
|
|
156
|
-
this.props.onDeselect({
|
|
157
|
-
dimensionId: _predefinedDimensions.DIMENSION_ID_ORGUNIT,
|
|
158
|
-
itemIdsToRemove: [event.target.name]
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
_defineProperty(this, "handleMultipleOrgUnitsSelect", orgUnits => {
|
|
165
|
-
const selected = this.props.ouItems;
|
|
166
|
-
this.props.onSelect({
|
|
167
|
-
dimensionId: _predefinedDimensions.DIMENSION_ID_ORGUNIT,
|
|
168
|
-
items: [...selected, ...orgUnits.reduce((obj, ou) => {
|
|
169
|
-
// avoid duplicates when clicking "Select children" multiple times
|
|
170
|
-
if (!selected.find(i => i.id === ou.id)) {
|
|
171
|
-
obj.push({ ...ou,
|
|
172
|
-
name: ou.name || ou.displayName
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return obj;
|
|
177
|
-
}, [])]
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
_defineProperty(this, "render", () => {
|
|
182
|
-
const ids = this.props.ouItems.map(ou => ou.id);
|
|
183
|
-
const selected = this.props.ouItems.filter(ou => !this.userOrgUnitIds.includes(ou.id) && !_ouIdHelper.ouIdHelper.hasLevelPrefix(ou.id) && !_ouIdHelper.ouIdHelper.hasGroupPrefix(ou.id));
|
|
184
|
-
const userOrgUnits = this.getUserOrgUnitsFromIds(ids);
|
|
185
|
-
const level = ids.filter(_ouIdHelper.ouIdHelper.hasLevelPrefix).map(_ouIdHelper.ouIdHelper.removePrefix);
|
|
186
|
-
const group = ids.filter(_ouIdHelper.ouIdHelper.hasGroupPrefix).map(_ouIdHelper.ouIdHelper.removePrefix);
|
|
187
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, this.state.root && this.state.showOrgUnitsTree && /*#__PURE__*/_react.default.createElement(_d2UiOrgUnitDialog.OrgUnitSelector, {
|
|
188
|
-
d2: this.props.d2,
|
|
189
|
-
root: this.state.root,
|
|
190
|
-
roots: this.state.roots,
|
|
191
|
-
selected: selected,
|
|
192
|
-
userOrgUnits: userOrgUnits,
|
|
193
|
-
level: level,
|
|
194
|
-
group: group,
|
|
195
|
-
levelOptions: this.state.ouLevels,
|
|
196
|
-
groupOptions: this.state.ouGroups,
|
|
197
|
-
onLevelChange: this.onLevelChange,
|
|
198
|
-
onGroupChange: this.onGroupChange,
|
|
199
|
-
onDeselectAllClick: this.onDeselectAllClick,
|
|
200
|
-
handleUserOrgUnitClick: this.handleUserOrgUnitClick,
|
|
201
|
-
handleOrgUnitClick: this.handleOrgUnitClick,
|
|
202
|
-
handleMultipleOrgUnitsSelect: this.handleMultipleOrgUnitsSelect,
|
|
203
|
-
checkboxColor: "secondary",
|
|
204
|
-
deselectAllTooltipFontColor: _ui.colors.grey900,
|
|
205
|
-
deselectAllTooltipBackgroundColor: _ui.colors.grey300,
|
|
206
|
-
displayNameProperty: this.props.displayNameProperty,
|
|
207
|
-
isUserDataViewFallback: true
|
|
208
|
-
}), !this.state.root && /*#__PURE__*/_react.default.createElement("div", {
|
|
209
|
-
className: `jsx-${_OrgUnitDimension.default.__hash}` + " " + "loader"
|
|
210
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.CircularLoader, null)), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
211
|
-
id: _OrgUnitDimension.default.__hash
|
|
212
|
-
}, _OrgUnitDimension.default));
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
this.state = defaultState;
|
|
216
|
-
this.userOrgUnitIds = _d2UiOrgUnitDialog.userOrgUnits.map(ou => ou.id);
|
|
217
|
-
this.loadOrgUnitTree(props.d2, props.displayNameProperty);
|
|
218
|
-
this.loadOrgUnitGroups(props.d2, props.displayNameProperty);
|
|
219
|
-
this.loadOrgUnitLevels(props.d2);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
componentDidUpdate(prevProps) {
|
|
223
|
-
const previousId = prevProps.current ? prevProps.current.id : null;
|
|
224
|
-
const currentId = this.props.current ? this.props.current.id : null; // remount org units selector component to ensure
|
|
225
|
-
// only selected org units are expanded
|
|
226
|
-
|
|
227
|
-
if (previousId !== currentId) {
|
|
228
|
-
this.hideOrgUnitsTree();
|
|
229
|
-
setTimeout(this.showOrgUnitsTree, 0);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
OrgUnitDimension.propTypes = {
|
|
236
|
-
current: _propTypes.default.object,
|
|
237
|
-
d2: _propTypes.default.object,
|
|
238
|
-
displayNameProperty: _propTypes.default.string,
|
|
239
|
-
ouItems: _propTypes.default.array,
|
|
240
|
-
onDeselect: _propTypes.default.func,
|
|
241
|
-
onSelect: _propTypes.default.func
|
|
242
|
-
};
|
|
243
|
-
var _default = OrgUnitDimension;
|
|
244
|
-
exports.default = _default;
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
|
|
3
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
|
|
5
|
-
import { OrgUnitSelector, userOrgUnits } from '@dhis2/d2-ui-org-unit-dialog';
|
|
6
|
-
import { CircularLoader, colors } from '@dhis2/ui';
|
|
7
|
-
import sortBy from 'lodash/sortBy';
|
|
8
|
-
import PropTypes from 'prop-types';
|
|
9
|
-
import React, { Component, Fragment } from 'react';
|
|
10
|
-
import { apiFetchOrganisationUnitGroups, apiFetchOrganisationUnitLevels, apiFetchOrganisationUnits } from '../../api/organisationUnits';
|
|
11
|
-
import { ouIdHelper } from '../../modules/ouIdHelper';
|
|
12
|
-
import { DIMENSION_ID_ORGUNIT } from '../../modules/predefinedDimensions';
|
|
13
|
-
import styles from './styles/OrgUnitDimension.style';
|
|
14
|
-
export const defaultState = {
|
|
15
|
-
root: undefined,
|
|
16
|
-
roots: undefined,
|
|
17
|
-
// use "selected" property for cloning org units while user org unit(s) is (are) selected
|
|
18
|
-
selected: [],
|
|
19
|
-
ouLevels: [],
|
|
20
|
-
ouGroups: [],
|
|
21
|
-
showOrgUnitsTree: true
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
class OrgUnitDimension extends Component {
|
|
25
|
-
constructor(props) {
|
|
26
|
-
super(props);
|
|
27
|
-
|
|
28
|
-
_defineProperty(this, "showOrgUnitsTree", () => {
|
|
29
|
-
this.setState({
|
|
30
|
-
showOrgUnitsTree: true
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
_defineProperty(this, "hideOrgUnitsTree", () => {
|
|
35
|
-
this.setState({
|
|
36
|
-
showOrgUnitsTree: false
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
_defineProperty(this, "getUserOrgUnitsFromIds", ids => {
|
|
41
|
-
return userOrgUnits.filter(ou => ids.includes(ou.id));
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
_defineProperty(this, "onLevelChange", event => {
|
|
45
|
-
const levelIds = event.target.value.filter(id => !!id);
|
|
46
|
-
this.props.onSelect({
|
|
47
|
-
dimensionId: DIMENSION_ID_ORGUNIT,
|
|
48
|
-
items: [...this.props.ouItems.filter(ou => !ouIdHelper.hasLevelPrefix(ou.id)), ...levelIds.map(id => {
|
|
49
|
-
const levelOu = this.state.ouLevels.find(ou => ou.id === id);
|
|
50
|
-
return { ...levelOu,
|
|
51
|
-
id: ouIdHelper.addLevelPrefix(levelOu.id)
|
|
52
|
-
};
|
|
53
|
-
})]
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
_defineProperty(this, "onGroupChange", event => {
|
|
58
|
-
const groupIds = event.target.value.filter(id => !!id);
|
|
59
|
-
this.props.onSelect({
|
|
60
|
-
dimensionId: DIMENSION_ID_ORGUNIT,
|
|
61
|
-
items: [...this.props.ouItems.filter(ou => !ouIdHelper.hasGroupPrefix(ou.id)), ...groupIds.map(id => {
|
|
62
|
-
const groupOu = this.state.ouGroups.find(ou => ou.id === id);
|
|
63
|
-
return { ...groupOu,
|
|
64
|
-
id: ouIdHelper.addGroupPrefix(id)
|
|
65
|
-
};
|
|
66
|
-
})]
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
_defineProperty(this, "onDeselectAllClick", () => this.props.onDeselect({
|
|
71
|
-
dimensionId: DIMENSION_ID_ORGUNIT,
|
|
72
|
-
itemIdsToRemove: this.props.ouItems.map(ou => ou.id)
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
|
-
_defineProperty(this, "loadOrgUnitTree", (d2, displayNameProperty) => {
|
|
76
|
-
apiFetchOrganisationUnits(d2, displayNameProperty).then(rootLevel => rootLevel.toArray()).then(roots => {
|
|
77
|
-
this.setState({
|
|
78
|
-
roots,
|
|
79
|
-
root: roots[0]
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
_defineProperty(this, "loadOrgUnitGroups", (d2, displayNameProperty) => {
|
|
85
|
-
apiFetchOrganisationUnitGroups(d2, displayNameProperty).then(organisationUnitGroups => this.setState({
|
|
86
|
-
ouGroups: organisationUnitGroups
|
|
87
|
-
}));
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
_defineProperty(this, "loadOrgUnitLevels", d2 => {
|
|
91
|
-
apiFetchOrganisationUnitLevels(d2).then(organisationUnitLevels => this.setState({
|
|
92
|
-
ouLevels: sortBy(organisationUnitLevels, ['level'])
|
|
93
|
-
}));
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
_defineProperty(this, "handleOrgUnitClick", (event, orgUnit) => {
|
|
97
|
-
const selected = this.props.ouItems;
|
|
98
|
-
|
|
99
|
-
if (selected.some(ou => ou.path === orgUnit.path)) {
|
|
100
|
-
this.props.onDeselect({
|
|
101
|
-
dimensionId: DIMENSION_ID_ORGUNIT,
|
|
102
|
-
itemIdsToRemove: [orgUnit.id]
|
|
103
|
-
});
|
|
104
|
-
} else {
|
|
105
|
-
this.props.onSelect({
|
|
106
|
-
dimensionId: DIMENSION_ID_ORGUNIT,
|
|
107
|
-
items: [...selected, { ...orgUnit,
|
|
108
|
-
name: orgUnit.name || orgUnit.displayName
|
|
109
|
-
}]
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
_defineProperty(this, "handleUserOrgUnitClick", (event, checked) => {
|
|
115
|
-
if (checked) {
|
|
116
|
-
if (!this.state.selected.length) {
|
|
117
|
-
this.setState({
|
|
118
|
-
selected: this.props.ouItems.slice()
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
this.props.onSelect({
|
|
123
|
-
dimensionId: DIMENSION_ID_ORGUNIT,
|
|
124
|
-
items: [...this.props.ouItems.filter(ou => this.userOrgUnitIds.includes(ou.id)), userOrgUnits.find(ou => ou.id === event.target.name)]
|
|
125
|
-
});
|
|
126
|
-
} else {
|
|
127
|
-
if (this.props.ouItems.length === 1 && this.state.selected.length > 0) {
|
|
128
|
-
this.props.onSelect({
|
|
129
|
-
dimensionId: DIMENSION_ID_ORGUNIT,
|
|
130
|
-
items: this.state.selected
|
|
131
|
-
});
|
|
132
|
-
} else {
|
|
133
|
-
this.props.onDeselect({
|
|
134
|
-
dimensionId: DIMENSION_ID_ORGUNIT,
|
|
135
|
-
itemIdsToRemove: [event.target.name]
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
_defineProperty(this, "handleMultipleOrgUnitsSelect", orgUnits => {
|
|
142
|
-
const selected = this.props.ouItems;
|
|
143
|
-
this.props.onSelect({
|
|
144
|
-
dimensionId: DIMENSION_ID_ORGUNIT,
|
|
145
|
-
items: [...selected, ...orgUnits.reduce((obj, ou) => {
|
|
146
|
-
// avoid duplicates when clicking "Select children" multiple times
|
|
147
|
-
if (!selected.find(i => i.id === ou.id)) {
|
|
148
|
-
obj.push({ ...ou,
|
|
149
|
-
name: ou.name || ou.displayName
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return obj;
|
|
154
|
-
}, [])]
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
_defineProperty(this, "render", () => {
|
|
159
|
-
const ids = this.props.ouItems.map(ou => ou.id);
|
|
160
|
-
const selected = this.props.ouItems.filter(ou => !this.userOrgUnitIds.includes(ou.id) && !ouIdHelper.hasLevelPrefix(ou.id) && !ouIdHelper.hasGroupPrefix(ou.id));
|
|
161
|
-
const userOrgUnits = this.getUserOrgUnitsFromIds(ids);
|
|
162
|
-
const level = ids.filter(ouIdHelper.hasLevelPrefix).map(ouIdHelper.removePrefix);
|
|
163
|
-
const group = ids.filter(ouIdHelper.hasGroupPrefix).map(ouIdHelper.removePrefix);
|
|
164
|
-
return /*#__PURE__*/React.createElement(Fragment, null, this.state.root && this.state.showOrgUnitsTree && /*#__PURE__*/React.createElement(OrgUnitSelector, {
|
|
165
|
-
d2: this.props.d2,
|
|
166
|
-
root: this.state.root,
|
|
167
|
-
roots: this.state.roots,
|
|
168
|
-
selected: selected,
|
|
169
|
-
userOrgUnits: userOrgUnits,
|
|
170
|
-
level: level,
|
|
171
|
-
group: group,
|
|
172
|
-
levelOptions: this.state.ouLevels,
|
|
173
|
-
groupOptions: this.state.ouGroups,
|
|
174
|
-
onLevelChange: this.onLevelChange,
|
|
175
|
-
onGroupChange: this.onGroupChange,
|
|
176
|
-
onDeselectAllClick: this.onDeselectAllClick,
|
|
177
|
-
handleUserOrgUnitClick: this.handleUserOrgUnitClick,
|
|
178
|
-
handleOrgUnitClick: this.handleOrgUnitClick,
|
|
179
|
-
handleMultipleOrgUnitsSelect: this.handleMultipleOrgUnitsSelect,
|
|
180
|
-
checkboxColor: "secondary",
|
|
181
|
-
deselectAllTooltipFontColor: colors.grey900,
|
|
182
|
-
deselectAllTooltipBackgroundColor: colors.grey300,
|
|
183
|
-
displayNameProperty: this.props.displayNameProperty,
|
|
184
|
-
isUserDataViewFallback: true
|
|
185
|
-
}), !this.state.root && /*#__PURE__*/React.createElement("div", {
|
|
186
|
-
className: `jsx-${styles.__hash}` + " " + "loader"
|
|
187
|
-
}, /*#__PURE__*/React.createElement(CircularLoader, null)), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
188
|
-
id: styles.__hash
|
|
189
|
-
}, styles));
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
this.state = defaultState;
|
|
193
|
-
this.userOrgUnitIds = userOrgUnits.map(ou => ou.id);
|
|
194
|
-
this.loadOrgUnitTree(props.d2, props.displayNameProperty);
|
|
195
|
-
this.loadOrgUnitGroups(props.d2, props.displayNameProperty);
|
|
196
|
-
this.loadOrgUnitLevels(props.d2);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
componentDidUpdate(prevProps) {
|
|
200
|
-
const previousId = prevProps.current ? prevProps.current.id : null;
|
|
201
|
-
const currentId = this.props.current ? this.props.current.id : null; // remount org units selector component to ensure
|
|
202
|
-
// only selected org units are expanded
|
|
203
|
-
|
|
204
|
-
if (previousId !== currentId) {
|
|
205
|
-
this.hideOrgUnitsTree();
|
|
206
|
-
setTimeout(this.showOrgUnitsTree, 0);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
OrgUnitDimension.propTypes = {
|
|
213
|
-
current: PropTypes.object,
|
|
214
|
-
d2: PropTypes.object,
|
|
215
|
-
displayNameProperty: PropTypes.string,
|
|
216
|
-
ouItems: PropTypes.array,
|
|
217
|
-
onDeselect: PropTypes.func,
|
|
218
|
-
onSelect: PropTypes.func
|
|
219
|
-
};
|
|
220
|
-
export default OrgUnitDimension;
|