@sis-cc/dotstatsuite-components 15.0.10 → 15.0.12

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.
@@ -56,7 +56,7 @@ var comparator = function comparator(size) {
56
56
  };
57
57
  };
58
58
 
59
- // simple call to ramda uniq method is very slow regarding performance
59
+ // simple call to ramda uniq method is very slow regarding performance
60
60
  var uniqIndexes = function uniqIndexes(indexes) {
61
61
  return R.pipe(R.reduce(function (acc, i) {
62
62
  var key = R.join(':', i);
@@ -71,7 +71,7 @@ var uniqIndexes = function uniqIndexes(indexes) {
71
71
  };
72
72
 
73
73
  var getSortedLayoutIndexes = exports.getSortedLayoutIndexes = function getSortedLayoutIndexes(layout, observations) {
74
- var dimIndexes = R.pipe(R.values, R.pluck('orderedDimIndexes'))(observations);
74
+ var dimIndexes = R.pipe(R.values, R.map(R.propOr([], 'orderedDimIndexes')))(observations);
75
75
 
76
76
  var headerLength = R.length(layout.header);
77
77
 
@@ -27,7 +27,7 @@ var getHeaderUnits = exports.getHeaderUnits = function getHeaderUnits(_ref) {
27
27
  var artefacts = R.converge(R.merge, [R.pathOr({}, ['dimensions', 'header']), R.pathOr({}, ['attributes', 'header'])])(unitsArtefacts);
28
28
 
29
29
  return R.pipe(R.props(unitsDefinitionCodes), R.reduce(function (acc, entry) {
30
- if (R.isNil(entry) || R.includes(R.path(['values', 0, 'id'], entry), rejectedValueIds)) {
30
+ if (R.isNil(entry) || !R.propOr(true, 'display', entry) || !R.pathOr(true, ['values', 0, 'display'], entry) || R.includes(R.path(['values', 0, 'id'], entry), rejectedValueIds)) {
31
31
  return acc;
32
32
  }
33
33
  return R.append((0, _extends3.default)({}, R.pick(['id', 'name'], entry), { value: R.path(['values', 0], entry) }), acc);
@@ -13,7 +13,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
13
13
 
14
14
  var duplicateObs = exports.duplicateObs = function duplicateObs(dims, observations) {
15
15
  var obsValues = R.values(observations);
16
- if (R.length(obsValues) < 2 || R.length(dims) === 0) {
16
+ if (R.length(dims) === 0) {
17
17
  return observations;
18
18
  }
19
19
  var duplicated = R.reduce(function (obs, 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": "15.0.10",
4
+ "version": "15.0.12",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -33,7 +33,7 @@ const comparator = size => (a, b) => {
33
33
  return a[i] - b[i];
34
34
  };
35
35
 
36
- // simple call to ramda uniq method is very slow regarding performance
36
+ // simple call to ramda uniq method is very slow regarding performance
37
37
  const uniqIndexes = (indexes) => R.pipe(
38
38
  R.reduce(
39
39
  (acc, i) => {
@@ -52,7 +52,7 @@ const uniqIndexes = (indexes) => R.pipe(
52
52
  )(indexes);
53
53
 
54
54
  export const getSortedLayoutIndexes = (layout, observations) => {
55
- const dimIndexes = R.pipe(R.values, R.pluck('orderedDimIndexes'))(observations);
55
+ const dimIndexes = R.pipe(R.values, R.map(R.propOr([], 'orderedDimIndexes')))(observations);
56
56
 
57
57
  const headerLength = R.length(layout.header);
58
58
 
@@ -17,7 +17,8 @@ export const getHeaderUnits = ({
17
17
  R.props(unitsDefinitionCodes),
18
18
  R.reduce(
19
19
  (acc, entry) => {
20
- if (R.isNil(entry) || R.includes(R.path(['values', 0, 'id'], entry), rejectedValueIds)) {
20
+ if (R.isNil(entry) || !(R.propOr(true, 'display', entry)) || !(R.pathOr(true, ['values', 0, 'display'], entry))
21
+ || R.includes(R.path(['values', 0, 'id'], entry), rejectedValueIds)) {
21
22
  return acc;
22
23
  }
23
24
  return R.append(
@@ -2,7 +2,7 @@ import * as R from 'ramda';
2
2
 
3
3
  export const duplicateObs = (dims, observations) => {
4
4
  const obsValues = R.values(observations);
5
- if ((R.length(obsValues) < 2) || R.length(dims) === 0) {
5
+ if (R.length(dims) === 0) {
6
6
  return observations;
7
7
  }
8
8
  const duplicated = R.reduce(
@@ -78,6 +78,41 @@ describe('duplicate obs tests', () => {
78
78
  }
79
79
  };
80
80
 
81
+ expect(duplicateObs(dims, obs)).to.deep.equal(expected);
82
+ });
83
+ it('handle uniq observation case', () => {
84
+ const dims = [{
85
+ id: 'REF_AREA',
86
+ __index: 2,
87
+ values: [
88
+ { id: 'W' },
89
+ { id: 'OECD' },
90
+ { id: 'FRA' },
91
+ { id: 'GER' },
92
+ { id: 'EA' },
93
+ { id: 'GER' },
94
+ { id: 'FRA' },
95
+ ]
96
+ }];
97
+ const obs = {
98
+ '0:0:0': {
99
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
100
+ dimValuesIndexes: [0, 0, 0],
101
+ }
102
+ };
103
+ const expected = {
104
+ '0:0:2': {
105
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
106
+ orderedDimIndexes: [0, 0, 2],
107
+ dimValuesIndexes: [0, 0, 0],
108
+ },
109
+ '0:0:6': {
110
+ indexedDimValIds: { FREQ: 'A', VAR: '_T', REF_AREA: 'FRA' },
111
+ orderedDimIndexes: [0, 0, 6],
112
+ dimValuesIndexes: [0, 0, 0],
113
+ }
114
+ };
115
+
81
116
  expect(duplicateObs(dims, obs)).to.deep.equal(expected);
82
117
  });
83
118
  });
@@ -31,4 +31,21 @@ describe('getHeaderUnits tests', () => {
31
31
  { id: 'A2', value: { id: 'V1' } }
32
32
  ]);
33
33
  });
34
+ it('no display', () => {
35
+ expect(getHeaderUnits({
36
+ unitsArtefacts: {
37
+ attributes: { header: {
38
+ A1: { id: 'A1', values: [{ id: 'V1' }] },
39
+ A2: { id: 'A2', display: false, values: [{ id: 'V1' }] },
40
+ A3: { id: 'A3', values: [{ id: 'RA' }] },
41
+ } },
42
+ dimensions: { header: {
43
+ D1: { id: 'D1', values: [{ id: 'V1', display: false }] },
44
+ D2: { id: 'D2', values: [{ id: 'RD' }] }
45
+ } }
46
+ },
47
+ rejectedValues: ['RA', 'RD'],
48
+ unitsDefinitionCodes: ['D1', 'C8', 'A2']
49
+ })).to.deep.equal([]);
50
+ })
34
51
  });
@@ -73,7 +73,7 @@ describe('hierarchiseDimensionWithNativeHierarchy tests', () => {
73
73
  { id: 'A', parent: undefined, parents: [], __indexPosition: 20 },
74
74
  { id: 'EA', parent: undefined, parents: [], __indexPosition: 30 },
75
75
  { id: 'GER', parent: 'EA', parents: ['EA'], __indexPosition: 100 },
76
- { id: '', parent: '', parents: [''], __indexPosition: 101 }
76
+ { id: '', parent: undefined, parents: [], __indexPosition: 101 }
77
77
  ]
78
78
  };
79
79