@hisptz/dhis2-analytics 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/components/CustomPivotTable/CustomPivotTable.stories.js +69 -0
- package/build/cjs/components/CustomPivotTable/components/Table/index.js +16 -0
- package/build/cjs/components/CustomPivotTable/components/TableBody/TableBody.module.css +12 -0
- package/build/cjs/components/CustomPivotTable/components/TableBody/index.js +109 -0
- package/build/cjs/components/CustomPivotTable/components/TableHeaders/TableHeaders.module.css +10 -0
- package/build/cjs/components/CustomPivotTable/components/TableHeaders/index.js +89 -0
- package/build/cjs/components/CustomPivotTable/index.js +30 -0
- package/build/cjs/components/{PivotTable → CustomPivotTable}/interfaces/index.js +0 -0
- package/build/cjs/components/CustomPivotTable/services/engine.js +89 -0
- package/build/cjs/components/{PivotTable/components/PivotTableEngineContext.js → CustomPivotTable/state/engine.js} +11 -13
- package/build/cjs/dataProviders/map.js +1 -1
- package/build/cjs/index.js +4 -4
- package/build/cjs/locales/en/translations.json +0 -33
- package/build/es/components/CustomPivotTable/CustomPivotTable.stories.js +59 -0
- package/build/es/components/CustomPivotTable/components/Table/index.js +9 -0
- package/build/es/components/CustomPivotTable/components/TableBody/TableBody.module.css +12 -0
- package/build/es/components/CustomPivotTable/components/TableBody/index.js +100 -0
- package/build/es/components/CustomPivotTable/components/TableHeaders/TableHeaders.module.css +10 -0
- package/build/es/components/CustomPivotTable/components/TableHeaders/index.js +82 -0
- package/build/es/components/CustomPivotTable/index.js +22 -0
- package/build/es/components/{PivotTable → CustomPivotTable}/interfaces/index.js +0 -0
- package/build/es/components/CustomPivotTable/services/engine.js +82 -0
- package/build/es/components/CustomPivotTable/state/engine.js +14 -0
- package/build/es/dataProviders/map.js +1 -1
- package/build/es/index.js +1 -1
- package/build/es/locales/en/translations.json +0 -33
- package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/components/Menu.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/constants/menu.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/index.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/interfaces/menu.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/hooks/useChart.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/index.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/models/column.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/models/index.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/models/line.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/models/multi-series.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/models/pie.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/services/export.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/types/props.d.ts +0 -0
- package/build/types/{components → src/components}/ChartAnalytics/utils/chart.d.ts +0 -0
- package/build/types/{components → src/components}/CircularProgressDashboard/index.d.ts +0 -0
- package/build/types/{components → src/components}/CircularProgressDashboard/types/props.d.ts +0 -0
- package/build/types/src/components/CustomPivotTable/components/Table/index.d.ts +11 -0
- package/build/types/src/components/CustomPivotTable/components/TableBody/index.d.ts +2 -0
- package/build/types/src/components/CustomPivotTable/components/TableHeaders/index.d.ts +2 -0
- package/build/types/{components/PivotTable → src/components/CustomPivotTable}/index.d.ts +19 -5
- package/build/types/src/components/CustomPivotTable/interfaces/index.d.ts +1 -0
- package/build/types/src/components/CustomPivotTable/services/engine.d.ts +58 -0
- package/build/types/src/components/CustomPivotTable/state/engine.d.ts +7 -0
- package/build/types/{components → src/components}/Map/components/EarthEngineLayerConfiguration/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapArea/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapArea/interfaces/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapControls/components/CustomControl/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapControls/components/DownloadControl/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapControls/components/FullscreenControl/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapControls/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/BoundaryLayer/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/services/api.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/LegendArea/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/PointLayer/hooks/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/PointLayer/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/hooks/config.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapLayer/interfaces/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapProvider/components/MapLayerProvider/hooks/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapProvider/components/MapLayerProvider/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapProvider/hooks/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapProvider/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/MapUpdater/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/constants/colors.d.ts +0 -0
- package/build/types/{components → src/components}/Map/constants/legendSet.d.ts +0 -0
- package/build/types/{components → src/components}/Map/hooks/map.d.ts +0 -0
- package/build/types/{components → src/components}/Map/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/interfaces/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/state/index.d.ts +0 -0
- package/build/types/{components → src/components}/Map/utils/colors.d.ts +0 -0
- package/build/types/{components → src/components}/Map/utils/helpers.d.ts +0 -0
- package/build/types/{components → src/components}/Map/utils/map.d.ts +0 -0
- package/build/types/{components → src/components}/SingleValueContainer/components/SingleValueItem/SingleValueItem.d.ts +0 -0
- package/build/types/{components → src/components}/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.d.ts +0 -0
- package/build/types/{components → src/components}/SingleValueContainer/index.d.ts +0 -0
- package/build/types/{components → src/components}/SingleValueContainer/types/props.d.ts +0 -0
- package/build/types/{dataProviders → src/dataProviders}/map.d.ts +0 -0
- package/build/types/{index.d.ts → src/index.d.ts} +1 -1
- package/package.json +4 -4
- package/build/cjs/components/PivotTable/PivotTable.stories.js +0 -277
- package/build/cjs/components/PivotTable/components/AssignedCategoriesIcon/index.js +0 -32
- package/build/cjs/components/PivotTable/components/PivotTable.js +0 -60
- package/build/cjs/components/PivotTable/components/PivotTableBody.js +0 -41
- package/build/cjs/components/PivotTable/components/PivotTableCell.js +0 -40
- package/build/cjs/components/PivotTable/components/PivotTableClippedAxis.js +0 -26
- package/build/cjs/components/PivotTable/components/PivotTableColumnHeaderCell.js +0 -71
- package/build/cjs/components/PivotTable/components/PivotTableColumnHeaders.js +0 -60
- package/build/cjs/components/PivotTable/components/PivotTableContainer.js +0 -33
- package/build/cjs/components/PivotTable/components/PivotTableDimensionLabelCell.js +0 -77
- package/build/cjs/components/PivotTable/components/PivotTableEmptyCell.js +0 -22
- package/build/cjs/components/PivotTable/components/PivotTableEmptyRow.js +0 -33
- package/build/cjs/components/PivotTable/components/PivotTableHead.js +0 -35
- package/build/cjs/components/PivotTable/components/PivotTableHeaderCell.js +0 -37
- package/build/cjs/components/PivotTable/components/PivotTableRow.js +0 -65
- package/build/cjs/components/PivotTable/components/PivotTableRowHeaderCell.js +0 -49
- package/build/cjs/components/PivotTable/components/PivotTableTitleRow.js +0 -52
- package/build/cjs/components/PivotTable/components/PivotTableTitleRows.js +0 -46
- package/build/cjs/components/PivotTable/components/PivotTableValueCell.js +0 -69
- package/build/cjs/components/PivotTable/constants/dataTypes.js +0 -129
- package/build/cjs/components/PivotTable/constants/pivotTable.js +0 -64
- package/build/cjs/components/PivotTable/constants/predefinedDimensions.js +0 -62
- package/build/cjs/components/PivotTable/constants/valueTypes.js +0 -55
- package/build/cjs/components/PivotTable/data/column-data.json +0 -210
- package/build/cjs/components/PivotTable/hooks/useParentSize.js +0 -41
- package/build/cjs/components/PivotTable/hooks/useScrollPosition.js +0 -38
- package/build/cjs/components/PivotTable/hooks/useSortableColumns.js +0 -34
- package/build/cjs/components/PivotTable/hooks/useTableClipping.js +0 -53
- package/build/cjs/components/PivotTable/index.js +0 -47
- package/build/cjs/components/PivotTable/services/adaptiveClippingController.js +0 -197
- package/build/cjs/components/PivotTable/services/engine.js +0 -901
- package/build/cjs/components/PivotTable/utils/getOuLevelAndGroupText.js +0 -71
- package/build/cjs/components/PivotTable/utils/index.js +0 -322
- package/build/cjs/components/PivotTable/utils/isColorBright.js +0 -29
- package/build/cjs/components/PivotTable/utils/layout/dimension.js +0 -61
- package/build/cjs/components/PivotTable/utils/layout/dimensionGetId.js +0 -12
- package/build/cjs/components/PivotTable/utils/layout/dimensionGetItems.js +0 -12
- package/build/cjs/components/PivotTable/utils/layout/dimensionIs.js +0 -9
- package/build/cjs/components/PivotTable/utils/layout/dimensionIsEmpty.js +0 -9
- package/build/cjs/components/PivotTable/utils/layout/dimensionIsValid.js +0 -25
- package/build/cjs/components/PivotTable/utils/legend.js +0 -40
- package/build/cjs/components/PivotTable/utils/ouIdHelper/index.js +0 -27
- package/build/cjs/data/map.json +0 -5984
- package/build/es/components/PivotTable/PivotTable.stories.js +0 -268
- package/build/es/components/PivotTable/components/AssignedCategoriesIcon/index.js +0 -24
- package/build/es/components/PivotTable/components/PivotTable.js +0 -51
- package/build/es/components/PivotTable/components/PivotTableBody.js +0 -33
- package/build/es/components/PivotTable/components/PivotTableCell.js +0 -32
- package/build/es/components/PivotTable/components/PivotTableClippedAxis.js +0 -18
- package/build/es/components/PivotTable/components/PivotTableColumnHeaderCell.js +0 -62
- package/build/es/components/PivotTable/components/PivotTableColumnHeaders.js +0 -52
- package/build/es/components/PivotTable/components/PivotTableContainer.js +0 -25
- package/build/es/components/PivotTable/components/PivotTableDimensionLabelCell.js +0 -68
- package/build/es/components/PivotTable/components/PivotTableEmptyCell.js +0 -14
- package/build/es/components/PivotTable/components/PivotTableEmptyRow.js +0 -25
- package/build/es/components/PivotTable/components/PivotTableEngineContext.js +0 -14
- package/build/es/components/PivotTable/components/PivotTableHead.js +0 -27
- package/build/es/components/PivotTable/components/PivotTableHeaderCell.js +0 -29
- package/build/es/components/PivotTable/components/PivotTableRow.js +0 -57
- package/build/es/components/PivotTable/components/PivotTableRowHeaderCell.js +0 -41
- package/build/es/components/PivotTable/components/PivotTableTitleRow.js +0 -42
- package/build/es/components/PivotTable/components/PivotTableTitleRows.js +0 -37
- package/build/es/components/PivotTable/components/PivotTableValueCell.js +0 -60
- package/build/es/components/PivotTable/constants/dataTypes.js +0 -98
- package/build/es/components/PivotTable/constants/pivotTable.js +0 -29
- package/build/es/components/PivotTable/constants/predefinedDimensions.js +0 -44
- package/build/es/components/PivotTable/constants/valueTypes.js +0 -27
- package/build/es/components/PivotTable/data/column-data.json +0 -210
- package/build/es/components/PivotTable/hooks/useParentSize.js +0 -33
- package/build/es/components/PivotTable/hooks/useScrollPosition.js +0 -30
- package/build/es/components/PivotTable/hooks/useSortableColumns.js +0 -27
- package/build/es/components/PivotTable/hooks/useTableClipping.js +0 -46
- package/build/es/components/PivotTable/index.js +0 -26
- package/build/es/components/PivotTable/services/adaptiveClippingController.js +0 -191
- package/build/es/components/PivotTable/services/engine.js +0 -894
- package/build/es/components/PivotTable/utils/getOuLevelAndGroupText.js +0 -63
- package/build/es/components/PivotTable/utils/index.js +0 -309
- package/build/es/components/PivotTable/utils/isColorBright.js +0 -22
- package/build/es/components/PivotTable/utils/layout/dimension.js +0 -48
- package/build/es/components/PivotTable/utils/layout/dimensionGetId.js +0 -5
- package/build/es/components/PivotTable/utils/layout/dimensionGetItems.js +0 -5
- package/build/es/components/PivotTable/utils/layout/dimensionIs.js +0 -2
- package/build/es/components/PivotTable/utils/layout/dimensionIsEmpty.js +0 -2
- package/build/es/components/PivotTable/utils/layout/dimensionIsValid.js +0 -18
- package/build/es/components/PivotTable/utils/legend.js +0 -27
- package/build/es/components/PivotTable/utils/ouIdHelper/index.js +0 -17
- package/build/es/data/map.json +0 -5984
- package/build/types/components/PivotTable/components/AssignedCategoriesIcon/index.d.ts +0 -3
- package/build/types/components/PivotTable/components/PivotTable.d.ts +0 -12
- package/build/types/components/PivotTable/components/PivotTableBody.d.ts +0 -7
- package/build/types/components/PivotTable/components/PivotTableCell.d.ts +0 -17
- package/build/types/components/PivotTable/components/PivotTableClippedAxis.d.ts +0 -7
- package/build/types/components/PivotTable/components/PivotTableColumnHeaderCell.d.ts +0 -13
- package/build/types/components/PivotTable/components/PivotTableColumnHeaders.d.ts +0 -11
- package/build/types/components/PivotTable/components/PivotTableContainer.d.ts +0 -8
- package/build/types/components/PivotTable/components/PivotTableDimensionLabelCell.d.ts +0 -13
- package/build/types/components/PivotTable/components/PivotTableEmptyCell.d.ts +0 -7
- package/build/types/components/PivotTable/components/PivotTableEmptyRow.d.ts +0 -5
- package/build/types/components/PivotTable/components/PivotTableEngineContext.d.ts +0 -8
- package/build/types/components/PivotTable/components/PivotTableHead.d.ts +0 -21
- package/build/types/components/PivotTable/components/PivotTableHeaderCell.d.ts +0 -22
- package/build/types/components/PivotTable/components/PivotTableRow.d.ts +0 -19
- package/build/types/components/PivotTable/components/PivotTableRowHeaderCell.d.ts +0 -8
- package/build/types/components/PivotTable/components/PivotTableTitleRow.d.ts +0 -21
- package/build/types/components/PivotTable/components/PivotTableTitleRows.d.ts +0 -12
- package/build/types/components/PivotTable/components/PivotTableValueCell.d.ts +0 -8
- package/build/types/components/PivotTable/constants/dataTypes.d.ts +0 -90
- package/build/types/components/PivotTable/constants/pivotTable.d.ts +0 -29
- package/build/types/components/PivotTable/constants/predefinedDimensions.d.ts +0 -80
- package/build/types/components/PivotTable/constants/valueTypes.d.ts +0 -22
- package/build/types/components/PivotTable/hooks/useParentSize.d.ts +0 -8
- package/build/types/components/PivotTable/hooks/useScrollPosition.d.ts +0 -5
- package/build/types/components/PivotTable/hooks/useSortableColumns.d.ts +0 -8
- package/build/types/components/PivotTable/hooks/useTableClipping.d.ts +0 -24
- package/build/types/components/PivotTable/interfaces/index.d.ts +0 -72
- package/build/types/components/PivotTable/services/adaptiveClippingController.d.ts +0 -44
- package/build/types/components/PivotTable/services/engine.d.ts +0 -252
- package/build/types/components/PivotTable/utils/getOuLevelAndGroupText.d.ts +0 -1
- package/build/types/components/PivotTable/utils/index.d.ts +0 -38
- package/build/types/components/PivotTable/utils/isColorBright.d.ts +0 -1
- package/build/types/components/PivotTable/utils/layout/dimension.d.ts +0 -35
- package/build/types/components/PivotTable/utils/layout/dimensionGetId.d.ts +0 -3
- package/build/types/components/PivotTable/utils/layout/dimensionGetItems.d.ts +0 -3
- package/build/types/components/PivotTable/utils/layout/dimensionIs.d.ts +0 -1
- package/build/types/components/PivotTable/utils/layout/dimensionIsEmpty.d.ts +0 -3
- package/build/types/components/PivotTable/utils/layout/dimensionIsValid.d.ts +0 -5
- package/build/types/components/PivotTable/utils/legend.d.ts +0 -11
- package/build/types/components/PivotTable/utils/ouIdHelper/index.d.ts +0 -10
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { dimensionGetItems } from './layout/dimensionGetItems.js';
|
|
2
|
-
import { dimensionIs } from './layout/dimensionIs.js';
|
|
3
|
-
import { ouIdHelper } from './ouIdHelper';
|
|
4
|
-
import { DIMENSION_ID_ORGUNIT } from '../constants/predefinedDimensions';
|
|
5
|
-
import i18n from '@dhis2/d2-i18n';
|
|
6
|
-
export const getOuLevelAndGroupText = (filter, metaData) => {
|
|
7
|
-
if (!dimensionIs(DIMENSION_ID_ORGUNIT)) {
|
|
8
|
-
return '';
|
|
9
|
-
}
|
|
10
|
-
const items = dimensionGetItems(filter);
|
|
11
|
-
const hasOuLevel = items.some(item => ouIdHelper.hasLevelPrefix(item.id));
|
|
12
|
-
const hasOuGroup = items.some(item => ouIdHelper.hasGroupPrefix(item.id));
|
|
13
|
-
const filterFragments = [];
|
|
14
|
-
if (hasOuGroup) {
|
|
15
|
-
filterFragments.push(getLevelAndGroupText(items, metaData, false));
|
|
16
|
-
}
|
|
17
|
-
if (hasOuLevel) {
|
|
18
|
-
filterFragments.push(getLevelAndGroupText(items, metaData, true));
|
|
19
|
-
}
|
|
20
|
-
return filterFragments.join(' - ');
|
|
21
|
-
};
|
|
22
|
-
const getLevelAndGroupText = (items, metaData, isLevel) => {
|
|
23
|
-
const getNameFromMetadata = id => metaData.items[id] ? metaData.items[id].name : id;
|
|
24
|
-
const dynamicOuItems = items.filter(item => isLevel ? ouIdHelper.hasLevelPrefix(item.id) : ouIdHelper.hasGroupPrefix(item.id));
|
|
25
|
-
const lastItem = dynamicOuItems.length > 1 ? dynamicOuItems.pop() : null;
|
|
26
|
-
const dynamicOuNames = dynamicOuItems.map(item => getNameFromMetadata(ouIdHelper.removePrefix(item.id))).join(', ');
|
|
27
|
-
let allDynamicOuNames;
|
|
28
|
-
if (lastItem) {
|
|
29
|
-
const lastOuName = getNameFromMetadata(ouIdHelper.removePrefix(lastItem.id));
|
|
30
|
-
allDynamicOuNames = i18n.t('{{dynamicOuNames}} and {{lastOuName}}', {
|
|
31
|
-
dynamicOuNames,
|
|
32
|
-
lastOuName
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
allDynamicOuNames = dynamicOuNames;
|
|
36
|
-
}
|
|
37
|
-
const staticOuNames = items.filter(item => !ouIdHelper.hasGroupPrefix(item.id) && !ouIdHelper.hasLevelPrefix(item.id)).map(item => getNameFromMetadata(item.id)).join(', ');
|
|
38
|
-
let ouLevelAndGroupText = '';
|
|
39
|
-
if (!staticOuNames) {
|
|
40
|
-
if (isLevel) {
|
|
41
|
-
ouLevelAndGroupText = i18n.t('{{allDynamicOuNames}} levels', {
|
|
42
|
-
allDynamicOuNames
|
|
43
|
-
});
|
|
44
|
-
} else {
|
|
45
|
-
ouLevelAndGroupText = i18n.t('{{allDynamicOuNames}} groups', {
|
|
46
|
-
allDynamicOuNames
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
if (isLevel) {
|
|
51
|
-
ouLevelAndGroupText = i18n.t('{{allDynamicOuNames}} levels in {{staticOuNames}}', {
|
|
52
|
-
allDynamicOuNames,
|
|
53
|
-
staticOuNames
|
|
54
|
-
});
|
|
55
|
-
} else {
|
|
56
|
-
ouLevelAndGroupText = i18n.t('{{allDynamicOuNames}} groups in {{staticOuNames}}', {
|
|
57
|
-
allDynamicOuNames,
|
|
58
|
-
staticOuNames
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return ouLevelAndGroupText;
|
|
63
|
-
};
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
|
|
3
|
-
import { getOuLevelAndGroupText } from './getOuLevelAndGroupText';
|
|
4
|
-
import { dimensionGetItems } from './layout/dimensionGetItems';
|
|
5
|
-
import { dimensionIs } from './layout/dimensionIs';
|
|
6
|
-
import { ouIdHelper } from './ouIdHelper';
|
|
7
|
-
import { DIMENSION_ID_ORGUNIT } from '../constants/predefinedDimensions';
|
|
8
|
-
import { CLIPPED_CELL_MAX_SIZE, NUMBER_TYPE_COLUMN_PERCENTAGE, NUMBER_TYPE_ROW_PERCENTAGE, WRAPPED_TEXT_JUSTIFY_BUFFER, WRAPPED_TEXT_LINE_HEIGHT } from '../constants/pivotTable';
|
|
9
|
-
import { isNumericValueType } from '../constants/valueTypes';
|
|
10
|
-
import { colors } from '@dhis2/ui';
|
|
11
|
-
import { getColorByValueFromLegendSet, LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM, LEGEND_DISPLAY_STRATEGY_FIXED, LEGEND_DISPLAY_STYLE_FILL, LEGEND_DISPLAY_STYLE_TEXT } from './legend';
|
|
12
|
-
import { isColorBright } from './isColorBright.js';
|
|
13
|
-
export const parseValue = valueString => {
|
|
14
|
-
const parsedValue = parseFloat(valueString);
|
|
15
|
-
if (isNaN(parsedValue)) {
|
|
16
|
-
return valueString;
|
|
17
|
-
}
|
|
18
|
-
return parsedValue;
|
|
19
|
-
};
|
|
20
|
-
let canvas;
|
|
21
|
-
const getContext = fontSize => {
|
|
22
|
-
if (!canvas) {
|
|
23
|
-
canvas = document.createElement('canvas');
|
|
24
|
-
}
|
|
25
|
-
const ctx = canvas.getContext('2d');
|
|
26
|
-
ctx.font = `${fontSize}px Roboto, Arial, sans-serif`;
|
|
27
|
-
return ctx;
|
|
28
|
-
};
|
|
29
|
-
const measureText = function (text) {
|
|
30
|
-
let fontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 11;
|
|
31
|
-
const ctx = getContext(fontSize);
|
|
32
|
-
const textMetrics = ctx.measureText(text);
|
|
33
|
-
return textMetrics.width;
|
|
34
|
-
};
|
|
35
|
-
export const measureTextWithWrapping = (text, _ref) => {
|
|
36
|
-
let {
|
|
37
|
-
fontSize = 11,
|
|
38
|
-
maxWidth = CLIPPED_CELL_MAX_SIZE,
|
|
39
|
-
justifyBuffer = WRAPPED_TEXT_JUSTIFY_BUFFER,
|
|
40
|
-
lineHeight = WRAPPED_TEXT_LINE_HEIGHT
|
|
41
|
-
} = _ref;
|
|
42
|
-
if (!text) {
|
|
43
|
-
return {
|
|
44
|
-
width: 0,
|
|
45
|
-
height: 0
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
// Multiple consecutive linebreaks are combined into one
|
|
49
|
-
const paragraphs = String(text).split(/\n/);
|
|
50
|
-
const lines = [];
|
|
51
|
-
let currentLine = '';
|
|
52
|
-
let currentLineWidth = 0;
|
|
53
|
-
let maxLineWidth = 0;
|
|
54
|
-
while (paragraphs.length) {
|
|
55
|
-
var _paragraphs$shift$spl, _paragraphs$shift;
|
|
56
|
-
// Currently, all different whitespace types are ignored and assumed to be just a space
|
|
57
|
-
const words = (_paragraphs$shift$spl = (_paragraphs$shift = paragraphs.shift()) === null || _paragraphs$shift === void 0 ? void 0 : _paragraphs$shift.split(/\s+/)) !== null && _paragraphs$shift$spl !== void 0 ? _paragraphs$shift$spl : [];
|
|
58
|
-
while (words.length) {
|
|
59
|
-
const nextWord = (currentLineWidth === 0 ? '' : ' ') + words.shift();
|
|
60
|
-
const nextWordWidth = measureText(nextWord, fontSize);
|
|
61
|
-
if (maxWidth && currentLineWidth + nextWordWidth > maxWidth) {
|
|
62
|
-
if (currentLineWidth <= maxWidth - justifyBuffer) {
|
|
63
|
-
// Wrapping this word would cause an unnaturally short line
|
|
64
|
-
// For now we allow the cell to expand to fit this word
|
|
65
|
-
// In the future, we might intelligently hyphenate the word
|
|
66
|
-
// TODO: if splitting words how would we localize hyphens?
|
|
67
|
-
// Do nothing, keep the word on this line
|
|
68
|
-
} else {
|
|
69
|
-
maxLineWidth = Math.max(currentLineWidth, maxLineWidth);
|
|
70
|
-
lines.push(currentLine);
|
|
71
|
-
currentLine = '';
|
|
72
|
-
currentLineWidth = 0;
|
|
73
|
-
words.unshift(nextWord.substring(1)); // Get rid of the extra space
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
currentLine += nextWord;
|
|
78
|
-
currentLineWidth += nextWordWidth;
|
|
79
|
-
}
|
|
80
|
-
if (currentLineWidth > 0) {
|
|
81
|
-
maxLineWidth = Math.max(currentLineWidth, maxLineWidth);
|
|
82
|
-
lines.push(currentLine);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
normalizedText: lines.join('\n'),
|
|
87
|
-
width: maxLineWidth,
|
|
88
|
-
height: lines.length * fontSize * lineHeight // TODO: use lineHeight=1 for last line?
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const trimTrailingZeros = stringValue => stringValue.replace(/\.?0+$/, '');
|
|
93
|
-
const decimalSeparator = '.';
|
|
94
|
-
const separateDigitGroups = (stringValue, decimalSeparator) => {
|
|
95
|
-
const isNegative = stringValue[0] === '-';
|
|
96
|
-
const [integer, remainder] = stringValue.replace(/^-/, '').split('.');
|
|
97
|
-
const groups = [];
|
|
98
|
-
for (let i = integer.length; i > 0; i -= 3) {
|
|
99
|
-
groups.unshift(integer.substring(i - 3, i));
|
|
100
|
-
}
|
|
101
|
-
if (isNegative) {
|
|
102
|
-
groups[0] = '-' + groups[0];
|
|
103
|
-
}
|
|
104
|
-
if (remainder) {
|
|
105
|
-
const trimmedRemainder = trimTrailingZeros(remainder);
|
|
106
|
-
if (trimmedRemainder.length) {
|
|
107
|
-
groups[groups.length - 1] += decimalSeparator + remainder;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return groups;
|
|
111
|
-
};
|
|
112
|
-
const getSeparator = visualization => {
|
|
113
|
-
switch (visualization.digitGroupSeparator) {
|
|
114
|
-
case 'SPACE':
|
|
115
|
-
return ' ';
|
|
116
|
-
case 'COMMA':
|
|
117
|
-
return ',';
|
|
118
|
-
case 'NONE':
|
|
119
|
-
default:
|
|
120
|
-
return '';
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const toFixedPrecisionString = (value, skipRounding) => {
|
|
124
|
-
if (typeof value !== 'number') {
|
|
125
|
-
// Values returned from the server should keep their string representation
|
|
126
|
-
return value;
|
|
127
|
-
}
|
|
128
|
-
const precision = skipRounding ? 10 : value > -1 && value < 1 ? 2 : 1;
|
|
129
|
-
return value.toFixed(precision);
|
|
130
|
-
};
|
|
131
|
-
export const renderValue = (value, valueType, visualization) => {
|
|
132
|
-
if (!isNumericValueType(valueType) || value === undefined) {
|
|
133
|
-
return String(value).replace(/[^\S\n]+/, ' ');
|
|
134
|
-
}
|
|
135
|
-
if (visualization.numberType === NUMBER_TYPE_ROW_PERCENTAGE || visualization.numberType === NUMBER_TYPE_COLUMN_PERCENTAGE) {
|
|
136
|
-
const stringValue = trimTrailingZeros(toFixedPrecisionString(value * 100, visualization.skipRounding));
|
|
137
|
-
return separateDigitGroups(stringValue, decimalSeparator).join(getSeparator(visualization)) + '%';
|
|
138
|
-
} else {
|
|
139
|
-
const stringValue = toFixedPrecisionString(value, visualization.skipRounding);
|
|
140
|
-
return separateDigitGroups(stringValue, decimalSeparator).join(getSeparator(visualization));
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
const getLegendSet = (engine, dxDimension) => {
|
|
144
|
-
var _engine$visualization, _engine$visualization2, _engine$visualization3;
|
|
145
|
-
let legendSetId;
|
|
146
|
-
switch ((_engine$visualization = engine.visualization.legend) === null || _engine$visualization === void 0 ? void 0 : _engine$visualization.strategy) {
|
|
147
|
-
case LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM:
|
|
148
|
-
if (dxDimension && dxDimension.legendSet) {
|
|
149
|
-
legendSetId = dxDimension.legendSet;
|
|
150
|
-
}
|
|
151
|
-
break;
|
|
152
|
-
case LEGEND_DISPLAY_STRATEGY_FIXED:
|
|
153
|
-
default:
|
|
154
|
-
legendSetId = (_engine$visualization2 = engine.visualization.legend) === null || _engine$visualization2 === void 0 ? void 0 : (_engine$visualization3 = _engine$visualization2.set) === null || _engine$visualization3 === void 0 ? void 0 : _engine$visualization3.id;
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
return engine.legendSets[legendSetId];
|
|
158
|
-
};
|
|
159
|
-
const buildStyleObject = (legendColor, engine) => {
|
|
160
|
-
var _engine$visualization4;
|
|
161
|
-
const style = {};
|
|
162
|
-
switch ((_engine$visualization4 = engine.visualization.legend) === null || _engine$visualization4 === void 0 ? void 0 : _engine$visualization4.style) {
|
|
163
|
-
case LEGEND_DISPLAY_STYLE_TEXT:
|
|
164
|
-
style.color = legendColor;
|
|
165
|
-
break;
|
|
166
|
-
case LEGEND_DISPLAY_STYLE_FILL:
|
|
167
|
-
default:
|
|
168
|
-
style.backgroundColor = legendColor;
|
|
169
|
-
if (isColorBright(legendColor)) {
|
|
170
|
-
style.color = colors.grey900;
|
|
171
|
-
} else {
|
|
172
|
-
style.color = colors.white;
|
|
173
|
-
}
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
return style;
|
|
177
|
-
};
|
|
178
|
-
export const applyLegendSet = (value, dxDimension, engine) => {
|
|
179
|
-
if (isNaN(value) || !engine.legendSets) {
|
|
180
|
-
return {};
|
|
181
|
-
}
|
|
182
|
-
const legendSet = getLegendSet(engine, dxDimension);
|
|
183
|
-
if (!legendSet) {
|
|
184
|
-
return {};
|
|
185
|
-
}
|
|
186
|
-
const legendColor = getColorByValueFromLegendSet(legendSet, value);
|
|
187
|
-
if (!legendColor) {
|
|
188
|
-
return {};
|
|
189
|
-
}
|
|
190
|
-
return buildStyleObject(legendColor, engine);
|
|
191
|
-
};
|
|
192
|
-
export function getFilterText(filters, metaData) {
|
|
193
|
-
if (!Array.isArray(filters) || !filters.length) {
|
|
194
|
-
return '';
|
|
195
|
-
}
|
|
196
|
-
const titleFragments = [];
|
|
197
|
-
let i;
|
|
198
|
-
let l;
|
|
199
|
-
filters.forEach(filter => {
|
|
200
|
-
const items = dimensionGetItems(filter);
|
|
201
|
-
if (dimensionIs(filter, DIMENSION_ID_ORGUNIT) && items.some(_ref2 => {
|
|
202
|
-
let {
|
|
203
|
-
id
|
|
204
|
-
} = _ref2;
|
|
205
|
-
return ouIdHelper.hasGroupPrefix(id) || ouIdHelper.hasLevelPrefix(id);
|
|
206
|
-
})) {
|
|
207
|
-
titleFragments.push(getOuLevelAndGroupText(filter, metaData));
|
|
208
|
-
} else {
|
|
209
|
-
const filterItems = metaData.dimensions[filter.dimension];
|
|
210
|
-
if (Array.isArray(filterItems)) {
|
|
211
|
-
l = filterItems.length;
|
|
212
|
-
let id;
|
|
213
|
-
const sectionParts = [];
|
|
214
|
-
for (i = 0; i < l; i++) {
|
|
215
|
-
id = filterItems[i];
|
|
216
|
-
|
|
217
|
-
// if the value is present in items take the name to show from there
|
|
218
|
-
if (metaData.items[id]) {
|
|
219
|
-
sectionParts.push(metaData.items[id].name);
|
|
220
|
-
}
|
|
221
|
-
// otherwise use the values directly
|
|
222
|
-
// this is a temporary fix to avoid app crashing when using filters with data items in EV
|
|
223
|
-
else {
|
|
224
|
-
sectionParts.push(metaData.items[filter.dimension].name + ': ' + filterItems.join(', '));
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
titleFragments.push(sectionParts.join(', '));
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
return titleFragments.join(' - ');
|
|
233
|
-
}
|
|
234
|
-
const headerStacksAreEqual = (a, b, limit) => {
|
|
235
|
-
for (let i = 0; i <= limit; ++i) {
|
|
236
|
-
if (a[i] !== b[i]) {
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return true;
|
|
241
|
-
};
|
|
242
|
-
export const getHeaderForDisplay = _ref3 => {
|
|
243
|
-
let {
|
|
244
|
-
start,
|
|
245
|
-
count,
|
|
246
|
-
index,
|
|
247
|
-
dimensionLevel,
|
|
248
|
-
getHeader,
|
|
249
|
-
showHierarchy
|
|
250
|
-
} = _ref3;
|
|
251
|
-
const header = getHeader(index);
|
|
252
|
-
const showHeader = index === start || !headerStacksAreEqual(header, getHeader(index - 1), dimensionLevel);
|
|
253
|
-
if (!showHeader) {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
let span = 1;
|
|
257
|
-
for (let i = index + 1; i < start + count; ++i) {
|
|
258
|
-
if (!headerStacksAreEqual(getHeader(i), header, dimensionLevel)) {
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
++span;
|
|
262
|
-
}
|
|
263
|
-
const currentHeader = header[dimensionLevel];
|
|
264
|
-
const includesHierarchy = showHierarchy && (currentHeader === null || currentHeader === void 0 ? void 0 : currentHeader.hierarchy);
|
|
265
|
-
const label = includesHierarchy ? currentHeader.hierarchy.join(' / ') : currentHeader === null || currentHeader === void 0 ? void 0 : currentHeader.name;
|
|
266
|
-
return {
|
|
267
|
-
span,
|
|
268
|
-
label,
|
|
269
|
-
includesHierarchy
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
export const clipPartitionedAxis = _ref4 => {
|
|
273
|
-
let {
|
|
274
|
-
partitionSize,
|
|
275
|
-
partitions,
|
|
276
|
-
axisMap,
|
|
277
|
-
widthMap,
|
|
278
|
-
viewportWidth,
|
|
279
|
-
viewportPosition,
|
|
280
|
-
totalWidth
|
|
281
|
-
} = _ref4;
|
|
282
|
-
const partition = Math.floor(viewportPosition / partitionSize);
|
|
283
|
-
if (partitions[partition] === undefined) {
|
|
284
|
-
return {
|
|
285
|
-
indices: [0],
|
|
286
|
-
pre: 0,
|
|
287
|
-
post: 0
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
let start = partitions[partition] - partitions[0];
|
|
291
|
-
while (start < axisMap.length && widthMap[axisMap[start]].pre < viewportPosition) {
|
|
292
|
-
++start;
|
|
293
|
-
}
|
|
294
|
-
start = start === 0 ? start : start - 1;
|
|
295
|
-
const pre = widthMap[axisMap[start]].pre;
|
|
296
|
-
const indices = [];
|
|
297
|
-
let end = start;
|
|
298
|
-
while (end < axisMap.length && widthMap[axisMap[end]].pre < viewportPosition + viewportWidth) {
|
|
299
|
-
indices.push(end);
|
|
300
|
-
++end;
|
|
301
|
-
}
|
|
302
|
-
end = end === 0 ? end : end - 1;
|
|
303
|
-
const post = totalWidth - (widthMap[axisMap[end]].pre + widthMap[axisMap[end]].size);
|
|
304
|
-
return {
|
|
305
|
-
indices,
|
|
306
|
-
pre,
|
|
307
|
-
post
|
|
308
|
-
};
|
|
309
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const calculateColorBrightness = function (rgb) {
|
|
2
|
-
if (!rgb) {
|
|
3
|
-
return 0;
|
|
4
|
-
}
|
|
5
|
-
return Math.round((parseInt(rgb[0]) * 299 + parseInt(rgb[1]) * 587 + parseInt(rgb[2]) * 114) / 1000);
|
|
6
|
-
};
|
|
7
|
-
const isHex = color => {
|
|
8
|
-
return typeof color === 'string' && color.charAt(0) === '#';
|
|
9
|
-
};
|
|
10
|
-
const hexToRgb = hex => {
|
|
11
|
-
let result;
|
|
12
|
-
if (typeof hex === "string") {
|
|
13
|
-
result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
14
|
-
}
|
|
15
|
-
return result ? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)] : null;
|
|
16
|
-
};
|
|
17
|
-
export const isColorBright = color => {
|
|
18
|
-
if (isHex(color)) {
|
|
19
|
-
color = hexToRgb(color);
|
|
20
|
-
}
|
|
21
|
-
return calculateColorBrightness(color) > 125;
|
|
22
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import isObject from 'lodash/isObject';
|
|
2
|
-
import isString from 'lodash/isString';
|
|
3
|
-
|
|
4
|
-
// Dimension
|
|
5
|
-
|
|
6
|
-
export const DIMENSION = {
|
|
7
|
-
isValid: dimension => isObject(dimension)
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// Props
|
|
11
|
-
|
|
12
|
-
export const DIMENSION_PROP_ID = {
|
|
13
|
-
name: 'dimension',
|
|
14
|
-
defaultValue: '',
|
|
15
|
-
required: true,
|
|
16
|
-
isValid: prop => isString(prop)
|
|
17
|
-
};
|
|
18
|
-
export const DIMENSION_PROP_ITEMS = {
|
|
19
|
-
name: 'items',
|
|
20
|
-
defaultValue: [],
|
|
21
|
-
required: false,
|
|
22
|
-
isValid: prop => Array.isArray(prop)
|
|
23
|
-
};
|
|
24
|
-
export const DIMENSION_PROP_FILTER = {
|
|
25
|
-
name: 'filter',
|
|
26
|
-
defaultValue: [],
|
|
27
|
-
required: false,
|
|
28
|
-
isValid: prop => isString(prop)
|
|
29
|
-
};
|
|
30
|
-
export const DIMENSION_PROP_LEGEND_SET = {
|
|
31
|
-
name: 'legendSet',
|
|
32
|
-
defaultValue: [],
|
|
33
|
-
required: false,
|
|
34
|
-
isValid: prop => isString(prop)
|
|
35
|
-
};
|
|
36
|
-
export const DIMENSION_PROP_PROGRAM_STAGE = {
|
|
37
|
-
name: 'programStage',
|
|
38
|
-
defaultValue: {},
|
|
39
|
-
required: false,
|
|
40
|
-
isValid: prop => isObject(prop)
|
|
41
|
-
};
|
|
42
|
-
export const DIMENSION_PROP_REPETITION = {
|
|
43
|
-
name: 'repetition',
|
|
44
|
-
defaultValue: [],
|
|
45
|
-
required: false,
|
|
46
|
-
isValid: prop => Array.isArray(prop)
|
|
47
|
-
};
|
|
48
|
-
export const DIMENSION_PROPS = [DIMENSION_PROP_ID, DIMENSION_PROP_ITEMS, DIMENSION_PROP_FILTER, DIMENSION_PROP_LEGEND_SET, DIMENSION_PROP_PROGRAM_STAGE, DIMENSION_PROP_REPETITION];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { DIMENSION_PROP_ID, DIMENSION_PROP_PROGRAM_STAGE } from './dimension';
|
|
2
|
-
export const dimensionGetId = dimension => {
|
|
3
|
-
var _dimension$DIMENSION_;
|
|
4
|
-
return (_dimension$DIMENSION_ = dimension[DIMENSION_PROP_PROGRAM_STAGE.name]) !== null && _dimension$DIMENSION_ !== void 0 && _dimension$DIMENSION_.id ? `${dimension[DIMENSION_PROP_PROGRAM_STAGE.name].id}.${dimension[DIMENSION_PROP_ID.name]}` : dimension[DIMENSION_PROP_ID.name];
|
|
5
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { DIMENSION_PROP_ITEMS } from './dimension';
|
|
2
|
-
import { dimensionIsValid } from './dimensionIsValid';
|
|
3
|
-
export const dimensionGetItems = dimension => dimensionIsValid(dimension, {
|
|
4
|
-
requireItems: true
|
|
5
|
-
}) ? dimension[DIMENSION_PROP_ITEMS.name] : DIMENSION_PROP_ITEMS.defaultValue;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DIMENSION, DIMENSION_PROPS } from './dimension';
|
|
2
|
-
import { dimensionIsEmpty } from './dimensionIsEmpty';
|
|
3
|
-
export const dimensionIsValid = function (dimension) {
|
|
4
|
-
let {
|
|
5
|
-
requireItems
|
|
6
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7
|
-
if (!DIMENSION.isValid(dimension)) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
const requiredProps = DIMENSION_PROPS.filter(prop => prop.required);
|
|
11
|
-
if (!requiredProps.every(prop => prop.isValid(dimension[prop.name]))) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
if (requireItems === true && dimensionIsEmpty(dimension)) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export const LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM = 'BY_DATA_ITEM';
|
|
2
|
-
export const LEGEND_DISPLAY_STRATEGY_FIXED = 'FIXED';
|
|
3
|
-
export const LEGEND_DISPLAY_STYLE_FILL = 'FILL';
|
|
4
|
-
export const LEGEND_DISPLAY_STYLE_TEXT = 'TEXT';
|
|
5
|
-
export const getLegendByValueFromLegendSet = (legendSet, value) => {
|
|
6
|
-
var _legendSet$legends;
|
|
7
|
-
return Number.isInteger(parseInt(value)) ? legendSet === null || legendSet === void 0 ? void 0 : (_legendSet$legends = legendSet.legends) === null || _legendSet$legends === void 0 ? void 0 : _legendSet$legends.find(legend => value >= legend.startValue && value < legend.endValue // TODO: Confirm inclusive/exclusive bounds
|
|
8
|
-
) : null;
|
|
9
|
-
};
|
|
10
|
-
export const getColorByValueFromLegendSet = (legendSet, value) => {
|
|
11
|
-
const legend = getLegendByValueFromLegendSet(legendSet, value);
|
|
12
|
-
return legend && legend.color;
|
|
13
|
-
};
|
|
14
|
-
export const getLegendSetByDisplayStrategy = _ref => {
|
|
15
|
-
let {
|
|
16
|
-
displayStrategy,
|
|
17
|
-
legendSets,
|
|
18
|
-
legendSetId
|
|
19
|
-
} = _ref;
|
|
20
|
-
if (displayStrategy === LEGEND_DISPLAY_STRATEGY_FIXED && legendSets.length) {
|
|
21
|
-
return legendSets[0];
|
|
22
|
-
} else if (displayStrategy === LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM) {
|
|
23
|
-
return legendSets.find(legendSet => legendSet.id === legendSetId);
|
|
24
|
-
} else {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const LEVEL_ID_PREFIX = 'LEVEL';
|
|
2
|
-
const GROUP_ID_PREFIX = 'OU_GROUP';
|
|
3
|
-
export const USER_ORG_UNIT = 'USER_ORGUNIT';
|
|
4
|
-
export const USER_ORG_UNIT_CHILDREN = 'USER_ORGUNIT_CHILDREN';
|
|
5
|
-
export const USER_ORG_UNIT_GRANDCHILDREN = 'USER_ORGUNIT_GRANDCHILDREN';
|
|
6
|
-
const hasGroupPrefix = id => id.substr(0, GROUP_ID_PREFIX.length) === GROUP_ID_PREFIX;
|
|
7
|
-
const hasLevelPrefix = id => id.substr(0, LEVEL_ID_PREFIX.length) === LEVEL_ID_PREFIX;
|
|
8
|
-
const stripLevelPrefix = id => hasLevelPrefix(id) ? id.substr(LEVEL_ID_PREFIX.length + 1) : id;
|
|
9
|
-
const stripGroupPrefix = id => hasGroupPrefix(id) ? id.substr(GROUP_ID_PREFIX.length + 1) : id;
|
|
10
|
-
const removePrefix = id => stripGroupPrefix(stripLevelPrefix(id));
|
|
11
|
-
export const ouIdHelper = Object.freeze({
|
|
12
|
-
addLevelPrefix: id => `${LEVEL_ID_PREFIX}-${removePrefix(id)}`,
|
|
13
|
-
addGroupPrefix: id => `${GROUP_ID_PREFIX}-${removePrefix(id)}`,
|
|
14
|
-
removePrefix,
|
|
15
|
-
hasGroupPrefix,
|
|
16
|
-
hasLevelPrefix
|
|
17
|
-
});
|