@sis-cc/dotstatsuite-components 13.0.3 → 13.2.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.
Files changed (44) hide show
  1. package/lib/rules/src/dimension-utils.js +3 -2
  2. package/lib/rules/src/preparators/enhanceObservations.js +4 -8
  3. package/lib/rules/src/sdmx-data/index.js +3 -4
  4. package/lib/rules/src/table/preparators/getOneValueDimensions.js +2 -14
  5. package/lib/rules/src/table/preparators/parseAttributes.js +3 -10
  6. package/lib/rules/src/table/preparators/prepareData.js +4 -25
  7. package/lib/rules/src/table/units/getUnitsArtefacts.js +6 -11
  8. package/lib/rules/src/v8-transformer.js +39 -23
  9. package/lib/rules2/src/getNotDisplayedIds.js +42 -0
  10. package/lib/rules2/src/getSidebarData.js +41 -18
  11. package/lib/rules2/src/index.js +9 -0
  12. package/lib/viewer/src/index.js +5 -3
  13. package/package.json +1 -1
  14. package/src/rules/src/dimension-utils.js +4 -4
  15. package/src/rules/src/preparators/enhanceObservations.js +4 -7
  16. package/src/rules/src/properties/getHeaderProps.js +1 -2
  17. package/src/rules/src/sdmx-data/index.js +4 -4
  18. package/src/rules/src/table/preparators/getOneValueDimensions.js +4 -22
  19. package/src/rules/src/table/preparators/parseAttributes.js +3 -3
  20. package/src/rules/src/table/preparators/prepareData.js +3 -21
  21. package/src/rules/src/table/units/getUnitsArtefacts.js +6 -6
  22. package/src/rules/src/v8-transformer.js +49 -36
  23. package/src/rules2/src/getNotDisplayedIds.js +40 -0
  24. package/src/rules2/src/getSidebarData.js +41 -23
  25. package/src/rules2/src/index.js +1 -0
  26. package/src/viewer/src/index.js +7 -7
  27. package/test/enhanceObservations.test.js +2 -2
  28. package/test/getNotDisplayedIds.test.js +31 -0
  29. package/test/getOneValueDimensions.test.js +12 -17
  30. package/test/getSidebarData.test.js +104 -0
  31. package/test/getUnitsArtefacts.test.js +10 -14
  32. package/test/mocks/table-prep-multi-hierarchies--attributes.json +2 -0
  33. package/test/parseAttributes.test.js +4 -9
  34. package/test/table-prep-perf.test.js +0 -7
  35. package/lib/rules/src/preparators/getDisplay.js +0 -32
  36. package/lib/rules/src/table/preparators/getDisplay.js +0 -32
  37. package/lib/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -16
  38. package/lib/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
  39. package/src/rules/src/preparators/getDisplay.js +0 -20
  40. package/src/rules/src/table/preparators/getDisplay.js +0 -20
  41. package/src/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -9
  42. package/src/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
  43. package/test/getNoDisplayAnnotationsIndexes.test.js +0 -18
  44. package/test/getNoDisplayCodes.test.js +0 -87
@@ -28,9 +28,10 @@ var _isEmpty3 = _interopRequireDefault(_isEmpty2);
28
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
29
 
30
30
  var dimensionValueDisplay = exports.dimensionValueDisplay = function dimensionValueDisplay(display) {
31
+ var accessors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
31
32
  return function (dimensionValue) {
32
- var id = (0, _get3.default)(dimensionValue, 'id', '');
33
- var name = (0, _get3.default)(dimensionValue, 'name', '');
33
+ var id = (0, _get3.default)(dimensionValue, accessors.id || 'id', '');
34
+ var name = (0, _get3.default)(dimensionValue, accessors.name || 'name', '');
34
35
  switch (display) {
35
36
  case 'label':
36
37
  return (0, _isEmpty3.default)(name) ? '[' + id + ']' : name;
@@ -13,8 +13,6 @@ var _ramda = require('ramda');
13
13
 
14
14
  var R = _interopRequireWildcard(_ramda);
15
15
 
16
- var _getDisplay = require('./getDisplay');
17
-
18
16
  var _formatValue = require('./formatValue');
19
17
 
20
18
  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; } }
@@ -28,8 +26,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
28
26
  decimals: id,
29
27
  prefscale: id,
30
28
  },
31
- noDisplayIndexes,
32
- notDisplayedCodes,
33
29
  unitsArtefacts,
34
30
  obsAttributes,
35
31
  rejectedValueIds,
@@ -55,11 +51,11 @@ var getUnitsValues = function getUnitsValues(indexes, options) {
55
51
  return acc;
56
52
  }
57
53
  var valueIndex = R.prop(codelist.__index, indexes);
