@sis-cc/dotstatsuite-components 17.12.6 → 17.13.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/{hierarchiseDimensionWithAdvancedHierarchy.js → hierarchiseDimensionWithAdvancedHierarchy2.js} +22 -17
- package/lib/rules2/src/{hierarchiseDimensionWithNativeHierarchy.js → hierarchiseDimensionWithNativeHierarchy2.js} +10 -5
- package/lib/rules2/src/index.js +21 -12
- package/lib/rules2/src/prepareData.js +2 -2
- package/lib/rules2/src/refineDimensions.js +3 -6
- package/lib/rules2/src/table/getLayoutData2.js +218 -0
- package/lib/rules2/src/table/getTableProps.js +6 -9
- package/lib/rules2/src/table/parseSeriesIndexesHierarchies.js +96 -0
- package/lib/rules2/src/table/{refineLayoutSize.js → refineLayoutSize2.js} +53 -34
- package/package.json +1 -1
- package/src/rules2/src/{hierarchiseDimensionWithAdvancedHierarchy.js → hierarchiseDimensionWithAdvancedHierarchy2.js} +24 -23
- package/src/rules2/src/{hierarchiseDimensionWithNativeHierarchy.js → hierarchiseDimensionWithNativeHierarchy2.js} +31 -28
- package/src/rules2/src/index.js +5 -5
- package/src/rules2/src/prepareData.js +2 -2
- package/src/rules2/src/refineDimensions.js +3 -6
- package/src/rules2/src/table/getLayoutData2.js +175 -0
- package/src/rules2/src/table/getTableProps.js +8 -4
- package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +62 -0
- package/src/rules2/src/table/{refineLayoutSize.js → refineLayoutSize2.js} +50 -21
- package/test/getLayoutData2.test.js +268 -0
- package/test/{hierarchiseDimensionWithAdvancedHierarchy.test.js → hierarchiseDimensionWithAdvancedHierarchy2.test.js} +34 -69
- package/test/{hierarchiseDimensionWithNativeHierarchy.test.js → hierarchiseDimensionWithNativeHierarchy2.test.js} +14 -14
- package/test/parseSeriesIndexesHierarchies.test.js +104 -0
- package/test/{refineLayoutSize.test.js → refineLayoutSize2.test.js} +63 -64
- package/test/refinedDimensions.test.js +8 -8
- package/lib/rules2/src/table/getLayoutData.js +0 -209
- package/src/rules2/src/table/getLayoutData.js +0 -193
- package/test/getLayoutData.test.js +0 -284
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { getFlagsAndNotes } from './getFlagsAndNotes';
|
|
3
|
-
import { getCombinationDimensionsData } from './getCombinationDimensionsData';
|
|
4
|
-
import { parseValueHierarchy, isSameValueAsPrevious } from './parseValueHierarchy';
|
|
5
|
-
import { getLayoutCoordinatesValidator } from '../utils';
|
|
6
|
-
|
|
7
|
-
const getSubLayoutData = (series, _definition, { metadataCoordinates, attributesSeries, customAttributes, topCoordinates={} }) => {
|
|
8
|
-
const getHasAdvancedAttributes = (attrValues) => R.pipe(
|
|
9
|
-
R.omit(R.concat(customAttributes.flags, customAttributes.notes)),
|
|
10
|
-
R.isEmpty,
|
|
11
|
-
R.not
|
|
12
|
-
)(attrValues);
|
|
13
|
-
|
|
14
|
-
const combinationConceptIds = R.reduce(
|
|
15
|
-
(acc, def) => {
|
|
16
|
-
const concepts = R.propOr([], 'concepts', def);
|
|
17
|
-
if (R.isEmpty(concepts)) {
|
|
18
|
-
return acc;
|
|
19
|
-
}
|
|
20
|
-
return R.concat(acc, concepts);
|
|
21
|
-
},
|
|
22
|
-
[],
|
|
23
|
-
_definition
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
const definition = R.map( //used for parseValueHierarchy ...
|
|
27
|
-
(entry) => {
|
|
28
|
-
if (R.has('dimensions', entry)) {
|
|
29
|
-
return ({
|
|
30
|
-
...entry,
|
|
31
|
-
dimensions: R.map(
|
|
32
|
-
dim => R.assoc('indexedValues', R.indexBy(R.prop('id'), dim.values || []), dim),
|
|
33
|
-
entry.dimensions
|
|
34
|
-
)
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return R.assoc('indexedValues', R.indexBy(R.prop('id'), entry.values || []), entry);
|
|
38
|
-
},
|
|
39
|
-
_definition
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const { res } = R.reduce(
|
|
43
|
-
(acc, serie) => {
|
|
44
|
-
let data = [];
|
|
45
|
-
let next = [];
|
|
46
|
-
let sameSerie = true;
|
|
47
|
-
let i = 0;
|
|
48
|
-
let hasAdvancedAttributes = false;
|
|
49
|
-
let coordinates = topCoordinates;
|
|
50
|
-
let ids = [];
|
|
51
|
-
while (i < serie.length) {
|
|
52
|
-
const entry = serie[i];
|
|
53
|
-
if (R.is(Array, entry)) {
|
|
54
|
-
const combination = definition[i];
|
|
55
|
-
const previousDimValues = R.nth(i, acc.previous);
|
|
56
|
-
const combData = getCombinationDimensionsData(entry, combination, previousDimValues, sameSerie);
|
|
57
|
-
data = R.append({
|
|
58
|
-
dimension: R.pick(['id', 'name'], combination),
|
|
59
|
-
dimValues: combData.dimValues
|
|
60
|
-
}, data);
|
|
61
|
-
next = R.append(combData.dimValues, next);
|
|
62
|
-
hasAdvancedAttributes = !hasAdvancedAttributes ? combData.hasAdvancedAttributes : true;
|
|
63
|
-
sameSerie = combData.sameSerie;
|
|
64
|
-
coordinates = { ...coordinates, ...combData.coordinates };
|
|
65
|
-
ids = R.concat(ids, combData.ids);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
const dimension = definition[i];
|
|
69
|
-
const value = R.nth(Math.abs(entry), dimension.values || []);
|
|
70
|
-
const previousValue = R.nth(i, acc.previous) || {};
|
|
71
|
-
coordinates = R.assoc(dimension.id, value.id, coordinates);
|
|
72
|
-
ids = R.append(`${dimension.id}=${value.id}`, ids);
|
|
73
|
-
if (isSameValueAsPrevious(value, previousValue) && sameSerie) {
|
|
74
|
-
next = R.append(previousValue, next);
|
|
75
|
-
data = R.append({
|
|
76
|
-
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
77
|
-
value: previousValue,
|
|
78
|
-
}, data);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
hasAdvancedAttributes = !hasAdvancedAttributes ? value.hasAdvancedAttributes : true;
|
|
82
|
-
const parsedValue = parseValueHierarchy(value, sameSerie ? previousValue || {} : {}, dimension.indexedValues);
|
|
83
|
-
next = R.append(parsedValue, next);
|
|
84
|
-
data = R.append({
|
|
85
|
-
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
86
|
-
value: parsedValue,
|
|
87
|
-
}, data);
|
|
88
|
-
if (!R.isNil(acc.previous)) {
|
|
89
|
-
sameSerie = false;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
i++;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const coordinatesValidator = getLayoutCoordinatesValidator(coordinates, topCoordinates);
|
|
97
|
-
const attributesValues = R.reduce(
|
|
98
|
-
(acc, serie) => {
|
|
99
|
-
const coordinates = R.path([0, 'coordinates'], R.values(serie));
|
|
100
|
-
const isValid = coordinatesValidator(coordinates);
|
|
101
|
-
if (!isValid) {
|
|
102
|
-
return acc;
|
|
103
|
-
}
|
|
104
|
-
const isSingleBounded = R.length(R.keys(coordinates)) === 1;
|
|
105
|
-
return ({ ...acc, ...(isSingleBounded ? R.pick(combinationConceptIds, serie) : serie) });
|
|
106
|
-
},
|
|
107
|
-
{},
|
|
108
|
-
R.values(attributesSeries)
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
data = R.addIndex(R.reduce)(
|
|
112
|
-
(acc, entry, ind) => {
|
|
113
|
-
if (!R.has('dimValues', entry)) {
|
|
114
|
-
return R.append(entry, acc);
|
|
115
|
-
}
|
|
116
|
-
const { dimValues, dimension } = entry;
|
|
117
|
-
const def = R.nth(ind, definition);
|
|
118
|
-
if (!R.propOr(true, 'display', def)) {
|
|
119
|
-
return acc;
|
|
120
|
-
}
|
|
121
|
-
const fixedDimValues = R.propOr([], 'fixedDimValues', def);
|
|
122
|
-
const values = R.reduce(
|
|
123
|
-
(_acc, id) => {
|
|
124
|
-
if (R.has(id, dimValues)) {
|
|
125
|
-
const value = R.prop(id, dimValues);
|
|
126
|
-
return R.append(value, _acc);
|
|
127
|
-
}
|
|
128
|
-
if (R.has(id, fixedDimValues)) {
|
|
129
|
-
return R.append(R.prop(id, fixedDimValues), _acc);
|
|
130
|
-
}
|
|
131
|
-
if (!R.has(id, attributesValues)) {
|
|
132
|
-
return _acc;
|
|
133
|
-
}
|
|
134
|
-
return R.append(R.path([id, 'value'], attributesValues), _acc);
|
|
135
|
-
},
|
|
136
|
-
[],
|
|
137
|
-
def.concepts
|
|
138
|
-
);
|
|
139
|
-
return R.append({ dimension, values }, acc);
|
|
140
|
-
},
|
|
141
|
-
[],
|
|
142
|
-
data
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
const layoutAttrValues = R.reject(
|
|
146
|
-
R.prop('isObs'),
|
|
147
|
-
R.omit(combinationConceptIds, attributesValues)
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
const flags = getFlagsAndNotes(layoutAttrValues, customAttributes);
|
|
151
|
-
const hasMetadata = !R.isNil(R.find(coordinatesValidator, metadataCoordinates));
|
|
152
|
-
|
|
153
|
-
if (!hasAdvancedAttributes) {
|
|
154
|
-
hasAdvancedAttributes = getHasAdvancedAttributes(layoutAttrValues);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const sideProps = hasMetadata || hasAdvancedAttributes
|
|
158
|
-
? { hasMetadata, hasAdvancedAttributes, coordinates } : null;
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
res: R.append({ data, key: R.join(':', ids), flags, sideProps, coordinates }, acc.res),
|
|
162
|
-
previous: next,
|
|
163
|
-
};
|
|
164
|
-
},
|
|
165
|
-
{ res: [], previous: [] },
|
|
166
|
-
series
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
return res;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export const getLayoutData = (layoutIndexes, layout, { metadataCoordinates, attributesSeries, customAttributes, topCoordinates={} }) => {
|
|
173
|
-
const { header, sections, ...rest } = layoutIndexes;
|
|
174
|
-
const opts = { metadataCoordinates, attributesSeries, customAttributes, topCoordinates };
|
|
175
|
-
const headerData = getSubLayoutData(header, layout.header, opts);
|
|
176
|
-
const sectionsData = R.pipe(
|
|
177
|
-
R.transpose,
|
|
178
|
-
([sections, sectionsRows]) => {
|
|
179
|
-
if (R.isNil(sections)) {
|
|
180
|
-
return [];
|
|
181
|
-
}
|
|
182
|
-
const _sectionsData = getSubLayoutData(sections, layout.sections, opts);
|
|
183
|
-
const rowsData = R.addIndex(R.map)((rows, sectionIndex) => {
|
|
184
|
-
const sectionCoordinates = R.path([sectionIndex, 'coordinates'], _sectionsData);
|
|
185
|
-
return getSubLayoutData(rows, layout.rows, R.assoc('topCoordinates', sectionCoordinates, opts));
|
|
186
|
-
}, sectionsRows);
|
|
187
|
-
|
|
188
|
-
return R.transpose([_sectionsData, rowsData]);
|
|
189
|
-
}
|
|
190
|
-
)(sections);
|
|
191
|
-
|
|
192
|
-
return ({ headerData, sectionsData, ...rest });
|
|
193
|
-
};
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai';
|
|
2
|
-
import { getLayoutData } from '../src/rules2/src/';
|
|
3
|
-
|
|
4
|
-
describe('getLayoutData tests', () => {
|
|
5
|
-
it('basic case with combination', () => {
|
|
6
|
-
const layout = {
|
|
7
|
-
header: [],
|
|
8
|
-
sections: [{ id: 'S', values: [{ id: 'S_V1' }, { id: 'S_V2' }] }],
|
|
9
|
-
rows: [{
|
|
10
|
-
id: 'COMB',
|
|
11
|
-
concepts: ['R1', 'R2', 'ATTR'],
|
|
12
|
-
dimensions: [
|
|
13
|
-
{ id: 'R1', values: [{ id: 'R1_V1' }, { id: 'R1_V2' }] },
|
|
14
|
-
{ id: 'R2', values: [{ id: 'R2_V1' }, { id: 'R2_V2', display: false }] },
|
|
15
|
-
]
|
|
16
|
-
}]
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const attributesSeries = {
|
|
20
|
-
'R1=R1_V1:R2=R2_V1': {
|
|
21
|
-
ATTR: { id: 'ATTR', value: { id: 'ATTR_V1' }, coordinates: { R1: 'R1_V1', R2: 'R2_V1' } },
|
|
22
|
-
},
|
|
23
|
-
'R1=R1_V1:R2=R2_V2': {
|
|
24
|
-
ATTR: { id: 'ATTR', value: { id: 'ATTR_V2' }, coordinates: { R1: 'R1_V1', R2: 'R2_V2' } },
|
|
25
|
-
},
|
|
26
|
-
'R1=R1_V2:R2=R2_V1': {
|
|
27
|
-
ATTR: { id: 'ATTR', value: { id: 'ATTR_V3' }, coordinates: { R1: 'R1_V2', R2: 'R2_V1' } },
|
|
28
|
-
},
|
|
29
|
-
'R1=R1_V2:R2=R2_V2': {
|
|
30
|
-
ATTR: { id: 'ATTR', value: { id: 'ATTR_V4' }, coordinates: { R1: 'R1_V2', R2: 'R2_V2' } },
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const layoutIndexes = {
|
|
35
|
-
header: [],
|
|
36
|
-
sections: [
|
|
37
|
-
[
|
|
38
|
-
[0],
|
|
39
|
-
[
|
|
40
|
-
[[0, 0]],
|
|
41
|
-
[[0, 1]],
|
|
42
|
-
[[1, 0]],
|
|
43
|
-
[[1, 1]],
|
|
44
|
-
]
|
|
45
|
-
],
|
|
46
|
-
[
|
|
47
|
-
[1],
|
|
48
|
-
[
|
|
49
|
-
[[0, 0]],
|
|
50
|
-
[[0, 1]],
|
|
51
|
-
[[1, 0]],
|
|
52
|
-
[[1, 1]],
|
|
53
|
-
]
|
|
54
|
-
]
|
|
55
|
-
]
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
expect(getLayoutData(layoutIndexes, layout, { attributesSeries, metadataCoordinates: [], customAttributes: { flags: [], notes: [] } })).to.deep.equal({
|
|
59
|
-
headerData: [],
|
|
60
|
-
sectionsData: [
|
|
61
|
-
[
|
|
62
|
-
{ data: [{ dimension: { id: 'S' }, value: { id: 'S_V1' } }], key: 'S=S_V1', flags: [], sideProps: null, coordinates: { S: 'S_V1' } },
|
|
63
|
-
[
|
|
64
|
-
{
|
|
65
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V1' }] }],
|
|
66
|
-
key: 'R1=R1_V1:R2=R2_V1',
|
|
67
|
-
coordinates: { R1: 'R1_V1', R2: 'R2_V1', S: 'S_V1' },
|
|
68
|
-
flags: [],
|
|
69
|
-
sideProps: null
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V2' }] }],
|
|
73
|
-
key: 'R1=R1_V1:R2=R2_V2',
|
|
74
|
-
coordinates: { R1: 'R1_V1', R2: 'R2_V2', S: 'S_V1' },
|
|
75
|
-
flags: [],
|
|
76
|
-
sideProps: null
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V3' }] }],
|
|
80
|
-
key: 'R1=R1_V2:R2=R2_V1',
|
|
81
|
-
coordinates: { R1: 'R1_V2', R2: 'R2_V1', S: 'S_V1' },
|
|
82
|
-
flags: [],
|
|
83
|
-
sideProps: null
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V4' }] }],
|
|
87
|
-
key: 'R1=R1_V2:R2=R2_V2',
|
|
88
|
-
coordinates: { R1: 'R1_V2', R2: 'R2_V2', S: 'S_V1' },
|
|
89
|
-
flags: [],
|
|
90
|
-
sideProps: null
|
|
91
|
-
},
|
|
92
|
-
]
|
|
93
|
-
],
|
|
94
|
-
[
|
|
95
|
-
{ data: [{ dimension: { id: 'S' }, value: { id: 'S_V2' } }], key: 'S=S_V2', flags: [], sideProps: null, coordinates: { S: 'S_V2' } },
|
|
96
|
-
[
|
|
97
|
-
{
|
|
98
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V1' }] }],
|
|
99
|
-
key: 'R1=R1_V1:R2=R2_V1',
|
|
100
|
-
coordinates: { R1: 'R1_V1', R2: 'R2_V1', S: 'S_V2' },
|
|
101
|
-
flags: [],
|
|
102
|
-
sideProps: null
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V2' }] }],
|
|
106
|
-
key: 'R1=R1_V1:R2=R2_V2',
|
|
107
|
-
coordinates: { R1: 'R1_V1', R2: 'R2_V2', S: 'S_V2' },
|
|
108
|
-
flags: [],
|
|
109
|
-
sideProps: null
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V3' }] }],
|
|
113
|
-
key: 'R1=R1_V2:R2=R2_V1',
|
|
114
|
-
coordinates: { R1: 'R1_V2', R2: 'R2_V1', S: 'S_V2' },
|
|
115
|
-
flags: [],
|
|
116
|
-
sideProps: null
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V4' }] }],
|
|
120
|
-
key: 'R1=R1_V2:R2=R2_V2',
|
|
121
|
-
coordinates: { R1: 'R1_V2', R2: 'R2_V2', S: 'S_V2' },
|
|
122
|
-
flags: [],
|
|
123
|
-
sideProps: null
|
|
124
|
-
},
|
|
125
|
-
]
|
|
126
|
-
]
|
|
127
|
-
]
|
|
128
|
-
})
|
|
129
|
-
});
|
|
130
|
-
it('not displayed combination', () => {
|
|
131
|
-
const layout = {
|
|
132
|
-
header: [{ id: 'H', values: [{ id: 'H_V1' }, { id: 'H_V2' }] }],
|
|
133
|
-
sections: [],
|
|
134
|
-
rows: [
|
|
135
|
-
{ id: 'R1', values: [{ id: 'R1_V1' }, { id: 'R1_V2' }] },
|
|
136
|
-
{
|
|
137
|
-
id: 'COMB',
|
|
138
|
-
display: false,
|
|
139
|
-
concepts: ['R2', 'ATTR'],
|
|
140
|
-
dimensions: [
|
|
141
|
-
{ id: 'R2', values: [{ id: 'R2_V1' }, { id: 'R2_V2' }] },
|
|
142
|
-
]
|
|
143
|
-
}
|
|
144
|
-
]
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const attributesSeries = {
|
|
148
|
-
'R1=R1_V1:R2=R2_V1': {
|
|
149
|
-
ATTR: { id: 'ATTR', value: { id: 'ATTR_V1' }, coordinates: { R1: 'R1_V1', R2: 'R2_V1' } },
|
|
150
|
-
},
|
|
151
|
-
'R1=R1_V2:R2=R2_V2': {
|
|
152
|
-
ATTR: { id: 'ATTR', value: { id: 'ATTR_V4' }, coordinates: { R1: 'R1_V2', R2: 'R2_V2' } },
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const layoutIndexes = {
|
|
157
|
-
header: [[0], [1]],
|
|
158
|
-
sections: [
|
|
159
|
-
[
|
|
160
|
-
[],
|
|
161
|
-
[
|
|
162
|
-
[0, [0]],
|
|
163
|
-
[1, [1]]
|
|
164
|
-
]
|
|
165
|
-
]
|
|
166
|
-
]
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
expect(getLayoutData(layoutIndexes, layout, { attributesSeries, metadataCoordinates: [], customAttributes: { flags: [], notes: [] } })).to.deep.equal({
|
|
170
|
-
headerData: [
|
|
171
|
-
{ data: [{ dimension: { id: 'H' }, value: { id: 'H_V1' } }], key: 'H=H_V1', flags: [], sideProps: null, coordinates: { H: 'H_V1' } },
|
|
172
|
-
{ data: [{ dimension: { id: 'H' }, value: { id: 'H_V2' } }], key: 'H=H_V2', flags: [], sideProps: null, coordinates: { H: 'H_V2' } }
|
|
173
|
-
],
|
|
174
|
-
sectionsData: [
|
|
175
|
-
[
|
|
176
|
-
{ data: [], key: '', flags: [], sideProps: null, coordinates: {} },
|
|
177
|
-
[
|
|
178
|
-
{ data: [{ dimension: { id: 'R1' }, value: { id: 'R1_V1' } }], key: 'R1=R1_V1:R2=R2_V1', flags: [], sideProps: null, coordinates: { R1: 'R1_V1', R2: 'R2_V1' } },
|
|
179
|
-
{ data: [{ dimension: { id: 'R1' }, value: { id: 'R1_V2' } }], key: 'R1=R1_V2:R2=R2_V2', flags: [], sideProps: null, coordinates: { R1: 'R1_V2', R2: 'R2_V2' } }
|
|
180
|
-
]
|
|
181
|
-
]
|
|
182
|
-
]
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
it('flags, advanced attributes and metadata availability', () => {
|
|
186
|
-
const customAttributes = { flags: ['FL'], notes: ['FT'] };
|
|
187
|
-
const topCoordinates = { FREQ: 'A' };
|
|
188
|
-
const layout = {
|
|
189
|
-
header: [
|
|
190
|
-
{ id: 'TIME_PERIOD', values: [{ id: '2020' }, { id: '2021' }] }
|
|
191
|
-
],
|
|
192
|
-
sections: [
|
|
193
|
-
{ id: 'TRANSACT', values: [{ id: 'TRANSACT1' }, { id: 'TRANSACT2' }] }
|
|
194
|
-
],
|
|
195
|
-
rows: [
|
|
196
|
-
{ id: 'REF_AREA', values: [{ id: 'US' }, { id: 'AUS' }, { id: 'FRA' }] },
|
|
197
|
-
{ id: 'COMB_UNIT', concepts: ['TRANSACT', "MEASURE", 'UNIT_MULT'], dimensions: [{ id: 'MEASURE', values: [{ id: 'USD' }, { id: 'AUSD' }, { id: 'EUR' }] }] }
|
|
198
|
-
]
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
const metadataCoordinates = [
|
|
202
|
-
{},
|
|
203
|
-
{ TIME_PERIOD: '2021', FREQ: 'A' },
|
|
204
|
-
{ TRANSACT: 'TRANSACT1' },
|
|
205
|
-
{ TRANSACT: 'TRANSACT2', REF_AREA: 'AUS', FREQ: 'A' }
|
|
206
|
-
];
|
|
207
|
-
|
|
208
|
-
const attributesSeries = {
|
|
209
|
-
'TIME_PERIOD=2020:FREQ=A': {
|
|
210
|
-
FL: { id: 'FL', serieKey: 'TIME_PERIOD=2020:FREQ=A', coordinates: { TIME_PERIOD: '2020', FREQ: 'A' }, value: { id: 'FL_V' } },
|
|
211
|
-
FT: { id: 'FT', serieKey: 'TIME_PERIOD=2020:FREQ=A', coordinates: { TIME_PERIOD: '2020', FREQ: 'A' }, value: { id: 'FT_V0' } }
|
|
212
|
-
},
|
|
213
|
-
'TRANSACT=TRANSACT1:MEASURE=USD': {
|
|
214
|
-
UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT1:MEASURE=USD', coordinates: { TRANSACT: 'TRANSACT1', MEASURE: 'USD' }, value: { id: 'BILL' } }
|
|
215
|
-
},
|
|
216
|
-
'TRANSACT=TRANSACT1:MEASURE=AUSD': {
|
|
217
|
-
UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT1:MEASURE=AUSD', coordinates: { TRANSACT: 'TRANSACT1', MEASURE: 'AUSD' }, value: { id: '0' } }
|
|
218
|
-
},
|
|
219
|
-
'TRANSACT=TRANSACT1:MEASURE=EUR': {
|
|
220
|
-
UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT1:MEASURE=EUR', coordinates: { TRANSACT: 'TRANSACT1', MEASURE: 'EUR' }, value: { id: 'MILL' } }
|
|
221
|
-
},
|
|
222
|
-
'TRANSACT=TRANSACT2:MEASURE=USD': {
|
|
223
|
-
UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT2:MEASURE=USD', coordinates: { TRANSACT: 'TRANSACT2', MEASURE: 'USD' }, value: { id: 'BILL' } }
|
|
224
|
-
},
|
|
225
|
-
'TRANSACT=TRANSACT2:MEASURE=AUSD': {
|
|
226
|
-
UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT2:MEASURE=AUSD', coordinates: { TRANSACT: 'TRANSACT2', MEASURE: 'AUSD' }, value: { id: '0' } }
|
|
227
|
-
},
|
|
228
|
-
'TRANSACT=TRANSACT2:MEASURE=EUR': {
|
|
229
|
-
UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT2:MEASURE=EUR', coordinates: { TRANSACT: 'TRANSACT2', MEASURE: 'EUR' }, value: { id: 'MILL' } }
|
|
230
|
-
},
|
|
231
|
-
'TRANSACT=TRANSACT1:FREQ=A': {
|
|
232
|
-
FT: { id: 'FT', serieKey: 'TRANSACT=TRANSACT1:FREQ=A', coordinates: { TRANSACT: 'TRANSACT1', FREQ: 'A' }, value: { id: 'FT_V1' } },
|
|
233
|
-
ADV: { id: 'ADV', serieKey: 'TRANSACT=TRANSACT1:FREQ=A', coordinates: { TRANSACT: 'TRANSACT1', FREQ: 'A' }, value: { id: 'ADV_V0' } }
|
|
234
|
-
},
|
|
235
|
-
'TRANSACT=TRANSACT2:REF_AREA=FRA': {
|
|
236
|
-
FT: { id: 'FT', serieKey: 'TRANSACT=TRANSACT2:REF_AREA=FRA', coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'FRA' }, value: { id: 'FT_V2' } }
|
|
237
|
-
},
|
|
238
|
-
'TRANSACT=TRANSACT2:MEASURE=USD:FREQ=A': {
|
|
239
|
-
ADV: { id: 'ADV', serieKey: 'TRANSACT=TRANSACT2:MEASURE=USD:FREQ=A', coordinates: { TRANSACT: 'TRANSACT2', MEASURE: 'USD', FREQ: 'A' }, value: { id: 'ADV_V1' } }
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
const layoutIndexes = {
|
|
244
|
-
header: [[0], [1]],
|
|
245
|
-
sections: [
|
|
246
|
-
[
|
|
247
|
-
[0],
|
|
248
|
-
[[0, [0]], [1, [1]], [2, [2]]],
|
|
249
|
-
],
|
|
250
|
-
[
|
|
251
|
-
[1],
|
|
252
|
-
[[0, [0]], [1, [1]], [2, [2]]],
|
|
253
|
-
]
|
|
254
|
-
]
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
const layoutData = {
|
|
258
|
-
headerData: [
|
|
259
|
-
{ data: [{ dimension: { id: 'TIME_PERIOD' }, value: { id: '2020' } }], flags: [{ id: 'FL', code: 'FL_V', value: { id: 'FL_V' } }, { id: 'FT', value: { id: 'FT_V0' } }], key: 'TIME_PERIOD=2020', sideProps: null, coordinates: { TIME_PERIOD: '2020', FREQ: 'A' } },
|
|
260
|
-
{ data: [{ dimension: { id: 'TIME_PERIOD' }, value: { id: '2021' } }], flags: [], key: 'TIME_PERIOD=2021', sideProps: { hasMetadata: true, hasAdvancedAttributes: false, coordinates: { TIME_PERIOD: '2021', FREQ: 'A' } }, coordinates: { TIME_PERIOD: '2021', FREQ: 'A' } },
|
|
261
|
-
],
|
|
262
|
-
sectionsData: [
|
|
263
|
-
[
|
|
264
|
-
{ data: [{ dimension: { id: 'TRANSACT' }, value: { id: 'TRANSACT1' } }], flags: [{ id: 'FT', value: { id: 'FT_V1' } }], key: 'TRANSACT=TRANSACT1', sideProps: { hasAdvancedAttributes: true, hasMetadata: true, coordinates: { TRANSACT: 'TRANSACT1', FREQ: 'A' } }, coordinates: { TRANSACT: 'TRANSACT1', FREQ: 'A' } },
|
|
265
|
-
[
|
|
266
|
-
{ data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'US' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'USD', display: true }, { id: 'BILL' }] }], flags: [], key: 'REF_AREA=US:MEASURE=USD', sideProps: null, coordinates: { TRANSACT: 'TRANSACT1', REF_AREA: 'US', MEASURE: 'USD', FREQ: 'A' } },
|
|
267
|
-
{ data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'AUS' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'AUSD', display: true }, { id: '0' }] }], flags: [], key: 'REF_AREA=AUS:MEASURE=AUSD', sideProps: null, coordinates: { TRANSACT: 'TRANSACT1', REF_AREA: 'AUS', MEASURE: 'AUSD', FREQ: 'A' } },
|
|
268
|
-
{ data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'FRA' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'EUR', display: true }, { id: 'MILL' }] }], flags: [], key: 'REF_AREA=FRA:MEASURE=EUR', sideProps: null, coordinates: { TRANSACT: 'TRANSACT1', REF_AREA: 'FRA', MEASURE: 'EUR', FREQ: 'A' } },
|
|
269
|
-
]
|
|
270
|
-
],
|
|
271
|
-
[
|
|
272
|
-
{ data: [{ dimension: { id: 'TRANSACT' }, value: { id: 'TRANSACT2' } }], flags: [], key: 'TRANSACT=TRANSACT2', sideProps: null, coordinates: { TRANSACT: 'TRANSACT2', FREQ: 'A' } },
|
|
273
|
-
[
|
|
274
|
-
{ data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'US' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'USD', display: true }, { id: 'BILL' }] }], flags: [], key: 'REF_AREA=US:MEASURE=USD', sideProps: { hasAdvancedAttributes: true, hasMetadata: false, coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'US', MEASURE: 'USD', FREQ: 'A' } }, coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'US', MEASURE: 'USD', FREQ: 'A' } },
|
|
275
|
-
{ data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'AUS' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'AUSD', display: true }, { id: '0' }] }], flags: [], key: 'REF_AREA=AUS:MEASURE=AUSD', sideProps: { hasAdvancedAttributes: false, hasMetadata: true, coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'AUS', MEASURE: 'AUSD', FREQ: 'A' } }, coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'AUS', MEASURE: 'AUSD', FREQ: 'A' } },
|
|
276
|
-
{ data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'FRA' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'EUR', display: true }, { id: 'MILL' }] }], flags: [{ id: 'FT', value: { id: 'FT_V2' } }], key: 'REF_AREA=FRA:MEASURE=EUR', sideProps: null, coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'FRA', MEASURE: 'EUR', FREQ: 'A' } },
|
|
277
|
-
]
|
|
278
|
-
],
|
|
279
|
-
]
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
expect(getLayoutData(layoutIndexes, layout, { attributesSeries, metadataCoordinates, customAttributes, topCoordinates })).to.deep.equal(layoutData);
|
|
283
|
-
});
|
|
284
|
-
});
|