@sis-cc/dotstatsuite-components 16.3.0 → 16.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.
@@ -39,7 +39,14 @@ var parseAttributesValues = function parseAttributesValues(obs, attributes, inde
39
39
  if (R.isNil(attribute) || !R.prop('series', attribute)) {
40
40
  return acc;
41
41
  }
42
- var value = R.nth(valueIndex, attribute.values || []);
42
+ var _value = R.nth(valueIndex, attribute.values || []);
43
+ var value = R.isNil(_value) ? _value : R.over(R.lensProp('display'), function () {
44
+ var display = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
45
+ return display && !R.includes(_value.id, _constants.REJECTED_VALUE_IDS);
46
+ })(_value);
47
+ if ((!R.propOr(true, 'display', attribute) || !R.propOr(true, 'display', value)) && !R.prop('combined', attribute)) {
48
+ value = null;
49
+ }
43
50
  var relationship = R.propOr([], 'relationship', attribute);
44
51
  var coordinates = {};
45
52
  var serieKey = R.pipe(function (dims) {
@@ -51,7 +58,7 @@ var parseAttributesValues = function parseAttributesValues(obs, attributes, inde
51
58
  return dim.id + '=' + valueId;
52
59
  }), R.ifElse(R.isEmpty, R.always(null), R.join(':')))(indexedDimensions);
53
60
 
54
- return R.assoc(attribute.id, (0, _extends3.default)({}, R.pick(['id', 'name', 'relationship'], attribute), { value: value, serieKey: serieKey, coordinates: coordinates, isObs: R.isEmpty(relationship) }), acc);
61
+ return R.assoc(attribute.id, (0, _extends3.default)({}, R.pick(['id', 'name', 'relationship', 'display'], attribute), { value: value, serieKey: serieKey, coordinates: coordinates, isObs: R.isEmpty(relationship) }), acc);
55
62
  }, {}, attrValuesIndexes);
56
63
  };
57
64
 
@@ -25,7 +25,7 @@ var refineAttributes = exports.refineAttributes = function refineAttributes(pars
25
25
  }, {}, seriesCombinations);
