@sis-cc/dotstatsuite-components 15.0.1 → 15.0.4

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.
@@ -92,6 +92,6 @@ var getSideProps = function getSideProps(_ref2, customAttributes, metadataCoordi
92
92
 
93
93
  var getCells = exports.getCells = function getCells(data, display, customAttributes, unitsProps, metadataCoordinates) {
94
94
  return R.mapObjIndexed(function (observation) {
95
- return R.pipe(R.set(R.lensProp('flags'), getFlags(customAttributes, (0, _dimensionUtils.dimensionValueDisplay)(display), unitsProps)(observation)), R.set(R.lensProp('intValue'), R.prop('value', observation)), R.set(R.lensProp('value'), R.prop('formattedValue', observation)), R.assoc('indexedDimValIds', R.prop('indexedDimValIds', observation)), R.assoc('sideProps', getSideProps(observation, customAttributes, metadataCoordinates)), R.set(R.lensProp('key'), R.prop('key', observation)))({});
95
+ return R.pipe(R.set(R.lensProp('flags'), getFlags(customAttributes, (0, _dimensionUtils.dimensionValueDisplay)(display), unitsProps)(observation)), R.set(R.lensProp('intValue'), R.is(Number, observation.value) ? observation.value : null), R.set(R.lensProp('value'), R.prop('formattedValue', observation)), R.assoc('indexedDimValIds', R.prop('indexedDimValIds', observation)), R.assoc('sideProps', getSideProps(observation, customAttributes, metadataCoordinates)), R.set(R.lensProp('key'), R.prop('key', observation)))({});
96
96
  }, R.propOr({}, 'observations', data));
97
97
  };
@@ -86,9 +86,7 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
86
86
  //------------------------------------------------------------------
87
87
  var unitsArtefacts = (0, _getUnitsArtefacts.getUnitsArtefacts)({ unitsDefinitionCodes: unitsDefinitionCodes, data: sdmxJson });
88
88
  var headerUnits = (0, _getHeaderUnits.getHeaderUnits)({ unitsArtefacts: unitsArtefacts, unitsDefinitionCodes: unitsDefinitionCodes, rejectedValueIds: rejectedValueIds });
89
- var _dimensions = R.pipe(R.pathOr([], ['data', 'structure', 'dimensions', 'observation']), R.addIndex(R.map)(function (dim, index) {
90
- return R.assoc('index', index, dim);
91
- }), R.indexBy(R.prop('id')))(sdmxJson);
89
+ var _dimensions = R.pipe(R.pathOr([], ['data', 'structure', 'dimensions', 'observation']), R.indexBy(R.prop('id')))(sdmxJson);
92
90
  var attachmentSeriesIndexes = (0, _getAttachmentSeriesIndexes.getAttachmentSeriesIndexes)({ dimensions: _dimensions, unitsArtefacts: unitsArtefacts });
93
91
  //------------------------------------------------------------------
94
92
 
@@ -21,5 +21,5 @@ var getAttachmentSeriesIndexes = exports.getAttachmentSeriesIndexes = function g
21
21
 
22
22
  return R.pipe(R.props(R.concat(unitsDimensionsCodes, targettedDimensionsCodes)), R.filter(function (dim) {
23
23
  return !R.isNil(dim);
24
- }), R.pluck('index'), R.uniq, R.sortBy(R.identity))(dimensions);
24
+ }), R.pluck('__index'), R.uniq, R.sortBy(R.identity))(dimensions);
25
25
  };
@@ -12,6 +12,10 @@ var R = _interopRequireWildcard(_ramda);
12
12
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
13
 
