@sis-cc/dotstatsuite-components 13.0.4 → 13.3.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/lib/rules/src/factories/timeline-series.js +0 -26
- package/lib/rules/src/preparators/enhanceObservations.js +4 -8
- package/lib/rules/src/sdmx-data/index.js +3 -4
- package/lib/rules/src/table/preparators/getOneValueDimensions.js +2 -14
- package/lib/rules/src/table/preparators/parseAttributes.js +3 -10
- package/lib/rules/src/table/preparators/prepareData.js +4 -25
- package/lib/rules/src/table/units/getUnitsArtefacts.js +6 -11
- package/lib/rules/src/v8-transformer.js +46 -37
- package/lib/rules2/src/getNotDisplayedIds.js +42 -0
- package/lib/rules2/src/getSidebarData.js +41 -18
- package/lib/rules2/src/index.js +9 -0
- package/lib/rules2/src/parseMetadataSeries.js +5 -4
- package/lib/viewer/src/index.js +5 -3
- package/package.json +2 -2
- package/src/rules/src/factories/choro-series.js +1 -1
- package/src/rules/src/factories/timeline-series.js +1 -40
- package/src/rules/src/preparators/enhanceObservations.js +4 -7
- package/src/rules/src/properties/getHeaderProps.js +1 -2
- package/src/rules/src/properties/scatter.js +0 -1
- package/src/rules/src/sdmx-data/index.js +4 -4
- package/src/rules/src/table/preparators/getOneValueDimensions.js +4 -22
- package/src/rules/src/table/preparators/parseAttributes.js +3 -3
- package/src/rules/src/table/preparators/prepareData.js +3 -21
- package/src/rules/src/table/units/getUnitsArtefacts.js +6 -6
- package/src/rules/src/v8-transformer.js +57 -47
- package/src/rules2/src/getNotDisplayedIds.js +40 -0
- package/src/rules2/src/getSidebarData.js +41 -23
- package/src/rules2/src/index.js +1 -0
- package/src/rules2/src/parseMetadataSeries.js +6 -5
- package/src/viewer/src/index.js +7 -7
- package/test/enhanceObservations.test.js +2 -2
- package/test/getNotDisplayedIds.test.js +31 -0
- package/test/getOneValueDimensions.test.js +12 -17
- package/test/getSidebarData.test.js +104 -0
- package/test/getUnitsArtefacts.test.js +10 -14
- package/test/mocks/large_metadata_series.json +20 -20
- package/test/mocks/table-prep-multi-hierarchies--attributes.json +2 -0
- package/test/parseAttributes.test.js +4 -9
- package/test/table-prep-perf.test.js +0 -7
- package/lib/rules/src/preparators/getDimensions.js +0 -55
- package/lib/rules/src/preparators/getDisplay.js +0 -32
- package/lib/rules/src/table/preparators/getDisplay.js +0 -32
- package/lib/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -16
- package/lib/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
- package/src/rules/src/preparators/getDimensions.js +0 -49
- package/src/rules/src/preparators/getDisplay.js +0 -20
- package/src/rules/src/table/preparators/getDisplay.js +0 -20
- package/src/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -9
- package/src/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
- package/test/getNoDisplayAnnotationsIndexes.test.js +0 -18
- package/test/getNoDisplayCodes.test.js +0 -87
package/lib/viewer/src/index.js
CHANGED
|
@@ -91,15 +91,17 @@ var useStyles = (0, _styles.makeStyles)(function () {
|
|
|
91
91
|
|
|
92
92
|
var ViewContent = function ViewContent(_ref3) {
|
|
93
93
|
var loading = _ref3.loading,
|
|
94
|
+
_ref3$loadingProps = _ref3.loadingProps,
|
|
95
|
+
loadingProps = _ref3$loadingProps === undefined ? {} : _ref3$loadingProps,
|
|
94
96
|
_ref3$noData = _ref3.noData,
|
|
95
97
|
noData = _ref3$noData === undefined ? 'No Data' : _ref3$noData,
|
|
96
98
|
type = _ref3.type,
|
|
97
99
|
width = _ref3.width,
|
|
98
100
|
errorMessage = _ref3.errorMessage,
|
|
99
|
-
rest = (0, _objectWithoutProperties3.default)(_ref3, ['loading', 'noData', 'type', 'width', 'errorMessage']);
|
|
101
|
+
rest = (0, _objectWithoutProperties3.default)(_ref3, ['loading', 'loadingProps', 'noData', 'type', 'width', 'errorMessage']);
|
|
100
102
|
|
|
101
|
-
if (loading) return _react2.default.createElement(_dotstatsuiteVisions.Loading, { message: loading });
|
|
102
|
-
if (!width) return _react2.default.createElement(_dotstatsuiteVisions.Loading, { message: loading });
|
|
103
|
+
if (loading) return _react2.default.createElement(_dotstatsuiteVisions.Loading, (0, _extends3.default)({ message: loading }, loadingProps));
|
|
104
|
+
if (!width) return _react2.default.createElement(_dotstatsuiteVisions.Loading, (0, _extends3.default)({ message: loading }, loadingProps));
|
|
103
105
|
if (errorMessage) return _react2.default.createElement(_dotstatsuiteVisions.NoData, { message: errorMessage });
|
|
104
106
|
|
|
105
107
|
if (type === 'table') {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sis-cc/dotstatsuite-components",
|
|
3
3
|
"description": "Set components based on React.",
|
|
4
|
-
"version": "13.0
|
|
4
|
+
"version": "13.3.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "OECD",
|
|
7
7
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@material-ui/core": "^4.x",
|
|
39
39
|
"@sis-cc/dotstatsuite-visions": "^7.x",
|
|
40
|
-
"@sis-cc/dotstatsuite-sdmxjs": "^
|
|
40
|
+
"@sis-cc/dotstatsuite-sdmxjs": "^6.x",
|
|
41
41
|
"react": "16.x"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { get, has, head, isUndefined, map, split, transform } from 'lodash';
|
|
2
2
|
import { getRefAreaDimension } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
3
3
|
import { categoryDisplay, dimensionValueDisplay } from '../dimension-utils';
|
|
4
4
|
|
|
@@ -1,47 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
concat, filter, findIndex, get, has, head, isEmpty, isNil, map, reduce, size, sortBy, split, keys, includes
|
|
3
|
-
} from 'lodash';
|
|
4
|
-
import { FREQ_A, FREQ_Q, FREQ_M } from '../constants';
|
|
1
|
+
import { findIndex, get, has, head, isEmpty, isNil, map, reduce, sortBy, split } from 'lodash';
|
|
5
2
|
import { getTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
6
3
|
import { categoryDisplay, dimensionValueDisplayAt } from '../dimension-utils';
|
|
7
4
|
import { getFormatedObservation } from '../observation-formater';
|
|
8
5
|
|
|
9
|
-
const getLineCategory = (
|
|
10
|
-
oDimensionValuesIndexes, dimensions, timePeriodDimensionIndex, dimensionsWithValuesIndexedById
|
|
11
|
-
) => (
|
|
12
|
-
reduce(
|
|
13
|
-
oDimensionValuesIndexes,
|
|
14
|
-
(memo, dimensionValueIndex, dimensionIndex) => {
|
|
15
|
-
const dimension = get(dimensions, `[${dimensionIndex}]`, {});
|
|
16
|
-
if ((dimensionIndex !== timePeriodDimensionIndex) && (has(dimensionsWithValuesIndexedById, dimension.id))) {
|
|
17
|
-
return concat(
|
|
18
|
-
memo, get(dimensions, `[${dimensionIndex}].values[${dimensionValueIndex}].name`, '')
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
return memo;
|
|
22
|
-
},
|
|
23
|
-
[]
|
|
24
|
-
).join(' - ')
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const getLineCategoryId = (
|
|
28
|
-
oDimensionValuesIndexes, dimensions, timePeriodDimensionIndex, dimensionsWithValuesIndexedById
|
|
29
|
-
) => (
|
|
30
|
-
reduce(
|
|
31
|
-
oDimensionValuesIndexes,
|
|
32
|
-
(memo, dimensionValueIndex, dimensionIndex) => {
|
|
33
|
-
const dimension = get(dimensions, `[${dimensionIndex}]`, {});
|
|
34
|
-
if ((dimensionIndex !== timePeriodDimensionIndex) && (has(dimensionsWithValuesIndexedById, dimension.id))) {
|
|
35
|
-
return concat(
|
|
36
|
-
memo, get(dimensions, `[${dimensionIndex}].values[${dimensionValueIndex}].id`, '')
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
return memo;
|
|
40
|
-
},
|
|
41
|
-
[]
|
|
42
|
-
).join(' - ')
|
|
43
|
-
);
|
|
44
|
-
|
|
45
6
|
const getDimensionValues = (splitObservationKey, dimensions, dimensionsWithValuesIndexedById, rejectedId, display) => (
|
|
46
7
|
reduce(
|
|
47
8
|
splitObservationKey,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
|
-
import { getDisplay } from './getDisplay';
|
|
3
2
|
import { formatValue } from './formatValue';
|
|
4
3
|
|
|
5
4
|
/*
|
|
@@ -9,8 +8,6 @@ import { formatValue } from './formatValue';
|
|
|
9
8
|
decimals: id,
|
|
10
9
|
prefscale: id,
|
|
11
10
|
},
|
|
12
|
-
noDisplayIndexes,
|
|
13
|
-
notDisplayedCodes,
|
|
14
11
|
unitsArtefacts,
|
|
15
12
|
obsAttributes,
|
|
16
13
|
rejectedValueIds,
|
|
@@ -38,12 +35,12 @@ const getUnitsValues = (indexes, options) => R.reduce(
|
|
|
38
35
|
return acc;
|
|
39
36
|
}
|
|
40
37
|
const valueIndex = R.prop(codelist.__index, indexes);
|
|
41
|
-
if (R.isNil(valueIndex) || !
|
|
38
|
+
if (R.isNil(valueIndex) || !R.propOr(true, 'display', codelist)) {
|
|
42
39
|
return acc;
|
|
43
40
|
}
|
|
44
41
|
const value = R.path(['values', Number(valueIndex)], codelist);
|
|
45
42
|
if (R.isNil(value) || R.includes(value.id, R.propOr([], 'rejectedValueIds', options))
|
|
46
|
-
|| !
|
|
43
|
+
|| !R.propOr(true, 'display', value)) {
|
|
47
44
|
return acc;
|
|
48
45
|
}
|
|
49
46
|
return R.assoc(
|
|
@@ -94,7 +91,7 @@ const getFormatAttributesIndexes = (attributes, customAttributes) => R.addIndex(
|
|
|
94
91
|
);
|
|
95
92
|
|
|
96
93
|
const getAttributeValue = (attribute, valueIndex, options) => {
|
|
97
|
-
if (!
|
|
94
|
+
if (!R.propOr(true, 'display', attribute)) {
|
|
98
95
|
return null;
|
|
99
96
|
}
|
|
100
97
|
const value = R.pipe(
|
|
@@ -102,7 +99,7 @@ const getAttributeValue = (attribute, valueIndex, options) => {
|
|
|
102
99
|
R.nth(valueIndex)
|
|
103
100
|
)(attribute);
|
|
104
101
|
|
|
105
|
-
if (R.isNil(value) || !
|
|
102
|
+
if (R.isNil(value) || !R.propOr(true, 'display', value)) {
|
|
106
103
|
return null;
|
|
107
104
|
}
|
|
108
105
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import {
|
|
3
3
|
getDefaultSubtitle,
|
|
4
|
-
getDefaultTitle,
|
|
5
4
|
getHeaderUnits,
|
|
6
5
|
getSubtitleFlags,
|
|
7
6
|
getTitleFlags
|
|
8
7
|
} from '../header';
|
|
9
|
-
import { dimensionValueDisplay,
|
|
8
|
+
import { dimensionValueDisplay, parseDisplay } from '../';
|
|
10
9
|
import { isChart } from './utils';
|
|
11
10
|
|
|
12
11
|
const isCustomInvalid = ({ type }) => (value) => R.isNil(value) || !isChart(type);
|
|
@@ -31,7 +31,7 @@ export const getRelationnalAnnotations = annotationIndexes => annotations => R.m
|
|
|
31
31
|
|
|
32
32
|
export const hiddenFormat = { isHidden: true }
|
|
33
33
|
|
|
34
|
-
export const getIsHidden = R.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
export const getIsHidden = annotations => R.pipe(
|
|
35
|
+
R.find(R.propEq('type', NOT_DISPLAYED)),
|
|
36
|
+
R.complement(R.isNil)
|
|
37
|
+
)(annotations);
|
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import { getAttributeValue } from './getAttributeValue';
|
|
3
3
|
|
|
4
|
-
export const getOneValueDimensions = (dimensions, attributesIds, attributes
|
|
4
|
+
export const getOneValueDimensions = (dimensions, attributesIds, attributes) => R.map(
|
|
5
5
|
(dimension) => {
|
|
6
6
|
const dimensionAttributes = R.pipe(
|
|
7
7
|
R.mapObjIndexed(attr => getAttributeValue(attr, 0)),
|
|
8
8
|
R.filter(R.complement(R.isNil))
|
|
9
9
|
)(R.pick(R.propOr([], dimension.id, attributesIds), attributes));
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
R.path(['values', 0]),
|
|
15
|
-
R.assoc('attributes', dimensionAttributes),
|
|
16
|
-
(val) => R.assoc(
|
|
17
|
-
'display',
|
|
18
|
-
getDisplay({ ...val, parent: dimension.id }),
|
|
19
|
-
val
|
|
20
|
-
)
|
|
21
|
-
)(dimension);
|
|
22
|
-
|
|
23
|
-
return R.pipe(
|
|
24
|
-
R.assoc(
|
|
25
|
-
'display',
|
|
26
|
-
display
|
|
27
|
-
),
|
|
28
|
-
R.assocPath(
|
|
29
|
-
['values', 0],
|
|
30
|
-
value
|
|
31
|
-
)
|
|
11
|
+
return R.over(
|
|
12
|
+
R.lensPath(['values', 0]),
|
|
13
|
+
R.assoc('attributes', dimensionAttributes)
|
|
32
14
|
)(dimension);
|
|
33
15
|
},
|
|
34
16
|
dimensions
|
|
@@ -78,11 +78,11 @@ const getAttributeRegisters = (attribute, parsedDimensionsIds, customAttributes)
|
|
|
78
78
|
]
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
export const parseAttributes = ({ attributes, parsedDimensionsIds, customAttributes
|
|
81
|
+
export const parseAttributes = ({ attributes, parsedDimensionsIds, customAttributes }) => R.addIndex(R.reduce)(
|
|
82
82
|
(acc, attribute, attributeIndex) => {
|
|
83
83
|
const values = R.propOr([], 'values', attribute);
|
|
84
84
|
|
|
85
|
-
if (R.isEmpty(values) || !
|
|
85
|
+
if (R.isEmpty(values) || !R.propOr(true, 'display', attribute) || R.includes(attribute.id, R.propOr([], 'units', customAttributes))) {
|
|
86
86
|
return acc;
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -92,7 +92,7 @@ export const parseAttributes = ({ attributes, parsedDimensionsIds, customAttribu
|
|
|
92
92
|
R.over(
|
|
93
93
|
R.lensProp('values'),
|
|
94
94
|
R.map((value) => {
|
|
95
|
-
if (!
|
|
95
|
+
if (!R.propOr(true, 'display', value)) {
|
|
96
96
|
return null;
|
|
97
97
|
}
|
|
98
98
|
return value;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import { getObservationsType } from '../../properties/getObservationsType';
|
|
3
3
|
import { parseDimensionsIds } from './parseDimensionsIds';
|
|
4
|
-
import { getNoDisplayAnnotationsIndexes } from './getNoDisplayAnnotationsIndexes';
|
|
5
|
-
import { getNoDisplayCodes } from './getNoDisplayCodes';
|
|
6
4
|
import { parseAttributes } from './parseAttributes';
|
|
7
5
|
import { getDimensionsAttributesRegisters } from './getDimensionsAttributesRegisters';
|
|
8
6
|
import { parseAttributesValuesFromObservations } from './parseAttributesValuesFromObservations';
|
|
@@ -17,7 +15,6 @@ import { getHeaderUnits } from '../units/getHeaderUnits';
|
|
|
17
15
|
import { getAttachmentSeriesIndexes } from '../units/getAttachmentSeriesIndexes';
|
|
18
16
|
import { getUnitsSeries } from '../units/getUnitsSeries';
|
|
19
17
|
|
|
20
|
-
import { getDisplay } from '../../preparators/getDisplay';
|
|
21
18
|
import { getObservations } from '../../preparators/getObservations';
|
|
22
19
|
import { enhanceObservations } from '../../preparators/enhanceObservations';
|
|
23
20
|
|
|
@@ -44,18 +41,8 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
|
|
|
44
41
|
|
|
45
42
|
const parsedDimensionsIds = parseDimensionsIds(dimensions);
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const noDisplayIndexes = getNoDisplayAnnotationsIndexes(annotations);
|
|
50
|
-
const notDisplayedCodes = getNoDisplayCodes({
|
|
51
|
-
noDisplayIndexes,
|
|
52
|
-
annotations,
|
|
53
|
-
datasetIndexes: R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson)
|
|
54
|
-
});
|
|
55
|
-
const _getDisplay = getDisplay({ noDisplayIndexes, notDisplayedCodes });
|
|
56
|
-
|
|
57
|
-
//------------------------------------------------------------------
|
|
58
|
-
const unitsArtefacts = getUnitsArtefacts({ unitsDefinitionCodes, data: sdmxJson, getDisplay: _getDisplay });
|
|
44
|
+
//------------------------------------------------------------------
|
|
45
|
+
const unitsArtefacts = getUnitsArtefacts({ unitsDefinitionCodes, data: sdmxJson });
|
|
59
46
|
const headerUnits = getHeaderUnits({ unitsArtefacts, unitsDefinitionCodes, rejectedValueIds });
|
|
60
47
|
const _dimensions = R.pipe(
|
|
61
48
|
R.pathOr([], ['data', 'structure', 'dimensions', 'observation']),
|
|
@@ -73,7 +60,6 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
|
|
|
73
60
|
R.pathOr([], ['data', 'structure', 'attributes', 'dataSet'], sdmxJson),
|
|
74
61
|
),
|
|
75
62
|
parsedDimensionsIds,
|
|
76
|
-
getDisplay: _getDisplay,
|
|
77
63
|
customAttributes: _customAttributes,
|
|
78
64
|
});
|
|
79
65
|
|
|
@@ -86,8 +72,6 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
|
|
|
86
72
|
const options = {
|
|
87
73
|
attachmentSeriesIndexes,
|
|
88
74
|
customAttributes,
|
|
89
|
-
noDisplayIndexes,
|
|
90
|
-
notDisplayedCodes,
|
|
91
75
|
attributesIds: R.concat(seriesAttributesIds, observationsAttributesIds),
|
|
92
76
|
unitsIds: obsUnitsIds
|
|
93
77
|
};
|
|
@@ -106,7 +90,7 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
|
|
|
106
90
|
attributesIndexedByIds
|
|
107
91
|
);
|
|
108
92
|
|
|
109
|
-
const dimensionsAttributesValues = parseAttributesValuesFromObservations( // => { series: { key: { attrId: [...indexes] } }, dimensions: {}
|
|
93
|
+
const dimensionsAttributesValues = parseAttributesValuesFromObservations( // => { series: { key: { attrId: [...indexes] } }, dimensions: {} }
|
|
110
94
|
observations,
|
|
111
95
|
attributesRegisters
|
|
112
96
|
);
|
|
@@ -128,7 +112,6 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
|
|
|
128
112
|
)(dimensionsIndexedByIds),
|
|
129
113
|
attributesIdsIndexedByTargets.oneValueDimensions,
|
|
130
114
|
attributesIndexedByIds,
|
|
131
|
-
_getDisplay
|
|
132
115
|
);
|
|
133
116
|
|
|
134
117
|
const manyValuesDimensions = getManyValuesDimensions(
|
|
@@ -155,7 +138,6 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
|
|
|
155
138
|
|
|
156
139
|
const dataflowAdvancedAttributes = getDataflowAdvancedAttributes(
|
|
157
140
|
headerAttributes,
|
|
158
|
-
//oneValueDimensions,
|
|
159
141
|
R.pick(R.keys(parsedDimensionsIds.oneValue), dimensionsIndexedByIds),
|
|
160
142
|
headerAdvancedAttrIds,
|
|
161
143
|
R.length(dimensions)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
|
-
export const getRelevantLength = (
|
|
3
|
+
export const getRelevantLength = (attr) => R.pipe(
|
|
4
4
|
R.propOr([], 'values'),
|
|
5
|
-
R.filter(
|
|
5
|
+
R.filter(R.propOr(true, 'display')),
|
|
6
6
|
R.length
|
|
7
7
|
)(attr);
|
|
8
8
|
|
|
9
|
-
export const getUnitsArtefacts = ({ unitsDefinitionCodes=[], data
|
|
9
|
+
export const getUnitsArtefacts = ({ unitsDefinitionCodes=[], data }) => {
|
|
10
10
|
const dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], data);
|
|
11
11
|
const parsedUnitsDimensions = R.addIndex(R.reduce)(
|
|
12
12
|
(acc, dimension, index) => {
|
|
@@ -39,7 +39,7 @@ export const getUnitsArtefacts = ({ unitsDefinitionCodes=[], data, getDisplay })
|
|
|
39
39
|
R.filter(R.pipe(R.propOr([], 'values'), R.length, R.equals(1))),
|
|
40
40
|
R.indexBy(R.prop('id')),
|
|
41
41
|
R.pick(unitsDefinitionCodes),
|
|
42
|
-
R.filter(
|
|
42
|
+
R.filter(R.propOr(true, 'display')),
|
|
43
43
|
R.mapObjIndexed(R.assoc('datasetLevel', true))
|
|
44
44
|
),
|
|
45
45
|
R.pipe(
|
|
@@ -47,10 +47,10 @@ export const getUnitsArtefacts = ({ unitsDefinitionCodes=[], data, getDisplay })
|
|
|
47
47
|
R.addIndex(R.reduce)(
|
|
48
48
|
(acc, attr, index) => {
|
|
49
49
|
if(!R.includes(attr.id, unitsDefinitionCodes) || R.length(R.propOr([], 'values', attr)) === 0
|
|
50
|
-
|| !
|
|
50
|
+
|| !R.propOr(true, 'display', attr)) {
|
|
51
51
|
return acc;
|
|
52
52
|
}
|
|
53
|
-
const length = getRelevantLength(
|
|
53
|
+
const length = getRelevantLength(attr);
|
|
54
54
|
if (length === 0) {
|
|
55
55
|
return acc;
|
|
56
56
|
}
|
|
@@ -1,26 +1,47 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import dateFns from 'date-fns';
|
|
3
|
-
import { getCodeOrder, isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
3
|
+
import { getCodeOrder, getRefinedName, isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
4
4
|
import {
|
|
5
|
-
getRelationnalAnnotations, setAnnotationsLayout, getIsHidden
|
|
5
|
+
getRelationnalAnnotations, setAnnotationsLayout, getIsHidden } from './sdmx-data';
|
|
6
6
|
import { getReportedTimePeriodLabel } from './date';
|
|
7
7
|
import { getReportingYearStart } from './preparators/getReportingYearStart';
|
|
8
|
+
import { getNotDisplayedIds } from '../../rules2/src';
|
|
8
9
|
|
|
9
10
|
export const dataTransformer = (dataNew, options = {}) => {
|
|
10
|
-
const
|
|
11
|
-
const locale = getLanguage(dataNew);
|
|
11
|
+
const { locale } = options;
|
|
12
12
|
const reportYearStart = getReportingYearStart(dataNew);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
13
|
+
|
|
14
|
+
//---------------------------------------------------------------------------------------Annotations
|
|
15
|
+
const getStructure = R.pathOr({},['data', 'structure']);
|
|
16
|
+
const structure = getStructure(dataNew);
|
|
17
|
+
const getAnnotations = R.propOr([], 'annotations');
|
|
18
|
+
const annotations = getAnnotations(structure);
|
|
19
|
+
const getDataSets = R.pathOr({},['data', 'dataSets']);
|
|
20
|
+
const dataSets = getDataSets(dataNew);
|
|
21
|
+
|
|
22
|
+
const dataSetsAnnotations = R.props(R.pathOr([],[0, 'annotations'], dataSets), annotations);
|
|
23
|
+
|
|
24
|
+
const hiddenIds = getNotDisplayedIds(dataSetsAnnotations);
|
|
25
|
+
|
|
26
|
+
//--------------------------------------------------------------------------------------------------
|
|
27
|
+
const getValues = (values, parent) => R.map((value) => {
|
|
28
|
+
const valAnnotations = R.props(value.annotations || [], annotations);
|
|
29
|
+
return ({
|
|
30
|
+
...value,
|
|
31
|
+
display: !R.has(`${parent}.${value.id}`, hiddenIds) && !getIsHidden(valAnnotations),
|
|
32
|
+
name: getRefinedName(value)
|
|
33
|
+
});
|
|
34
|
+
}, values);
|
|
35
|
+
|
|
36
|
+
const getValuesEnhanced = (locale, annotations, isTimeDimension, parent) =>
|
|
17
37
|
R.pipe(
|
|
18
38
|
R.addIndex(R.map)((value, __index) => {
|
|
19
39
|
const valueAnnotations = R.pipe(
|
|
20
40
|
R.propOr([], 'annotations'),
|
|
21
41
|
R.flip(R.props)(annotations)
|
|
22
42
|
)(value);
|
|
23
|
-
const
|
|
43
|
+
const isHidden = R.has(`${parent}.${value.id}`, hiddenIds) || getIsHidden(valueAnnotations);
|
|
44
|
+
const name = getRefinedName(value);
|
|
24
45
|
let __indexPosition = NaN;
|
|
25
46
|
let start = null;
|
|
26
47
|
if (isTimeDimension) {
|
|
@@ -31,7 +52,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
31
52
|
__indexPosition = dateFns.getTime(new Date(R.prop('start', value)));
|
|
32
53
|
}
|
|
33
54
|
if (isNaN(__indexPosition)) {
|
|
34
|
-
__indexPosition = getCodeOrder(
|
|
55
|
+
__indexPosition = getCodeOrder({ annotations: valueAnnotations });
|
|
35
56
|
}
|
|
36
57
|
const timeFormat = R.prop('timeFormat', options);
|
|
37
58
|
return ({
|
|
@@ -40,6 +61,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
40
61
|
R.always(isTimeDimension),
|
|
41
62
|
R.replace(/M/g, '')
|
|
42
63
|
)(value.id),
|
|
64
|
+
display: !isHidden,
|
|
43
65
|
name: R.when(
|
|
44
66
|
R.always(isTimeDimension),
|
|
45
67
|
R.always(getReportedTimePeriodLabel(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start:value.start }))
|
|
@@ -56,12 +78,6 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
56
78
|
R.addIndex(R.map)((val, index) => R.assoc('__indexPosition', index, val))
|
|
57
79
|
);
|
|
58
80
|
|
|
59
|
-
const getDataSets = R.pathOr({},['data', 'dataSets']);
|
|
60
|
-
const dataSets = getDataSets(dataNew);
|
|
61
|
-
|
|
62
|
-
const getStructure = R.pathOr({},['data', 'structure']);
|
|
63
|
-
const structure = getStructure(dataNew);
|
|
64
|
-
|
|
65
81
|
//--------------------------------------------------------------------------------------------Header
|
|
66
82
|
const getMeta = R.propOr({}, 'meta');
|
|
67
83
|
const meta = getMeta(dataNew);
|
|
@@ -71,23 +87,9 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
71
87
|
|
|
72
88
|
const resHeader = {
|
|
73
89
|
...meta,
|
|
74
|
-
sender: {...sender, name:
|
|
90
|
+
sender: {...sender, name: getRefinedName(sender)},
|
|
75
91
|
};
|
|
76
92
|
|
|
77
|
-
//---------------------------------------------------------------------------------------Annotations
|
|
78
|
-
const getAnnotations = R.propOr([], 'annotations');
|
|
79
|
-
const annotations = getAnnotations(structure);
|
|
80
|
-
|
|
81
|
-
const dataSetsAnnotations = getRelationnalAnnotations(
|
|
82
|
-
R.pathOr([],[0, 'annotations'])(dataSets)
|
|
83
|
-
)(annotations);
|
|
84
|
-
|
|
85
|
-
const hiddenIds = R.pipe(
|
|
86
|
-
R.find(R.propEq('type', 'NOT_DISPLAYED')),
|
|
87
|
-
R.propOr('', 'title'),
|
|
88
|
-
R.ifElse(R.isEmpty, R.always([]), R.split(','))
|
|
89
|
-
)(annotations);
|
|
90
|
-
|
|
91
93
|
//----------------------------------------------------------------------------------------Attributes
|
|
92
94
|
const getAttributes = R.propOr({}, 'attributes');
|
|
93
95
|
const attributes = getAttributes(structure);
|
|
@@ -95,19 +97,27 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
95
97
|
const getAttrObservations = R.propOr([], 'observation');
|
|
96
98
|
const attrObservations = getAttrObservations(attributes);
|
|
97
99
|
|
|
98
|
-
const resAttrObservations = R.map((observation) =>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
const resAttrObservations = R.map((observation) => {
|
|
101
|
+
const obsAnnotations = R.props(observation.annotations || [], annotations);
|
|
102
|
+
return ({
|
|
103
|
+
...observation,
|
|
104
|
+
display: !R.has(observation.id, hiddenIds) && !getIsHidden(obsAnnotations),
|
|
105
|
+
name: getRefinedName(observation),
|
|
106
|
+
values: getValues(observation.values || [], observation.id),
|
|
107
|
+
roles: !R.isNil(observation.role) ? R.head(observation.role) : null,
|
|
108
|
+
});
|
|
109
|
+
}, attrObservations);
|
|
104
110
|
|
|
105
111
|
const datasetAttributes = R.map(
|
|
106
|
-
(attr) =>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
(attr) => {
|
|
113
|
+
const attrAnnotations = R.props(attr.annotations || [], annotations);
|
|
114
|
+
return ({
|
|
115
|
+
...attr,
|
|
116
|
+
display: !R.has(attr.id, hiddenIds) && !getIsHidden(attrAnnotations),
|
|
117
|
+
name: getRefinedName(observation),
|
|
118
|
+
values: getValues(attr.values || [], attr.id)
|
|
119
|
+
});
|
|
120
|
+
},
|
|
111
121
|
R.propOr([], 'dataSet', attributes)
|
|
112
122
|
)
|
|
113
123
|
|
|
@@ -126,10 +136,10 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
126
136
|
const getObservations = locale => R.addIndex(R.reduce)((acc, observation, obsIndex) => {
|
|
127
137
|
const id = R.prop('id')(observation);
|
|
128
138
|
const dimAnnotations = getRelationnalAnnotations(R.propOr([],'annotations')(observation))(annotations)
|
|
129
|
-
const isHidden = R.
|
|
139
|
+
const isHidden = R.has(id, hiddenIds) || getIsHidden(dimAnnotations);
|
|
130
140
|
const isTime = isTimePeriodDimension(observation);
|
|
131
141
|
|
|
132
|
-
const values = getValuesEnhanced(locale, annotations, isTime)(R.propOr([],'values', observation));
|
|
142
|
+
const values = getValuesEnhanced(locale, annotations, isTime, id)(R.propOr([],'values', observation));
|
|
133
143
|
const ids = R.pipe(R.pluck('id'), R.indexBy(R.identity))(values);
|
|
134
144
|
const groupedByParentsValues = R.groupBy(val => {
|
|
135
145
|
const parentId = R.propOr('##ROOT', 'parent', val);
|
|
@@ -158,11 +168,11 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
158
168
|
return ({
|
|
159
169
|
observation: R.append({
|
|
160
170
|
...observation,
|
|
171
|
+
display: !isHidden,
|
|
161
172
|
__index: obsIndex,
|
|
162
|
-
name:
|
|
173
|
+
name: getRefinedName(observation),
|
|
163
174
|
values: sortedValues,
|
|
164
175
|
role: R.isNil(observation.roles) ? null : R.head(observation.roles),
|
|
165
|
-
...isHidden,
|
|
166
176
|
})(acc.observation),
|
|
167
177
|
dimensionsLayout: setAnnotationsLayout(id, acc.dimensionsLayout)(dimAnnotations),
|
|
168
178
|
});
|
|
@@ -172,7 +182,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
172
182
|
const { dimensionsLayout, observation } = getObservations(locale)(dimObservations);
|
|
173
183
|
const resStructure = {
|
|
174
184
|
...structure,
|
|
175
|
-
name:
|
|
185
|
+
name: getRefinedName({ ...structure, id: options.dataflowId }),
|
|
176
186
|
annotations,
|
|
177
187
|
attributes: resAttributes,
|
|
178
188
|
dimensions: { observation },
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const getNotDisplayedIds = (annotations) => R.pipe(
|
|
4
|
+
R.find(R.propEq('type', 'NOT_DISPLAYED')),
|
|
5
|
+
annot => {
|
|
6
|
+
if (R.isNil(annot)) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
const ids = R.split(',', annot.title || '');
|
|
10
|
+
return R.reduce(
|
|
11
|
+
(acc, entry) => {
|
|
12
|
+
if (R.isEmpty(entry)) {
|
|
13
|
+
return acc;
|
|
14
|
+
}
|
|
15
|
+
const parsed = R.split('=', entry);
|
|
16
|
+
const dimensionId = parsed[0];
|
|
17
|
+
if (R.length(parsed) === 1) {
|
|
18
|
+
return R.assoc(dimensionId, dimensionId, acc);
|
|
19
|
+
}
|
|
20
|
+
const values = R.split('+', parsed[1]);
|
|
21
|
+
if (R.length(values) === 1 && R.isEmpty(values[0])) {
|
|
22
|
+
return R.assoc(dimensionId, dimensionId, acc);
|
|
23
|
+
}
|
|
24
|
+
return R.reduce(
|
|
25
|
+
(_acc, val) => {
|
|
26
|
+
if (R.isEmpty(val)) {
|
|
27
|
+
return _acc;
|
|
28
|
+
}
|
|
29
|
+
const key = `${dimensionId}.${val}`;
|
|
30
|
+
return R.assoc(key, key, _acc);
|
|
31
|
+
},
|
|
32
|
+
acc,
|
|
33
|
+
values
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
{},
|
|
37
|
+
ids
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
)(annotations);
|
|
@@ -42,33 +42,51 @@ export const getSidebarData = (attributesSeries, metadataSeries, dataflow, dimen
|
|
|
42
42
|
R.isNil(metadata) ? [] : metadata,
|
|
43
43
|
);
|
|
44
44
|
const splitCoord = R.split(':', coordinate);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
R.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
45
|
+
const { split, labels } = R.addIndex(R.reduce)(
|
|
46
|
+
(acc, valIndex, dimIndex) => {
|
|
47
|
+
if (R.isEmpty(valIndex)) {
|
|
48
|
+
return ({ ...acc, split: R.append('', acc.split) });
|
|
49
|
+
}
|
|
50
|
+
const dim = R.nth(dimIndex, dimensions);
|
|
51
|
+
const value = R.nth(Number(valIndex), dim.values);
|
|
52
|
+
if (!R.propOr(true, 'display', dim) || !R.propOr(true, 'display', value)) {
|
|
53
|
+
return ({ ...acc, split: R.append('', acc.split) });
|
|
54
|
+
}
|
|
55
|
+
const dimLabel = dimensionValueDisplay(options.display)(dim);
|
|
56
|
+
const valLabel = dimensionValueDisplay(options.display)(value);
|
|
57
|
+
return ({
|
|
58
|
+
labels: R.append(`${dimLabel}: ${valLabel}`, acc.labels),
|
|
59
|
+
split: R.append(valIndex, acc.split)
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
{ split: [], labels: [] },
|
|
63
|
+
splitCoord
|
|
64
|
+
);
|
|
65
|
+
const label = R.isEmpty(labels)
|
|
66
|
+
? dimensionValueDisplay(options.display)(dataflow)
|
|
67
|
+
: R.join(' - ', labels);
|
|
68
|
+
|
|
65
69
|
return ({
|
|
66
|
-
id:
|
|
67
|
-
splitCoord,
|
|
70
|
+
id: R.join(':', split),
|
|
71
|
+
splitCoord: split,
|
|
68
72
|
label,
|
|
69
73
|
children: R.filter(R.identity, children),
|
|
70
74
|
});
|
|
71
75
|
}),
|
|
72
|
-
|
|
76
|
+
series => { // after removed non displayed dim vals, some series might be duplicated
|
|
77
|
+
const grouped = R.groupBy(R.prop('id'), series);
|
|
78
|
+
return R.pipe(
|
|
79
|
+
R.map(entries => {
|
|
80
|
+
if (R.length(entries) === 1) {
|
|
81
|
+
return R.head(entries);
|
|
82
|
+
}
|
|
83
|
+
const head = R.head(entries);
|
|
84
|
+
const children = R.pipe(R.pluck('children'), R.unnest)(entries);
|
|
85
|
+
return R.assoc('children', children, head);
|
|
86
|
+
}),
|
|
87
|
+
R.values
|
|
88
|
+
)(grouped);
|
|
89
|
+
},
|
|
90
|
+
R.sort(sortByCoordinates),
|
|
73
91
|
)(coordinates);
|
|
74
92
|
};
|