26
26
  return R.map(function (attr) {
27
27
  if (R.has(attr.id, indexedRelationships)) {
28
- return (0, _extends3.default)({}, attr, { series: true, relationship: R.prop(attr.id, indexedRelationships) });
28
+ return (0, _extends3.default)({}, attr, { series: true, relationship: R.prop(attr.id, indexedRelationships), combined: true });
29
29
  }
30
30
  return attr;
31
31
  }, parsedAttributes);
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": "16.3.0",
4
+ "version": "16.4.0",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -19,7 +19,13 @@ const parseAttributesValues = (obs, attributes, indexedDimensions) => {
19
19
  if (R.isNil(attribute) || !R.prop('series', attribute)) {
20
20
  return acc;
21
21
  }
22
- let value = R.nth(valueIndex, attribute.values || []);
22
+ const _value = R.nth(valueIndex, attribute.values || []);
23
+ let value = R.isNil(_value)
24
+ ? _value
25
+ : R.over(R.lensProp('display'), (display=true) => display && !R.includes(_value.id, REJECTED_VALUE_IDS))(_value);
26
+ if ((!R.propOr(true, 'display', attribute) || !R.propOr(true, 'display', value)) && !R.prop('combined', attribute)) {
27
+ value = null;
28
+ }
23
29
  const relationship = R.propOr([], 'relationship', attribute);
24
30
  let coordinates = {};
25
31
  const serieKey = R.pipe(
@@ -33,7 +39,7 @@ const parseAttributesValues = (obs, attributes, indexedDimensions) => {
33
39
  R.ifElse(R.isEmpty, R.always(null), R.join(':'))
34
40
  )(indexedDimensions);
35
41
 
36
- return R.assoc(attribute.id, { ...R.pick(['id', 'name', 'relationship'], attribute), value, serieKey, coordinates, isObs: R.isEmpty(relationship) }, acc);
42
+ return R.assoc(attribute.id, { ...R.pick(['id', 'name', 'relationship', 'display'], attribute), value, serieKey, coordinates, isObs: R.isEmpty(relationship) }, acc);
37
43
  },
38
44
  {},
39
45
  attrValuesIndexes
@@ -9,7 +9,7 @@ export const refineAttributes = (parsedAttributes, seriesCombinations) => {
9
9
  );
10
10
  return R.map(attr => {
11
11
  if (R.has(attr.id, indexedRelationships)) {
12
- return { ...attr, series: true, relationship: R.prop(attr.id, indexedRelationships) };
12
+ return { ...attr, series: true, relationship: R.prop(attr.id, indexedRelationships), combined: true };
13
13
  }
14
14
  return attr;
15
15
  }, parsedAttributes);
@@ -74,7 +74,7 @@ describe('enhanceObservations tests', () => {
74
74
  },
75
75
  {
76
76
  id: 'a4',
77
- values: [{ id: 'v0' }, { id: 'v1', display: false }],
77
+ values: [{ id: 'v0' }, { id: 'v1' }],
78
78
  relationship: ['d4'],
79
79
  series: true
80
80
  },
@@ -159,9 +159,9 @@ describe('enhanceObservations tests', () => {
159
159
  value: 22,
160
160
  formattedValue: '22',
161
161
  attributes: {
162
- a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v0' }, serieKey: 'd0=v0:d1=v0', coordinates: { d0: 'v0', d1: 'v0' }, isObs: false },
163
- a3: { id: 'a3', relationship: ['d2', 'd3'], value: { id: 'v0' }, serieKey: 'd2=v0:d3=v0', coordinates: { d2: 'v0', d3: 'v0' }, isObs: false },
164
- a4: { id: 'a4', relationship: ['d4'], value: { id: 'v0' }, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
162
+ a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v0', display: true }, serieKey: 'd0=v0:d1=v0', coordinates: { d0: 'v0', d1: 'v0' }, isObs: false },
163
+ a3: { id: 'a3', relationship: ['d2', 'd3'], value: { id: 'v0', display: true }, serieKey: 'd2=v0:d3=v0', coordinates: { d2: 'v0', d3: 'v0' }, isObs: false },
164
+ a4: { id: 'a4', relationship: ['d4'], value: { id: 'v0', display: true }, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
165
165
  },
166
166
  indexedDimValIds: { d0: 'v0', d1: 'v0', d2: 'v0', d3: 'v0', d4: 'v0' }
167
167
  },
@@ -171,9 +171,9 @@ describe('enhanceObservations tests', () => {
171
171
  value: 17,
172
172
  formattedValue: '17',
173
173
  attributes: {
174
- a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v1' }, serieKey: 'd0=v0:d1=v0', coordinates: { d0: 'v0', d1: 'v0' }, isObs: false },
175
- a3: { id: 'a3', relationship: ['d2', 'd3'], value: { id: 'v1' }, serieKey: 'd2=v0:d3=v1', coordinates: { d2: 'v0', d3: 'v1' }, isObs: false },
176
- a4: { id: 'a4', relationship: ['d4'], value: { id: 'v0' }, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
174
+ a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v1', display: true }, serieKey: 'd0=v0:d1=v0', coordinates: { d0: 'v0', d1: 'v0' }, isObs: false },
175
+ a3: { id: 'a3', relationship: ['d2', 'd3'], value: { id: 'v1', display: true }, serieKey: 'd2=v0:d3=v1', coordinates: { d2: 'v0', d3: 'v1' }, isObs: false },
176
+ a4: { id: 'a4', relationship: ['d4'], value: { id: 'v0', display: true }, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
177
177
  },
178
178
  indexedDimValIds: { d0: 'v0', d1: 'v0', d2: 'v0', d3: 'v1', d4: 'v0' }
179
179
  },
@@ -183,9 +183,9 @@ describe('enhanceObservations tests', () => {
183
183
  value: 55,
184
184
  formattedValue: '55',
185
185
  attributes: {
186
- a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v2' }, serieKey: 'd0=v1:d1=v0', coordinates: { d0: 'v1', d1: 'v0' }, isObs: false },
186
+ a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v2', display: true }, serieKey: 'd0=v1:d1=v0', coordinates: { d0: 'v1', d1: 'v0' }, isObs: false },
187
187
  a3: { id: 'a3', relationship: ['d2', 'd3'], value: undefined, serieKey: 'd2=v0:d3=v0', coordinates: { d2: 'v0', d3: 'v0' }, isObs: false },
188
- a4: { id: 'a4', relationship: ['d4'], value: { id: 'v0' }, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
188
+ a4: { id: 'a4', relationship: ['d4'], value: { id: 'v0', display: true }, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
189
189
  },
190
190
  indexedDimValIds: { d0: 'v1', d1: 'v0', d2: 'v0', d3: 'v0', d4: 'v0' }
191
191
  },
@@ -195,7 +195,7 @@ describe('enhanceObservations tests', () => {
195
195
  value: 35,
196
196
  formattedValue: '35',
197
197
  attributes: {
198
- a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v2' }, serieKey: 'd0=v2:d1=v0', coordinates: { d0: 'v2', d1: 'v0' }, isObs: false },
198
+ a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v2', display: true }, serieKey: 'd0=v2:d1=v0', coordinates: { d0: 'v2', d1: 'v0' }, isObs: false },
199
199
  a3: { id: 'a3', relationship: ['d2', 'd3'], value: undefined, serieKey: 'd2=v0:d3=v0', coordinates: { d2: 'v0', d3: 'v0' }, isObs: false },
200
200
  a4: { id: 'a4', relationship: ['d4'], value: undefined, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
201
201
  },
@@ -207,7 +207,7 @@ describe('enhanceObservations tests', () => {
207
207
  value: 35,
208
208
  formattedValue: '35',
209
209
  attributes: {
210
- a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v2' }, serieKey: 'd0=v3:d1=v0', coordinates: { d0: 'v3', d1: 'v0' }, isObs: false },
210
+ a0: { id: 'a0', relationship: ['d0', 'd1'], value: { id: 'v2', display: true }, serieKey: 'd0=v3:d1=v0', coordinates: { d0: 'v3', d1: 'v0' }, isObs: false },
211
211
  a3: { id: 'a3', relationship: ['d2', 'd3'], value: undefined, serieKey: 'd2=v0:d3=v0', coordinates: { d2: 'v0', d3: 'v0' }, isObs: false },
212
212
  a4: { id: 'a4', relationship: ['d4'], value: undefined, serieKey: 'd4=v0', coordinates: { d4: 'v0' }, isObs: false },
213
213
  },
@@ -215,5 +215,43 @@ describe('enhanceObservations tests', () => {
215
215
  }
216
216
  });
217
217
  });
218
+ it('not displayed attributes and combinations', () => {
219
+ const attributes = [
220
+ { id: 'A1', display: false, series: true, values: [{ id: 'A1v' }], relationship: [] },
221
+ { id: 'A2', series: true, values: [{ id: 'A2v', display: false }], relationship: [] },
222
+ { id: 'A3', series: true, values: [{ id: '_T', display: true }], relationship: [] },
223
+ { id: 'A4', display: false, series: true, values: [{ id: 'A4v' }], relationship: [], combined: true },
224
+ { id: 'A5', series: true, values: [{ id: 'A5v', display: false }], relationship: [], combined: true },
225
+ { id: 'A6', series: true, values: [{ id: '_T', display: true }], relationship: [], combined: true },
226
+ ];
227
+
228
+ const dimensions = [];
229
+
230
+ const observations = {
231
+ obs: {
232
+ attrValuesIndexes: [0, 0, 0, 0, 0, 0],
233
+ dimValuesIndexes: [],
234
+ value: 22,
235
+ }
236
+ };
237
+
238
+ expect(enhanceObservations(dimensions, observations, attributes, {})).to.deep.equal({
239
+ obs: {
240
+ attrValuesIndexes: [0, 0, 0, 0, 0, 0],
241
+ dimValuesIndexes: [],
242
+ value: 22,
243
+ formattedValue: '22',
244
+ attributes: {
245
+ A1: { id: 'A1', display: false, value: null, relationship: [], serieKey: null, coordinates: {}, isObs: true },
246
+ A2: { id: 'A2', value: null, relationship: [], serieKey: null, coordinates: {}, isObs: true },
247
+ A3: { id: 'A3', value: null, relationship: [], serieKey: null, coordinates: {}, isObs: true },
248
+ A4: { id: 'A4', display: false, value: { id: 'A4v', display: true }, relationship: [], serieKey: null, coordinates: {}, isObs: true },
249
+ A5: { id: 'A5', value: { id: 'A5v', display: false }, relationship: [], serieKey: null, coordinates: {}, isObs: true },
250
+ A6: { id: 'A6', value: { id: '_T', display: false }, relationship: [], serieKey: null, coordinates: {}, isObs: true },
251
+ },
252
+ indexedDimValIds: {}
253
+ }
254
+ })
255
+ });
218
256
  });
219
257
 
@@ -0,0 +1,29 @@
1
+ import { expect } from 'chai';
2
+ import { refineAttributes } from '../src/rules2/src';
3
+
4
+ describe('refineAttributes tests', () => {
5
+ it('basic test', () => {
6
+ const attributes = [
7
+ { id: 'A1', relationship: [] },
8
+ { id: 'A2', relationship: ['D1', 'D2'] },
9
+ { id: 'A3', series: true, relationship: [] },
10
+ { id: 'A4', series: true, relationship: ['D3', 'D4'] },
11
+ { id: 'A5', header: true, relationship: [] },
12
+ { id: 'A6', series: true, relationship: ['D3', 'D4'] },
13
+ ];
14
+
15
+ const combinations = [
16
+ { id: 'COMB1', concepts: ['A1', 'A3', 'A4'], relationship: ['D5', 'D6'] },
17
+ { id: 'COMB2', concepts: ['A2'], relationship: [] },
18
+ ];
19
+
20
+ expect(refineAttributes(attributes, combinations)).to.deep.equal([
21
+ { id: 'A1', series: true, relationship: ['D5', 'D6'], combined: true },
22
+ { id: 'A2', series: true, relationship: [], combined: true },
23
+ { id: 'A3', series: true, relationship: ['D5', 'D6'], combined: true },
24
+ { id: 'A4', series: true, relationship: ['D5', 'D6'], combined: true },
25
+ { id: 'A5', header: true, relationship: [] },
26
+ { id: 'A6', series: true, relationship: ['D3', 'D4'] },
27
+ ]);
28
+ });
29
+ });