@sis-cc/dotstatsuite-components 16.2.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
 
@@ -23,20 +23,32 @@ var getHeaderCombinations = exports.getHeaderCombinations = function getHeaderCo
23
23
 
24
24
  var header = (0, _src.dimensionValueDisplay)(display)(comb);
25
25
 
26
- var values = R.pipe(R.reduce(function (_acc, concept) {
26
+ var combinedDisplay = function combinedDisplay(_display, values) {
27
+ if (_display === 'label') {
28
+ return R.pipe(R.filter(R.propOr(true, 'display')), R.map((0, _src.dimensionValueDisplay)(_display)), R.join(', '))(values);
29
+ }
30
+ return R.pipe(R.map((0, _src.dimensionValueDisplay)(_display)), R.join(', '))(values);
31
+ };
32
+
33
+ var label = R.pipe(R.reduce(function (_acc, concept) {
27
34
  var artefact = R.has(concept, indexedDimensions) ? R.prop(concept, indexedDimensions) : R.prop(concept, indexedAttributes);
28
35
  if (R.isNil(artefact) || !R.propOr(true, 'display', artefact || {})) {
29
36
  return _acc;
30
37
  }
31
38
  var value = R.path(['values', 0], artefact);
32
- if (R.isNil(value) || !R.propOr(true, 'display', value || {})) {
39
+ if (R.isNil(value)) {
33
40
  return _acc;
34
41
  }
35
- return R.append((0, _src.dimensionValueDisplay)(display)(value), _acc);
36
- }, []), R.join(', '))(comb.concepts || []);
37
- if (R.isEmpty(values)) {
42
+ return R.append(value, _acc);
43
+ }, []), function (values) {
44
+ if (display === 'both') {
45
+ return '(' + combinedDisplay('code', values) + ') ' + combinedDisplay('label', values);
46
+ }
47
+ return combinedDisplay(display, values);
48
+ })(comb.concepts || []);
49
+ if (R.isEmpty(label)) {
38
50
  return acc;
39
51
  }
40
- return R.append({ header: header, label: values }, acc);
52
+ return R.append({ header: header, label: label }, acc);
41
53
  }, [], combinations);
42
54
  };
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSeriesCombinations = undefined;
7
+
8
+ var _extends2 = require('babel-runtime/helpers/extends');
9
+
10
+ var _extends3 = _interopRequireDefault(_extends2);
11
+
12
+ var _ramda = require('ramda');
13
+
14
+ var R = _interopRequireWildcard(_ramda);
15
+
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; } }
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ var getSeriesCombinations = exports.getSeriesCombinations = function getSeriesCombinations(combinations, oneValuesDimensions) {
21
+ var indexedValues = R.reduce(function (acc, dim) {
22
+ var value = R.head(dim.values);
23
+ return R.assoc(dim.id, value, acc);
24
+ }, {}, oneValuesDimensions);
25
+
26
+ return R.reduce(function (acc, comb) {
27
+ if (!R.prop('series', comb)) {
28
+ return acc;
29
+ }
30
+ var fixedDimValues = R.pick(comb.concepts, indexedValues);
31
+ return R.append((0, _extends3.default)({}, comb, { fixedDimValues: fixedDimValues }), acc);
32
+ }, [], combinations);
33
+ };
@@ -247,6 +247,15 @@ Object.defineProperty(exports, 'getHeaderSubtitle', {
247
247
  }
248
248
  });
249
249
 
250
+ var _getSeriesCombinations = require('./getSeriesCombinations');
251
+
252
+ Object.defineProperty(exports, 'getSeriesCombinations', {
253
+ enumerable: true,
254
+ get: function get() {
255
+ return _getSeriesCombinations.getSeriesCombinations;
256
+ }
257
+ });
258
+
250
259
  var _getHeaderCombinations = require('./getHeaderCombinations');
251
260
 
252
261
  Object.defineProperty(exports, 'getHeaderCombinations', {
@@ -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);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getCells = exports.getCellCombinedAttributes = exports.getCellRelevantAttributes = undefined;
6
+ exports.getCells = exports.getCellCombinedSeries = exports.getCellRelevantAttributes = undefined;
7
7
 
8
8
  var _extends2 = require('babel-runtime/helpers/extends');
9
9
 
@@ -17,8 +17,6 @@ var _getFlagsAndNotes = require('./getFlagsAndNotes');
17
17
 
18
18
  var _hasCellMetadata = require('../hasCellMetadata');
19
19
 
20
- var _utils = require('../utils');
21
-
22
20
  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; } }
