@sis-cc/dotstatsuite-components 17.9.0 → 17.10.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/table/getCombinationDimensionsData.js +1 -1
- package/lib/rules2/src/table/getLayoutData.js +1 -1
- package/lib/rules2/src/table/parseValueHierarchy.js +8 -1
- package/package.json +1 -1
- package/src/rules2/src/table/getCombinationDimensionsData.js +2 -2
- package/src/rules2/src/table/getLayoutData.js +2 -2
- package/src/rules2/src/table/parseValueHierarchy.js +7 -0
- package/test/getCombinationDimensionsData.test.js +46 -0
|
@@ -29,7 +29,7 @@ var getCombinationDimensionsData = exports.getCombinationDimensionsData = functi
|
|
|
29
29
|
coordinates = R.assoc(dimension.id, value.id, coordinates);
|
|
30
30
|
ids = R.append(dimension.id + '=' + value.id, ids);
|
|
31
31
|
var previousValue = R.propOr({}, dimension.id, previous);
|
|
32
|
-
if (
|
|
32
|
+
if ((0, _parseValueHierarchy.isSameValueAsPrevious)(value, previousValue) && _sameSerie) {
|
|
33
33
|
return R.assoc(dimension.id, previousValue, acc);
|
|
34
34
|
} else {
|
|
35
35
|
var _parsedValue = (0, _parseValueHierarchy.parseValueHierarchy)(value, _sameSerie ? previousValue || {} : {}, dimension.indexedValues);
|
|
@@ -93,7 +93,7 @@ var getSubLayoutData = function getSubLayoutData(series, _definition, _ref) {
|
|
|
93
93
|
var previousValue = R.nth(i, acc.previous) || {};
|
|
94
94
|
coordinates = R.assoc(dimension.id, value.id, coordinates);
|
|
95
95
|
ids = R.append(dimension.id + '=' + value.id, ids);
|
|
96
|
-
if (
|
|
96
|
+
if ((0, _parseValueHierarchy.isSameValueAsPrevious)(value, previousValue) && sameSerie) {
|
|
97
97
|
next = R.append(previousValue, next);
|
|
98
98
|
data = R.append({
|
|
99
99
|
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.parseValueHierarchy = undefined;
|
|
6
|
+
exports.parseValueHierarchy = exports.isSameValueAsPrevious = undefined;
|
|
7
7
|
|
|
8
8
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
9
9
|
|
|
@@ -21,6 +21,13 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
|
|
24
|
+
var isSameValueAsPrevious = exports.isSameValueAsPrevious = function isSameValueAsPrevious(value, previousValue) {
|
|
25
|
+
var valueHierarchicalPath = R.append(value.id, R.propOr([], 'parents', value));
|
|
26
|
+
var previousValueHierarchicalPath = R.append(previousValue.id, R.propOr([], 'parents', previousValue));
|
|
27
|
+
|
|
28
|
+
return R.equals(valueHierarchicalPath, previousValueHierarchicalPath);
|
|
29
|
+
};
|
|
30
|
+
|
|
24
31
|
var parseValueHierarchy = exports.parseValueHierarchy = function parseValueHierarchy(value, previousValue, indexedValues) {
|
|
25
32
|
var parentsIds = R.propOr([], 'parents', value);
|
|
26
33
|
if (R.isEmpty(parentsIds)) {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
|
-
import { parseValueHierarchy } from './parseValueHierarchy';
|
|
2
|
+
import { parseValueHierarchy, isSameValueAsPrevious } from './parseValueHierarchy';
|
|
3
3
|
|
|
4
4
|
export const getCombinationDimensionsData = (indexes, combination, previous, sameSerie) => {
|
|
5
5
|
let coordinates = {};
|
|
@@ -16,7 +16,7 @@ export const getCombinationDimensionsData = (indexes, combination, previous, sam
|
|
|
16
16
|
coordinates = R.assoc(dimension.id, value.id, coordinates);
|
|
17
17
|
ids = R.append(`${dimension.id}=${value.id}`, ids);
|
|
18
18
|
const previousValue = R.propOr({}, dimension.id, previous);
|
|
19
|
-
if (value
|
|
19
|
+
if (isSameValueAsPrevious(value, previousValue) && _sameSerie) {
|
|
20
20
|
return R.assoc(dimension.id, previousValue, acc);
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import { getFlagsAndNotes } from './getFlagsAndNotes';
|
|
3
3
|
import { getCombinationDimensionsData } from './getCombinationDimensionsData';
|
|
4
|
-
import { parseValueHierarchy } from './parseValueHierarchy';
|
|
4
|
+
import { parseValueHierarchy, isSameValueAsPrevious } from './parseValueHierarchy';
|
|
5
5
|
import { getLayoutCoordinatesValidator } from '../utils';
|
|
6
6
|
|
|
7
7
|
const getSubLayoutData = (series, _definition, { metadataCoordinates, attributesSeries, customAttributes, topCoordinates={} }) => {
|
|
@@ -70,7 +70,7 @@ const getSubLayoutData = (series, _definition, { metadataCoordinates, attributes
|
|
|
70
70
|
const previousValue = R.nth(i, acc.previous) || {};
|
|
71
71
|
coordinates = R.assoc(dimension.id, value.id, coordinates);
|
|
72
72
|
ids = R.append(`${dimension.id}=${value.id}`, ids);
|
|
73
|
-
if (value
|
|
73
|
+
if (isSameValueAsPrevious(value, previousValue) && sameSerie) {
|
|
74
74
|
next = R.append(previousValue, next);
|
|
75
75
|
data = R.append({
|
|
76
76
|
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
|
+
export const isSameValueAsPrevious = (value, previousValue) => {
|
|
4
|
+
const valueHierarchicalPath = R.append(value.id, R.propOr([], 'parents', value));
|
|
5
|
+
const previousValueHierarchicalPath = R.append(previousValue.id, R.propOr([], 'parents', previousValue));
|
|
6
|
+
|
|
7
|
+
return R.equals(valueHierarchicalPath, previousValueHierarchicalPath);
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
export const parseValueHierarchy = (value, previousValue, indexedValues) => {
|
|
4
11
|
const parentsIds = R.propOr([], 'parents', value);
|
|
5
12
|
if (R.isEmpty(parentsIds)) {
|
|
@@ -50,4 +50,50 @@ describe('getCombinationDimensionsData', () => {
|
|
|
50
50
|
hasAdvancedAttributes: true
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
|
+
it('same value but under different hierarchy', () => {
|
|
54
|
+
const combination = {
|
|
55
|
+
id: 'COMB',
|
|
56
|
+
dimensions: [
|
|
57
|
+
{
|
|
58
|
+
id: 'D0',
|
|
59
|
+
values: [
|
|
60
|
+
{ id: 'v0' },
|
|
61
|
+
{ id: 'v1' },
|
|
62
|
+
{ id: 'v2' },
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'D1',
|
|
67
|
+
values: [
|
|
68
|
+
{ id: 'EU' },
|
|
69
|
+
{ id: 'FRA', parents: ['EU'] },
|
|
70
|
+
{ id: 'GER', parents: ['EU'] },
|
|
71
|
+
{ id: 'OECD' },
|
|
72
|
+
{ id: 'FRA', parents: ['OECD'] },
|
|
73
|
+
{ id: 'GER', parents: ['OECD'] },
|
|
74
|
+
],
|
|
75
|
+
indexedValues: {
|
|
76
|
+
EU: { id: 'EU' },
|
|
77
|
+
FRA: { id: 'FRA' },
|
|
78
|
+
GER: { id: 'GER' },
|
|
79
|
+
OECD: { id: 'OECD' },
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
]
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const indexes = [0, 4];
|
|
86
|
+
|
|
87
|
+
const previous = { D0: { id: 'v0', display: true }, D1: { id: 'FRA', display: true, parents: [{ id: 'EU' }], parentsIds: ['EU'], missingParents: [] } };
|
|
88
|
+
expect(getCombinationDimensionsData(indexes, combination, previous, true)).to.deep.equal({
|
|
89
|
+
dimValues: {
|
|
90
|
+
D0: { id: 'v0', display: true },
|
|
91
|
+
D1: { id: 'FRA', display: true, parents: [], missingParents: [{ id: 'OECD' }], parentsIds: ['OECD'] },
|
|
92
|
+
},
|
|
93
|
+
sameSerie: false,
|
|
94
|
+
coordinates: { D0: 'v0', D1: 'FRA' },
|
|
95
|
+
ids: ['D0=v0', 'D1=FRA'],
|
|
96
|
+
hasAdvancedAttributes: undefined
|
|
97
|
+
});
|
|
98
|
+
});
|
|
53
99
|
});
|