@sis-cc/dotstatsuite-components 17.26.0 → 17.26.1

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.
@@ -16,13 +16,19 @@ var _src = require('../../rules2/src');
16
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
17
 
18
18
  var isTableLayoutCompatible = function isTableLayoutCompatible(data, layout) {
19
- var dataquery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
19
+ var combinationsDefinitions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
20
+ var dataquery = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
20
21
 
21
22
  var multiValuesDimensions = R.pipe(R.pathOr([], ['structure', 'dimensions', 'observation']), function (dimensions) {
22
23
  return (0, _src.refineDimensions)(dimensions, dataquery);
23
24
  }, R.reject(function (d) {
24
25
  return R.prop('header', d) || !R.length(d.values || []);
25
- }), R.pluck('id'))(data);
26
+ }), R.pluck('id'), R.map(function (d) {
27
+ var conceptId = R.find(function (comb) {
28
+ return R.includes(d, R.propOr([], 'concepts', comb));
29
+ })(combinationsDefinitions);
30
+ return conceptId ? conceptId.id : d;
31
+ }))(data);
26
32
  var dimensionsInLayout = R.pipe(R.values, R.unnest)(layout);
27
33
 
28
34
  var dimensionsLength = R.length(multiValuesDimensions);
@@ -72,7 +78,10 @@ var isSharedLayoutCompatible = exports.isSharedLayoutCompatible = function isSha
72
78
  if (type === 'table') {
73
79
  var layoutIds = R.pathOr({}, ['config', 'table', 'layoutIds'], sharedData);
74
80
  var dataquery = R.path(['config', 'sdmxSource', 'dataquery'], sharedData);
75
- return isTableLayoutCompatible(sdmxData, layoutIds, dataquery);
81
+ var annotations = R.pathOr({}, ['structure', 'annotations'], sdmxData);
82
+ var locale = R.pathOr({}, ['config', 'table', 'locale'], sharedData);
83
+ var combinationsDefinitions = (0, _src.getCombinationDefinitions)(annotations, locale);
84
+ return isTableLayoutCompatible(sdmxData, layoutIds, combinationsDefinitions, dataquery);
76
85
  }
77
86
  var chartDimension = R.pathOr({}, ['config', 'chart', 'chartDimension'], sharedData);
78
87
  return isChartLayoutCompatible(sdmxData, type, chartDimension);
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": "17.26.0",
4
+ "version": "17.26.1",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -6,14 +6,18 @@ import {
6
6
  STACKED_ROW,
7
7
  V_SYMBOL
8
8
  } from './constants';
9
- import { refineDimensions } from '../../rules2/src';
9
+ import { getCombinationDefinitions, refineDimensions } from '../../rules2/src';
10
10
 
11
- const isTableLayoutCompatible = (data, layout, dataquery='') => {
11
+ const isTableLayoutCompatible = (data, layout, combinationsDefinitions = [], dataquery = '') => {
12
12
  const multiValuesDimensions = R.pipe(
13
13
  R.pathOr([], ['structure', 'dimensions', 'observation']),
14
14
  dimensions => refineDimensions(dimensions, dataquery),
15
15
  R.reject(d => R.prop('header', d) || !R.length(d.values || [])),
16
- R.pluck('id')
16
+ R.pluck('id'),
17
+ R.map(d => {
18
+ const conceptId = R.find(comb => R.includes(d, R.propOr([], 'concepts', comb)))(combinationsDefinitions)
19
+ return conceptId ? conceptId.id : d
20
+ }),
17
21
  )(data);
18
22
  const dimensionsInLayout = R.pipe(R.values, R.unnest)(layout);
19
23
 
@@ -85,7 +89,10 @@ export const isSharedLayoutCompatible = (sdmxData, sharedData) => {
85
89
  if (type === 'table') {
86
90
  const layoutIds = R.pathOr({}, ['config', 'table', 'layoutIds'], sharedData);
87
91
  const dataquery = R.path(['config', 'sdmxSource', 'dataquery'], sharedData);
88
- return isTableLayoutCompatible(sdmxData, layoutIds, dataquery);
92
+ const annotations = R.pathOr({}, ['structure', 'annotations'], sdmxData)
93
+ const locale = R.pathOr({}, ['config', 'table', 'locale'], sharedData)
94
+ const combinationsDefinitions = getCombinationDefinitions(annotations, locale)
95
+ return isTableLayoutCompatible(sdmxData, layoutIds, combinationsDefinitions, dataquery);
89
96
  }
90
97
  const chartDimension = R.pathOr({}, ['config', 'chart', 'chartDimension'], sharedData);
91
98
  return isChartLayoutCompatible(sdmxData, type, chartDimension);
@@ -11,7 +11,30 @@ const sdmxData = {
11
11
  { id: 'd3', values: [{ id: 'v1' }] },
12
12
  { id: 'd4', values: [] },
13
13
  ]
14
- }
14
+ },
15
+ }
16
+ }
17
+ const sdmxData2 = {
18
+ structure: {
19
+ dimensions: {
20
+ observation: [
21
+ { id: 'd0', values: [{ id: 'v1' }, { id: 'v2' }] },
22
+ { id: 'd1', values: [{ id: 'v1' }, { id: 'v2' }, { id: 'v3' }] },
23
+ { id: 'd2', values: [{ id: 'v1' }, { id: 'v2' }] },
24
+ { id: 'd3', values: [{ id: 'v1' }] },
25
+ { id: 'd4', values: [] },
26
+ ]
27
+ },
28
+ annotations: [
29
+ {
30
+ title: "d6:d1,d3,d4",
31
+ type: "COMBINED_CONCEPTS",
32
+ text: "d6:Combined unit of measure",
33
+ texts: {
34
+ en: "d6:Combined unit of measure"
35
+ }
36
+ }
37
+ ]
15
38
  }
16
39
  }
17
40
 
@@ -20,6 +43,10 @@ describe('isSharedLayoutCompatible', () => {
20
43
  const layoutIds = { rows: ['d0'], sections: ['d1'], header: ['d2'] };
21
44
  expect(isSharedLayoutCompatible(sdmxData, { type: 'table', config: { table: { layoutIds } } })).to.equal(true);
22
45
  });
46
+ it('table compatible test combined', () => {
47
+ const layoutIds = { rows: ['d0'], sections: ['d6'], header: ['d2'] };
48
+ expect(isSharedLayoutCompatible(sdmxData2, { type: 'table', config: { table: { layoutIds, locale: 'en' } } })).to.equal(true);
49
+ });
23
50
  it('table incompatible absent dimension in multi dims test', () => {
24
51
  const layoutIds = { rows: ['d0', 'd3'], sections: ['d1'], header: ['d2'] };
25
52
  expect(isSharedLayoutCompatible(sdmxData, { type: 'table', config: { table: { layoutIds } } })).to.equal(false);