23
21
 
24
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -36,13 +34,22 @@ var getCellRelevantAttributes = exports.getCellRelevantAttributes = function get
36
34
  }, attributes);
37
35
  };
38
36
 
39
- var getCellCombinedAttributes = exports.getCellCombinedAttributes = function getCellCombinedAttributes(attributes, combinations) {
37
+ var getCellCombinedSeries = exports.getCellCombinedSeries = function getCellCombinedSeries(attributes, combinations) {
40
38
  return R.reduce(function (acc, comb) {
41
- var values = (0, _utils.trimedProps)(comb.concepts, attributes);
39
+ var values = R.reduce(function (acc, concept) {
40
+ if (R.has(concept, comb.fixedDimValues || {})) {
41
+ return R.append(R.prop(concept, comb.fixedDimValues), acc);
42
+ }
43
+ if (R.has(concept, attributes || {})) {
44
+ return R.append(R.path([concept, 'value'], attributes), acc);
45
+ }
46
+ return acc;
47
+ }, [], comb.concepts);
48
+
42
49
  if (R.isEmpty(values)) {
43
50
  return acc;
44
51
  }
45
- return R.append((0, _extends3.default)({}, R.pick(['id', 'name'], comb), { values: R.pluck('value', values) }), acc);
52
+ return R.append((0, _extends3.default)({}, R.pick(['id', 'name'], comb), { values: values }), acc);
46
53
  }, [], combinations);
47
54
  };
48
55
 
@@ -60,13 +67,13 @@ var getCells = exports.getCells = function getCells(customAttributes, cellsAttri
60
67
  return R.mapObjIndexed(function (obs) {
61
68
  var relevantAttributes = getCellRelevantAttributes(obs.attributes, attributesSeries, cellsAttributesId);
62
69
  var flagsAndNotes = (0, _getFlagsAndNotes.getFlagsAndNotes)(R.omit(attributesInCellsCombination, relevantAttributes), _customAttributes);
63
- var combinedAttributes = getCellCombinedAttributes(relevantAttributes, combinations.cells || []);
70
+ var combinedSeries = getCellCombinedSeries(relevantAttributes, combinations.cells || []);
64
71
  var hasAdvancedAttributes = R.pipe(R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination])), R.isEmpty, R.not)(relevantAttributes);
65
72
 
66
73
  var hasMetadata = (0, _hasCellMetadata.hasCellMetadata)(metadataCoordinates, obs.indexedDimValIds);
67
74
 
68
75
  return (0, _extends3.default)({}, R.pick(['indexedDimValIds', 'key'], obs), {
69
- flags: R.concat(flagsAndNotes, combinedAttributes),
76
+ flags: R.concat(flagsAndNotes, combinedSeries),
70
77
  sideProps: hasAdvancedAttributes || hasMetadata ? { hasAdvancedAttributes: hasAdvancedAttributes, hasMetadata: hasMetadata, coordinates: obs.indexedDimValIds } : null,
71
78
  intValue: R.is(Number, obs.value) ? obs.value : null,
72
79
  value: obs.formattedValue
@@ -25,14 +25,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
25
25
 
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
 
28
- var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, combinations, isTimeInverted, fixedDimensions) {
28
+ var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, combinations, isTimeInverted) {
29
29
  var indexedDimensions = R.pipe(R.indexBy(R.prop('id')), R.map(function (d) {
30
30
  return (0, _dotstatsuiteSdmxjs.isTimePeriodDimension)(d) && isTimeInverted ? R.assoc('isInverted', true, d) : d;
31
31
  }))(dimensions);
32
- var indexedFixedDimsValues = R.reduce(function (acc, dim) {
33
- var value = R.head(dim.values);
34
- return !dim.display ? acc : R.assoc(dim.id, R.head(dim.values), acc);
35
- }, {}, fixedDimensions);
36
32
  var indexedHeaderIds = R.indexBy(R.identity, layoutIds.header);
37
33
  var indexedSectionsIds = R.indexBy(R.identity, layoutIds.sections);
38
34
  var indexedRowsIds = (0, _extends3.default)({}, indexedSectionsIds, R.indexBy(R.identity, layoutIds.rows));
@@ -51,8 +47,7 @@ var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, co
51
47
 
52
48
  if (R.isEmpty(rest)) {
53
49
  layout = R.over(R.lensProp('header'), R.append((0, _extends3.default)({}, comb, {
54
- dimensions: (0, _utils.trimedProps)(comb.concepts, indexedDimensions),
55
- fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues)
50
+ dimensions: (0, _utils.trimedProps)(comb.concepts, indexedDimensions)
56
51
  })))(layout);
57
52
  } else if (!R.isEmpty(idsInHeader)) {
58
53
  return;
@@ -62,8 +57,7 @@ var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, co
62
57
  }, comb.relationship);
63
58
  if (R.isEmpty(idsNotInSections)) {
64
59
  layout = R.over(R.lensProp('sections'), R.append((0, _extends3.default)({}, comb, {
65
- dimensions: (0, _utils.trimedProps)(comb.concepts, indexedDimensions),
66
- fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues)
60
+ dimensions: (0, _utils.trimedProps)(comb.concepts, indexedDimensions)
67
61
  })))(layout);
68
62
  } else {
69
63
  var idsNotInRows = R.reject(function (id) {
@@ -73,8 +67,7 @@ var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, co
73
67
  layout = R.over(R.lensProp('rows'), R.append((0, _extends3.default)({}, comb, {
74
68
  dimensions: R.pipe(R.omit(layoutIds.sections), function (o) {
75
69
  return (0, _utils.trimedProps)(comb.concepts, o);
76
- })(indexedDimensions),
77
- fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues)
70
+ })(indexedDimensions)
78
71
  })))(layout);
