@sis-cc/dotstatsuite-components 16.1.6 → 16.3.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.
@@ -36,13 +36,10 @@ var parseAttributesValues = function parseAttributesValues(obs, attributes, inde
36
36
 
37
37
  return R.addIndex(R.reduce)(function (acc, valueIndex, attrIndex) {
38
38
  var attribute = R.nth(attrIndex, attributes);
39
- if (R.isNil(attribute) || !R.propOr(true, 'display', attribute) || !R.prop('series', attribute)) {
39
+ if (R.isNil(attribute) || !R.prop('series', attribute)) {
40
40
  return acc;
41
41
  }
42
42
  var value = R.nth(valueIndex, attribute.values || []);
43
- if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value), _constants.REJECTED_VALUE_IDS)) {
44
- value = null;
45
- }
46
43
  var relationship = R.propOr([], 'relationship', attribute);
47
44
  var coordinates = {};
48
45
  var serieKey = R.pipe(function (dims) {
@@ -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
  };
@@ -39,7 +39,7 @@ var getOneValueDimensions = exports.getOneValueDimensions = function getOneValue
39
39
  })(acc);
40
40
  }, {}, attributes);
41
41
  return R.reduce(function (acc, dim) {
42
- if (R.length(dim.values || []) !== 1 || !R.propOr(true, 'display', dim) || !R.pathOr(true, ['values', 0, 'display'], dim) || R.includes(R.path(['values', 0, 'id'], dim), _constants.REJECTED_VALUE_IDS)) {
42
+ if (R.length(dim.values || []) !== 1) {
43
43
  return acc;
44
44
  }
45
45
  var attrValues = R.propOr({}, dim.id, indexedRelevantAttributes);
@@ -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', {
@@ -362,4 +371,13 @@ Object.defineProperty(exports, 'getTableProps', {
362
371
  get: function get() {
363
372
  return _getTableProps.getTableProps;
364
373
  }
374
+ });
375
+
376
+ var _getTableLabelAccessor = require('./table/getTableLabelAccessor');
377
+
378
+ Object.defineProperty(exports, 'getTableLabelAccessor', {
379
+ enumerable: true,
380
+ get: function get() {
381
+ return _getTableLabelAccessor.getTableLabelAccessor;
382
+ }
365
383
  });
@@ -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
@@ -9,6 +9,8 @@ var _ramda = require('ramda');
9
9
 
10
10
  var R = _interopRequireWildcard(_ramda);
11
11
 
12
+ var _constants = require('../constants');
13
+
12
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; } }
13
15
 
14
16
  var getFlagsAndNotes = exports.getFlagsAndNotes = function getFlagsAndNotes(attributesValues, customAttributes) {
@@ -20,7 +22,7 @@ var getFlagsAndNotes = exports.getFlagsAndNotes = function getFlagsAndNotes(attr
20
22
  return acc;
21
23
  }
22
24
  var attr = R.prop(id, attributesValues);
23
- if (R.isNil(attr.value)) {
25
+ if (R.isNil(attr.value) || !R.pathOr(true, ['value', 'display'], attr) || !R.propOr(true, 'display', attr) || R.includes(R.path(['value', 'id'], attr), _constants.REJECTED_VALUE_IDS)) {
24
26
  return acc;
25
27
  }
26
28
  return R.append(index < flagsIds.length ? R.assoc('code', R.path(['value', 'id'], attr), attr) : attr, acc);
@@ -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 || !value.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
  }
@@ -145,10 +145,7 @@ var getSubLayoutData = function getSubLayoutData(series, _definition, _ref) {
145
145
  var values = R.reduce(function (_acc, id) {
146
146
  if (R.has(id, dimValues)) {
147
147
  var _value = R.prop(id, dimValues);
148
- if (!R.propOr(true, 'display', _value) || R.includes(R.prop('id', _value), _constants.REJECTED_VALUE_IDS)) {
149
- return _acc;
150
- }
151
- return R.append(R.dissoc('display', _value), _acc);
148
+ return R.append(_value, _acc);
152
149
  }
153
150
  if (R.has(id, fixedDimValues)) {
154
151
  return R.append(R.prop(id, fixedDimValues), _acc);
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTableLabelAccessor = undefined;
7
+
8
+ var _ramda = require('ramda');
9
+
10
+ var R = _interopRequireWildcard(_ramda);
11
+
12
+ var _src = require('../../../rules/src');
13
+
14
+ var _constants = require('../constants');
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
+ var getRefinedMissinParentsLabels = R.pipe(R.propOr([], 'missingParents'), R.reduce(function (acc, par) {
19
+ if (!R.propOr(true, 'display', par) || R.includes(par.id, _constants.REJECTED_VALUE_IDS)) {
20
+ return acc;
21
+ }
22
+ return R.append((0, _src.dimensionValueDisplay)('label')(par), acc);
23
+ }, []));
24
+
25
+ var granularDisplay = function granularDisplay(display, value) {
26
+ if (display === 'label') {
27
+ return R.converge(function (missingParents, label) {
28
+ return R.isEmpty(missingParents) ? label : R.join(' > ', R.append(label, missingParents));
29
+ }, [getRefinedMissinParentsLabels, (0, _src.dimensionValueDisplay)(display)])(value);
30
+ } else if (display === 'both') {
31
+ return '(' + granularDisplay('code', value) + ') ' + granularDisplay('label', value);
32
+ }
33
+ return (0, _src.dimensionValueDisplay)(display)(value);
34
+ };
35
+
36
+ var combinedDisplay = function combinedDisplay(_display) {
37
+ return R.pipe(R.reduce(function (acc, val) {
38
+ if ((!R.propOr(true, 'display', val) || R.includes(val.id, _constants.REJECTED_VALUE_IDS)) && _display === 'label') {
39
+ return acc;
40
+ }
41
+ return R.append(granularDisplay(_display, val), acc);
42
+ }, []), R.join(', '));
43
+ };
44
+
45
+ var getTableLabelAccessor = exports.getTableLabelAccessor = function getTableLabelAccessor(display) {
46
+ return function (item) {
47
+ if (!R.is(Array, item)) {
48
+ return granularDisplay(display, item);
49
+ }
50
+ if (display === 'both') {
51
+ return R.converge(function (ids, labels) {
52
+ return '(' + ids + ') ' + labels;
53
+ }, [combinedDisplay('code'), combinedDisplay('label')])(item);
54
+ }
55
+ return combinedDisplay(display)(item);
56
+ };
57
+ };
@@ -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.1.6",
4
+ "version": "16.3.0",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -16,13 +16,10 @@ const parseAttributesValues = (obs, attributes, indexedDimensions) => {
16
16
  return R.addIndex(R.reduce)(
17
17
  (acc, valueIndex, attrIndex) => {
18
18
  const attribute = R.nth(attrIndex, attributes);
19
- if (R.isNil(attribute) || !R.propOr(true, 'display', attribute) || !R.prop('series', attribute)) {
19
+ if (R.isNil(attribute) || !R.prop('series', attribute)) {
20
20
  return acc;
21
21
  }
22
22
  let value = R.nth(valueIndex, attribute.values || []);
23
- if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value), REJECTED_VALUE_IDS)) {
24
- value = null;
25
- }
26
23
  const relationship = R.propOr([], 'relationship', attribute);
27
24
  let coordinates = {};
28
25
  const serieKey = R.pipe(
@@ -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,
@@ -22,8 +22,7 @@ export const getOneValueDimensions = (dimensions, attributes) => {
22
22
  );
23
23
  return R.reduce(
24
24
  (acc, dim) => {
25
- if (R.length(dim.values || []) !== 1 || !R.propOr(true, 'display', dim) || !R.pathOr(true, ['values', 0, 'display'], dim)
26
- || R.includes(R.path(['values', 0, 'id'], dim), REJECTED_VALUE_IDS)) {
25
+ if (R.length(dim.values || []) !== 1) {
27
26
  return acc;
28
27
  }
29
28
  const attrValues = R.propOr({}, dim.id, indexedRelevantAttributes);
@@ -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';
@@ -41,3 +42,4 @@ export { getCells } from './table/getCells';
41
42
  export { getCuratedCells } from './table/getCuratedCells';
42
43
  export { prepareData } from './prepareData';
43
44
  export { getTableProps } from './table/getTableProps';
45
+ export { getTableLabelAccessor } from './table/getTableLabelAccessor';
@@ -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,
@@ -1,4 +1,5 @@
1
1
  import * as R from 'ramda';
2
+ import { REJECTED_VALUE_IDS } from '../constants';
2
3
 
3
4
  export const getFlagsAndNotes = (attributesValues, customAttributes) => {
4
5
  const flagsIds = R.propOr([], 'flags', customAttributes);
@@ -10,7 +11,8 @@ export const getFlagsAndNotes = (attributesValues, customAttributes) => {
10
11
  return acc;
11
12
  }
12
13
  const attr = R.prop(id, attributesValues);
13
- if (R.isNil(attr.value)) {
14
+ if (R.isNil(attr.value) || !R.pathOr(true, ['value', 'display'], attr) || !R.propOr(true, 'display', attr)
15
+ || R.includes(R.path(['value', 'id'], attr), REJECTED_VALUE_IDS)) {
14
16
  return acc;
15
17
  }
16
18
  return R.append(index < flagsIds.length ? R.assoc('code', R.path(['value', 'id'], attr), attr) : attr, acc);
@@ -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 || !value.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
  }
@@ -122,10 +122,7 @@ const getSubLayoutData = (series, _definition, { metadataCoordinates, attributes
122
122
  (_acc, id) => {
123
123
  if (R.has(id, dimValues)) {
124
124
  const value = R.prop(id, dimValues);
125
- if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value), REJECTED_VALUE_IDS)) {
126
- return _acc;
127
- }
128
- return R.append(R.dissoc('display', value), _acc);
125
+ return R.append(value, _acc);
129
126
  }
130
127
  if (R.has(id, fixedDimValues)) {
131
128
  return R.append(R.prop(id, fixedDimValues), _acc);
@@ -0,0 +1,53 @@
1
+ import * as R from 'ramda';
2
+ import { dimensionValueDisplay } from '../../../rules/src';
3
+ import { REJECTED_VALUE_IDS } from '../constants';
4
+
5
+ const getRefinedMissinParentsLabels = R.pipe(
6
+ R.propOr([], 'missingParents'),
7
+ R.reduce((acc, par) => {
8
+ if (!R.propOr(true, 'display', par) || R.includes(par.id, REJECTED_VALUE_IDS)) {
9
+ return acc;
10
+ }
11
+ return R.append(dimensionValueDisplay('label')(par), acc);
12
+ }, []),
13
+ );
14
+
15
+ const granularDisplay = (display, value) => {
16
+ if (display === 'label') {
17
+ return R.converge(
18
+ (missingParents, label) =>
19
+ R.isEmpty(missingParents) ? label : R.join(' > ', R.append(label, missingParents)),
20
+ [
21
+ getRefinedMissinParentsLabels,
22
+ dimensionValueDisplay(display),
23
+ ],
24
+ )(value);
25
+ } else if (display === 'both') {
26
+ return `(${granularDisplay('code', value)}) ${granularDisplay('label', value)}`;
27
+ }
28
+ return dimensionValueDisplay(display)(value);
29
+ };
30
+
31
+ const combinedDisplay = _display => R.pipe(
32
+ R.reduce((acc, val) => {
33
+ if ((!R.propOr(true, 'display', val) || R.includes(val.id, REJECTED_VALUE_IDS))
34
+ && _display === 'label') {
35
+ return acc;
36
+ }
37
+ return R.append(granularDisplay(_display, val), acc);
38
+ }, []),
39
+ R.join(', '),
40
+ );
41
+
42
+ export const getTableLabelAccessor = display => item => {
43
+ if (!R.is(Array, item)) {
44
+ return granularDisplay(display, item);
45
+ }
46
+ if (display === 'both') {
47
+ return R.converge((ids, labels) => `(${ids}) ${labels}`, [
48
+ combinedDisplay('code'),
49
+ combinedDisplay('label'),
50
+ ])(item);
51
+ }
52
+ return combinedDisplay(display)(item);
53
+ };
@@ -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 });
@@ -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
+ });
@@ -62,28 +62,28 @@ describe('getLayoutData tests', () => {
62
62
  { data: [{ dimension: { id: 'S' }, value: { id: 'S_V1' } }], key: 'S=S_V1', flags: [], sideProps: null, coordinates: { S: 'S_V1' } },
63
63
  [
64
64
  {
65
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1' }, { id: 'R2_V1' }, { id: 'ATTR_V1' }] }],
65
+ data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V1' }] }],
66
66
  key: 'R1=R1_V1:R2=R2_V1',
67
67
  coordinates: { R1: 'R1_V1', R2: 'R2_V1', S: 'S_V1' },
68
68
  flags: [],
69
69
  sideProps: null
70
70
  },
71
71
  {
72
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1' }, { id: 'ATTR_V2' }] }],
72
+ data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V2' }] }],
73
73
  key: 'R1=R1_V1:R2=R2_V2',
74
74
  coordinates: { R1: 'R1_V1', R2: 'R2_V2', S: 'S_V1' },
75
75
  flags: [],
76
76
  sideProps: null
77
77
  },
78
78
  {
79
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2' }, { id: 'R2_V1' }, { id: 'ATTR_V3' }] }],
79
+ data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V3' }] }],
80
80
  key: 'R1=R1_V2:R2=R2_V1',
81
81
  coordinates: { R1: 'R1_V2', R2: 'R2_V1', S: 'S_V1' },
82
82
  flags: [],
83
83
  sideProps: null
84
84
  },
85
85
  {
86
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2' }, { id: 'ATTR_V4' }] }],
86
+ data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V4' }] }],
87
87
  key: 'R1=R1_V2:R2=R2_V2',
88
88
  coordinates: { R1: 'R1_V2', R2: 'R2_V2', S: 'S_V1' },
89
89
  flags: [],
@@ -95,28 +95,28 @@ describe('getLayoutData tests', () => {
95
95
  { data: [{ dimension: { id: 'S' }, value: { id: 'S_V2' } }], key: 'S=S_V2', flags: [], sideProps: null, coordinates: { S: 'S_V2' } },
96
96
  [
97
97
  {
98
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1' }, { id: 'R2_V1' }, { id: 'ATTR_V1' }] }],
98
+ data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V1' }] }],
99
99
  key: 'R1=R1_V1:R2=R2_V1',
100
100
  coordinates: { R1: 'R1_V1', R2: 'R2_V1', S: 'S_V2' },
101
101
  flags: [],
102
102
  sideProps: null
103
103
  },
104
104
  {
105
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1' }, { id: 'ATTR_V2' }] }],
105
+ data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V2' }] }],
106
106
  key: 'R1=R1_V1:R2=R2_V2',
107
107
  coordinates: { R1: 'R1_V1', R2: 'R2_V2', S: 'S_V2' },
108
108
  flags: [],
109
109
  sideProps: null
110
110
  },
111
111
  {
112
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2' }, { id: 'R2_V1' }, { id: 'ATTR_V3' }] }],
112
+ data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V3' }] }],
113
113
  key: 'R1=R1_V2:R2=R2_V1',
114
114
  coordinates: { R1: 'R1_V2', R2: 'R2_V1', S: 'S_V2' },
115
115
  flags: [],
116
116
  sideProps: null
117
117
  },
118
118
  {
119
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2' }, { id: 'ATTR_V4' }] }],
119
+ data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V4' }] }],
120
120
  key: 'R1=R1_V2:R2=R2_V2',
121
121
  coordinates: { R1: 'R1_V2', R2: 'R2_V2', S: 'S_V2' },
122
122
  flags: [],
@@ -24,6 +24,9 @@ describe('getOneValueDimensions tests', () => {
24
24
  expect(getOneValueDimensions(dimensions, attributes)).to.deep.equal([
25
25
  { id: 'd0', values: [{ id: 'v' }], attrValues: { a1: { id: 'a1', header: true, values: [{ id: 'v' }], relationship: ['d0'], value: { id: 'v' } } } },
26
26
  { id: 'd1', values: [{ id: 'v' }], attrValues: {} },
27
+ { id: 'd2', values: [{ id: 'v' }], display: false, attrValues: {} },
28
+ { id: 'd3', values: [{ id: 'v', display: false }], attrValues: {} },
29
+ { id: 'd4', values: [{ id: '_T' }], attrValues: {} },
27
30
  ])
28
31
  });
29
32
  });
@@ -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,25 @@
1
+ import { expect } from 'chai';
2
+ import { getTableLabelAccessor } from '../src/rules2/src/table/getTableLabelAccessor';
3
+
4
+ describe('getTableLabelAccessor tests', () => {
5
+ const values = [
6
+ { id: 'V0', name: 'Value 0', display: false },
7
+ { id: 'V1', name: 'Value 1', missingParents: [{ id: 'P0', name: 'Parent 0' }, { id: 'P1', name: 'Parent 1', display: false }] },
8
+ { id: '_T', name: 'Value 2' },
9
+ ];
10
+ it('combination label display', () => {
11
+ expect(getTableLabelAccessor('label')(values)).to.deep.equal('Parent 0 > Value 1');
12
+ });
13
+ it('combination code display', () => {
14
+ expect(getTableLabelAccessor('code')(values)).to.deep.equal('V0, V1, _T');
15
+ });
16
+ it('combination both display', () => {
17
+ expect(getTableLabelAccessor('both')(values)).to.deep.equal('(V0, V1, _T) Parent 0 > Value 1');
18
+ });
19
+ it('single value witrh missingParents', () => {
20
+ expect(getTableLabelAccessor('label')(values[1])).to.deep.equal('Parent 0 > Value 1');
21
+ });
22
+ it('not displayed single value', () => {
23
+ expect(getTableLabelAccessor('both')(values[0])).to.deep.equal('(V0) Value 0');
24
+ });
25
+ });