@sis-cc/dotstatsuite-components 16.2.0 → 16.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/rules2/src/getHeaderCombinations.js +18 -6
- package/lib/rules2/src/getSeriesCombinations.js +33 -0
- package/lib/rules2/src/index.js +9 -0
- package/lib/rules2/src/table/getCells.js +15 -8
- package/lib/rules2/src/table/getLayout.js +4 -11
- package/lib/rules2/src/table/getTableProps.js +4 -2
- package/package.json +1 -1
- package/src/rules2/src/getHeaderCombinations.js +31 -16
- package/src/rules2/src/getSeriesCombinations.js +24 -0
- package/src/rules2/src/index.js +1 -0
- package/src/rules2/src/table/getCells.js +19 -7
- package/src/rules2/src/table/getLayout.js +1 -12
- package/src/rules2/src/table/getTableProps.js +3 -2
- package/test/getCells.test.js +44 -3
- package/test/getLayout.test.js +42 -0
- package/test/getSeriesCombinations.test.js +29 -0
|
@@ -23,20 +23,32 @@ var getHeaderCombinations = exports.getHeaderCombinations = function getHeaderCo
|
|
|
23
23
|
|
|
24
24
|
var header = (0, _src.dimensionValueDisplay)(display)(comb);
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var combinedDisplay = function combinedDisplay(_display, values) {
|
|
27
|
+
if (_display === 'label') {
|
|
28
|
+
return R.pipe(R.filter(R.propOr(true, 'display')), R.map((0, _src.dimensionValueDisplay)(_display)), R.join(', '))(values);
|
|
29
|
+
}
|
|
30
|
+
return R.pipe(R.map((0, _src.dimensionValueDisplay)(_display)), R.join(', '))(values);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var label = R.pipe(R.reduce(function (_acc, concept) {
|
|
27
34
|
var artefact = R.has(concept, indexedDimensions) ? R.prop(concept, indexedDimensions) : R.prop(concept, indexedAttributes);
|
|
28
35
|
if (R.isNil(artefact) || !R.propOr(true, 'display', artefact || {})) {
|
|
29
36
|
return _acc;
|
|
30
37
|
}
|
|
31
38
|
var value = R.path(['values', 0], artefact);
|
|
32
|
-
if (R.isNil(value)
|
|
39
|
+
if (R.isNil(value)) {
|
|
33
40
|
return _acc;
|
|
34
41
|
}
|
|
35
|
-
return R.append(
|
|
36
|
-
}, []),
|
|
37
|
-
|
|
42
|
+
return R.append(value, _acc);
|
|
43
|
+
}, []), function (values) {
|
|
44
|
+
if (display === 'both') {
|
|
45
|
+
return '(' + combinedDisplay('code', values) + ') ' + combinedDisplay('label', values);
|
|
46
|
+
}
|
|
47
|
+
return combinedDisplay(display, values);
|
|
48
|
+
})(comb.concepts || []);
|
|
49
|
+
if (R.isEmpty(label)) {
|
|
38
50
|
return acc;
|
|
39
51
|
}
|
|
40
|
-
return R.append({ header: header, label:
|
|
52
|
+
return R.append({ header: header, label: label }, acc);
|
|
41
53
|
}, [], combinations);
|
|
42
54
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSeriesCombinations = undefined;
|
|
7
|
+
|
|
8
|
+
var _extends2 = require('babel-runtime/helpers/extends');
|
|
9
|
+
|
|
10
|
+
var _extends3 = _interopRequireDefault(_extends2);
|
|
11
|
+
|
|
12
|
+
var _ramda = require('ramda');
|
|
13
|
+
|
|
14
|
+
var R = _interopRequireWildcard(_ramda);
|
|
15
|
+
|
|
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
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
var getSeriesCombinations = exports.getSeriesCombinations = function getSeriesCombinations(combinations, oneValuesDimensions) {
|
|
21
|
+
var indexedValues = R.reduce(function (acc, dim) {
|
|
22
|
+
var value = R.head(dim.values);
|
|
23
|
+
return R.assoc(dim.id, value, acc);
|
|
24
|
+
}, {}, oneValuesDimensions);
|
|
25
|
+
|
|
26
|
+
return R.reduce(function (acc, comb) {
|
|
27
|
+
if (!R.prop('series', comb)) {
|
|
28
|
+
return acc;
|
|
29
|
+
}
|
|
30
|
+
var fixedDimValues = R.pick(comb.concepts, indexedValues);
|
|
31
|
+
return R.append((0, _extends3.default)({}, comb, { fixedDimValues: fixedDimValues }), acc);
|
|
32
|
+
}, [], combinations);
|
|
33
|
+
};
|
package/lib/rules2/src/index.js
CHANGED
|
@@ -247,6 +247,15 @@ Object.defineProperty(exports, 'getHeaderSubtitle', {
|
|
|
247
247
|
}
|
|
248
248
|
});
|
|
249
249
|
|
|
250
|
+
var _getSeriesCombinations = require('./getSeriesCombinations');
|
|
251
|
+
|
|
252
|
+
Object.defineProperty(exports, 'getSeriesCombinations', {
|
|
253
|
+
enumerable: true,
|
|
254
|
+
get: function get() {
|
|
255
|
+
return _getSeriesCombinations.getSeriesCombinations;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
250
259
|
var _getHeaderCombinations = require('./getHeaderCombinations');
|
|
251
260
|
|
|
252
261
|
Object.defineProperty(exports, 'getHeaderCombinations', {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getCells = exports.
|
|
6
|
+
exports.getCells = exports.getCellCombinedSeries = exports.getCellRelevantAttributes = undefined;
|
|
7
7
|
|
|
8
8
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
9
9
|
|
|
@@ -17,8 +17,6 @@ var _getFlagsAndNotes = require('./getFlagsAndNotes');
|
|
|
17
17
|
|
|
18
18
|
var _hasCellMetadata = require('../hasCellMetadata');
|
|
19
19
|
|
|
20
|
-
var _utils = require('../utils');
|
|
21
|
-
|
|
22
20
|
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; } }
|
|
23
21
|
|
|
24
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -36,13 +34,22 @@ var getCellRelevantAttributes = exports.getCellRelevantAttributes = function get
|
|
|
36
34
|
}, attributes);
|
|
37
35
|
};
|
|
38
36
|
|
|
39
|
-
var
|
|
37
|
+
var getCellCombinedSeries = exports.getCellCombinedSeries = function getCellCombinedSeries(attributes, combinations) {
|
|
40
38
|
return R.reduce(function (acc, comb) {
|
|
41
|
-
var values = (
|
|
39
|
+
var values = R.reduce(function (acc, concept) {
|
|
40
|
+
if (R.has(concept, comb.fixedDimValues || {})) {
|
|
41
|
+
return R.append(R.prop(concept, comb.fixedDimValues), acc);
|
|
42
|
+
}
|
|
43
|
+
if (R.has(concept, attributes || {})) {
|
|
44
|
+
return R.append(R.path([concept, 'value'], attributes), acc);
|
|
45
|
+
}
|
|
46
|
+
return acc;
|
|
47
|
+
}, [], comb.concepts);
|
|
48
|
+
|
|
42
49
|
if (R.isEmpty(values)) {
|
|
43
50
|
return acc;
|
|
44
51
|
}
|
|
45
|
-
return R.append((0, _extends3.default)({}, R.pick(['id', 'name'], comb), { values:
|
|
52
|
+
return R.append((0, _extends3.default)({}, R.pick(['id', 'name'], comb), { values: values }), acc);
|
|
46
53
|
}, [], combinations);
|
|
47
54
|
};
|
|
48
55
|
|
|
@@ -60,13 +67,13 @@ var getCells = exports.getCells = function getCells(customAttributes, cellsAttri
|
|
|
60
67
|
return R.mapObjIndexed(function (obs) {
|
|
61
68
|
var relevantAttributes = getCellRelevantAttributes(obs.attributes, attributesSeries, cellsAttributesId);
|
|
62
69
|
var flagsAndNotes = (0, _getFlagsAndNotes.getFlagsAndNotes)(R.omit(attributesInCellsCombination, relevantAttributes), _customAttributes);
|
|
63
|
-
var
|
|
70
|
+
var combinedSeries = getCellCombinedSeries(relevantAttributes, combinations.cells || []);
|
|
64
71
|
var hasAdvancedAttributes = R.pipe(R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination])), R.isEmpty, R.not)(relevantAttributes);
|
|
65
72
|
|
|
66
73
|
var hasMetadata = (0, _hasCellMetadata.hasCellMetadata)(metadataCoordinates, obs.indexedDimValIds);
|
|
67
74
|
|
|
68
75
|
return (0, _extends3.default)({}, R.pick(['indexedDimValIds', 'key'], obs), {
|
|
69
|
-
flags: R.concat(flagsAndNotes,
|
|
76
|
+
flags: R.concat(flagsAndNotes, combinedSeries),
|
|
70
77
|
sideProps: hasAdvancedAttributes || hasMetadata ? { hasAdvancedAttributes: hasAdvancedAttributes, hasMetadata: hasMetadata, coordinates: obs.indexedDimValIds } : null,
|
|
71
78
|
intValue: R.is(Number, obs.value) ? obs.value : null,
|
|
72
79
|
value: obs.formattedValue
|
|
@@ -25,14 +25,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
25
25
|
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
27
|
|
|
28
|
-
var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, combinations, isTimeInverted
|
|
28
|
+
var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, combinations, isTimeInverted) {
|
|
29
29
|
var indexedDimensions = R.pipe(R.indexBy(R.prop('id')), R.map(function (d) {
|
|
30
30
|
return (0, _dotstatsuiteSdmxjs.isTimePeriodDimension)(d) && isTimeInverted ? R.assoc('isInverted', true, d) : d;
|
|
31
31
|
}))(dimensions);
|
|
32
|
-
var indexedFixedDimsValues = R.reduce(function (acc, dim) {
|
|
33
|
-
var value = R.head(dim.values);
|
|
34
|
-
return !dim.display ? acc : R.assoc(dim.id, R.head(dim.values), acc);
|
|
35
|
-
}, {}, fixedDimensions);
|
|
36
32
|
var indexedHeaderIds = R.indexBy(R.identity, layoutIds.header);
|
|
37
33
|
var indexedSectionsIds = R.indexBy(R.identity, layoutIds.sections);
|
|
38
34
|
var indexedRowsIds = (0, _extends3.default)({}, indexedSectionsIds, R.indexBy(R.identity, layoutIds.rows));
|
|
@@ -51,8 +47,7 @@ var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, co
|
|
|
51
47
|
|
|
52
48
|
if (R.isEmpty(rest)) {
|
|
53
49
|
layout = R.over(R.lensProp('header'), R.append((0, _extends3.default)({}, comb, {
|
|
54
|
-
dimensions: (0, _utils.trimedProps)(comb.concepts, indexedDimensions)
|
|
55
|
-
fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues)
|
|
50
|
+
dimensions: (0, _utils.trimedProps)(comb.concepts, indexedDimensions)
|
|
56
51
|
})))(layout);
|
|
57
52
|
} else if (!R.isEmpty(idsInHeader)) {
|
|
58
53
|
return;
|
|
@@ -62,8 +57,7 @@ var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, co
|
|
|
62
57
|
}, comb.relationship);
|
|
63
58
|
if (R.isEmpty(idsNotInSections)) {
|
|
64
59
|
layout = R.over(R.lensProp('sections'), R.append((0, _extends3.default)({}, comb, {
|
|
65
|
-
dimensions: (0, _utils.trimedProps)(comb.concepts, indexedDimensions)
|
|
66
|
-
fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues)
|
|
60
|
+
dimensions: (0, _utils.trimedProps)(comb.concepts, indexedDimensions)
|
|
67
61
|
})))(layout);
|
|
68
62
|
} else {
|
|
69
63
|
var idsNotInRows = R.reject(function (id) {
|
|
@@ -73,8 +67,7 @@ var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, co
|
|
|
73
67
|
layout = R.over(R.lensProp('rows'), R.append((0, _extends3.default)({}, comb, {
|
|
74
68
|
dimensions: R.pipe(R.omit(layoutIds.sections), function (o) {
|
|
75
69
|
return (0, _utils.trimedProps)(comb.concepts, o);
|
|
76
|
-
})(indexedDimensions)
|
|
77
|
-
fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues)
|
|
70
|
+
})(indexedDimensions)
|
|
78
71
|
})))(layout);
|
|
79
72
|
}
|
|
80
73
|
}
|
|
@@ -29,6 +29,8 @@ var _getCells = require('./getCells');
|
|
|
29
29
|
|
|
30
30
|
var _getCuratedCells = require('./getCuratedCells');
|
|
31
31
|
|
|
32
|
+
var _getSeriesCombinations = require('../getSeriesCombinations');
|
|
33
|
+
|
|
32
34
|
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; } }
|
|
33
35
|
|
|
34
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -48,8 +50,8 @@ var getTableProps = exports.getTableProps = function getTableProps(_ref) {
|
|
|
48
50
|
attributes = data.attributes;
|
|
49
51
|
|
|
50
52
|
|
|
51
|
-
var seriesCombinations =
|
|
52
|
-
var layout = (0, _getLayout.getLayout)(layoutIds, dimensions, seriesCombinations, isTimeInverted
|
|
53
|
+
var seriesCombinations = (0, _getSeriesCombinations.getSeriesCombinations)(combinations, oneValueDimensions);
|
|
54
|
+
var layout = (0, _getLayout.getLayout)(layoutIds, dimensions, seriesCombinations, isTimeInverted);
|
|
53
55
|
var layoutIndexes = (0, _getSortedLayoutIndexes.getSortedLayoutIndexes)(layout, observations);
|
|
54
56
|
var refinedLayoutIndexes = (0, _refineLayoutSize.refineLayoutSize)({ layout: layout, observations: observations, limit: limit })(layoutIndexes);
|
|
55
57
|
var layoutData = (0, _getLayoutData.getLayoutData)(refinedLayoutIndexes, layout, { metadataCoordinates: metadataCoordinates, attributesSeries: attributesSeries, customAttributes: customAttributes });
|
package/package.json
CHANGED
|
@@ -12,26 +12,41 @@ export const getHeaderCombinations = (combinations, dimensions, attributes, disp
|
|
|
12
12
|
|
|
13
13
|
const header = dimensionValueDisplay(display)(comb);
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
const combinedDisplay = (_display, values) => {
|
|
16
|
+
if (_display === 'label') {
|
|
17
|
+
return R.pipe(R.filter(R.propOr(true, 'display')), R.map(dimensionValueDisplay(_display)), R.join(', '))(values);
|
|
18
|
+
}
|
|
19
|
+
return R.pipe(R.map(dimensionValueDisplay(_display)), R.join(', '))(values);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const label = R.pipe(
|
|
23
|
+
R.reduce(
|
|
24
|
+
(_acc, concept) => {
|
|
25
|
+
const artefact = R.has(concept, indexedDimensions)
|
|
26
|
+
? R.prop(concept, indexedDimensions)
|
|
27
|
+
: R.prop(concept, indexedAttributes);
|
|
28
|
+
if (R.isNil(artefact) || !R.propOr(true, 'display', artefact || {})) {
|
|
29
|
+
return _acc;
|
|
30
|
+
}
|
|
31
|
+
const value = R.path(['values', 0], artefact);
|
|
32
|
+
if (R.isNil(value)) {
|
|
33
|
+
return _acc;
|
|
34
|
+
}
|
|
35
|
+
return R.append(value, _acc);
|
|
36
|
+
},
|
|
37
|
+
[]
|
|
38
|
+
),
|
|
39
|
+
values => {
|
|
40
|
+
if (display === 'both') {
|
|
41
|
+
return `(${combinedDisplay('code', values)}) ${combinedDisplay('label', values)}`
|
|
26
42
|
}
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
R.join(', '),
|
|
43
|
+
return combinedDisplay(display, values);
|
|
44
|
+
}
|
|
30
45
|
)(comb.concepts || []);
|
|
31
|
-
if (R.isEmpty(
|
|
46
|
+
if (R.isEmpty(label)) {
|
|
32
47
|
return acc;
|
|
33
48
|
}
|
|
34
|
-
return R.append({ header, label
|
|
49
|
+
return R.append({ header, label }, acc);
|
|
35
50
|
},
|
|
36
51
|
[],
|
|
37
52
|
combinations,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const getSeriesCombinations = (combinations, oneValuesDimensions) => {
|
|
4
|
+
const indexedValues = R.reduce(
|
|
5
|
+
(acc, dim) => {
|
|
6
|
+
const value = R.head(dim.values);
|
|
7
|
+
return R.assoc(dim.id, value, acc);
|
|
8
|
+
},
|
|
9
|
+
{},
|
|
10
|
+
oneValuesDimensions
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
return R.reduce(
|
|
14
|
+
(acc, comb) => {
|
|
15
|
+
if (!R.prop('series', comb)) {
|
|
16
|
+
return acc;
|
|
17
|
+
}
|
|
18
|
+
const fixedDimValues = R.pick(comb.concepts, indexedValues);
|
|
19
|
+
return R.append({ ...comb, fixedDimValues }, acc);
|
|
20
|
+
},
|
|
21
|
+
[],
|
|
22
|
+
combinations
|
|
23
|
+
);
|
|
24
|
+
};
|
package/src/rules2/src/index.js
CHANGED
|
@@ -28,6 +28,7 @@ export { getOneValueDimensions } from './getOneValueDimensions';
|
|
|
28
28
|
export { getDataflowAttributes } from './getDataflowAttributes';
|
|
29
29
|
export { getHeaderTitle } from './getHeaderTitle';
|
|
30
30
|
export { getHeaderSubtitle } from './getHeaderSubtitle';
|
|
31
|
+
export { getSeriesCombinations } from './getSeriesCombinations';
|
|
31
32
|
export { getHeaderCombinations } from './getHeaderCombinations';
|
|
32
33
|
export { getLayout } from './table/getLayout';
|
|
33
34
|
export { getSortedLayoutIndexes } from './table/getSortedLayoutIndexes';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import { getFlagsAndNotes } from './getFlagsAndNotes';
|
|
3
3
|
import { hasCellMetadata } from '../hasCellMetadata';
|
|
4
|
-
import { trimedProps } from '../utils';
|
|
5
4
|
|
|
6
5
|
export const getCellRelevantAttributes = (attributes, attributesSeries, cellAttributeIds) => R.filter(
|
|
7
6
|
(attr) => {
|
|
@@ -17,17 +16,30 @@ export const getCellRelevantAttributes = (attributes, attributesSeries, cellAttr
|
|
|
17
16
|
attributes
|
|
18
17
|
);
|
|
19
18
|
|
|
20
|
-
export const
|
|
19
|
+
export const getCellCombinedSeries = (attributes, combinations) => R.reduce(
|
|
21
20
|
(acc, comb) => {
|
|
22
|
-
const values =
|
|
21
|
+
const values = R.reduce(
|
|
22
|
+
(acc, concept) => {
|
|
23
|
+
if (R.has(concept, comb.fixedDimValues || {})) {
|
|
24
|
+
return R.append(R.prop(concept, comb.fixedDimValues), acc);
|
|
25
|
+
}
|
|
26
|
+
if (R.has(concept, attributes || {})) {
|
|
27
|
+
return R.append(R.path([concept, 'value'], attributes), acc);
|
|
28
|
+
}
|
|
29
|
+
return acc;
|
|
30
|
+
},
|
|
31
|
+
[],
|
|
32
|
+
comb.concepts
|
|
33
|
+
);
|
|
34
|
+
|
|
23
35
|
if (R.isEmpty(values)) {
|
|
24
36
|
return acc;
|
|
25
37
|
}
|
|
26
|
-
return R.append({ ...R.pick(['id', 'name'], comb), values
|
|
38
|
+
return R.append({ ...R.pick(['id', 'name'], comb), values }, acc);
|
|
27
39
|
},
|
|
28
40
|
[],
|
|
29
41
|
combinations
|
|
30
|
-
)
|
|
42
|
+
);
|
|
31
43
|
|
|
32
44
|
// combinations = { cells, layout };
|
|
33
45
|
export const getCells = (customAttributes, cellsAttributesId, combinations, attributesSeries, metadataCoordinates) => observations => {
|
|
@@ -52,7 +64,7 @@ export const getCells = (customAttributes, cellsAttributesId, combinations, attr
|
|
|
52
64
|
obs => {
|
|
53
65
|
const relevantAttributes = getCellRelevantAttributes(obs.attributes, attributesSeries, cellsAttributesId);
|
|
54
66
|
const flagsAndNotes = getFlagsAndNotes(R.omit(attributesInCellsCombination, relevantAttributes), _customAttributes);
|
|
55
|
-
const
|
|
67
|
+
const combinedSeries = getCellCombinedSeries(relevantAttributes, combinations.cells || []);
|
|
56
68
|
const hasAdvancedAttributes = R.pipe(
|
|
57
69
|
R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination])),
|
|
58
70
|
R.isEmpty,
|
|
@@ -63,7 +75,7 @@ export const getCells = (customAttributes, cellsAttributesId, combinations, attr
|
|
|
63
75
|
|
|
64
76
|
return ({
|
|
65
77
|
...R.pick(['indexedDimValIds', 'key'], obs),
|
|
66
|
-
flags: R.concat(flagsAndNotes,
|
|
78
|
+
flags: R.concat(flagsAndNotes, combinedSeries),
|
|
67
79
|
sideProps: hasAdvancedAttributes || hasMetadata ? { hasAdvancedAttributes, hasMetadata, coordinates: obs.indexedDimValIds } : null,
|
|
68
80
|
intValue: R.is(Number, obs.value) ? obs.value : null,
|
|
69
81
|
value: obs.formattedValue,
|
|
@@ -2,19 +2,11 @@ import * as R from 'ramda';
|
|
|
2
2
|
import { isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
3
3
|
import { trimedProps } from '../utils';
|
|
4
4
|
|
|
5
|
-
export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted
|
|
5
|
+
export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted) => {
|
|
6
6
|
const indexedDimensions = R.pipe(
|
|
7
7
|
R.indexBy(R.prop('id')),
|
|
8
8
|
R.map(d => (isTimePeriodDimension(d) && isTimeInverted ? R.assoc('isInverted', true, d) : d)),
|
|
9
9
|
)(dimensions);
|
|
10
|
-
const indexedFixedDimsValues = R.reduce(
|
|
11
|
-
(acc, dim) => {
|
|
12
|
-
const value = R.head(dim.values);
|
|
13
|
-
return !dim.display ? acc : R.assoc(dim.id, R.head(dim.values), acc);
|
|
14
|
-
},
|
|
15
|
-
{},
|
|
16
|
-
fixedDimensions,
|
|
17
|
-
);
|
|
18
10
|
const indexedHeaderIds = R.indexBy(R.identity, layoutIds.header);
|
|
19
11
|
const indexedSectionsIds = R.indexBy(R.identity, layoutIds.sections);
|
|
20
12
|
const indexedRowsIds = { ...indexedSectionsIds, ...R.indexBy(R.identity, layoutIds.rows) };
|
|
@@ -30,7 +22,6 @@ export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted, f
|
|
|
30
22
|
R.append({
|
|
31
23
|
...comb,
|
|
32
24
|
dimensions: trimedProps(comb.concepts, indexedDimensions),
|
|
33
|
-
fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues),
|
|
34
25
|
}),
|
|
35
26
|
)(layout);
|
|
36
27
|
} else if (!R.isEmpty(idsInHeader)) {
|
|
@@ -43,7 +34,6 @@ export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted, f
|
|
|
43
34
|
R.append({
|
|
44
35
|
...comb,
|
|
45
36
|
dimensions: trimedProps(comb.concepts, indexedDimensions),
|
|
46
|
-
fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues),
|
|
47
37
|
}),
|
|
48
38
|
)(layout);
|
|
49
39
|
} else {
|
|
@@ -56,7 +46,6 @@ export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted, f
|
|
|
56
46
|
dimensions: R.pipe(R.omit(layoutIds.sections), o => trimedProps(comb.concepts, o))(
|
|
57
47
|
indexedDimensions,
|
|
58
48
|
),
|
|
59
|
-
fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues),
|
|
60
49
|
}),
|
|
61
50
|
)(layout);
|
|
62
51
|
}
|
|
@@ -7,6 +7,7 @@ import { getCellsAttributesIds } from './getCellsAttributesIds';
|
|
|
7
7
|
import { getIndexedCombinationsByDisplay } from './getIndexedCombinationsByDisplay';
|
|
8
8
|
import { getCells } from './getCells';
|
|
9
9
|
import { getCuratedCells } from './getCuratedCells';
|
|
10
|
+
import { getSeriesCombinations } from '../getSeriesCombinations';
|
|
10
11
|
|
|
11
12
|
export const getTableProps = ({ data, layoutIds, customAttributes, limit, isTimeInverted }) => {
|
|
12
13
|
const {
|
|
@@ -19,8 +20,8 @@ export const getTableProps = ({ data, layoutIds, customAttributes, limit, isTime
|
|
|
19
20
|
attributes
|
|
20
21
|
} = data;
|
|
21
22
|
|
|
22
|
-
const seriesCombinations =
|
|
23
|
-
const layout = getLayout(layoutIds, dimensions, seriesCombinations, isTimeInverted
|
|
23
|
+
const seriesCombinations = getSeriesCombinations(combinations, oneValueDimensions);
|
|
24
|
+
const layout = getLayout(layoutIds, dimensions, seriesCombinations, isTimeInverted);
|
|
24
25
|
const layoutIndexes = getSortedLayoutIndexes(layout, observations);
|
|
25
26
|
const refinedLayoutIndexes = refineLayoutSize({ layout, observations, limit })(layoutIndexes);
|
|
26
27
|
const layoutData = getLayoutData(refinedLayoutIndexes, layout, { metadataCoordinates, attributesSeries, customAttributes });
|
package/test/getCells.test.js
CHANGED
|
@@ -8,7 +8,8 @@ const customAttributes = {
|
|
|
8
8
|
|
|
9
9
|
describe('getCells tests', () => {
|
|
10
10
|
it('flags', () => {
|
|
11
|
-
expect(
|
|
11
|
+
expect(
|
|
12
|
+
getCells(customAttributes, ['FL1', 'FL2', 'FT1', 'FT2', 'FT3'], [], {}, [])({
|
|
12
13
|
a: {
|
|
13
14
|
key: 'a',
|
|
14
15
|
value: 33,
|
|
@@ -21,8 +22,7 @@ describe('getCells tests', () => {
|
|
|
21
22
|
},
|
|
22
23
|
indexedDimValIds: {}
|
|
23
24
|
}
|
|
24
|
-
}
|
|
25
|
-
{ unitsDefinitionCodes: [], unitsSeries: {}, unitsDisplay: 'cells', unitDimension: {} }, [])).to.deep.equal({
|
|
25
|
+
})).to.deep.equal({
|
|
26
26
|
a: {
|
|
27
27
|
key: 'a',
|
|
28
28
|
value: '33',
|
|
@@ -37,4 +37,45 @@ describe('getCells tests', () => {
|
|
|
37
37
|
}
|
|
38
38
|
})
|
|
39
39
|
});
|
|
40
|
+
it('combinations', () => {
|
|
41
|
+
const combinations = {
|
|
42
|
+
cells: [{ id: 'CELLS_COMB', concepts: ['D1', 'D2', 'A1', 'A4'], fixedDimValues: { D1: { id: 'D1V' } } }],
|
|
43
|
+
layout: [{ id: 'LAYOUT_COMB', concepts: ['D3', 'A2', 'A3'] }]
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const attributesSeries = {
|
|
47
|
+
'D3=v0': { serieKey: 'D3=v0', A2: { value: 'A2V' } }
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const cellsAttributesIds = ['FL1', 'FT1', 'A1'];
|
|
51
|
+
|
|
52
|
+
const observations = {
|
|
53
|
+
'obs': {
|
|
54
|
+
formattedValue: '33',
|
|
55
|
+
value: 33,
|
|
56
|
+
attributes: {
|
|
57
|
+
FL1: { id: 'FL1', value: { id: 'A' } },
|
|
58
|
+
FT1: { id: 'FT1', value: { id: 'V' } },
|
|
59
|
+
A1: { id: 'A1', value: { id: 'A1V' } },
|
|
60
|
+
A2: { id: 'A2', value: { id: 'A2V' }, serieKey: 'D3=v0' },
|
|
61
|
+
A3: { id: 'A3', value: { id: 'A3V' }, serieKey: 'D3=v0' },
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
expect(getCells(customAttributes, cellsAttributesIds, combinations, attributesSeries, [])(observations)).to.deep.equal({
|
|
68
|
+
'obs': {
|
|
69
|
+
value: '33',
|
|
70
|
+
intValue: 33,
|
|
71
|
+
sideProps: null,
|
|
72
|
+
flags: [
|
|
73
|
+
{ code: 'A', id: 'FL1', value: { id: 'A' } }, // regular flag
|
|
74
|
+
{ id: 'FT1', value: { id: 'V' } }, // regular foot note
|
|
75
|
+
{ id: 'A3', value: { id: 'A3V' }, serieKey: 'D3=v0' }, // rejected layout combination value displayed as a footnote
|
|
76
|
+
{ id: 'CELLS_COMB', values: [{ id: 'D1V' }, { id: 'A1V' }] } // cell level combination with fixed dim value
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
40
81
|
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getLayout } from '../src/rules2/src';
|
|
3
|
+
|
|
4
|
+
describe('getLayout tests', () => {
|
|
5
|
+
it('complete test', () => {
|
|
6
|
+
const isTimeInverted = true;
|
|
7
|
+
const dimensions = [
|
|
8
|
+
{ id: 'D1', values: [{ id: 'v1' }, { id: 'v2' }] },
|
|
9
|
+
{ id: 'D2', values: [{ id: 'v1' }, { id: 'v2' }] },
|
|
10
|
+
{ id: 'D3', values: [{ id: 'v1' }, { id: 'v2' }] },
|
|
11
|
+
{ id: 'D4', values: [{ id: 'v1' }, { id: 'v2' }] },
|
|
12
|
+
{ id: 'TIME_PERIOD', values: [{ id: 'v1' }, { id: 'v2' }] }
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const layoutIds = {
|
|
16
|
+
header: ['TIME_PERIOD'],
|
|
17
|
+
sections: ['D1'],
|
|
18
|
+
rows: ['D4', 'D2', 'D3']
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const combinations = [
|
|
22
|
+
{ id: 'COMB1', concepts: ['D2', 'D3'], relationship: [] }, // rejected for empty relationship
|
|
23
|
+
{ id: 'COMB2', concepts: ['D3', 'D4', 'A1'], relationship: ['D3', 'D4', 'TIME_PERIOD'] }, // rejected because relationship is incompatible with layout
|
|
24
|
+
{ id: 'COMB3', concepts: ['D1', 'D2', 'A2', 'D5'], relationship: ['D1', 'D2', 'D3'] },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
expect(getLayout(layoutIds, dimensions, combinations, isTimeInverted)).to.deep.equal({
|
|
28
|
+
header: [{ id: 'TIME_PERIOD', isInverted: true, values: [{ id: 'v1' }, { id: 'v2' }] }],
|
|
29
|
+
sections: [{ id: 'D1', values: [{ id: 'v1' }, { id: 'v2' }] }],
|
|
30
|
+
rows: [
|
|
31
|
+
{ id: 'D4', values: [{ id: 'v1' }, { id: 'v2' }] },
|
|
32
|
+
{ id: 'D3', values: [{ id: 'v1' }, { id: 'v2' }] },
|
|
33
|
+
{
|
|
34
|
+
id: 'COMB3',
|
|
35
|
+
concepts: ['D1', 'D2', 'A2', 'D5'],
|
|
36
|
+
relationship: ['D1', 'D2', 'D3'],
|
|
37
|
+
dimensions: [{ id: 'D2', values: [{ id: 'v1' }, { id: 'v2' }] }] // D1 kept at section level
|
|
38
|
+
},
|
|
39
|
+
]
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getSeriesCombinations } from '../src/rules2/src/';
|
|
3
|
+
|
|
4
|
+
describe('getSeriesCombinations tests', () => {
|
|
5
|
+
it('basic test', () => {
|
|
6
|
+
const oneValueDimensions = [
|
|
7
|
+
{ id: 'D1', values: [{ id: 'v', display: false }] },
|
|
8
|
+
{ id: 'D2', values: [{ id: 'v' }] }
|
|
9
|
+
];
|
|
10
|
+
const combinations = [
|
|
11
|
+
{ id: 'COMB1', header: true, concepts: ['D1', 'D2'] },
|
|
12
|
+
{ id: 'COMB2', series: true, concepts: ['D1', 'D2', 'A1', 'A2'] },
|
|
13
|
+
{ id: 'COMB3', series: true, concepts: ['D3', 'D4', 'A3'] },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
expect(getSeriesCombinations(combinations, oneValueDimensions)).to.deep.equal([
|
|
17
|
+
{
|
|
18
|
+
id: 'COMB2',
|
|
19
|
+
series: true,
|
|
20
|
+
concepts: ['D1', 'D2', 'A1', 'A2'],
|
|
21
|
+
fixedDimValues: {
|
|
22
|
+
D1: { id: 'v', display: false },
|
|
23
|
+
D2: { id: 'v' }
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{ id: 'COMB3', series: true, concepts: ['D3', 'D4', 'A3'], fixedDimValues: {} },
|
|
27
|
+
])
|
|
28
|
+
});
|
|
29
|
+
});
|