@sis-cc/dotstatsuite-components 17.25.0 → 17.26.1
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/layout.js +12 -3
- package/lib/rules2/src/parseAttributes.js +1 -1
- package/lib/rules2/src/table/getCells.js +1 -1
- package/package.json +1 -1
- package/src/rules/src/layout.js +11 -4
- package/src/rules2/src/parseAttributes.js +1 -1
- package/src/rules2/src/table/getCells.js +1 -1
- package/test/getCells.test.js +37 -0
- package/test/isTableLayoutCompatible.test.js +28 -1
- package/test/parseAttributes.test.js +3 -0
package/lib/rules/src/layout.js
CHANGED
|
@@ -16,13 +16,19 @@ var _src = require('../../rules2/src');
|
|
|
16
16
|
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; } }
|
|
17
17
|
|
|
18
18
|
var isTableLayoutCompatible = function isTableLayoutCompatible(data, layout) {
|
|
19
|
-
var
|
|
19
|
+
var combinationsDefinitions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
20
|
+
var dataquery = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
|
|
20
21
|
|
|
21
22
|
var multiValuesDimensions = R.pipe(R.pathOr([], ['structure', 'dimensions', 'observation']), function (dimensions) {
|
|
22
23
|
return (0, _src.refineDimensions)(dimensions, dataquery);
|
|
23
24
|
}, R.reject(function (d) {
|
|
24
25
|
return R.prop('header', d) || !R.length(d.values || []);
|
|
25
|
-
}), R.pluck('id')
|
|
26
|
+
}), R.pluck('id'), R.map(function (d) {
|
|
27
|
+
var conceptId = R.find(function (comb) {
|
|
28
|
+
return R.includes(d, R.propOr([], 'concepts', comb));
|
|
29
|
+
})(combinationsDefinitions);
|
|
30
|
+
return conceptId ? conceptId.id : d;
|
|
31
|
+
}))(data);
|
|
26
32
|
var dimensionsInLayout = R.pipe(R.values, R.unnest)(layout);
|
|
27
33
|
|
|
28
34
|
var dimensionsLength = R.length(multiValuesDimensions);
|
|
@@ -72,7 +78,10 @@ var isSharedLayoutCompatible = exports.isSharedLayoutCompatible = function isSha
|
|
|
72
78
|
if (type === 'table') {
|
|
73
79
|
var layoutIds = R.pathOr({}, ['config', 'table', 'layoutIds'], sharedData);
|
|
74
80
|
var dataquery = R.path(['config', 'sdmxSource', 'dataquery'], sharedData);
|
|
75
|
-
|
|
81
|
+
var annotations = R.pathOr({}, ['structure', 'annotations'], sdmxData);
|
|
82
|
+
var locale = R.pathOr({}, ['config', 'table', 'locale'], sharedData);
|
|
83
|
+
var combinationsDefinitions = (0, _src.getCombinationDefinitions)(annotations, locale);
|
|
84
|
+
return isTableLayoutCompatible(sdmxData, layoutIds, combinationsDefinitions, dataquery);
|
|
76
85
|
}
|
|
77
86
|
var chartDimension = R.pathOr({}, ['config', 'chart', 'chartDimension'], sharedData);
|
|
78
87
|
return isChartLayoutCompatible(sdmxData, type, chartDimension);
|
|
@@ -40,7 +40,7 @@ var parseAttributes = exports.parseAttributes = function parseAttributes(attribu
|
|
|
40
40
|
}
|
|
41
41
|
var seriesDimensions = R.pipe(R.pathOr([], ['relationship', 'dimensions']), R.filter(function (id) {
|
|
42
42
|
var dimension = R.prop(id, indexedDimensions);
|
|
43
|
-
return !dimension.header;
|
|
43
|
+
return !dimension.header && R.length(dimension.values || []) > 1;
|
|
44
44
|
}))(attr);
|
|
45
45
|
if (R.length(seriesDimensions) > 0) {
|
|
46
46
|
return (0, _extends3.default)({}, res, { series: true, relationship: seriesDimensions });
|
|
@@ -61,7 +61,7 @@ var getCells = exports.getCells = function getCells(customAttributes, cellsAttri
|
|
|
61
61
|
var attributesInCellsCombination = R.pipe(R.propOr([], 'cells'), R.pluck('concepts'), R.unnest)(combinations);
|
|
62
62
|
|
|
63
63
|
var _customAttributes = R.over(R.lensProp('notes'), function (notes) {
|
|
64
|
-
return R.concat(notes || [], attributesInLayoutCombination);
|
|
64
|
+
return R.pipe(R.concat, R.uniq)(notes || [], attributesInLayoutCombination);
|
|
65
65
|
})(customAttributes);
|
|
66
66
|
|
|
67
67
|
return R.mapObjIndexed(function (obs) {
|
package/package.json
CHANGED
package/src/rules/src/layout.js
CHANGED
|
@@ -6,14 +6,18 @@ import {
|
|
|
6
6
|
STACKED_ROW,
|
|
7
7
|
V_SYMBOL
|
|
8
8
|
} from './constants';
|
|
9
|
-
import { refineDimensions } from '../../rules2/src';
|
|
9
|
+
import { getCombinationDefinitions, refineDimensions } from '../../rules2/src';
|
|
10
10
|
|
|
11
|
-
const isTableLayoutCompatible = (data, layout, dataquery='') => {
|
|
11
|
+
const isTableLayoutCompatible = (data, layout, combinationsDefinitions = [], dataquery = '') => {
|
|
12
12
|
const multiValuesDimensions = R.pipe(
|
|
13
13
|
R.pathOr([], ['structure', 'dimensions', 'observation']),
|
|
14
14
|
dimensions => refineDimensions(dimensions, dataquery),
|
|
15
15
|
R.reject(d => R.prop('header', d) || !R.length(d.values || [])),
|
|
16
|
-
R.pluck('id')
|
|
16
|
+
R.pluck('id'),
|
|
17
|
+
R.map(d => {
|
|
18
|
+
const conceptId = R.find(comb => R.includes(d, R.propOr([], 'concepts', comb)))(combinationsDefinitions)
|
|
19
|
+
return conceptId ? conceptId.id : d
|
|
20
|
+
}),
|
|
17
21
|
)(data);
|
|
18
22
|
const dimensionsInLayout = R.pipe(R.values, R.unnest)(layout);
|
|
19
23
|
|
|
@@ -85,7 +89,10 @@ export const isSharedLayoutCompatible = (sdmxData, sharedData) => {
|
|
|
85
89
|
if (type === 'table') {
|
|
86
90
|
const layoutIds = R.pathOr({}, ['config', 'table', 'layoutIds'], sharedData);
|
|
87
91
|
const dataquery = R.path(['config', 'sdmxSource', 'dataquery'], sharedData);
|
|
88
|
-
|
|
92
|
+
const annotations = R.pathOr({}, ['structure', 'annotations'], sdmxData)
|
|
93
|
+
const locale = R.pathOr({}, ['config', 'table', 'locale'], sharedData)
|
|
94
|
+
const combinationsDefinitions = getCombinationDefinitions(annotations, locale)
|
|
95
|
+
return isTableLayoutCompatible(sdmxData, layoutIds, combinationsDefinitions, dataquery);
|
|
89
96
|
}
|
|
90
97
|
const chartDimension = R.pathOr({}, ['config', 'chart', 'chartDimension'], sharedData);
|
|
91
98
|
return isChartLayoutCompatible(sdmxData, type, chartDimension);
|
|
@@ -25,7 +25,7 @@ export const parseAttributes = (attributes, dimensions, customAttributes) => {
|
|
|
25
25
|
R.pathOr([], ['relationship', 'dimensions']),
|
|
26
26
|
R.filter(id => {
|
|
27
27
|
const dimension = R.prop(id, indexedDimensions);
|
|
28
|
-
return !dimension.header;
|
|
28
|
+
return !dimension.header && R.length(dimension.values || []) > 1;
|
|
29
29
|
}),
|
|
30
30
|
)(attr);
|
|
31
31
|
if (R.length(seriesDimensions) > 0) {
|
|
@@ -57,7 +57,7 @@ export const getCells = (customAttributes, cellsAttributesId, combinations, attr
|
|
|
57
57
|
|
|
58
58
|
const _customAttributes = R.over(
|
|
59
59
|
R.lensProp('notes'),
|
|
60
|
-
notes => R.concat(notes || [], attributesInLayoutCombination)
|
|
60
|
+
notes => R.pipe(R.concat, R.uniq)(notes || [], attributesInLayoutCombination)
|
|
61
61
|
)(customAttributes);
|
|
62
62
|
|
|
63
63
|
return R.mapObjIndexed(
|
package/test/getCells.test.js
CHANGED
|
@@ -78,4 +78,41 @@ describe('getCells tests', () => {
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
|
+
it('duplication between notes and combinations definitions', () => {
|
|
82
|
+
const _customAttributes = {
|
|
83
|
+
flags: [],
|
|
84
|
+
notes: ['A1', 'A2']
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const combinations = {
|
|
88
|
+
cells: [],
|
|
89
|
+
layout: [{ id: 'LAYOUT_COMB', concepts: ['D1', 'A1'] }]
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const attributesSeries = { 'D1=V0': {} };
|
|
93
|
+
|
|
94
|
+
const cellsAttributesIds = ['A2'];
|
|
95
|
+
|
|
96
|
+
const observations = {
|
|
97
|
+
'obs': {
|
|
98
|
+
value: 'val',
|
|
99
|
+
formattedValue: 'val',
|
|
100
|
+
attributes: {
|
|
101
|
+
A1: { id: 'A1', value: { id: 'A1V' }, serieKey: 'D1=V0' },
|
|
102
|
+
A2: { id: 'A2', value: { id: 'A2V' } },
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
expect(getCells(_customAttributes, cellsAttributesIds, combinations, attributesSeries, [])(observations)).to.deep.equal({
|
|
107
|
+
'obs': {
|
|
108
|
+
value: 'val',
|
|
109
|
+
intValue: null,
|
|
110
|
+
sideProps: null,
|
|
111
|
+
flags: [
|
|
112
|
+
{ id: 'A1', value: { id: 'A1V' } },
|
|
113
|
+
{ id: 'A2', value: { id: 'A2V' } }
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
81
118
|
});
|
|
@@ -11,7 +11,30 @@ const sdmxData = {
|
|
|
11
11
|
{ id: 'd3', values: [{ id: 'v1' }] },
|
|
12
12
|
{ id: 'd4', values: [] },
|
|
13
13
|
]
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const sdmxData2 = {
|
|
18
|
+
structure: {
|
|
19
|
+
dimensions: {
|
|
20
|
+
observation: [
|
|
21
|
+
{ id: 'd0', values: [{ id: 'v1' }, { id: 'v2' }] },
|
|
22
|
+
{ id: 'd1', values: [{ id: 'v1' }, { id: 'v2' }, { id: 'v3' }] },
|
|
23
|
+
{ id: 'd2', values: [{ id: 'v1' }, { id: 'v2' }] },
|
|
24
|
+
{ id: 'd3', values: [{ id: 'v1' }] },
|
|
25
|
+
{ id: 'd4', values: [] },
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
annotations: [
|
|
29
|
+
{
|
|
30
|
+
title: "d6:d1,d3,d4",
|
|
31
|
+
type: "COMBINED_CONCEPTS",
|
|
32
|
+
text: "d6:Combined unit of measure",
|
|
33
|
+
texts: {
|
|
34
|
+
en: "d6:Combined unit of measure"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
15
38
|
}
|
|
16
39
|
}
|
|
17
40
|
|
|
@@ -20,6 +43,10 @@ describe('isSharedLayoutCompatible', () => {
|
|
|
20
43
|
const layoutIds = { rows: ['d0'], sections: ['d1'], header: ['d2'] };
|
|
21
44
|
expect(isSharedLayoutCompatible(sdmxData, { type: 'table', config: { table: { layoutIds } } })).to.equal(true);
|
|
22
45
|
});
|
|
46
|
+
it('table compatible test combined', () => {
|
|
47
|
+
const layoutIds = { rows: ['d0'], sections: ['d6'], header: ['d2'] };
|
|
48
|
+
expect(isSharedLayoutCompatible(sdmxData2, { type: 'table', config: { table: { layoutIds, locale: 'en' } } })).to.equal(true);
|
|
49
|
+
});
|
|
23
50
|
it('table incompatible absent dimension in multi dims test', () => {
|
|
24
51
|
const layoutIds = { rows: ['d0', 'd3'], sections: ['d1'], header: ['d2'] };
|
|
25
52
|
expect(isSharedLayoutCompatible(sdmxData, { type: 'table', config: { table: { layoutIds } } })).to.equal(false);
|
|
@@ -7,6 +7,7 @@ const attributes = [
|
|
|
7
7
|
{ id: 'a9', relationship: { dimensions: ['d4'] }, values: [{ id: 'a9v1' }] }, // single 'many values' dimension relationship
|
|
8
8
|
{ id: 'a10', relationship: { dimensions: ['d1', 'd2'] }, values: [{ id: 'a10v1' }] }, // many 'single value' dimensions realtionship
|
|
9
9
|
{ id: 'a11', relationship: { dimensions: ['d1', 'd2', 'd4'] }, values: [{ id: 'a11v1' }] }, // one 'many values' and many 'single value' dimensions relationship
|
|
10
|
+
{ id: 'a12', relationship: { dimensions: ['d4', 'd5', 'd7'] }, values: [{ id: 'a11v1' }] }, // exclude empty dimension from relationship
|
|
10
11
|
];
|
|
11
12
|
|
|
12
13
|
const customAttributes = {};
|
|
@@ -18,6 +19,7 @@ const dimensions = [
|
|
|
18
19
|
{ id: 'd4', header: false, values: [{ id: 'v0' }, { id: 'v1' }] },
|
|
19
20
|
{ id: 'd5', header: false, values: [{ id: 'v0' }, { id: 'v1' }] },
|
|
20
21
|
{ id: 'd6', header: false, values: [{ id: 'v0' }, { id: 'v1' }] },
|
|
22
|
+
{ id: 'd7', header: false, values: [] }
|
|
21
23
|
];
|
|
22
24
|
|
|
23
25
|
describe('parseAttributes test', () => {
|
|
@@ -28,6 +30,7 @@ describe('parseAttributes test', () => {
|
|
|
28
30
|
{ id: 'a9', index: 2, relationship: ['d4'], series: true, values: [{ id: 'a9v1' }] },
|
|
29
31
|
{ id: 'a10', index: 3, relationship: ['d1', 'd2'], header: true, values: [{ id: 'a10v1' }] },
|
|
30
32
|
{ id: 'a11', index: 4, relationship: ['d4'], series: true, values: [{ id: 'a11v1' }] },
|
|
33
|
+
{ id: 'a12', index: 5, relationship: ['d4', 'd5'], series: true, values: [{ id: 'a11v1' }] },
|
|
31
34
|
]);
|
|
32
35
|
});
|
|
33
36
|
});
|