@sis-cc/dotstatsuite-components 20.0.1 → 20.2.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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getTableLayoutIds = exports.injectRemainingDimensionsInLayout = exports.getLayoutCombinations = exports.getLayoutDimsIds = exports.injectCombinationsInLayout = exports.injectCombination = exports.getLayoutRelationships = exports.getLayoutLevelRelationship = exports.indexCombsRelationships = exports.getCombinationsNotInLayout = undefined;
6
+ exports.getTableLayoutIds = exports.injectRemainingDimensionsInLayout = exports.getLayoutCombinations = exports.getLayoutDimsIds = exports.injectCombinationsInLayout = exports.getCombinationLevelCompatibility = exports.injectCombination = exports.getLayoutRelationships = exports.getLayoutLevelRelationship = exports.indexCombsRelationships = exports.getCombinationsNotInLayout = undefined;
7
7
 
8
8
  var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
9
9
 
@@ -96,53 +96,71 @@ var injectCombination = exports.injectCombination = function injectCombination(c
96
96
  };
97
97
  };
98
98
 
99
+ var getCombinationLevelCompatibility = exports.getCombinationLevelCompatibility = function getCombinationLevelCompatibility(layoutRelationships, combination) {
100
+ var _combination$relation = combination.relationship,
101
+ relationship = _combination$relation === undefined ? [] : _combination$relation;
102
+
103
+ var idsInHeaderSet = new _set2.default(layoutRelationships.header);
104
+ var idsInSectionsSet = new _set2.default(layoutRelationships.sections);
105
+ var idsInRowsSet = new _set2.default(layoutRelationships.rows);
106
+
107
+ var _R$partition = R.partition(function (i) {
108
+ return idsInHeaderSet.has(i);
109
+ }, relationship),
110
+ _R$partition2 = (0, _slicedToArray3.default)(_R$partition, 2),
111
+ idsInHeader = _R$partition2[0],
112
+ rest = _R$partition2[1];
113
+
114
+ var _R$reduce = R.reduce(function (_acc, id) {
115
+ if (idsInSectionsSet.has(id)) return R.over(R.lensIndex(0), R.append(id), _acc);
116
+ if (idsInRowsSet.has(id)) return R.over(R.lensIndex(1), R.append(id), _acc);
117
+ return R.over(R.lensIndex(2), R.append(id), _acc);
118
+ }, [[], [], []], rest),
119
+ _R$reduce2 = (0, _slicedToArray3.default)(_R$reduce, 2),
120
+ idsInSections = _R$reduce2[0],
121
+ idsInRows = _R$reduce2[1];
122
+
123
+ if (!R.isEmpty(idsInHeader) && R.isEmpty(idsInSections) && R.isEmpty(idsInRows)) {
124
+ return 'header';
125
+ }
126
+ if (!R.isEmpty(idsInHeader)) {
127
+ return null;
128
+ }
129
+ if (!R.isEmpty(idsInSections) && R.isEmpty(idsInRows)) {
130
+ return 'sections';
131
+ }
132
+ if (!R.isEmpty(idsInRows)) {
133
+ return 'rows';
134
+ }
135
+ return 'blank';
136
+ };
137
+
99
138
  var injectCombinationsInLayout = exports.injectCombinationsInLayout = function injectCombinationsInLayout(combinations, layoutIds) {
139
+ var defaultLayoutIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
140
+
100
141
  var notInLayoutCombs = getCombinationsNotInLayout(combinations, layoutIds);
101
142
  if (R.isEmpty(notInLayoutCombs)) {
102
143
  return layoutIds;
103
144
  }
104
145
  var indexedCombsRelationships = indexCombsRelationships(combinations);
105
146
  var layoutRelationships = getLayoutRelationships(indexedCombsRelationships, layoutIds);
147
+ var defaultLayoutRelationships = getLayoutRelationships(indexedCombsRelationships, defaultLayoutIds);
106
148
  return R.reduce(function (acc, comb) {
107
- var _comb$relationship2 = comb.relationship,
108
- relationship = _comb$relationship2 === undefined ? [] : _comb$relationship2;
109
-
110
- var idsInHeaderSet = new _set2.default(layoutRelationships.header);
111
- var idsInSectionsSet = new _set2.default(layoutRelationships.sections);
112
- var idsInRowsSet = new _set2.default(layoutRelationships.rows);
113
-
114
- var _R$partition = R.partition(function (i) {
115
- return idsInHeaderSet.has(i);
116
- }, relationship),
117
- _R$partition2 = (0, _slicedToArray3.default)(_R$partition, 2),
118
- idsInHeader = _R$partition2[0],
119
- rest = _R$partition2[1];
120
-
121
- var _R$reduce = R.reduce(function (_acc, id) {
122
- if (idsInSectionsSet.has(id)) return R.over(R.lensIndex(0), R.append(id), _acc);
123
- if (idsInRowsSet.has(id)) return R.over(R.lensIndex(1), R.append(id), _acc);
124
- return R.over(R.lensIndex(2), R.append(id), _acc);
125
- }, [[], [], []], rest),
126
- _R$reduce2 = (0, _slicedToArray3.default)(_R$reduce, 2),
127
- idsInSections = _R$reduce2[0],
128
- idsInRows = _R$reduce2[1];
129
-
130
- if (!R.isEmpty(idsInHeader) && R.isEmpty(idsInSections) && R.isEmpty(idsInRows)) {
131
- layoutRelationships.header = R.concat(layoutRelationships.header, relationship);
132
- var _ids = injectCombination(comb)(acc.header);
133
- return R.assoc('header', _ids)(acc);
134
- }
135
- if (!R.isEmpty(idsInHeader)) {
149
+ var levelCompatibility = getCombinationLevelCompatibility(layoutRelationships, comb);
150
+ if (R.isNil(levelCompatibility)) {
136
151
  return acc;
137
152
  }
138
- if (!R.isEmpty(idsInSections) && R.isEmpty(idsInRows)) {
139
- layoutRelationships.sections = R.concat(layoutRelationships.sections, relationship);
140
- var _ids2 = injectCombination(comb)(acc.sections);
141
- return R.assoc('sections', _ids2)(acc);
153
+ if (R.equals('blank', levelCompatibility)) {
154
+ levelCompatibility = getCombinationLevelCompatibility(defaultLayoutRelationships, comb);
155
+ if (R.isNil(levelCompatibility)) {
156
+ return acc;
157
+ }
158
+ levelCompatibility = R.equals('blank', levelCompatibility) ? 'rows' : levelCompatibility;
142
159
  }
143
- layoutRelationships.rows = R.concat(layoutRelationships.rows, relationship);
144
- var ids = injectCombination(comb)(acc.rows);
145
- return R.assoc('rows', ids)(acc);
160
+
161
+ layoutRelationships[levelCompatibility] = R.concat(layoutRelationships[levelCompatibility], comb.relationship);
162
+ var ids = injectCombination(comb)(acc[levelCompatibility]);
163
+ return R.assoc(levelCompatibility, ids)(acc);
146
164
  }, layoutIds, notInLayoutCombs);
147
165
  };
148
166
 
@@ -256,7 +274,7 @@ var injectRemainingDimensionsInLayout = exports.injectRemainingDimensionsInLayou
256
274
  return _layout;
257
275
  };
258
276
 
259
- var getTableLayoutIds = exports.getTableLayoutIds = function getTableLayoutIds(defaultLayoutIds, dimensions, attributes, combinations) {
277
+ var getTableLayoutIds = exports.getTableLayoutIds = function getTableLayoutIds(defaultLayoutIds, currentLayoutIds, dimensions, attributes, combinations) {
260
278
  var layoutDimsIds = getLayoutDimsIds(dimensions);
261
279
  var layoutCombinations = getLayoutCombinations(combinations, layoutDimsIds, attributes);
262
280
 
@@ -272,8 +290,8 @@ var getTableLayoutIds = exports.getTableLayoutIds = function getTableLayoutIds(d
272
290
  return !R.isEmpty(obsAttributes);
273
291
  }
274
292
  return R.has(id, indexedCombinations) || layoutDimsIds.has(id);
275
- }), defaultLayoutIds);
276
- var layoutWithCombs = injectCombinationsInLayout(layoutCombinations, filteredLayoutIds);
293
+ }), currentLayoutIds);
294
+ var layoutWithCombs = injectCombinationsInLayout(layoutCombinations, filteredLayoutIds, defaultLayoutIds);
277
295
  var layoutRelationshipsSets = R.map(R.pipe(function (ids) {
278
296
  return R.pick(ids, indexedCombinations);
279
297
  }, R.values, R.pluck('relationship'), R.unnest, function (i) {
@@ -287,18 +305,21 @@ var getTableLayoutIds = exports.getTableLayoutIds = function getTableLayoutIds(d
287
305
  }, [])), R.values, R.unnest, function (ids) {
288
306
  return new _set2.default(ids);
289
307
  })(layoutWithCombs);
