@sis-cc/dotstatsuite-components 20.3.0 → 20.4.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.
|
@@ -135,6 +135,37 @@ var getCombinationLevelCompatibility = exports.getCombinationLevelCompatibility
|
|
|
135
135
|
return 'blank';
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
+
var filterLayoutIds = function filterLayoutIds(indexedCombinations, layoutDimsIds, obsAttributes) {
|
|
139
|
+
return function (layoutIds) {
|
|
140
|
+
var layoutConcepts = R.map(R.reduce(function (acc, id) {
|
|
141
|
+
if (R.has(id, indexedCombinations)) {
|
|
142
|
+
return R.concat(acc, R.path([id, 'concepts'], indexedCombinations));
|
|
143
|
+
}
|
|
144
|
+
return R.append(id, acc);
|
|
145
|
+
}, []), layoutIds);
|
|
146
|
+
|
|
147
|
+
return R.mapObjIndexed(function (ids, level) {
|
|
148
|
+
return R.filter(function (id) {
|
|
149
|
+
if (id === 'OBS_ATTRIBUTES') {
|
|
150
|
+
return !R.isEmpty(obsAttributes);
|
|
151
|
+
}
|
|
152
|
+
if (R.has(id, indexedCombinations)) {
|
|
153
|
+
var comb = R.prop(id, indexedCombinations);
|
|
154
|
+
var dims = R.filter(function (i) {
|
|
155
|
+
return layoutDimsIds.has(i);
|
|
156
|
+
}, comb.concepts);
|
|
157
|
+
if (!R.isEmpty(dims)) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
var oppositeIds = level === 'header' ? R.concat(R.prop('sections', layoutConcepts), R.prop('rows', layoutConcepts)) : R.prop('header', layoutConcepts);
|
|
161
|
+
return R.isEmpty(R.intersection(comb.relationship, oppositeIds));
|
|
162
|
+
}
|
|
163
|
+
return layoutDimsIds.has(id);
|
|
164
|
+
}, ids);
|
|
165
|
+
}, layoutIds);
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
|
|
138
169
|
var injectCombinationsInLayout = exports.injectCombinationsInLayout = function injectCombinationsInLayout(combinations, layoutIds) {
|
|
139
170
|
var defaultLayoutIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
140
171
|
|
|
@@ -277,6 +308,7 @@ var injectRemainingDimensionsInLayout = exports.injectRemainingDimensionsInLayou
|
|
|
277
308
|
var getTableLayoutIds = exports.getTableLayoutIds = function getTableLayoutIds(defaultLayoutIds, currentLayoutIds, dimensions, attributes, combinations) {
|
|
278
309
|
var layoutDimsIds = getLayoutDimsIds(dimensions);
|
|
279
310
|
var layoutCombinations = getLayoutCombinations(combinations, layoutDimsIds, attributes);
|
|
311
|
+
var isBlank = R.pipe(R.values, R.all(R.isEmpty))(currentLayoutIds);
|
|
280
312
|
|
|
281
313
|
var combinationsConcepts = R.pipe(R.pluck('_concepts'), R.unnest, function (ids) {
|
|
282
314
|
return new _set2.default(ids);
|
|
@@ -285,12 +317,8 @@ var getTableLayoutIds = exports.getTableLayoutIds = function getTableLayoutIds(d
|
|
|
285
317
|
return a.series && R.isEmpty(a.relationship || []) && a.display && !combinationsConcepts.has(a);
|
|
286
318
|
}, attributes);
|
|
287
319
|
var indexedCombinations = R.indexBy(R.prop('id'), layoutCombinations);
|
|
288
|
-
var filteredLayoutIds =
|
|
289
|
-
|
|
290
|
-
return !R.isEmpty(obsAttributes);
|
|
291
|
-
}
|
|
292
|
-
return R.has(id, indexedCombinations) || layoutDimsIds.has(id);
|
|
293
|
-
}), currentLayoutIds);
|
|
320
|
+
var filteredLayoutIds = filterLayoutIds(indexedCombinations, layoutDimsIds, obsAttributes)(isBlank ? defaultLayoutIds : currentLayoutIds);
|
|
321
|
+
|
|
294
322
|
var layoutWithCombs = injectCombinationsInLayout(layoutCombinations, filteredLayoutIds, defaultLayoutIds);
|
|
295
323
|
var layoutRelationshipsSets = R.map(R.pipe(function (ids) {
|
|
296
324
|
return R.pick(ids, indexedCombinations);
|
|
@@ -316,10 +344,10 @@ var getTableLayoutIds = exports.getTableLayoutIds = function getTableLayoutIds(d
|
|
|
316
344
|
if (layoutRelationshipsSets.header.has(dim.id) || defaultLayoutConceptsSets.header.has(dim.id)) {
|
|
317
345
|
return R.over(R.lensPath(['nextLayout', 'header']), R.append(dim.id))(acc);
|
|
318
346
|
}
|
|
319
|
-
if (layoutRelationshipsSets.sections.has(dim.id) || defaultLayoutConceptsSets.
|
|
347
|
+
if (layoutRelationshipsSets.sections.has(dim.id) || defaultLayoutConceptsSets.sections.has(dim.id)) {
|
|
320
348
|
return R.over(R.lensPath(['nextLayout', 'sections']), R.append(dim.id))(acc);
|
|
321
349
|
}
|
|
322
|
-
if (layoutRelationshipsSets.rows.has(dim.id) || defaultLayoutConceptsSets.
|
|
350
|
+
if (layoutRelationshipsSets.rows.has(dim.id) || defaultLayoutConceptsSets.rows.has(dim.id)) {
|
|
323
351
|
return R.over(R.lensPath(['nextLayout', 'rows']), R.append(dim.id))(acc);
|
|
324
352
|
}
|
|
325
353
|
if ((0, _dotstatsuiteSdmxjs.isTimePeriodDimension)(dim)) {
|
package/package.json
CHANGED
|
@@ -72,6 +72,39 @@ export const getCombinationLevelCompatibility = (layoutRelationships, combinatio
|
|
|
72
72
|
return 'blank';
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
const filterLayoutIds = (indexedCombinations, layoutDimsIds, obsAttributes) => (layoutIds) => {
|
|
76
|
+
const layoutConcepts = R.map(
|
|
77
|
+
R.reduce((acc, id) => {
|
|
78
|
+
if (R.has(id, indexedCombinations)) {
|
|
79
|
+
return R.concat(acc, R.path([id, 'concepts'], indexedCombinations));
|
|
80
|
+
}
|
|
81
|
+
return R.append(id, acc);
|
|
82
|
+
}, []),
|
|
83
|
+
layoutIds
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return R.mapObjIndexed(
|
|
87
|
+
(ids, level) => R.filter(id => {
|
|
88
|
+
if (id === 'OBS_ATTRIBUTES') {
|
|
89
|
+
return !R.isEmpty(obsAttributes);
|
|
90
|
+
}
|
|
91
|
+
if (R.has(id, indexedCombinations)) {
|
|
92
|
+
const comb = R.prop(id, indexedCombinations);
|
|
93
|
+
const dims = R.filter(i => layoutDimsIds.has(i), comb.concepts);
|
|
94
|
+
if (!R.isEmpty(dims)) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
const oppositeIds = level === 'header'
|
|
98
|
+
? R.concat(R.prop('sections', layoutConcepts), R.prop('rows', layoutConcepts))
|
|
99
|
+
: R.prop('header', layoutConcepts);
|
|
100
|
+
return R.isEmpty(R.intersection(comb.relationship, oppositeIds));
|
|
101
|
+
}
|
|
102
|
+
return layoutDimsIds.has(id);
|
|
103
|
+
}, ids),
|
|
104
|
+
layoutIds
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
75
108
|
export const injectCombinationsInLayout = (combinations, layoutIds, defaultLayoutIds = {}) => {
|
|
76
109
|
const notInLayoutCombs = getCombinationsNotInLayout(combinations, layoutIds);
|
|
77
110
|
if (R.isEmpty(notInLayoutCombs)) {
|
|
@@ -219,21 +252,16 @@ export const getTableLayoutIds = (
|
|
|
219
252
|
layoutDimsIds,
|
|
220
253
|
attributes,
|
|
221
254
|
);
|
|
255
|
+
const isBlank = R.pipe(R.values, R.all(R.isEmpty))(currentLayoutIds);
|
|
222
256
|
|
|
223
257
|
const combinationsConcepts = R.pipe(R.pluck('_concepts'), R.unnest, ids => new Set(ids))(combinations);
|
|
224
258
|
const obsAttributes = R.filter(a =>
|
|
225
259
|
a.series && R.isEmpty(a.relationship || []) && a.display && !combinationsConcepts.has(a)
|
|
226
260
|
, attributes);
|
|
227
261
|
const indexedCombinations = R.indexBy(R.prop('id'), layoutCombinations);
|
|
228
|
-
const filteredLayoutIds =
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return !R.isEmpty(obsAttributes);
|
|
232
|
-
}
|
|
233
|
-
return R.has(id, indexedCombinations) || layoutDimsIds.has(id);
|
|
234
|
-
}),
|
|
235
|
-
currentLayoutIds
|
|
236
|
-
);
|
|
262
|
+
const filteredLayoutIds = filterLayoutIds(indexedCombinations, layoutDimsIds, obsAttributes)
|
|
263
|
+
(isBlank ? defaultLayoutIds : currentLayoutIds);
|
|
264
|
+
|
|
237
265
|
const layoutWithCombs = injectCombinationsInLayout(layoutCombinations, filteredLayoutIds, defaultLayoutIds);
|
|
238
266
|
const layoutRelationshipsSets = R.map(R.pipe(
|
|
239
267
|
ids => R.pick(ids, indexedCombinations),
|
|
@@ -267,10 +295,10 @@ export const getTableLayoutIds = (
|
|
|
267
295
|
if (layoutRelationshipsSets.header.has(dim.id) || defaultLayoutConceptsSets.header.has(dim.id)) {
|
|
268
296
|
return R.over(R.lensPath(['nextLayout', 'header']), R.append(dim.id))(acc);
|
|
269
297
|
}
|
|
270
|
-
if (layoutRelationshipsSets.sections.has(dim.id) || defaultLayoutConceptsSets.
|
|
298
|
+
if (layoutRelationshipsSets.sections.has(dim.id) || defaultLayoutConceptsSets.sections.has(dim.id)) {
|
|
271
299
|
return R.over(R.lensPath(['nextLayout', 'sections']), R.append(dim.id))(acc);
|
|
272
300
|
}
|
|
273
|
-
if (layoutRelationshipsSets.rows.has(dim.id) || defaultLayoutConceptsSets.
|
|
301
|
+
if (layoutRelationshipsSets.rows.has(dim.id) || defaultLayoutConceptsSets.rows.has(dim.id)) {
|
|
274
302
|
return R.over(R.lensPath(['nextLayout','rows']), R.append(dim.id))(acc);
|
|
275
303
|
}
|
|
276
304
|
if (isTimePeriodDimension(dim)) {
|
|
@@ -329,8 +329,14 @@ describe('getTableLayoutIds tests', () => {
|
|
|
329
329
|
rows: []
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
+
const layoutIds3 = {
|
|
333
|
+
header: [],
|
|
334
|
+
sections: ['MEASURE'],
|
|
335
|
+
rows: []
|
|
336
|
+
}
|
|
337
|
+
|
|
332
338
|
expect(getTableLayoutIds(defaultLayoutIds, layoutIds1, dimensions, attributes, combinations)).to.deep.equal({
|
|
333
|
-
header: ['COMB1', '
|
|
339
|
+
header: ['COMB1', 'REF_AREA', 'COMB3',],
|
|
334
340
|
sections: ['COMB2'],
|
|
335
341
|
rows: ['TRANSACTION']
|
|
336
342
|
});
|
|
@@ -340,5 +346,11 @@ describe('getTableLayoutIds tests', () => {
|
|
|
340
346
|
sections: ['COMB2'],
|
|
341
347
|
rows: ['REF_AREA']
|
|
342
348
|
});
|
|
349
|
+
|
|
350
|
+
expect(getTableLayoutIds(defaultLayoutIds, layoutIds3, dimensions, attributes, combinations)).to.deep.equal({
|
|
351
|
+
header: ['REF_AREA'],
|
|
352
|
+
sections: ['COMB1', 'COMB2', 'COMB3'],
|
|
353
|
+
rows: ['TRANSACTION']
|
|
354
|
+
});
|
|
343
355
|
});
|
|
344
356
|
});
|