@sis-cc/dotstatsuite-components 13.0.3 → 13.2.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/dimension-utils.js +3 -2
- 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 +39 -23
- 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/viewer/src/index.js +5 -3
- package/package.json +1 -1
- package/src/rules/src/dimension-utils.js +4 -4
- package/src/rules/src/preparators/enhanceObservations.js +4 -7
- package/src/rules/src/properties/getHeaderProps.js +1 -2
- 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 +49 -36
- 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/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/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/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/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
|
@@ -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
|
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
getRelationnalAnnotations, setAnnotationsLayout, getIsHidden, hiddenFormat } 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
11
|
const getLanguage = R.pipe(R.pathOr('', ['meta', 'contentLanguages']), R.head());
|
|
@@ -12,14 +13,37 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
12
13
|
const reportYearStart = getReportingYearStart(dataNew);
|
|
13
14
|
const getProp = (prop, locale) => R.pathOr(null,[prop, locale]);
|
|
14
15
|
const getLocalisedProp = R.curry((prop, collection) => getProp(prop, locale)(collection));
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
//---------------------------------------------------------------------------------------Annotations
|
|
18
|
+
const getStructure = R.pathOr({},['data', 'structure']);
|
|
19
|
+
const structure = getStructure(dataNew);
|
|
20
|
+
const getAnnotations = R.propOr([], 'annotations');
|
|
21
|
+
const annotations = getAnnotations(structure);
|
|
22
|
+
const getDataSets = R.pathOr({},['data', 'dataSets']);
|
|
23
|
+
const dataSets = getDataSets(dataNew);
|
|
24
|
+
|
|
25
|
+
const dataSetsAnnotations = R.props(R.pathOr([],[0, 'annotations'], dataSets), annotations);
|
|
26
|
+
|
|
27
|
+
const hiddenIds = getNotDisplayedIds(dataSetsAnnotations);
|
|
28
|
+
|
|
29
|
+
//--------------------------------------------------------------------------------------------------
|
|
30
|
+
const getValues = (values, parent) => R.map((value) => {
|
|
31
|
+
const valAnnotations = R.props(value.annotations || [], annotations);
|
|
32
|
+
return ({
|
|
33
|
+
...value,
|
|
34
|
+
display: !R.has(`${parent}.${value.id}`, hiddenIds) && !getIsHidden(valAnnotations),
|
|
35
|
+
name: getLocalisedProp('names', value)
|
|
36
|
+
});
|
|
37
|
+
}, values);
|
|
38
|
+
|
|
39
|
+
const getValuesEnhanced = (locale, annotations, isTimeDimension, parent) =>
|
|
17
40
|
R.pipe(
|
|
18
41
|
R.addIndex(R.map)((value, __index) => {
|
|
19
42
|
const valueAnnotations = R.pipe(
|
|
20
43
|
R.propOr([], 'annotations'),
|
|
21
44
|
R.flip(R.props)(annotations)
|
|
22
45
|
)(value);
|
|
46
|
+
const isHidden = R.has(`${parent}.${value.id}`, hiddenIds) || getIsHidden(valueAnnotations);
|
|
23
47
|
const name = getLocalisedProp('names')(value);
|
|
24
48
|
let __indexPosition = NaN;
|
|
25
49
|
let start = null;
|
|
@@ -40,6 +64,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
40
64
|
R.always(isTimeDimension),
|
|
41
65
|
R.replace(/M/g, '')
|
|
42
66
|
)(value.id),
|
|
67
|
+
display: !isHidden,
|
|
43
68
|
name: R.when(
|
|
44
69
|
R.always(isTimeDimension),
|
|
45
70
|
R.always(getReportedTimePeriodLabel(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start:value.start }))
|
|
@@ -56,12 +81,6 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
56
81
|
R.addIndex(R.map)((val, index) => R.assoc('__indexPosition', index, val))
|
|
57
82
|
);
|
|
58
83
|
|
|
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
84
|
//--------------------------------------------------------------------------------------------Header
|
|
66
85
|
const getMeta = R.propOr({}, 'meta');
|
|
67
86
|
const meta = getMeta(dataNew);
|
|
@@ -74,20 +93,6 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
74
93
|
sender: {...sender, name: getLocalisedProp('names', sender)},
|
|
75
94
|
};
|
|
76
95
|
|
|
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
96
|
//----------------------------------------------------------------------------------------Attributes
|
|
92
97
|
const getAttributes = R.propOr({}, 'attributes');
|
|
93
98
|
const attributes = getAttributes(structure);
|
|
@@ -95,19 +100,27 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
95
100
|
const getAttrObservations = R.propOr([], 'observation');
|
|
96
101
|
const attrObservations = getAttrObservations(attributes);
|
|
97
102
|
|
|
98
|
-
const resAttrObservations = R.map((observation) =>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
const resAttrObservations = R.map((observation) => {
|
|
104
|
+
const obsAnnotations = R.props(observation.annotations || [], annotations);
|
|
105
|
+
return ({
|
|
106
|
+
...observation,
|
|
107
|
+
display: !R.has(observation.id, hiddenIds) && !getIsHidden(obsAnnotations),
|
|
108
|
+
name: getLocalisedProp('names', observation),
|
|
109
|
+
values: getValues(observation.values || [], observation.id),
|
|
110
|
+
roles: !R.isNil(observation.role) ? R.head(observation.role) : null,
|
|
111
|
+
});
|
|
112
|
+
}, attrObservations);
|
|
104
113
|
|
|
105
114
|
const datasetAttributes = R.map(
|
|
106
|
-
(attr) =>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
(attr) => {
|
|
116
|
+
const attrAnnotations = R.props(attr.annotations || [], annotations);
|
|
117
|
+
return ({
|
|
118
|
+
...attr,
|
|
119
|
+
display: !R.has(attr.id, hiddenIds) && !getIsHidden(attrAnnotations),
|
|
120
|
+
name: getLocalisedProp('names', observation),
|
|
121
|
+
values: getValues(attr.values || [], attr.id)
|
|
122
|
+
});
|
|
123
|
+
},
|
|
111
124
|
R.propOr([], 'dataSet', attributes)
|
|
112
125
|
)
|
|
113
126
|
|
|
@@ -126,10 +139,10 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
126
139
|
const getObservations = locale => R.addIndex(R.reduce)((acc, observation, obsIndex) => {
|
|
127
140
|
const id = R.prop('id')(observation);
|
|
128
141
|
const dimAnnotations = getRelationnalAnnotations(R.propOr([],'annotations')(observation))(annotations)
|
|
129
|
-
const isHidden = R.
|
|
142
|
+
const isHidden = R.has(id, hiddenIds) || getIsHidden(dimAnnotations);
|
|
130
143
|
const isTime = isTimePeriodDimension(observation);
|
|
131
144
|
|
|
132
|
-
const values = getValuesEnhanced(locale, annotations, isTime)(R.propOr([],'values', observation));
|
|
145
|
+
const values = getValuesEnhanced(locale, annotations, isTime, id)(R.propOr([],'values', observation));
|
|
133
146
|
const ids = R.pipe(R.pluck('id'), R.indexBy(R.identity))(values);
|
|
134
147
|
const groupedByParentsValues = R.groupBy(val => {
|
|
135
148
|
const parentId = R.propOr('##ROOT', 'parent', val);
|
|
@@ -158,11 +171,11 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
158
171
|
return ({
|
|
159
172
|
observation: R.append({
|
|
160
173
|
...observation,
|
|
174
|
+
display: !isHidden,
|
|
161
175
|
__index: obsIndex,
|
|
162
176
|
name: getLocalisedProp('names', observation),
|
|
163
177
|
values: sortedValues,
|
|
164
178
|
role: R.isNil(observation.roles) ? null : R.head(observation.roles),
|
|
165
|
-
...isHidden,
|
|
166
179
|
})(acc.observation),
|
|
167
180
|
dimensionsLayout: setAnnotationsLayout(id, acc.dimensionsLayout)(dimAnnotations),
|
|
168
181
|
});
|
|
@@ -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
|
};
|
package/src/rules2/src/index.js
CHANGED
|
@@ -8,3 +8,4 @@ export { parseMetadataSeries } from './parseMetadataSeries';
|
|
|
8
8
|
export { sdmx_3_0_DataFormatPatch } from './sdmx3.0DataFormatPatch';
|
|
9
9
|
export { getDataflowTooltipAttributesIds } from './getDataflowTooltipAttributesIds';
|
|
10
10
|
export { getMSDInformations } from './getMSDInformations';
|
|
11
|
+
export { getNotDisplayedIds } from './getNotDisplayedIds';
|
package/src/viewer/src/index.js
CHANGED
|
@@ -33,11 +33,11 @@ const useStyles = makeStyles(() => ({
|
|
|
33
33
|
}
|
|
34
34
|
}));
|
|
35
35
|
|
|
36
|
-
const ViewContent = ({ loading, noData = 'No Data', type, width, errorMessage, ...rest }) => {
|
|
37
|
-
if (loading) return <Loading message={loading} />;
|
|
38
|
-
if (!width) return <Loading message={loading} />;
|
|
36
|
+
const ViewContent = ({ loading, loadingProps={}, noData = 'No Data', type, width, errorMessage, ...rest }) => {
|
|
37
|
+
if (loading) return <Loading message={loading} {...loadingProps} />;
|
|
38
|
+
if (!width) return <Loading message={loading} {...loadingProps} />;
|
|
39
39
|
if (errorMessage) return <NoData message={errorMessage} />;
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
if (type === 'table') {
|
|
42
42
|
const tableProps = R.propOr({}, 'tableProps', rest);
|
|
43
43
|
const hasNoObs = R.pipe(R.prop('cells'), R.anyPass([R.isNil, R.isEmpty]))(tableProps);
|
|
@@ -60,8 +60,8 @@ const ViewContent = ({ loading, noData = 'No Data', type, width, errorMessage, .
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
const Viewer = ({ getResponsiveSize, setFooterOffset, setHeaderOffset, size, type, ...rest }) => {
|
|
63
|
-
const classes = useStyles({
|
|
64
|
-
fixedWidth: rest.fixedWidth,
|
|
63
|
+
const classes = useStyles({
|
|
64
|
+
fixedWidth: rest.fixedWidth,
|
|
65
65
|
fixedHeight: rest.fixedHeight
|
|
66
66
|
});
|
|
67
67
|
useEffect(() => {
|
|
@@ -74,7 +74,7 @@ const Viewer = ({ getResponsiveSize, setFooterOffset, setHeaderOffset, size, typ
|
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
return (
|
|
77
|
-
<div
|
|
77
|
+
<div
|
|
78
78
|
className={cx(classes.container, {
|
|
79
79
|
[classes.tableContainer]: type === 'table',
|
|
80
80
|
[classes.chartContainer]: type !== 'table'
|
|
@@ -100,7 +100,7 @@ describe('enhanceObservations tests', () => {
|
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
id: 'a4',
|
|
103
|
-
values: [{ id: 'v0' }, { id: 'v1' }],
|
|
103
|
+
values: [{ id: 'v0' }, { id: 'v1', display: false }],
|
|
104
104
|
},
|
|
105
105
|
];
|
|
106
106
|
|
|
@@ -112,7 +112,7 @@ describe('enhanceObservations tests', () => {
|
|
|
112
112
|
{ id: 'v0', __index: 0, __indexPosition: 0 },
|
|
113
113
|
{ id: 'v1', __index: 1, __indexPosition: 1 },
|
|
114
114
|
{ id: 'v2', __index: 2, __indexPosition: 2 },
|
|
115
|
-
{ id: 'v3', __index: 3, __indexPosition: 3 }
|
|
115
|
+
{ id: 'v3', __index: 3, __indexPosition: 3, display: false }
|
|
116
116
|
]
|
|
117
117
|
},
|
|
118
118
|
{
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getNotDisplayedIds } from '../src/rules2/src/getNotDisplayedIds';
|
|
3
|
+
|
|
4
|
+
describe('getNotDisplayedIds tests', () => {
|
|
5
|
+
it('not provided case', () => {
|
|
6
|
+
const annotations = [
|
|
7
|
+
{ type: 'test0' },
|
|
8
|
+
{ type: 'test1' },
|
|
9
|
+
{ type: 'NOT_DISPLAYED', title: '' },
|
|
10
|
+
{ type: 'test2' },
|
|
11
|
+
];
|
|
12
|
+
expect(getNotDisplayedIds(annotations)).to.deep.equal({});
|
|
13
|
+
});
|
|
14
|
+
it('complete case', () => {
|
|
15
|
+
const annotations = [
|
|
16
|
+
{ type: 'test0' },
|
|
17
|
+
{ type: 'test1' },
|
|
18
|
+
{ type: 'NOT_DISPLAYED', title: 'd0,d1=,d2=v0,d3=v0+,d4=v0+v1' },
|
|
19
|
+
{ type: 'test2' },
|
|
20
|
+
];
|
|
21
|
+
const expected = {
|
|
22
|
+
d0: 'd0',
|
|
23
|
+
d1: 'd1',
|
|
24
|
+
'd2.v0': 'd2.v0',
|
|
25
|
+
'd3.v0': 'd3.v0',
|
|
26
|
+
'd4.v0': 'd4.v0',
|
|
27
|
+
'd4.v1': 'd4.v1'
|
|
28
|
+
};
|
|
29
|
+
expect(getNotDisplayedIds(annotations)).to.deep.equal(expected);
|
|
30
|
+
});
|
|
31
|
+
})
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import { getOneValueDimensions } from '../src/rules/src/table/preparators/getOneValueDimensions';
|
|
3
|
-
import { getDisplay } from '../src/rules/src/preparators/getDisplay';
|
|
4
|
-
|
|
5
|
-
const noDisplayIndexes = [0, 2, 4];
|
|
6
|
-
|
|
7
|
-
const notDisplayedCodes = { '5': { id: '5' }, '6': { id: '6', values: { '6.1': '6.1' } } }
|
|
8
3
|
|
|
9
4
|
describe('getOneValueDimensions tests', () => {
|
|
10
5
|
it('no display indexes test', () => {
|
|
11
6
|
const dimensions = [
|
|
12
|
-
{ id: '0', values: [{ id: '0.1' }] },
|
|
13
|
-
{ id: '1',
|
|
14
|
-
{ id: '2',
|
|
15
|
-
{ id: '3', values: [{ id: '3.1',
|
|
16
|
-
{ id: '4', values: [{ id: '4.1',
|
|
17
|
-
{ id: '5', values: [{ id: '5.1' }] },
|
|
18
|
-
{ id: '6', values: [{ id: '6.1' }] },
|
|
7
|
+
{ id: '0', display: true, values: [{ id: '0.1', display: true }] },
|
|
8
|
+
{ id: '1', display: true, values: [{ id: '1.1', display: true }] },
|
|
9
|
+
{ id: '2', display: false, values: [{ id: '2.1', display: true }] },
|
|
10
|
+
{ id: '3', display: true, values: [{ id: '3.1', display: true }] },
|
|
11
|
+
{ id: '4', display: true, values: [{ id: '4.1', display: false }] },
|
|
12
|
+
{ id: '5', display: false, values: [{ id: '5.1', display: true }] },
|
|
13
|
+
{ id: '6', display: true, values: [{ display: false, id: '6.1' }] },
|
|
19
14
|
];
|
|
20
15
|
|
|
21
|
-
expect(getOneValueDimensions(dimensions, {}, []
|
|
16
|
+
expect(getOneValueDimensions(dimensions, {}, [])).to.deep.equal([
|
|
22
17
|
{ id: '0', display: true, values: [{ id: '0.1', attributes: {}, display: true }] },
|
|
23
|
-
{ id: '1',
|
|
24
|
-
{ id: '2',
|
|
25
|
-
{ id: '3', display: true, values: [{ id: '3.1',
|
|
26
|
-
{ id: '4', display: true, values: [{ id: '4.1',
|
|
18
|
+
{ id: '1', display: true, values: [{ id: '1.1', attributes: {}, display: true }] },
|
|
19
|
+
{ id: '2', display: false, values: [{ id: '2.1', attributes: {}, display: true }] },
|
|
20
|
+
{ id: '3', display: true, values: [{ id: '3.1', attributes: {}, display: true }] },
|
|
21
|
+
{ id: '4', display: true, values: [{ id: '4.1', attributes: {}, display: false }] },
|
|
27
22
|
{ id: '5', display: false, values: [{ id: '5.1', attributes: {}, display: true }] },
|
|
28
23
|
{ id: '6', display: true, values: [{ id: '6.1', attributes: {}, display: false }] },
|
|
29
24
|
]);
|