@sis-cc/dotstatsuite-components 15.0.9 → 15.0.11
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/table/factories/getSortedLayoutIndexes.js +2 -2
- package/lib/rules2/src/duplicateObservations.js +1 -1
- package/lib/rules2/src/getDataflowTooltipAttributesIds.js +10 -5
- package/package.json +1 -1
- package/src/rules/src/table/factories/getSortedLayoutIndexes.js +2 -2
- package/src/rules2/src/duplicateObservations.js +1 -1
- package/src/rules2/src/getDataflowTooltipAttributesIds.js +12 -6
- package/test/duplicateObs.test.js +35 -0
- package/test/getDataflowTooltipAttributesIds.test.js +52 -0
|
@@ -56,7 +56,7 @@ var comparator = function comparator(size) {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
// simple call to ramda uniq method is very slow regarding performance
|
|
59
|
+
// simple call to ramda uniq method is very slow regarding performance
|
|
60
60
|
var uniqIndexes = function uniqIndexes(indexes) {
|
|
61
61
|
return R.pipe(R.reduce(function (acc, i) {
|
|
62
62
|
var key = R.join(':', i);
|
|
@@ -71,7 +71,7 @@ var uniqIndexes = function uniqIndexes(indexes) {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
var getSortedLayoutIndexes = exports.getSortedLayoutIndexes = function getSortedLayoutIndexes(layout, observations) {
|
|
74
|
-
var dimIndexes = R.pipe(R.values, R.
|
|
74
|
+
var dimIndexes = R.pipe(R.values, R.map(R.propOr([], 'orderedDimIndexes')))(observations);
|
|
75
75
|
|
|
76
76
|
var headerLength = R.length(layout.header);
|
|
77
77
|
|
|
@@ -13,7 +13,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
13
13
|
|
|
14
14
|
var duplicateObs = exports.duplicateObs = function duplicateObs(dims, observations) {
|
|
15
15
|
var obsValues = R.values(observations);
|
|
16
|
-
if (R.length(
|
|
16
|
+
if (R.length(dims) === 0) {
|
|
17
17
|
return observations;
|
|
18
18
|
}
|
|
19
19
|
var duplicated = R.reduce(function (obs, dim) {
|
|
@@ -11,7 +11,9 @@ var R = _interopRequireWildcard(_ramda);
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
13
13
|
|
|
14
|
-
var getDataflowTooltipAttributesIds = exports.getDataflowTooltipAttributesIds = function getDataflowTooltipAttributesIds(sdmxJson
|
|
14
|
+
var getDataflowTooltipAttributesIds = exports.getDataflowTooltipAttributesIds = function getDataflowTooltipAttributesIds(sdmxJson) {
|
|
15
|
+
var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
16
|
+
|
|
15
17
|
var dataflowAnnotationsIndexes = R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson);
|
|
16
18
|
var dataflowAnnotations = R.props(dataflowAnnotationsIndexes, R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson));
|
|
17
19
|
|
|
@@ -24,10 +26,13 @@ var getDataflowTooltipAttributesIds = exports.getDataflowTooltipAttributesIds =
|
|
|
24
26
|
|
|
25
27
|
var customNotes = R.pipe(R.propOr('', 'title'), function (title) {
|
|
26
28
|
return R.isNil(title) || R.isEmpty(title) ? [] : R.split(',', title);
|
|
29
|
+
}, function (notes) {
|
|
30
|
+
return R.difference(notes, customFlags);
|
|
27
31
|
})(footnotesAttrAnnotation || {});
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
var flags = R.isNil(flagsAttrAnnotation) ? R.difference(defaults.flags || [], customNotes) : customFlags;
|
|
34
|
+
|
|
35
|
+
var notes = R.isNil(footnotesAttrAnnotation) ? R.difference(defaults.notes, flags) : customNotes;
|
|
36
|
+
|
|
37
|
+
return { flags: flags, notes: notes };
|
|
33
38
|
};
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@ const comparator = size => (a, b) => {
|
|
|
33
33
|
return a[i] - b[i];
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
// simple call to ramda uniq method is very slow regarding performance
|
|
36
|
+
// simple call to ramda uniq method is very slow regarding performance
|
|
37
37
|
const uniqIndexes = (indexes) => R.pipe(
|
|
38
38
|
R.reduce(
|
|
39
39
|
(acc, i) => {
|
|
@@ -52,7 +52,7 @@ const uniqIndexes = (indexes) => R.pipe(
|
|
|
52
52
|
)(indexes);
|
|
53
53
|
|
|
54
54
|
export const getSortedLayoutIndexes = (layout, observations) => {
|
|
55
|
-
const dimIndexes = R.pipe(R.values, R.
|
|
55
|
+
const dimIndexes = R.pipe(R.values, R.map(R.propOr([], 'orderedDimIndexes')))(observations);
|
|
56
56
|
|
|
57
57
|
const headerLength = R.length(layout.header);
|
|
58
58
|
|
|
@@ -2,7 +2,7 @@ import * as R from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
export const duplicateObs = (dims, observations) => {
|
|
4
4
|
const obsValues = R.values(observations);
|
|
5
|
-
if (
|
|
5
|
+
if (R.length(dims) === 0) {
|
|
6
6
|
return observations;
|
|
7
7
|
}
|
|
8
8
|
const duplicated = R.reduce(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
|
-
export const getDataflowTooltipAttributesIds = (sdmxJson, defaults) => {
|
|
3
|
+
export const getDataflowTooltipAttributesIds = (sdmxJson, defaults = {}) => {
|
|
4
4
|
const dataflowAnnotationsIndexes = R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson);
|
|
5
5
|
const dataflowAnnotations = R.props(dataflowAnnotationsIndexes, R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson));
|
|
6
6
|
|
|
@@ -14,12 +14,18 @@ export const getDataflowTooltipAttributesIds = (sdmxJson, defaults) => {
|
|
|
14
14
|
|
|
15
15
|
const customNotes = R.pipe(
|
|
16
16
|
R.propOr('', 'title'),
|
|
17
|
-
title => R.isNil(title) || R.isEmpty(title) ? [] : R.split(',', title)
|
|
17
|
+
title => R.isNil(title) || R.isEmpty(title) ? [] : R.split(',', title),
|
|
18
|
+
notes => R.difference(notes, customFlags)
|
|
18
19
|
)(footnotesAttrAnnotation || {});
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const flags = R.isNil(flagsAttrAnnotation)
|
|
22
|
+
? R.difference(defaults.flags || [], customNotes)
|
|
23
|
+
: customFlags;
|
|
24
|
+
|
|
25
|
+
const notes = R.isNil(footnotesAttrAnnotation)
|
|
26
|
+
? R.difference(defaults.notes, flags)
|
|
27
|
+
: customNotes;
|
|
28
|
+
|
|
29
|
+
return ({ flags, notes });
|
|
24
30
|
};
|
|
25
31
|
|
|
@@ -78,6 +78,41 @@ describe('duplicate obs tests', () => {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
expect(duplicateObs(dims, obs)).to.deep.equal(expected);
|
|
82
|
+
});
|
|
83
|
+
it('handle uniq observation case', () => {
|
|
84
|
+
const dims = [{
|
|
85
|
+
id: 'REF_AREA',
|
|
86
|
+
__index: 2,
|
|
87
|
+
values: [
|
|
88
|
+
{ id: 'W' },
|
|
89
|
+
{ id: 'OECD' },
|
|
90
|
+
{ id: 'FRA' },
|
|
91
|
+
{ id: 'GER' },
|
|
92
|
+
{ id: 'EA' },
|
|
93
|
+
{ id: 'GER' },
|
|
94
|
+
{ id: 'FRA' },
|
|
95
|
+
]
|
|
96
|
+
}];
|
|
97
|
+
const obs = {
|
|
98
|
+
'0:0:0': {
|
|
99
|
+
indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
|
|
100
|
+
dimValuesIndexes: [0, 0, 0],
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const expected = {
|
|
104
|
+
'0:0:2': {
|
|
105
|
+
indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
|
|
106
|
+
orderedDimIndexes: [0, 0, 2],
|
|
107
|
+
dimValuesIndexes: [0, 0, 0],
|
|
108
|
+
},
|
|
109
|
+
'0:0:6': {
|
|
110
|
+
indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
|
|
111
|
+
orderedDimIndexes: [0, 0, 6],
|
|
112
|
+
dimValuesIndexes: [0, 0, 0],
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
81
116
|
expect(duplicateObs(dims, obs)).to.deep.equal(expected);
|
|
82
117
|
});
|
|
83
118
|
});
|
|
@@ -87,4 +87,56 @@ describe('getDataflowTooltipAttributesIds tests', () => {
|
|
|
87
87
|
|
|
88
88
|
expect(getDataflowTooltipAttributesIds({ data }, def)).to.deep.equal({ flags: ['f2', 'f3'], notes: [] });
|
|
89
89
|
});
|
|
90
|
+
it('custom flags overrides default notes', () => {
|
|
91
|
+
const defaultIds = {
|
|
92
|
+
flags: [],
|
|
93
|
+
notes: ['ATTR0', 'ATTR1']
|
|
94
|
+
};
|
|
95
|
+
const data = {
|
|
96
|
+
dataSets: [{
|
|
97
|
+
annotations: [0]
|
|
98
|
+
}],
|
|
99
|
+
structure: {
|
|
100
|
+
annotations: [
|
|
101
|
+
{ id: 'annot0', type: 'LAYOUT_FLAG', title: 'ATTR0,ATTR1' },
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
expect(getDataflowTooltipAttributesIds({ data }, defaultIds)).to.deep.equal({ flags: ['ATTR0', 'ATTR1'], notes: [] });
|
|
106
|
+
});
|
|
107
|
+
it('custom notes overrides default flags', () => {
|
|
108
|
+
const defaultIds = {
|
|
109
|
+
flags: ['ATTR0', 'ATTR1'],
|
|
110
|
+
notes: ['ATTR2', 'ATTR3']
|
|
111
|
+
};
|
|
112
|
+
const data = {
|
|
113
|
+
dataSets: [{
|
|
114
|
+
annotations: [0]
|
|
115
|
+
}],
|
|
116
|
+
structure: {
|
|
117
|
+
annotations: [
|
|
118
|
+
{ id: 'annot0', type: 'LAYOUT_NOTE', title: 'ATTR1,ATTR2' },
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
expect(getDataflowTooltipAttributesIds({ data }, defaultIds)).to.deep.equal({ flags: ['ATTR0'], notes: ['ATTR1', 'ATTR2'] });
|
|
123
|
+
});
|
|
124
|
+
it('custom flags overrides custom notes', () => {
|
|
125
|
+
const defaultIds = {
|
|
126
|
+
flags: [],
|
|
127
|
+
notes: []
|
|
128
|
+
};
|
|
129
|
+
const data = {
|
|
130
|
+
dataSets: [{
|
|
131
|
+
annotations: [0, 1]
|
|
132
|
+
}],
|
|
133
|
+
structure: {
|
|
134
|
+
annotations: [
|
|
135
|
+
{ id: 'annot0', type: 'LAYOUT_FLAG', title: 'ATTR0,ATTR1' },
|
|
136
|
+
{ id: 'annot1', type: 'LAYOUT_NOTE', title: 'ATTR1,ATTR2' },
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
expect(getDataflowTooltipAttributesIds({ data }, defaultIds)).to.deep.equal({ flags: ['ATTR0', 'ATTR1'], notes: ['ATTR2'] });
|
|
141
|
+
});
|
|
90
142
|
});
|