@sis-cc/dotstatsuite-components 17.31.0 → 17.32.1

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.
@@ -33,7 +33,7 @@ var getDisplayableValues = function getDisplayableValues(values) {
33
33
  // - empty/null/undefined/!array values (so far)
34
34
  var hasInvalidValues = R.pipe(R.prop('values'), R.anyPass([R.isNil, R.complement(R.is(Array)), R.isEmpty]));
35
35
  var isConceptInvalid = R.anyPass([hasInvalidValues /* add more... */]);
36
- var filterInvalidConcepts = R.filter(isConceptInvalid);
36
+ var filterValidConcepts = R.reject(isConceptInvalid);
37
37
  // concepts is an array of ids... (misnamed!)
38
38
  var conceptIdsLens = R.lensProp('concepts');
39
39
  var rejectInvalidConceptIds = function rejectInvalidConceptIds() {
@@ -41,8 +41,14 @@ var rejectInvalidConceptIds = function rejectInvalidConceptIds() {
41
41
  return function () {
42
42
  var combinations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
43
43
 
44
- var invalidConceptIds = R.pluck('id', filterInvalidConcepts(concepts));
45
- return R.map(R.over(conceptIdsLens, R.without(invalidConceptIds)), combinations);
44
+ var validConceptIds = R.pluck('id', filterValidConcepts(concepts));
45
+ return R.reduce(function (acc, comb) {
46
+ var refinedConcepts = R.intersection(validConceptIds, comb.concepts);
47
+ if (R.length(refinedConcepts) < 2) {
48
+ return acc;
49
+ }
50
+ return R.append((0, _extends4.default)({}, comb, { concepts: refinedConcepts }), acc);
51
+ }, [], combinations);
46
52
  };
47
53
  };
48
54
 
@@ -90,7 +90,7 @@ var getCoordinates = function getCoordinates(indexes, topCoordinates, definition
90
90
 
91
91
  var getAttributesSeries = function getAttributesSeries(validator, attributesSeries) {
92
92
  return R.reduce(function (acc, attrs) {
93
- var attr = R.head(R.values(attrs));
93
+ var attr = R.head(R.values(attrs)) || {};
94
94
  if (R.length(attr.relationship || []) === 1 && !attr.combined) {
95
95
  return acc;
96
96
  }
@@ -130,7 +130,7 @@ var getSerieFlagsAndSideProps = function getSerieFlagsAndSideProps(coordinates,
130
130
  var flags = (0, _getFlagsAndNotes.getFlagsAndNotes)(layoutAttrValues, customAttributes);
131
131
  var hasMetadata = !R.isNil(R.find(validator, metadataCoordinates));
132
132
  var hasDataAdvancedAttributes = R.any(function (d) {
133
- return R.has('value', d) ? d.hasAdvancedAttributes : R.any(R.prop('hasAdvancedAttributes'), d.values);
133
+ return R.has('value', d) ? R.prop('hasAdvancedAttributes', d.value) : R.any(R.prop('hasAdvancedAttributes'), d.values);
134
134
  }, data);
135
135
  var hasAdvancedAttributes = hasDataAdvancedAttributes || getHasAdvancedAttributes(layoutAttrValues, customAttributes);
136
136
  var sideProps = hasMetadata || hasAdvancedAttributes ? { hasMetadata: hasMetadata, hasAdvancedAttributes: hasAdvancedAttributes, coordinates: coordinates } : null;
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": "17.31.0",
4
+ "version": "17.32.1",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -16,17 +16,20 @@ const hasInvalidValues = R.pipe(
16
16
  R.anyPass([R.isNil, R.complement(R.is(Array)), R.isEmpty]),
17
17
  );
18
18
  const isConceptInvalid = R.anyPass([hasInvalidValues /* add more... */]);
19
- const filterInvalidConcepts = R.filter(isConceptInvalid);
19
+ const filterValidConcepts = R.reject(isConceptInvalid);
20
20
  // concepts is an array of ids... (misnamed!)
21
21
  const conceptIdsLens = R.lensProp('concepts');
22
22
  const rejectInvalidConceptIds =
23
23
  (concepts = []) =>
24
24
  (combinations = []) => {
25
- const invalidConceptIds = R.pluck('id', filterInvalidConcepts(concepts));
26
- return R.map(
27
- R.over(conceptIdsLens, R.without(invalidConceptIds)),
28
- combinations,
29
- );
25
+ const validConceptIds = R.pluck('id', filterValidConcepts(concepts));
26
+ return R.reduce((acc, comb) => {
27
+ const refinedConcepts = R.intersection(validConceptIds, comb.concepts);
28
+ if (R.length(refinedConcepts) < 2) {
29
+ return acc;
30
+ }
31
+ return R.append({ ...comb, concepts: refinedConcepts }, acc);
32
+ }, [], combinations);
30
33
  };
31
34
 
32
35
  export const parseCombinations = (
@@ -51,7 +51,7 @@ const getCoordinates = (indexes, topCoordinates, definition) => R.addIndex(R.red
51
51
  }, topCoordinates, definition);
52
52
 
53
53
  const getAttributesSeries = (validator, attributesSeries) => R.reduce((acc, attrs) => {
54
- const attr = R.head(R.values(attrs));
54
+ const attr = R.head(R.values(attrs)) || {};
55
55
  if (R.length(attr.relationship || []) === 1 && !attr.combined) {
56
56
  return acc;
57
57
  }
@@ -87,7 +87,7 @@ const getSerieFlagsAndSideProps = (coordinates, validator, attributesValues, cus
87
87
  const flags = getFlagsAndNotes(layoutAttrValues, customAttributes);
88
88
  const hasMetadata = !R.isNil(R.find(validator, metadataCoordinates));
89
89
  const hasDataAdvancedAttributes = R.any(
90
- d => R.has('value', d) ? d.hasAdvancedAttributes : R.any(R.prop('hasAdvancedAttributes'), d.values)
90
+ d => R.has('value', d) ? R.prop('hasAdvancedAttributes', d.value) : R.any(R.prop('hasAdvancedAttributes'), d.values)
91
91
  , data);
92
92
  const hasAdvancedAttributes = hasDataAdvancedAttributes || getHasAdvancedAttributes(layoutAttrValues, customAttributes);
93
93
  const sideProps = hasMetadata || hasAdvancedAttributes
@@ -439,4 +439,52 @@ describe('getLayoutData 2 tests', () => {
439
439
  }
440
440
  });
441
441
  });
442
+ it('getSerieDataWithMissingLines, advanced attributes as dim level plus enpty series', () => {
443
+ const dimensions = [
444
+ {
445
+ id: 'D0',
446
+ values: [
447
+ { id: 'D0V0', flags: [], hasAdvancedAttributes: true },
448
+ { id: 'D0V1' }
449
+ ]
450
+ }
451
+ ];
452
+
453
+ const attributesSeries = {
454
+ 'D1=D1V0': {},
455
+ 'D0=D0V0:D1=D1V0': {},
456
+ };
457
+
458
+ const topCoordinates = {};
459
+
460
+ const serie = {
461
+ indexes: [0],
462
+ parentsIndexes: [[]],
463
+ missingIndexes: [[]],
464
+ };
465
+
466
+ const customAttributes = {
467
+ flags: [],
468
+ notes: ['A0', 'A2']
469
+ }
470
+
471
+ expect(getSerieDataWithMissingLines(serie, dimensions, topCoordinates, attributesSeries, customAttributes, {})).to.deep.equal([{
472
+ data: [
473
+ {
474
+ dimension: { id: 'D0' },
475
+ value: { id: 'D0V0', missingParents: [], parents: [], flags: [], hasAdvancedAttributes: true }
476
+ },
477
+ ],
478
+ coordinates: { D0: 'D0V0' },
479
+ key: 'D0=D0V0',
480
+ flags: [],
481
+ sideProps: {
482
+ coordinates: {
483
+ D0: 'D0V0',
484
+ },
485
+ hasAdvancedAttributes: true,
486
+ hasMetadata: false
487
+ }
488
+ }]);
489
+ });
442
490
  });
@@ -17,7 +17,7 @@ describe('parseCombinations tests', () => {
17
17
  { id: 'COMB11', concepts: ['DIM4', 'DIM7'] },
18
18
  { id: 'COMB12', concepts: ['DIM4', 'ATTR7'] },
19
19
  { id: 'COMB13', concepts: ['DIM7', 'ATTR7'] },
20
- { id: 'COMB14', concepts: ['DIM3', 'ATTR5', 'ATTR8'] }
20
+ { id: 'COMB14', concepts: ['DIM3', 'ATTR5', 'ATTR8'] },
21
21
  ];
22
22
 
23
23
  const dimensions = [
@@ -146,26 +146,6 @@ describe('parseCombinations tests', () => {
146
146
  relationship: ['DIM4'],
147
147
  display: true,
148
148
  },
149
- {
150
- id: 'COMB11',
151
- concepts: ['DIM4'],
152
- series: true,
153
- relationship: ['DIM4'],
154
- display: true,
155
- },
156
- {
157
- id: 'COMB12',
158
- concepts: ['DIM4'],
159
- series: true,
160
- relationship: ['DIM4'],
161
- display: true,
162
- },
163
- {
164
- id: 'COMB13',
165
- concepts: [],
166
- display: false,
167
- header: true,
168
- },
169
149
  {
170
150
  id: 'COMB14',
171
151
  concepts: ['DIM3', 'ATTR5', 'ATTR8'],