58
- if (R.isNil(valueIndex) || !(0, _getDisplay.getDisplay)(options)(codelist)) {
54
+ if (R.isNil(valueIndex) || !R.propOr(true, 'display', codelist)) {
59
55
  return acc;
60
56
  }
61
57
  var value = R.path(['values', Number(valueIndex)], codelist);
62
- if (R.isNil(value) || R.includes(value.id, R.propOr([], 'rejectedValueIds', options)) || !(0, _getDisplay.getDisplay)(options)((0, _extends3.default)({}, value, { parent: codelist.id }))) {
58
+ if (R.isNil(value) || R.includes(value.id, R.propOr([], 'rejectedValueIds', options)) || !R.propOr(true, 'display', value)) {
63
59
  return acc;
64
60
  }
65
61
  return R.assoc(id, (0, _extends3.default)({}, R.pick(['id', 'name', '__index'], codelist), {
@@ -97,12 +93,12 @@ var getFormatAttributesIndexes = function getFormatAttributesIndexes(attributes,
97
93
  };
98
94
 
99
95
  var getAttributeValue = function getAttributeValue(attribute, valueIndex, options) {
100
- if (!(0, _getDisplay.getDisplay)(options)(attribute)) {
96
+ if (!R.propOr(true, 'display', attribute)) {
101
97
  return null;
102
98
  }
103
99
  var value = R.pipe(R.propOr([], 'values'), R.nth(valueIndex))(attribute);
104
100
 
105
- if (R.isNil(value) || !(0, _getDisplay.getDisplay)(options)((0, _extends3.default)({}, value, { parent: attribute.id }))) {
101
+ if (R.isNil(value) || !R.propOr(true, 'display', value)) {
106
102
  return null;
107
103
  }
108
104
 
@@ -50,7 +50,6 @@ var getRelationnalAnnotations = exports.getRelationnalAnnotations = function get
50
50
 
51
51
  var hiddenFormat = exports.hiddenFormat = { isHidden: true };
52
52
 
53
- var getIsHidden = exports.getIsHidden = R.reduce(function (acc, annotation) {
54
- if (R.equals(getType(annotation), NOT_DISPLAYED)) return hiddenFormat;
55
- return acc;
56
- }, {});
53
+ var getIsHidden = exports.getIsHidden = function getIsHidden(annotations) {
54
+ return R.pipe(R.find(R.propEq('type', NOT_DISPLAYED)), R.complement(R.isNil))(annotations);
55
+ };
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getOneValueDimensions = undefined;
7
7
 
8
- var _extends2 = require('babel-runtime/helpers/extends');
9
-
10
- var _extends3 = _interopRequireDefault(_extends2);
11
-
12
8
  var _ramda = require('ramda');
13
9
 
14
10
  var R = _interopRequireWildcard(_ramda);
@@ -17,20 +13,12 @@ var _getAttributeValue = require('./getAttributeValue');
17
13
 
18
14
  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; } }
19
15
 
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- var getOneValueDimensions = exports.getOneValueDimensions = function getOneValueDimensions(dimensions, attributesIds, attributes, getDisplay) {
16
+ var getOneValueDimensions = exports.getOneValueDimensions = function getOneValueDimensions(dimensions, attributesIds, attributes) {
23
17
  return R.map(function (dimension) {
24
18
  var dimensionAttributes = R.pipe(R.mapObjIndexed(function (attr) {
25
19
  return (0, _getAttributeValue.getAttributeValue)(attr, 0);
26
20
  }), R.filter(R.complement(R.isNil)))(R.pick(R.propOr([], dimension.id, attributesIds), attributes));
27
21
 
28
- var display = getDisplay(dimension);
29
-
30
- var value = R.pipe(R.path(['values', 0]), R.assoc('attributes', dimensionAttributes), function (val) {
31
- return R.assoc('display', getDisplay((0, _extends3.default)({}, val, { parent: dimension.id })), val);
32
- })(dimension);
33
-
34
- return R.pipe(R.assoc('display', display), R.assocPath(['values', 0], value))(dimension);
22
+ return R.over(R.lensPath(['values', 0]), R.assoc('attributes', dimensionAttributes))(dimension);
35
23
  }, dimensions);
36
24
  };
@@ -5,18 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.parseAttributes = undefined;
7
7
 
8
- var _extends2 = require('babel-runtime/helpers/extends');
9
-
10
- var _extends3 = _interopRequireDefault(_extends2);
11
-
12
8
  var _ramda = require('ramda');
13
9
 
14
10
  var R = _interopRequireWildcard(_ramda);
15
11
 
16
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; } }
17
13
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
14
  var registerAttrId = function registerAttrId(path, id) {
21
15
  return R.over(R.lensPath(R.prepend('attributesIdsIndexedByTargets', path)), R.ifElse(R.isNil, R.always([id]), R.append(id)));
22
16
  };
@@ -62,17 +56,16 @@ var getAttributeRegisters = function getAttributeRegisters(attribute, parsedDime
62
56
  var parseAttributes = exports.parseAttributes = function parseAttributes(_ref) {
63
57
  var attributes = _ref.attributes,
64
58
  parsedDimensionsIds = _ref.parsedDimensionsIds,
65
- customAttributes = _ref.customAttributes,
66
- getDisplay = _ref.getDisplay;
59
+ customAttributes = _ref.customAttributes;
67
60
  return R.addIndex(R.reduce)(function (acc, attribute, attributeIndex) {
68
61
  var values = R.propOr([], 'values', attribute);
69
62
 
70
- if (R.isEmpty(values) || !getDisplay(attribute) || R.includes(attribute.id, R.propOr([], 'units', customAttributes))) {
63
+ if (R.isEmpty(values) || !R.propOr(true, 'display', attribute) || R.includes(attribute.id, R.propOr([], 'units', customAttributes))) {
71
64
  return acc;
72
65
  }
73
66
 
74
67
  var registers = getAttributeRegisters(R.pipe(R.assoc('index', attributeIndex), R.over(R.lensProp('values'), R.map(function (value) {
75
- if (!getDisplay((0, _extends3.default)({}, value, { parent: attribute.id }))) {
68
+ if (!R.propOr(true, 'display', value)) {
76
69
  return null;
77
70
  }
78
71
  return value;
@@ -17,10 +17,6 @@ var _getObservationsType = require('../../properties/getObservationsType');
17
17
 
18
18
  var _parseDimensionsIds = require('./parseDimensionsIds');
19
19
 
20
- var _getNoDisplayAnnotationsIndexes = require('./getNoDisplayAnnotationsIndexes');
21
-
22
- var _getNoDisplayCodes = require('./getNoDisplayCodes');
23
-
24
20
  var _parseAttributes2 = require('./parseAttributes');
25
21
 
26
22
  var _getDimensionsAttributesRegisters = require('./getDimensionsAttributesRegisters');
@@ -45,8 +41,6 @@ var _getAttachmentSeriesIndexes = require('../units/getAttachmentSeriesIndexes')
45
41
 
46
42
  var _getUnitsSeries = require('../units/getUnitsSeries');
47
43
 
48
- var _getDisplay2 = require('../../preparators/getDisplay');
49
-
50
44
  var _getObservations = require('../../preparators/getObservations');
51
45
 
52
46
  var _enhanceObservations = require('../../preparators/enhanceObservations');
@@ -80,18 +74,8 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
80
74
 
81
75
  var parsedDimensionsIds = (0, _parseDimensionsIds.parseDimensionsIds)(dimensions);
82
76
 
83
- var annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
84
-
85
- var noDisplayIndexes = (0, _getNoDisplayAnnotationsIndexes.getNoDisplayAnnotationsIndexes)(annotations);
86
- var notDisplayedCodes = (0, _getNoDisplayCodes.getNoDisplayCodes)({
87
- noDisplayIndexes: noDisplayIndexes,
88
- annotations: annotations,
89
- datasetIndexes: R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson)
90
- });
91
- var _getDisplay = (0, _getDisplay2.getDisplay)({ noDisplayIndexes: noDisplayIndexes, notDisplayedCodes: notDisplayedCodes });
92
-
93
77
  //------------------------------------------------------------------
94
- var unitsArtefacts = (0, _getUnitsArtefacts.getUnitsArtefacts)({ unitsDefinitionCodes: unitsDefinitionCodes, data: sdmxJson, getDisplay: _getDisplay });
78
+ var unitsArtefacts = (0, _getUnitsArtefacts.getUnitsArtefacts)({ unitsDefinitionCodes: unitsDefinitionCodes, data: sdmxJson });
95
79
  var headerUnits = (0, _getHeaderUnits.getHeaderUnits)({ unitsArtefacts: unitsArtefacts, unitsDefinitionCodes: unitsDefinitionCodes, rejectedValueIds: rejectedValueIds });
96
80
  var _dimensions = R.pipe(R.pathOr([], ['data', 'structure', 'dimensions', 'observation']), R.addIndex(R.map)(function (dim, index) {
97
81
  return R.assoc('index', index, dim);
@@ -104,7 +88,6 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
104
88
  var _parseAttributes = (0, _parseAttributes2.parseAttributes)({
105
89
  attributes: R.concat(attributes, R.pathOr([], ['data', 'structure', 'attributes', 'dataSet'], sdmxJson)),
106
90
  parsedDimensionsIds: parsedDimensionsIds,
107
- getDisplay: _getDisplay,
108
91
  customAttributes: _customAttributes
109
92
  }),
110
93
  attributesIndexedByIds = _parseAttributes.attributesIndexedByIds,
@@ -120,8 +103,6 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
120
103
  var options = {
121
104
  attachmentSeriesIndexes: attachmentSeriesIndexes,
122
105
  customAttributes: customAttributes,
123
- noDisplayIndexes: noDisplayIndexes,
124
- notDisplayedCodes: notDisplayedCodes,
125
106
  attributesIds: R.concat(seriesAttributesIds, observationsAttributesIds),
126
107
  unitsIds: obsUnitsIds
127
108
  };
@@ -134,14 +115,14 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
134
115
  //------------------------------------------------------------------
135
116
  var attributesRegisters = (0, _getDimensionsAttributesRegisters.getDimensionsAttributesRegisters)(attributesIdsIndexedByTargets, attributesIndexedByIds);
136
117
 
137
- var dimensionsAttributesValues = (0, _parseAttributesValuesFromObservations.parseAttributesValuesFromObservations)( // => { series: { key: { attrId: [...indexes] } }, dimensions: {} }
118
+ var dimensionsAttributesValues = (0, _parseAttributesValuesFromObservations.parseAttributesValuesFromObservations)( // => { series: { key: { attrId: [...indexes] } }, dimensions: {} }
138
119
  observations, attributesRegisters);
139
120
 
140
121
  var dataflowAttributes = R.mapObjIndexed(function (attribute) {
141
122
  return (0, _getAttributeValue.getAttributeValue)(attribute, 0);
142
123
  }, R.pipe(R.pick(R.propOr([], 'dataflow', attributesIdsIndexedByTargets)), R.filter(R.complement(R.isNil)))(attributesIndexedByIds));
143
124
 
144
- var oneValueDimensions = (0, _getOneValueDimensions.getOneValueDimensions)(R.pipe(R.pick(R.keys(parsedDimensionsIds.oneValue)), R.omit(unitsDefinitionCodes))(dimensionsIndexedByIds), attributesIdsIndexedByTargets.oneValueDimensions, attributesIndexedByIds, _getDisplay);
125
+ var oneValueDimensions = (0, _getOneValueDimensions.getOneValueDimensions)(R.pipe(R.pick(R.keys(parsedDimensionsIds.oneValue)), R.omit(unitsDefinitionCodes))(dimensionsIndexedByIds), attributesIdsIndexedByTargets.oneValueDimensions, attributesIndexedByIds);
145
126
 
146
127
  var manyValuesDimensions = (0, _getManyValuesDimensions.getManyValuesDimensions)(dimensionsIndexedByIds, parsedDimensionsIds.manyValues, dimensionsAttributesValues.dimensions, attributesIndexedByIds);
147
128
 
@@ -156,9 +137,7 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
156
137
  return !R.includes(id, customAttributes.flags || []) && !R.includes(id, customAttributes.notes || []);
157
138
  }))(headerAttributesIds);
158
139
 
159
- var dataflowAdvancedAttributes = (0, _getAdvancedAttributes.getDataflowAdvancedAttributes)(headerAttributes,
160
- //oneValueDimensions,
161
- R.pick(R.keys(parsedDimensionsIds.oneValue), dimensionsIndexedByIds), headerAdvancedAttrIds, R.length(dimensions));
140
+ var dataflowAdvancedAttributes = (0, _getAdvancedAttributes.getDataflowAdvancedAttributes)(headerAttributes, R.pick(R.keys(parsedDimensionsIds.oneValue), dimensionsIndexedByIds), headerAdvancedAttrIds, R.length(dimensions));
162
141
 
163
142
  var observationsAdvancedAttributesIds = R.filter(function (id) {
164
143
  return !R.includes(id, customAttributes.flags || []) && !R.includes(id, customAttributes.notes || []);
@@ -17,19 +17,14 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- var getRelevantLength = exports.getRelevantLength = function getRelevantLength(getDisplay) {
21
- return function (attr) {
22
- return R.pipe(R.propOr([], 'values'), R.filter(function (val) {
23
- return getDisplay(R.assoc('parent', attr.id, val));
24
- }), R.length)(attr);
25
- };
20
+ var getRelevantLength = exports.getRelevantLength = function getRelevantLength(attr) {
21
+ return R.pipe(R.propOr([], 'values'), R.filter(R.propOr(true, 'display')), R.length)(attr);
26
22
  };
27
23
 
28
24
  var getUnitsArtefacts = exports.getUnitsArtefacts = function getUnitsArtefacts(_ref) {
29
25
  var _ref$unitsDefinitionC = _ref.unitsDefinitionCodes,
30
26
  unitsDefinitionCodes = _ref$unitsDefinitionC === undefined ? [] : _ref$unitsDefinitionC,
31
- data = _ref.data,
32
- getDisplay = _ref.getDisplay;
27
+ data = _ref.data;
33
28
 
34
29
  var dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], data);
35
30
  var parsedUnitsDimensions = R.addIndex(R.reduce)(function (acc, dimension, index) {
@@ -50,11 +45,11 @@ var getUnitsArtefacts = exports.getUnitsArtefacts = function getUnitsArtefacts(_
50
45
 
51
46
  var parsedUnitsAttributes = R.converge(function (datasetLevel, observationLevel) {
52
47
  return R.over(R.lensProp('header'), R.merge(datasetLevel))(observationLevel);
53
- }, [R.pipe(R.pathOr([], ['data', 'structure', 'attributes', 'dataSet']), R.filter(R.pipe(R.propOr([], 'values'), R.length, R.equals(1))), R.indexBy(R.prop('id')), R.pick(unitsDefinitionCodes), R.filter(getDisplay), R.mapObjIndexed(R.assoc('datasetLevel', true))), R.pipe(R.pathOr([], ['data', 'structure', 'attributes', 'observation']), R.addIndex(R.reduce)(function (acc, attr, index) {
54
- if (!R.includes(attr.id, unitsDefinitionCodes) || R.length(R.propOr([], 'values', attr)) === 0 || !getDisplay(attr)) {
48
+ }, [R.pipe(R.pathOr([], ['data', 'structure', 'attributes', 'dataSet']), R.filter(R.pipe(R.propOr([], 'values'), R.length, R.equals(1))), R.indexBy(R.prop('id')), R.pick(unitsDefinitionCodes), R.filter(R.propOr(true, 'display')), R.mapObjIndexed(R.assoc('datasetLevel', true))), R.pipe(R.pathOr([], ['data', 'structure', 'attributes', 'observation']), R.addIndex(R.reduce)(function (acc, attr, index) {
49
+ if (!R.includes(attr.id, unitsDefinitionCodes) || R.length(R.propOr([], 'values', attr)) === 0 || !R.propOr(true, 'display', attr)) {
55
50
  return acc;
56
51
  }
57
- var length = getRelevantLength(getDisplay)(attr);
52
+ var length = getRelevantLength(attr);
58
53
  if (length === 0) {
59
54
  return acc;
60
55
  }
@@ -25,6 +25,8 @@ var _date = require('./date');
25
25
 
26
26
  var _getReportingYearStart = require('./preparators/getReportingYearStart');
27
27
 
28
+ var _src = require('../../rules2/src');
29
+
28
30
  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; } }
29
31
 
30
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -41,12 +43,34 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
41
43
  var getLocalisedProp = R.curry(function (prop, collection) {
42
44
  return getProp(prop, locale)(collection);
43
45
  });
44
- var getValues = R.map(function (value) {
45
- return (0, _extends3.default)({}, value, { name: getLocalisedProp('names', value) });
46
- });
47
- var getValuesEnhanced = function getValuesEnhanced(locale, annotations, isTimeDimension) {
46
+
47
+ //---------------------------------------------------------------------------------------Annotations
48
+ var getStructure = R.pathOr({}, ['data', 'structure']);
49
+ var structure = getStructure(dataNew);
50
+ var getAnnotations = R.propOr([], 'annotations');
51
+ var annotations = getAnnotations(structure);
52
+ var getDataSets = R.pathOr({}, ['data', 'dataSets']);
53
+ var dataSets = getDataSets(dataNew);
54
+
55
+ var dataSetsAnnotations = R.props(R.pathOr([], [0, 'annotations'], dataSets), annotations);
56
+
57
+ var hiddenIds = (0, _src.getNotDisplayedIds)(dataSetsAnnotations);
58
+
59
+ //--------------------------------------------------------------------------------------------------
60
+ var getValues = function getValues(values, parent) {
61
+ return R.map(function (value) {
62
+ var valAnnotations = R.props(value.annotations || [], annotations);
63
+ return (0, _extends3.default)({}, value, {
64
+ display: !R.has(parent + '.' + value.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(valAnnotations),
65
+ name: getLocalisedProp('names', value)
66
+ });
67
+ }, values);
68
+ };
69
+
70
+ var getValuesEnhanced = function getValuesEnhanced(locale, annotations, isTimeDimension, parent) {
48
71
  return R.pipe(R.addIndex(R.map)(function (value, __index) {
49
72
  var valueAnnotations = R.pipe(R.propOr([], 'annotations'), R.flip(R.props)(annotations))(value);
73
+ var isHidden = R.has(parent + '.' + value.id, hiddenIds) || (0, _sdmxData.getIsHidden)(valueAnnotations);
50
74
  var name = getLocalisedProp('names')(value);
51
75
  var __indexPosition = NaN;
52
76
  var start = null;
@@ -63,6 +87,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
63
87
  var timeFormat = R.prop('timeFormat', options);
64
88
  return (0, _extends3.default)({}, value, {
65
89
  id: R.when(R.always(isTimeDimension), R.replace(/M/g, ''))(value.id),
90
+ display: !isHidden,
66
91
  name: R.when(R.always(isTimeDimension), R.always((0, _date.getReportedTimePeriodLabel)(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start: value.start })))(name),
67
92
  start: start ? start.toISOString() : null,
68
93
  __indexPosition: __indexPosition,
@@ -73,12 +98,6 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
73
98
  }));
74
99
  };
75
100
 
76
- var getDataSets = R.pathOr({}, ['data', 'dataSets']);
77
- var dataSets = getDataSets(dataNew);
78
-
79
- var getStructure = R.pathOr({}, ['data', 'structure']);
80
- var structure = getStructure(dataNew);
81
-
82
101
  //--------------------------------------------------------------------------------------------Header
83
102
  var getMeta = R.propOr({}, 'meta');
84
103
  var meta = getMeta(dataNew);
@@ -90,14 +109,6 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
90
109
  sender: (0, _extends3.default)({}, sender, { name: getLocalisedProp('names', sender) })
91
110
  });
92
111
 
93
- //---------------------------------------------------------------------------------------Annotations
94
- var getAnnotations = R.propOr([], 'annotations');
95
- var annotations = getAnnotations(structure);
96
-
97
- var dataSetsAnnotations = (0, _sdmxData.getRelationnalAnnotations)(R.pathOr([], [0, 'annotations'])(dataSets))(annotations);
98
-
99
- var hiddenIds = R.pipe(R.find(R.propEq('type', 'NOT_DISPLAYED')), R.propOr('', 'title'), R.ifElse(R.isEmpty, R.always([]), R.split(',')))(annotations);
100
-
101
112
  //----------------------------------------------------------------------------------------Attributes
102
113
  var getAttributes = R.propOr({}, 'attributes');
103
114
  var attributes = getAttributes(structure);
@@ -106,17 +117,21 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
106
117
  var attrObservations = getAttrObservations(attributes);
107
118
 
108
119
  var resAttrObservations = R.map(function (observation) {
120
+ var obsAnnotations = R.props(observation.annotations || [], annotations);
109
121
  return (0, _extends3.default)({}, observation, {
122
+ display: !R.has(observation.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(obsAnnotations),
110
123
  name: getLocalisedProp('names', observation),
111
- values: getValues(observation.values || []),
124
+ values: getValues(observation.values || [], observation.id),
112
125
  roles: !R.isNil(observation.role) ? R.head(observation.role) : null
113
126
  });
114
127
  }, attrObservations);
115
128
 
116
129
  var datasetAttributes = R.map(function (attr) {
130
+ var attrAnnotations = R.props(attr.annotations || [], annotations);
117
131
  return (0, _extends3.default)({}, attr, {
132
+ display: !R.has(attr.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(attrAnnotations),
118
133
  name: getLocalisedProp('names', observation),
119
- values: getValues(attr.values || [])
134
+ values: getValues(attr.values || [], attr.id)
120
135
  });
121
136
  }, R.propOr([], 'dataSet', attributes));
122
137
 
@@ -135,10 +150,10 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
135
150
  return R.addIndex(R.reduce)(function (acc, observation, obsIndex) {
136
151
  var id = R.prop('id')(observation);
137
152
  var dimAnnotations = (0, _sdmxData.getRelationnalAnnotations)(R.propOr([], 'annotations')(observation))(annotations);
138
- var isHidden = R.includes(id)(hiddenIds) ? _sdmxData.hiddenFormat : (0, _sdmxData.getIsHidden)(dimAnnotations);
153
+ var isHidden = R.has(id, hiddenIds) || (0, _sdmxData.getIsHidden)(dimAnnotations);
139
154
  var isTime = (0, _dotstatsuiteSdmxjs.isTimePeriodDimension)(observation);
140
155
 
141
- var values = getValuesEnhanced(locale, annotations, isTime)(R.propOr([], 'values', observation));
156
+ var values = getValuesEnhanced(locale, annotations, isTime, id)(R.propOr([], 'values', observation));
142
157
  var ids = R.pipe(R.pluck('id'), R.indexBy(R.identity))(values);
143
158
  var groupedByParentsValues = R.groupBy(function (val) {
144
159
  var parentId = R.propOr('##ROOT', 'parent', val);
@@ -162,11 +177,12 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
162
177
 
163
178
  return {
164
179
  observation: R.append((0, _extends3.default)({}, observation, {
180
+ display: !isHidden,
165
181
  __index: obsIndex,
166
182
  name: getLocalisedProp('names', observation),
167
183
  values: sortedValues,
168
184
  role: R.isNil(observation.roles) ? null : R.head(observation.roles)
169
- }, isHidden))(acc.observation),
185
+ }))(acc.observation),
170
186
  dimensionsLayout: (0, _sdmxData.setAnnotationsLayout)(id, acc.dimensionsLayout)(dimAnnotations)
171
187
  };
172
188
  }, { observation: [], dimensionsLayout: {} });
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getNotDisplayedIds = undefined;
7
+
8
+ var _ramda = require('ramda');
9
+
10
+ var R = _interopRequireWildcard(_ramda);
11
+
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
+
14
+ var getNotDisplayedIds = exports.getNotDisplayedIds = function getNotDisplayedIds(annotations) {
15
+ return R.pipe(R.find(R.propEq('type', 'NOT_DISPLAYED')), function (annot) {
16
+ if (R.isNil(annot)) {
17
+ return {};
18
+ }
19
+ var ids = R.split(',', annot.title || '');
20
+ return R.reduce(function (acc, entry) {
21
+ if (R.isEmpty(entry)) {
22
+ return acc;
23
+ }
24
+ var parsed = R.split('=', entry);
25
+ var dimensionId = parsed[0];
26
+ if (R.length(parsed) === 1) {
27
+ return R.assoc(dimensionId, dimensionId, acc);
28
+ }
29
+ var values = R.split('+', parsed[1]);
30
+ if (R.length(values) === 1 && R.isEmpty(values[0])) {
31
+ return R.assoc(dimensionId, dimensionId, acc);
32
+ }
33
+ return R.reduce(function (_acc, val) {
34
+ if (R.isEmpty(val)) {
35
+ return _acc;
36
+ }
37
+ var key = dimensionId + '.' + val;
38
+ return R.assoc(key, key, _acc);
39
+ }, acc, values);
40
+ }, {}, ids);
41
+ })(annotations);
42
+ };
@@ -5,12 +5,18 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getSidebarData = undefined;
7
7
 
8
+ var _extends2 = require('babel-runtime/helpers/extends');
9
+
10
+ var _extends3 = _interopRequireDefault(_extends2);
11
+
8
12
  var _ramda = require('ramda');
9
13
 
10
14
  var R = _interopRequireWildcard(_ramda);
11
15
 
12
16
  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
17
 
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
14
20
  var dimensionValueDisplay = function dimensionValueDisplay(display) {
15
21
  return function (data) {
16
22
  var name = R.isNil(data.name) ? '[' + data.id + ']' : data.name;
@@ -51,27 +57,44 @@ var getSidebarData = exports.getSidebarData = function getSidebarData(attributes
51
57
  var metadata = R.prop(coordinate, metadataSeries);
52
58
  var children = R.concat(R.isNil(attributes) ? [] : [{ id: coordinate + '-attr', label: options.attributesLabel, children: attributes }], R.isNil(metadata) ? [] : metadata);
53
59
  var splitCoord = R.split(':', coordinate);
54
- var label = null;
55
- if (R.all(R.isEmpty, splitCoord)) {
56
- label = dimensionValueDisplay(options.display)(dataflow);
57
- } else {
58
- label = R.pipe(R.addIndex(R.reduce)(function (acc, valIndex, dimIndex) {
59
- if (R.isEmpty(valIndex)) {
60
- return acc;
61
- }
62
- var dim = R.nth(dimIndex, dimensions);
63
- var dimLabel = dimensionValueDisplay(options.display)(dim);
64
- var value = R.nth(Number(valIndex), dim.values);
65
- var valLabel = dimensionValueDisplay(options.display)(value);
66
- return R.append(dimLabel + ': ' + valLabel, acc);
67
- }, []), R.join(' - '))(splitCoord);
68
- }
60
+
61
+ var _R$addIndex = R.addIndex(R.reduce)(function (acc, valIndex, dimIndex) {
62
+ if (R.isEmpty(valIndex)) {
63
+ return (0, _extends3.default)({}, acc, { split: R.append('', acc.split) });
64
+ }
65
+ var dim = R.nth(dimIndex, dimensions);
66
+ var value = R.nth(Number(valIndex), dim.values);
67
+ if (!R.propOr(true, 'display', dim) || !R.propOr(true, 'display', value)) {
68
+ return (0, _extends3.default)({}, acc, { split: R.append('', acc.split) });
69
+ }
70
+ var dimLabel = dimensionValueDisplay(options.display)(dim);
71
+ var valLabel = dimensionValueDisplay(options.display)(value);
72
+ return {
73
+ labels: R.append(dimLabel + ': ' + valLabel, acc.labels),
74
+ split: R.append(valIndex, acc.split)
75
+ };
76
+ }, { split: [], labels: [] }, splitCoord),
77
+ split = _R$addIndex.split,
78
+ labels = _R$addIndex.labels;
79
+
80
+ var label = R.isEmpty(labels) ? dimensionValueDisplay(options.display)(dataflow) : R.join(' - ', labels);
69
81
 
70
82
  return {
71
- id: coordinate,
72
- splitCoord: splitCoord,
83
+ id: R.join(':', split),
84
+ splitCoord: split,
73
85
  label: label,
74
86
  children: R.filter(R.identity, children)
75
87
  };
76
- }), R.sort(sortByCoordinates))(coordinates);
88
+ }), function (series) {
89
+ // after removed non displayed dim vals, some series might be duplicated
90
+ var grouped = R.groupBy(R.prop('id'), series);
91
+ return R.pipe(R.map(function (entries) {
92
+ if (R.length(entries) === 1) {
93
+ return R.head(entries);
94
+ }
95
+ var head = R.head(entries);
96
+ var children = R.pipe(R.pluck('children'), R.unnest)(entries);
97
+ return R.assoc('children', children, head);
98
+ }), R.values)(grouped);
99
+ }, R.sort(sortByCoordinates))(coordinates);
77
100
  };
@@ -62,4 +62,13 @@ Object.defineProperty(exports, 'getMSDInformations', {
62
62
  get: function get() {
63
63
  return _getMSDInformations.getMSDInformations;
64
64
  }
65
+ });
66
+
67
+ var _getNotDisplayedIds = require('./getNotDisplayedIds');
68
+
69
+ Object.defineProperty(exports, 'getNotDisplayedIds', {
70
+ enumerable: true,
71
+ get: function get() {
72
+ return _getNotDisplayedIds.getNotDisplayedIds;
73
+ }
65
74
  });
@@ -91,15 +91,17 @@ var useStyles = (0, _styles.makeStyles)(function () {
91
91
 
92
92
  var ViewContent = function ViewContent(_ref3) {
93
93
  var loading = _ref3.loading,
94
+ _ref3$loadingProps = _ref3.loadingProps,
95
+ loadingProps = _ref3$loadingProps === undefined ? {} : _ref3$loadingProps,
94
96
  _ref3$noData = _ref3.noData,
95
97
  noData = _ref3$noData === undefined ? 'No Data' : _ref3$noData,
96
98
  type = _ref3.type,
97
99
  width = _ref3.width,
98
100
  errorMessage = _ref3.errorMessage,
99
- rest = (0, _objectWithoutProperties3.default)(_ref3, ['loading', 'noData', 'type', 'width', 'errorMessage']);
101
+ rest = (0, _objectWithoutProperties3.default)(_ref3, ['loading', 'loadingProps', 'noData', 'type', 'width', 'errorMessage']);
100
102
 
101
- if (loading) return _react2.default.createElement(_dotstatsuiteVisions.Loading, { message: loading });
102
- if (!width) return _react2.default.createElement(_dotstatsuiteVisions.Loading, { message: loading });
103
+ if (loading) return _react2.default.createElement(_dotstatsuiteVisions.Loading, (0, _extends3.default)({ message: loading }, loadingProps));
104
+ if (!width) return _react2.default.createElement(_dotstatsuiteVisions.Loading, (0, _extends3.default)({ message: loading }, loadingProps));
103
105
  if (errorMessage) return _react2.default.createElement(_dotstatsuiteVisions.NoData, { message: errorMessage });
104
106
 
105
107
  if (type === 'table') {
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": "13.0.3",
4
+ "version": "13.2.0",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -1,8 +1,8 @@
1
- import { includes, isEmpty, isNil, get, has, reduce } from 'lodash';
1
+ import { isEmpty, isNil, get, has, reduce } from 'lodash';
2
2
 
3
- export const dimensionValueDisplay = (display) => (dimensionValue) => {
4
- const id = get(dimensionValue, 'id', '');
5
- const name = get(dimensionValue, 'name', '');
3
+ export const dimensionValueDisplay = (display, accessors = {}) => (dimensionValue) => {
4
+ const id = get(dimensionValue, accessors.id || 'id', '');
5
+ const name = get(dimensionValue, accessors.name || 'name', '');
6
6
  switch(display) {
7
7
  case 'label':
8
8
  return isEmpty(name) ? `[${id}]` : name;
@@ -1,5 +1,4 @@
1
1
  import * as R from 'ramda';
2
- import { getDisplay } from './getDisplay';
3
2
  import { formatValue } from './formatValue';
4
3
 
5
4
  /*
@@ -9,8 +8,6 @@ import { formatValue } from './formatValue';
9
8
  decimals: id,
10
9
  prefscale: id,
11
10
  },
12
- noDisplayIndexes,
13
- notDisplayedCodes,
14
11
  unitsArtefacts,
15
12
  obsAttributes,
16
13
  rejectedValueIds,
@@ -38,12 +35,12 @@ const getUnitsValues = (indexes, options) => R.reduce(
38
35
  return acc;
39
36
  }
40
37
  const valueIndex = R.prop(codelist.__index, indexes);
41
- if (R.isNil(valueIndex) || !getDisplay(options)(codelist)) {
38
+ if (R.isNil(valueIndex) || !R.propOr(true, 'display', codelist)) {
42
39
  return acc;
43
40
  }
44
41
  const value = R.path(['values', Number(valueIndex)], codelist);
45
42
  if (R.isNil(value) || R.includes(value.id, R.propOr([], 'rejectedValueIds', options))
46
- || !getDisplay(options)({ ...value, parent: codelist.id })) {
43
+ || !R.propOr(true, 'display', value)) {
47
44
  return acc;
48
45
  }
49
46
  return R.assoc(
@@ -94,7 +91,7 @@ const getFormatAttributesIndexes = (attributes, customAttributes) => R.addIndex(
94
91
  );
95
92
 
96
93
  const getAttributeValue = (attribute, valueIndex, options) => {
97
- if (!getDisplay(options)(attribute)) {
94
+ if (!R.propOr(true, 'display', attribute)) {
98
95
  return null;
99
96
  }
100
97
  const value = R.pipe(
@@ -102,7 +99,7 @@ const getAttributeValue = (attribute, valueIndex, options) => {
102
99
  R.nth(valueIndex)
103
100
  )(attribute);
104
101
 
105
- if (R.isNil(value) || !getDisplay(options)({ ...value, parent: attribute.id })) {
102
+ if (R.isNil(value) || !R.propOr(true, 'display', value)) {
106
103
  return null;
107
104
  }
108
105