14
14
  var duplicateObs = exports.duplicateObs = function duplicateObs(dims, observations) {
15
+ var obsValues = R.values(observations);
16
+ if (R.length(obsValues) < 2 || R.length(dims) === 0) {
17
+ return observations;
18
+ }
15
19
  var duplicated = R.reduce(function (obs, dim) {
16
20
  var groupedObs = R.groupBy(function (o) {
17
21
  return R.prop(dim.id, o.indexedDimValIds);
@@ -29,7 +33,7 @@ var duplicateObs = exports.duplicateObs = function duplicateObs(dims, observatio
29
33
  }, matchingObs);
30
34
  }, dim.values);
31
35
  return R.unnest(enhancedObs);
32
- }, R.values(observations), dims);
36
+ }, obsValues, dims);
33
37
  var res = R.indexBy(R.pipe(R.prop('orderedDimIndexes'), R.join(':')), duplicated);
34
38
  return res;
35
39
  };
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.1",
4
+ "version": "15.0.4",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -92,7 +92,7 @@ export const getCells = (data, display, customAttributes, unitsProps, metadataCo
92
92
  customAttributes, dimensionValueDisplay(display), unitsProps
93
93
  )(observation)
94
94
  ),
95
- R.set(R.lensProp('intValue'), R.prop('value', observation)),
95
+ R.set(R.lensProp('intValue'), R.is(Number, observation.value) ? observation.value : null),
96
96
  R.set(R.lensProp('value'), R.prop('formattedValue', observation)),
97
97
  R.assoc('indexedDimValIds', R.prop('indexedDimValIds', observation)),
98
98
  R.assoc('sideProps', getSideProps(observation, customAttributes, metadataCoordinates)),
@@ -50,7 +50,6 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}, _options=
50
50
  const headerUnits = getHeaderUnits({ unitsArtefacts, unitsDefinitionCodes, rejectedValueIds });
51
51
  const _dimensions = R.pipe(
52
52
  R.pathOr([], ['data', 'structure', 'dimensions', 'observation']),
53
- R.addIndex(R.map)((dim, index) => R.assoc('index', index, dim)),
54
53
  R.indexBy(R.prop('id'))
55
54
  )(sdmxJson);
56
55
  const attachmentSeriesIndexes = getAttachmentSeriesIndexes({ dimensions: _dimensions, unitsArtefacts });
@@ -2,7 +2,7 @@ import * as R from 'ramda';
2
2
 
3
3
  export const getAttachmentSeriesIndexes = ({
4
4
  unitsArtefacts,
5
- dimensions // { id: { index, ...dim } }
5
+ dimensions // { id: { __index, ...dim } }
6
6
  }) => {
7
7
  const targettedDimensionsCodes = R.pipe(
8
8
  R.pathOr({}, ['attributes', 'series']),
@@ -20,7 +20,7 @@ export const getAttachmentSeriesIndexes = ({
20
20
  return R.pipe(
21
21
  R.props(R.concat(unitsDimensionsCodes, targettedDimensionsCodes)),
22
22
  R.filter(dim => !R.isNil(dim)),
23
- R.pluck('index'),
23
+ R.pluck('__index'),
24
24
  R.uniq,
25
25
  R.sortBy(R.identity)
26
26
  )(dimensions);
@@ -1,6 +1,10 @@
1
1
  import * as R from 'ramda';
2
2
 
3
3
  export const duplicateObs = (dims, observations) => {
4
+ const obsValues = R.values(observations);
5
+ if ((R.length(obsValues) < 2) || R.length(dims) === 0) {
6
+ return observations;
7
+ }
4
8
  const duplicated = R.reduce(
5
9
  (obs, dim) => {
6
10
  const groupedObs = R.groupBy(o => R.prop(dim.id, o.indexedDimValIds), obs);
@@ -23,7 +27,7 @@ export const duplicateObs = (dims, observations) => {
23
27
  );
24
28
  return R.unnest(enhancedObs);
25
29
  },
26
- R.values(observations),
30
+ obsValues,
27
31
  dims
28
32
  );
29
33
  const res = R.indexBy(R.pipe(R.prop('orderedDimIndexes'), R.join(':')), duplicated);