308
+ var defaultLayoutConceptsSets = R.map(function (ids) {
309
+ return new _set2.default(ids);
310
+ }, defaultLayoutIds);
290
311
 
291
312
  var _R$reduce4 = R.reduce(function (acc, dim) {
292
313
  if (layoutConceptsSets.has(dim.id) || dim.header) {
293
314
  return acc;
294
315
  }
295
- if (layoutRelationshipsSets.header.has(dim.id)) {
316
+ if (layoutRelationshipsSets.header.has(dim.id) || defaultLayoutConceptsSets.header.has(dim.id)) {
296
317
  return R.over(R.lensPath(['nextLayout', 'header']), R.append(dim.id))(acc);
297
318
  }
298
- if (layoutRelationshipsSets.sections.has(dim.id)) {
319
+ if (layoutRelationshipsSets.sections.has(dim.id) || defaultLayoutConceptsSets.header.has(dim.id)) {
299
320
  return R.over(R.lensPath(['nextLayout', 'sections']), R.append(dim.id))(acc);
300
321
  }
301
- if (layoutRelationshipsSets.rows.has(dim.id)) {
322
+ if (layoutRelationshipsSets.rows.has(dim.id) || defaultLayoutConceptsSets.header.has(dim.id)) {
302
323
  return R.over(R.lensPath(['nextLayout', 'rows']), R.append(dim.id))(acc);
303
324
  }
304
325
  if ((0, _dotstatsuiteSdmxjs.isTimePeriodDimension)(dim)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sis-cc/dotstatsuite-components",
3
3
  "description": "Set components based on React.",
4
- "version": "20.0.1",
4
+ "version": "20.2.0",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
7
7
  "author": "OECD",
@@ -16,9 +16,9 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@react-hook/size": "^2.1.1",
19
- "@sis-cc/dotstatsuite-d3-charts": "~9.1.2",
20
- "@sis-cc/dotstatsuite-sdmxjs": "~10.1.0",
21
- "@sis-cc/dotstatsuite-visions": "~12.7.0",
19
+ "@sis-cc/dotstatsuite-d3-charts": "^9.1.2",
20
+ "@sis-cc/dotstatsuite-sdmxjs": "^10.1.0",
21
+ "@sis-cc/dotstatsuite-visions": "^12.8.0",
22
22
  "date-fns": "^1.30.1",
23
23
  "lodash": "^4.17.2",
24
24
  "lodash.compose": "^2.4.1",
@@ -41,45 +41,61 @@ export const injectCombination = combination => ids => {
41
41
  return inject ? R.append(id, refined) : refined;
42
42
  };
43
43
 
44
- export const injectCombinationsInLayout = (combinations, layoutIds) => {
44
+ export const getCombinationLevelCompatibility = (layoutRelationships, combination) => {
45
+ const { relationship=[] } = combination;
46
+ const idsInHeaderSet = new Set(layoutRelationships.header);
47
+ const idsInSectionsSet = new Set(layoutRelationships.sections);
48
+ const idsInRowsSet = new Set(layoutRelationships.rows);
49
+ const [idsInHeader, rest] = R.partition(
50
+ i => idsInHeaderSet.has(i),
51
+ relationship
52
+ );
53
+ const [idsInSections, idsInRows] = R.reduce((_acc, id) => {
54
+ if (idsInSectionsSet.has(id))
55
+ return R.over(R.lensIndex(0), R.append(id), _acc);
56
+ if (idsInRowsSet.has(id))
57
+ return R.over(R.lensIndex(1), R.append(id), _acc);
58
+ return R.over(R.lensIndex(2), R.append(id), _acc);
59
+ }, [[], [], []], rest);
60
+ if (!R.isEmpty(idsInHeader) && R.isEmpty(idsInSections) && R.isEmpty(idsInRows)) {
61
+ return 'header';
62
+ }
63
+ if (!R.isEmpty(idsInHeader)) {
64
+ return null;
65
+ }
66
+ if (!R.isEmpty(idsInSections) && R.isEmpty(idsInRows)) {
67
+ return 'sections';
68
+ }
69
+ if (!R.isEmpty(idsInRows)) {
70
+ return 'rows';
71
+ }
72
+ return 'blank';
73
+ }
74
+
75
+ export const injectCombinationsInLayout = (combinations, layoutIds, defaultLayoutIds = {}) => {
45
76
  const notInLayoutCombs = getCombinationsNotInLayout(combinations, layoutIds);
46
77
  if (R.isEmpty(notInLayoutCombs)) {
47
78
  return layoutIds;
48
79
  }
49
80
  const indexedCombsRelationships = indexCombsRelationships(combinations);
50
81
  let layoutRelationships = getLayoutRelationships(indexedCombsRelationships, layoutIds);
82
+ const defaultLayoutRelationships = getLayoutRelationships(indexedCombsRelationships, defaultLayoutIds);
51
83
  return R.reduce((acc, comb) => {
52
- const { relationship=[] } = comb;
53
- const idsInHeaderSet = new Set(layoutRelationships.header);
54
- const idsInSectionsSet = new Set(layoutRelationships.sections);
55
- const idsInRowsSet = new Set(layoutRelationships.rows);
56
- const [idsInHeader, rest] = R.partition(
57
- i => idsInHeaderSet.has(i),
58
- relationship
59
- );
60
- const [idsInSections, idsInRows] = R.reduce((_acc, id) => {
61
- if (idsInSectionsSet.has(id))
62
- return R.over(R.lensIndex(0), R.append(id), _acc);
63
- if (idsInRowsSet.has(id))
64
- return R.over(R.lensIndex(1), R.append(id), _acc);
65
- return R.over(R.lensIndex(2), R.append(id), _acc);
66
- }, [[], [], []], rest);
67
- if (!R.isEmpty(idsInHeader) && R.isEmpty(idsInSections) && R.isEmpty(idsInRows)) {
68
- layoutRelationships.header = R.concat(layoutRelationships.header, relationship);
69
- const ids = injectCombination(comb)(acc.header);
70
- return R.assoc('header', ids)(acc);
71
- }
72
- if (!R.isEmpty(idsInHeader)) {
84
+ let levelCompatibility = getCombinationLevelCompatibility(layoutRelationships, comb);
85
+ if (R.isNil(levelCompatibility)) {
73
86
  return acc;
74
87
  }
75
- if (!R.isEmpty(idsInSections) && R.isEmpty(idsInRows)) {
76
- layoutRelationships.sections = R.concat(layoutRelationships.sections, relationship);
77
- const ids = injectCombination(comb)(acc.sections);
78
- return R.assoc('sections', ids)(acc);
88
+ if (R.equals('blank', levelCompatibility)) {
89
+ levelCompatibility = getCombinationLevelCompatibility(defaultLayoutRelationships, comb);
90
+ if (R.isNil(levelCompatibility)) {
91
+ return acc;
92
+ }
93
+ levelCompatibility = R.equals('blank', levelCompatibility) ? 'rows' : levelCompatibility;
79
94
  }
80
- layoutRelationships.rows = R.concat(layoutRelationships.rows, relationship);
81
- const ids = injectCombination(comb)(acc.rows);
82
- return R.assoc('rows', ids)(acc);
95
+
96
+ layoutRelationships[levelCompatibility] = R.concat(layoutRelationships[levelCompatibility], comb.relationship);
97
+ const ids = injectCombination(comb)(acc[levelCompatibility]);
98
+ return R.assoc(levelCompatibility, ids)(acc);
83
99
  }, layoutIds, notInLayoutCombs);
84
100
  };
85
101
 
@@ -192,6 +208,7 @@ export const injectRemainingDimensionsInLayout = (layoutIds, remainingDims, inde
192
208
 
193
209
  export const getTableLayoutIds = (
194
210
  defaultLayoutIds,
211
+ currentLayoutIds,
195
212
  dimensions,
196
213
  attributes,
197
214
  combinations
@@ -215,9 +232,9 @@ export const getTableLayoutIds = (
215
232
  }
216
233
  return R.has(id, indexedCombinations) || layoutDimsIds.has(id);
217
234
  }),
218
- defaultLayoutIds,
235
+ currentLayoutIds
219
236
  );
220
- const layoutWithCombs = injectCombinationsInLayout(layoutCombinations, filteredLayoutIds);
237
+ const layoutWithCombs = injectCombinationsInLayout(layoutCombinations, filteredLayoutIds, defaultLayoutIds);
221
238
  const layoutRelationshipsSets = R.map(R.pipe(
222
239
  ids => R.pick(ids, indexedCombinations),
223
240
  R.values,
@@ -238,18 +255,22 @@ export const getTableLayoutIds = (
238
255
  R.unnest,
239
256
  ids => new Set(ids)
240
257
  )(layoutWithCombs);
258
+ const defaultLayoutConceptsSets = R.map(
259
+ ids => new Set(ids),
260
+ defaultLayoutIds
261
+ );
241
262
 
242
263
  const { nextLayout, remaining } = R.reduce((acc, dim) => {
243
264
  if (layoutConceptsSets.has(dim.id) || dim.header) {
244
265
  return acc;
245
266
  }
246
- if (layoutRelationshipsSets.header.has(dim.id)) {
267
+ if (layoutRelationshipsSets.header.has(dim.id) || defaultLayoutConceptsSets.header.has(dim.id)) {
247
268
  return R.over(R.lensPath(['nextLayout', 'header']), R.append(dim.id))(acc);
248
269
  }
249
- if (layoutRelationshipsSets.sections.has(dim.id)) {
270
+ if (layoutRelationshipsSets.sections.has(dim.id) || defaultLayoutConceptsSets.header.has(dim.id)) {
250
271
  return R.over(R.lensPath(['nextLayout', 'sections']), R.append(dim.id))(acc);
251
272
  }
252
- if (layoutRelationshipsSets.rows.has(dim.id)) {
273
+ if (layoutRelationshipsSets.rows.has(dim.id) || defaultLayoutConceptsSets.header.has(dim.id)) {
253
274
  return R.over(R.lensPath(['nextLayout','rows']), R.append(dim.id))(acc);
254
275
  }
255
276
  if (isTimePeriodDimension(dim)) {
@@ -45,6 +45,11 @@ describe('injectCombinationsInLayout', () => {
45
45
 
46
46
  describe('getTableLayoutIds tests', () => {
47
47
  it('simple case blank start', () => {
48
+ const defaultLayoutIds = {
49
+ header: [],
50
+ sections: [],
51
+ rows: []
52
+ };
48
53
  const layoutIds = {
49
54
  header: [],
50
55
  sections: [],
@@ -59,13 +64,18 @@ describe('getTableLayoutIds tests', () => {
59
64
  { id: 'TIME_PERIOD' },
60
65
  ];
61
66
 
62
- expect(getTableLayoutIds(layoutIds, dimensions, attributes, combinations)).to.deep.equal({
67
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds, dimensions, attributes, combinations)).to.deep.equal({
63
68
  header: ['TIME_PERIOD'],
64
69
  sections: ['MEASURE', 'REF_SECTOR'],
65
70
  rows: ['REF_AREA']
66
71
  });
67
72
  });
68
73
  it('blank start with combinations', () => {
74
+ const defaultLayoutIds = {
75
+ header: [],
76
+ sections: [],
77
+ rows: []
78
+ };
69
79
  const layoutIds = {
70
80
  header: [],
71
81
  sections: ['COMB1'],
@@ -104,7 +114,7 @@ describe('getTableLayoutIds tests', () => {
104
114
  { id: 'ATTR4', relationship: [], series: true },
105
115
  ];
106
116
 
107
- expect(getTableLayoutIds(layoutIds, dimensions, attributes, combinations)).to.deep.equal({
117
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds, dimensions, attributes, combinations)).to.deep.equal({
108
118
  header: ['TRANSACTION'],
109
119
  sections: ['COMB1', 'COMB3'],
110
120
  rows: ['COMB2', 'REF_AREA']
@@ -123,8 +133,13 @@ describe('getTableLayoutIds tests', () => {
123
133
  header: ['D2'],
124
134
  rows: ['D3']
125
135
  };
136
+ const defaultLayoutIds = {
137
+ header: [],
138
+ sections: [],
139
+ rows: []
140
+ };
126
141
 
127
- expect(getTableLayoutIds(layoutIds, dimensions, attributes, combinations)).to.deep.equal({
142
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds, dimensions, attributes, combinations)).to.deep.equal({
128
143
  header: [],
129
144
  sections: [],
130
145
  rows: ['D2']
@@ -155,8 +170,13 @@ describe('getTableLayoutIds tests', () => {
155
170
  header: ['D3'],
156
171
  rows: []
157
172
  };
173
+ const defaultLayoutIds = {
174
+ header: [],
175
+ sections: [],
176
+ rows: []
177
+ };
158
178
 
159
- expect(getTableLayoutIds(layoutIds, dimensions, attributes, combinations)).to.deep.equal({
179
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds, dimensions, attributes, combinations)).to.deep.equal({
160
180
  header: ['D3'],
161
181
  sections: [],
162
182
  rows: ['COMB1', 'COMB2']
@@ -183,6 +203,11 @@ describe('getTableLayoutIds tests', () => {
183
203
  { id: 'D3' },
184
204
  { id: 'D4' }
185
205
  ];
206
+ const defaultLayoutIds = {
207
+ header: [],
208
+ sections: [],
209
+ rows: []
210
+ };
186
211
  const layoutIds1 = {
187
212
  sections: ['COMB1', 'D4', 'COMB2'],
188
213
  header: ['D3'],
@@ -203,22 +228,22 @@ describe('getTableLayoutIds tests', () => {
203
228
  header: ['D3'],
204
229
  rows: []
205
230
  };
206
- expect(getTableLayoutIds(layoutIds1, dimensions, attributes, combinations)).to.deep.equal({
231
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds1, dimensions, attributes, combinations)).to.deep.equal({
207
232
  header: ['D3'],
208
233
  sections: ['D4'],
209
234
  rows: ['COMB1', 'COMB2']
210
235
  });
211
- expect(getTableLayoutIds(layoutIds2, dimensions, attributes, combinations)).to.deep.equal({
236
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds2, dimensions, attributes, combinations)).to.deep.equal({
212
237
  header: ['D3'],
213
238
  sections: ['COMB1', 'COMB2'],
214
239
  rows: ['D4']
215
240
  });
216
- expect(getTableLayoutIds(layoutIds3, dimensions, attributes, combinations)).to.deep.equal({
241
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds3, dimensions, attributes, combinations)).to.deep.equal({
217
242
  header: ['D3'],
218
243
  sections: ['D4'],
219
244
  rows: ['COMB2', 'COMB1']
220
245
  });
221
- expect(getTableLayoutIds(layoutIds4, dimensions, attributes, combinations)).to.deep.equal({
246
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds4, dimensions, attributes, combinations)).to.deep.equal({
222
247
  header: ['D3'],
223
248
  sections: ['COMB1', 'COMB2'],
224
249
  rows: ['D4']
@@ -237,15 +262,83 @@ describe('getTableLayoutIds tests', () => {
237
262
  { id: 'D1' },
238
263
  { id: 'D2' },
239
264
  ];
265
+ const defaultLayoutIds = {
266
+ header: [],
267
+ sections: [],
268
+ rows: []
269
+ };
240
270
  const layoutIds = {
241
271
  header: ['D2'],
242
272
  sections: ['COMB', 'D1'],
243
273
  rows: ['D3']
244
274
  };
245
- expect(getTableLayoutIds(layoutIds, dimensions, attributes, combinations)).to.deep.equal({
275
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds, dimensions, attributes, combinations)).to.deep.equal({
246
276
  header: ['D2'],
247
277
  sections: [],
248
278
  rows: ['COMB', 'D1']
249
279
  });
250
280
  });
281
+ it('combinations and default layout definition', () => {
282
+ const defaultLayoutIds = {
283
+ header: ['MEASURE', 'REF_AREA'],
284
+ sections: ['COMB2', 'COMB3'],
285
+ rows: []
286
+ };
287
+ const combinations = [
288
+ {
289
+ id: 'COMB1',
290
+ concepts: ['REF_SECTOR', 'MEASURE'],
291
+ },
292
+ {
293
+ id: 'COMB2',
294
+ concepts: ['UNIT_MEASURE', 'CURRENCY'],
295
+ },
296
+ {
297
+ id: 'COMB3',
298
+ concepts: ['ATTR1', 'ATTR2'],
299
+ },
300
+ {
301
+ id: 'COMB4',
302
+ concepts: ['ATTR3', 'ATTR4']
303
+ }
304
+ ];
305
+ const dimensions = [
306
+ { id: 'REF_AREA' },
307
+ { id: 'REF_SECTOR' },
308
+ { id: 'TRANSACTION' },
309
+ { id: 'MEASURE' },
310
+ { id: 'UNIT_MEASURE' },
311
+ { id: 'CURRENCY' }
312
+ ];
313
+ const attributes = [
314
+ { id: 'ATTR1', relationship: ['MEASURE'], series: true },
315
+ { id: 'ATTR2', relationship: ['MEASURE'], series: true },
316
+ { id: 'ATTR3', relationship: [], series: true },
317
+ { id: 'ATTR4', relationship: [], series: true },
318
+ ];
319
+
320
+ const layoutIds1 = {
321
+ header: [],
322
+ sections: [],
323
+ rows: []
324
+ };
325
+
326
+ const layoutIds2 = {
327
+ header: ['TRANSACTION'],
328
+ sections: ['REF_AREA'],
329
+ rows: []
330
+ };
331
+
332
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds1, dimensions, attributes, combinations)).to.deep.equal({
333
+ header: ['COMB1', 'COMB3', 'REF_AREA'],
334
+ sections: ['COMB2'],
335
+ rows: ['TRANSACTION']
336
+ });
337
+
338
+ expect(getTableLayoutIds(defaultLayoutIds, layoutIds2, dimensions, attributes, combinations)).to.deep.equal({
339
+ header: ['TRANSACTION', 'COMB1', 'COMB3'],
340
+ sections: ['COMB2'],
341
+ rows: ['REF_AREA']
342
+ });
343
+ });
251
344
  });