79
72
  }
80
73
  }
@@ -29,6 +29,8 @@ var _getCells = require('./getCells');
29
29
 
30
30
  var _getCuratedCells = require('./getCuratedCells');
31
31
 
32
+ var _getSeriesCombinations = require('../getSeriesCombinations');
33
+
32
34
  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; } }
33
35
 
34
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -48,8 +50,8 @@ var getTableProps = exports.getTableProps = function getTableProps(_ref) {
48
50
  attributes = data.attributes;
49
51
 
50
52
 
51
- var seriesCombinations = R.filter(R.prop('series'), combinations);
52
- var layout = (0, _getLayout.getLayout)(layoutIds, dimensions, seriesCombinations, isTimeInverted, oneValueDimensions);
53
+ var seriesCombinations = (0, _getSeriesCombinations.getSeriesCombinations)(combinations, oneValueDimensions);
54
+ var layout = (0, _getLayout.getLayout)(layoutIds, dimensions, seriesCombinations, isTimeInverted);
53
55
  var layoutIndexes = (0, _getSortedLayoutIndexes.getSortedLayoutIndexes)(layout, observations);
54
56
  var refinedLayoutIndexes = (0, _refineLayoutSize.refineLayoutSize)({ layout: layout, observations: observations, limit: limit })(layoutIndexes);
55
57
  var layoutData = (0, _getLayoutData.getLayoutData)(refinedLayoutIndexes, layout, { metadataCoordinates: metadataCoordinates, attributesSeries: attributesSeries, customAttributes: customAttributes });
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.2.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
@@ -12,26 +12,41 @@ export const getHeaderCombinations = (combinations, dimensions, attributes, disp
12
12
 
13
13
  const header = dimensionValueDisplay(display)(comb);
14
14
 
15
- const values = R.pipe(
16
- R.reduce((_acc, concept) => {
17
- const artefact = R.has(concept, indexedDimensions)
18
- ? R.prop(concept, indexedDimensions)
19
- : R.prop(concept, indexedAttributes);
20
- if (R.isNil(artefact) || !R.propOr(true, 'display', artefact || {})) {
21
- return _acc;
22
- }
23
- const value = R.path(['values', 0], artefact);
24
- if (R.isNil(value) || !R.propOr(true, 'display', value || {})) {
25
- return _acc;
15
+ const combinedDisplay = (_display, values) => {
16
+ if (_display === 'label') {
17
+ return R.pipe(R.filter(R.propOr(true, 'display')), R.map(dimensionValueDisplay(_display)), R.join(', '))(values);
18
+ }
19
+ return R.pipe(R.map(dimensionValueDisplay(_display)), R.join(', '))(values);
20
+ };
21
+
22
+ const label = R.pipe(
23
+ R.reduce(
24
+ (_acc, concept) => {
25
+ const artefact = R.has(concept, indexedDimensions)
26
+ ? R.prop(concept, indexedDimensions)
27
+ : R.prop(concept, indexedAttributes);
28
+ if (R.isNil(artefact) || !R.propOr(true, 'display', artefact || {})) {
29
+ return _acc;
30
+ }
31
+ const value = R.path(['values', 0], artefact);
32
+ if (R.isNil(value)) {
33
+ return _acc;
34
+ }
35
+ return R.append(value, _acc);
36
+ },
37
+ []
38
+ ),
39
+ values => {
40
+ if (display === 'both') {
41
+ return `(${combinedDisplay('code', values)}) ${combinedDisplay('label', values)}`
26
42
  }
27
- return R.append(dimensionValueDisplay(display)(value), _acc);
28
- }, []),
29
- R.join(', '),
43
+ return combinedDisplay(display, values);
44
+ }
30
45
  )(comb.concepts || []);
31
- if (R.isEmpty(values)) {
46
+ if (R.isEmpty(label)) {
32
47
  return acc;
33
48
  }
34
- return R.append({ header, label: values }, acc);
49
+ return R.append({ header, label }, acc);
35
50
  },
36
51
  [],
37
52
  combinations,
@@ -0,0 +1,24 @@
1
+ import * as R from 'ramda';
2
+
3
+ export const getSeriesCombinations = (combinations, oneValuesDimensions) => {
4
+ const indexedValues = R.reduce(
5
+ (acc, dim) => {
6
+ const value = R.head(dim.values);
7
+ return R.assoc(dim.id, value, acc);
8
+ },
9
+ {},
10
+ oneValuesDimensions
11
+ );
12
+
13
+ return R.reduce(
14
+ (acc, comb) => {
15
+ if (!R.prop('series', comb)) {
16
+ return acc;
17
+ }
18
+ const fixedDimValues = R.pick(comb.concepts, indexedValues);
19
+ return R.append({ ...comb, fixedDimValues }, acc);
20
+ },
21
+ [],
22
+ combinations
23
+ );
24
+ };
@@ -28,6 +28,7 @@ export { getOneValueDimensions } from './getOneValueDimensions';
28
28
  export { getDataflowAttributes } from './getDataflowAttributes';
29
29
  export { getHeaderTitle } from './getHeaderTitle';
30
30
  export { getHeaderSubtitle } from './getHeaderSubtitle';
31
+ export { getSeriesCombinations } from './getSeriesCombinations';
31
32
  export { getHeaderCombinations } from './getHeaderCombinations';
32
33
  export { getLayout } from './table/getLayout';
33
34
  export { getSortedLayoutIndexes } from './table/getSortedLayoutIndexes';
@@ -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);
@@ -1,7 +1,6 @@
1
1
  import * as R from 'ramda';
2
2
  import { getFlagsAndNotes } from './getFlagsAndNotes';
3
3
  import { hasCellMetadata } from '../hasCellMetadata';
4
- import { trimedProps } from '../utils';
5
4
 
6
5
  export const getCellRelevantAttributes = (attributes, attributesSeries, cellAttributeIds) => R.filter(
7
6
  (attr) => {
@@ -17,17 +16,30 @@ export const getCellRelevantAttributes = (attributes, attributesSeries, cellAttr
17
16
  attributes
18
17
  );
19
18
 
20
- export const getCellCombinedAttributes = (attributes, combinations) => R.reduce(
19
+ export const getCellCombinedSeries = (attributes, combinations) => R.reduce(
21
20
  (acc, comb) => {
22
- const values = trimedProps(comb.concepts, attributes);
21
+ const values = R.reduce(
22
+ (acc, concept) => {
23
+ if (R.has(concept, comb.fixedDimValues || {})) {
24
+ return R.append(R.prop(concept, comb.fixedDimValues), acc);
25
+ }
26
+ if (R.has(concept, attributes || {})) {
27
+ return R.append(R.path([concept, 'value'], attributes), acc);
28
+ }
29
+ return acc;
30
+ },
31
+ [],
32
+ comb.concepts
33
+ );
34
+
23
35
  if (R.isEmpty(values)) {
24
36
  return acc;
25
37
  }
26
- return R.append({ ...R.pick(['id', 'name'], comb), values: R.pluck('value', values) }, acc);
38
+ return R.append({ ...R.pick(['id', 'name'], comb), values }, acc);
27
39
  },
28
40
  [],
29
41
  combinations
30
- )
42
+ );
31
43
 
32
44
  // combinations = { cells, layout };
33
45
  export const getCells = (customAttributes, cellsAttributesId, combinations, attributesSeries, metadataCoordinates) => observations => {
@@ -52,7 +64,7 @@ export const getCells = (customAttributes, cellsAttributesId, combinations, attr
52
64
  obs => {
53
65
  const relevantAttributes = getCellRelevantAttributes(obs.attributes, attributesSeries, cellsAttributesId);
54
66
  const flagsAndNotes = getFlagsAndNotes(R.omit(attributesInCellsCombination, relevantAttributes), _customAttributes);
55
- const combinedAttributes = getCellCombinedAttributes(relevantAttributes, combinations.cells || []);
67
+ const combinedSeries = getCellCombinedSeries(relevantAttributes, combinations.cells || []);
56
68
  const hasAdvancedAttributes = R.pipe(
57
69
  R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination])),
58
70
  R.isEmpty,
@@ -63,7 +75,7 @@ export const getCells = (customAttributes, cellsAttributesId, combinations, attr
63
75
 
64
76
  return ({
65
77
  ...R.pick(['indexedDimValIds', 'key'], obs),
66
- flags: R.concat(flagsAndNotes, combinedAttributes),
78
+ flags: R.concat(flagsAndNotes, combinedSeries),
67
79
  sideProps: hasAdvancedAttributes || hasMetadata ? { hasAdvancedAttributes, hasMetadata, coordinates: obs.indexedDimValIds } : null,
68
80
  intValue: R.is(Number, obs.value) ? obs.value : null,
69
81
  value: obs.formattedValue,
@@ -2,19 +2,11 @@ import * as R from 'ramda';
2
2
  import { isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
3
3
  import { trimedProps } from '../utils';
4
4
 
5
- export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted, fixedDimensions) => {
5
+ export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted) => {
6
6
  const indexedDimensions = R.pipe(
7
7
  R.indexBy(R.prop('id')),
8
8
  R.map(d => (isTimePeriodDimension(d) && isTimeInverted ? R.assoc('isInverted', true, d) : d)),
9
9
  )(dimensions);
10
- const indexedFixedDimsValues = R.reduce(
11
- (acc, dim) => {
12
- const value = R.head(dim.values);
13
- return !dim.display ? acc : R.assoc(dim.id, R.head(dim.values), acc);
14
- },
15
- {},
16
- fixedDimensions,
17
- );
18
10
  const indexedHeaderIds = R.indexBy(R.identity, layoutIds.header);
19
11
  const indexedSectionsIds = R.indexBy(R.identity, layoutIds.sections);
20
12
  const indexedRowsIds = { ...indexedSectionsIds, ...R.indexBy(R.identity, layoutIds.rows) };
@@ -30,7 +22,6 @@ export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted, f
30
22
  R.append({
31
23
  ...comb,
32
24
  dimensions: trimedProps(comb.concepts, indexedDimensions),
33
- fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues),
34
25
  }),
35
26
  )(layout);
36
27
  } else if (!R.isEmpty(idsInHeader)) {
@@ -43,7 +34,6 @@ export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted, f
43
34
  R.append({
44
35
  ...comb,
45
36
  dimensions: trimedProps(comb.concepts, indexedDimensions),
46
- fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues),
47
37
  }),
48
38
  )(layout);
49
39
  } else {
@@ -56,7 +46,6 @@ export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted, f
56
46
  dimensions: R.pipe(R.omit(layoutIds.sections), o => trimedProps(comb.concepts, o))(
57
47
  indexedDimensions,
58
48
  ),
59
- fixedDimValues: R.pick(comb.concepts, indexedFixedDimsValues),
60
49
  }),
61
50
  )(layout);
62
51
  }
@@ -7,6 +7,7 @@ import { getCellsAttributesIds } from './getCellsAttributesIds';
7
7
  import { getIndexedCombinationsByDisplay } from './getIndexedCombinationsByDisplay';
8
8
  import { getCells } from './getCells';
9
9
  import { getCuratedCells } from './getCuratedCells';
10
+ import { getSeriesCombinations } from '../getSeriesCombinations';
10
11
 
11
12
  export const getTableProps = ({ data, layoutIds, customAttributes, limit, isTimeInverted }) => {
12
13
  const {
@@ -19,8 +20,8 @@ export const getTableProps = ({ data, layoutIds, customAttributes, limit, isTime
19
20
  attributes
20
21
  } = data;
21
22
 
22
- const seriesCombinations = R.filter(R.prop('series'), combinations);
23
- const layout = getLayout(layoutIds, dimensions, seriesCombinations, isTimeInverted, oneValueDimensions);
23
+ const seriesCombinations = getSeriesCombinations(combinations, oneValueDimensions);
24
+ const layout = getLayout(layoutIds, dimensions, seriesCombinations, isTimeInverted);
24
25
  const layoutIndexes = getSortedLayoutIndexes(layout, observations);
25
26
  const refinedLayoutIndexes = refineLayoutSize({ layout, observations, limit })(layoutIndexes);
26
27
  const layoutData = getLayoutData(refinedLayoutIndexes, layout, { metadataCoordinates, attributesSeries, customAttributes });
@@ -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
 
@@ -8,7 +8,8 @@ const customAttributes = {
8
8
 
9
9
  describe('getCells tests', () => {
10
10
  it('flags', () => {
11
- expect(getCells(customAttributes, ['FL1', 'FL2', 'FT1', 'FT2', 'FT3'], [], {}, {})({
11
+ expect(
12
+ getCells(customAttributes, ['FL1', 'FL2', 'FT1', 'FT2', 'FT3'], [], {}, [])({
12
13
  a: {
13
14
  key: 'a',
14
15
  value: 33,
@@ -21,8 +22,7 @@ describe('getCells tests', () => {
21
22
  },
22
23
  indexedDimValIds: {}
23
24
  }
24
- }, 'label', customAttributes,
25
- { unitsDefinitionCodes: [], unitsSeries: {}, unitsDisplay: 'cells', unitDimension: {} }, [])).to.deep.equal({
25
+ })).to.deep.equal({
26
26
  a: {
27
27
  key: 'a',
28
28
  value: '33',
@@ -37,4 +37,45 @@ describe('getCells tests', () => {
37
37
  }
38
38
  })
39
39
  });
40
+ it('combinations', () => {
41
+ const combinations = {
42
+ cells: [{ id: 'CELLS_COMB', concepts: ['D1', 'D2', 'A1', 'A4'], fixedDimValues: { D1: { id: 'D1V' } } }],
43
+ layout: [{ id: 'LAYOUT_COMB', concepts: ['D3', 'A2', 'A3'] }]
44
+ };
45
+
46
+ const attributesSeries = {
47
+ 'D3=v0': { serieKey: 'D3=v0', A2: { value: 'A2V' } }
48
+ };
49
+
50
+ const cellsAttributesIds = ['FL1', 'FT1', 'A1'];
51
+
52
+ const observations = {
53
+ 'obs': {
54
+ formattedValue: '33',
55
+ value: 33,
56
+ attributes: {
57
+ FL1: { id: 'FL1', value: { id: 'A' } },
58
+ FT1: { id: 'FT1', value: { id: 'V' } },
59
+ A1: { id: 'A1', value: { id: 'A1V' } },
60
+ A2: { id: 'A2', value: { id: 'A2V' }, serieKey: 'D3=v0' },
61
+ A3: { id: 'A3', value: { id: 'A3V' }, serieKey: 'D3=v0' },
62
+ }
63
+ }
64
+ };
65
+
66
+
67
+ expect(getCells(customAttributes, cellsAttributesIds, combinations, attributesSeries, [])(observations)).to.deep.equal({
68
+ 'obs': {
69
+ value: '33',
70
+ intValue: 33,
71
+ sideProps: null,
72
+ flags: [
73
+ { code: 'A', id: 'FL1', value: { id: 'A' } }, // regular flag
74
+ { id: 'FT1', value: { id: 'V' } }, // regular foot note
75
+ { id: 'A3', value: { id: 'A3V' }, serieKey: 'D3=v0' }, // rejected layout combination value displayed as a footnote
76
+ { id: 'CELLS_COMB', values: [{ id: 'D1V' }, { id: 'A1V' }] } // cell level combination with fixed dim value
77
+ ]
78
+ }
79
+ });
80
+ });
40
81
  });
@@ -0,0 +1,42 @@
1
+ import { expect } from 'chai';
2
+ import { getLayout } from '../src/rules2/src';
3
+
4
+ describe('getLayout tests', () => {
5
+ it('complete test', () => {
6
+ const isTimeInverted = true;
7
+ const dimensions = [
8
+ { id: 'D1', values: [{ id: 'v1' }, { id: 'v2' }] },
9
+ { id: 'D2', values: [{ id: 'v1' }, { id: 'v2' }] },
10
+ { id: 'D3', values: [{ id: 'v1' }, { id: 'v2' }] },
11
+ { id: 'D4', values: [{ id: 'v1' }, { id: 'v2' }] },
12
+ { id: 'TIME_PERIOD', values: [{ id: 'v1' }, { id: 'v2' }] }
13
+ ];
14
+
15
+ const layoutIds = {
16
+ header: ['TIME_PERIOD'],
17
+ sections: ['D1'],
18
+ rows: ['D4', 'D2', 'D3']
19
+ };
20
+
21
+ const combinations = [
22
+ { id: 'COMB1', concepts: ['D2', 'D3'], relationship: [] }, // rejected for empty relationship
23
+ { id: 'COMB2', concepts: ['D3', 'D4', 'A1'], relationship: ['D3', 'D4', 'TIME_PERIOD'] }, // rejected because relationship is incompatible with layout
24
+ { id: 'COMB3', concepts: ['D1', 'D2', 'A2', 'D5'], relationship: ['D1', 'D2', 'D3'] },
25
+ ];
26
+
27
+ expect(getLayout(layoutIds, dimensions, combinations, isTimeInverted)).to.deep.equal({
28
+ header: [{ id: 'TIME_PERIOD', isInverted: true, values: [{ id: 'v1' }, { id: 'v2' }] }],
29
+ sections: [{ id: 'D1', values: [{ id: 'v1' }, { id: 'v2' }] }],
30
+ rows: [
31
+ { id: 'D4', values: [{ id: 'v1' }, { id: 'v2' }] },
32
+ { id: 'D3', values: [{ id: 'v1' }, { id: 'v2' }] },
33
+ {
34
+ id: 'COMB3',
35
+ concepts: ['D1', 'D2', 'A2', 'D5'],
36
+ relationship: ['D1', 'D2', 'D3'],
37
+ dimensions: [{ id: 'D2', values: [{ id: 'v1' }, { id: 'v2' }] }] // D1 kept at section level
38
+ },
39
+ ]
40
+ })
41
+ });
42
+ });
@@ -0,0 +1,29 @@
1
+ import { expect } from 'chai';
2
+ import { getSeriesCombinations } from '../src/rules2/src/';
3
+
4
+ describe('getSeriesCombinations tests', () => {
5
+ it('basic test', () => {
6
+ const oneValueDimensions = [
7
+ { id: 'D1', values: [{ id: 'v', display: false }] },
8
+ { id: 'D2', values: [{ id: 'v' }] }
9
+ ];
10
+ const combinations = [
11
+ { id: 'COMB1', header: true, concepts: ['D1', 'D2'] },
12
+ { id: 'COMB2', series: true, concepts: ['D1', 'D2', 'A1', 'A2'] },
13
+ { id: 'COMB3', series: true, concepts: ['D3', 'D4', 'A3'] },
14
+ ];
15
+
16
+ expect(getSeriesCombinations(combinations, oneValueDimensions)).to.deep.equal([
17
+ {
18
+ id: 'COMB2',
19
+ series: true,
20
+ concepts: ['D1', 'D2', 'A1', 'A2'],
21
+ fixedDimValues: {
22
+ D1: { id: 'v', display: false },
23
+ D2: { id: 'v' }
24
+ }
25
+ },
26
+ { id: 'COMB3', series: true, concepts: ['D3', 'D4', 'A3'], fixedDimValues: {} },
27
+ ])
28
+ });
29
+ });
@@ -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
+ });