@sis-cc/dotstatsuite-components 17.3.0 → 17.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.
@@ -17,10 +17,25 @@ 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 parseTexts = function parseTexts(texts) {
21
+ return R.reduce(function (acc, text) {
22
+ var splitted = R.split(':', text);
23
+ if (R.length(splitted) !== 2) {
24
+ return acc;
25
+ }
26
+
27
+ var _splitted = (0, _slicedToArray3.default)(splitted, 2),
28
+ id = _splitted[0],
29
+ name = _splitted[1];
30
+
31
+ return R.assoc(id, name, acc);
32
+ }, {}, texts);
33
+ };
34
+
20
35
  var parseCombinationDefinition = exports.parseCombinationDefinition = function parseCombinationDefinition(locale) {
21
36
  return function (title, texts) {
22
37
  return R.useWith(function (titles, texts) {
23
- return R.addIndex(R.reduce)(function (acc, title, index) {
38
+ return R.reduce(function (acc, title) {
24
39
  var split = R.split(':', title);
25
40
  if (R.length(split) !== 2) {
26
41
  return acc;
@@ -36,10 +51,10 @@ var parseCombinationDefinition = exports.parseCombinationDefinition = function p
36
51
  return R.append({
37
52
  id: id,
38
53
  concepts: R.split(',', codes),
39
- name: R.has(locale, texts) ? R.pipe(R.prop(locale), R.nth(index), R.split(':'), R.last)(texts) : '[' + id + ']'
54
+ name: R.hasPath([locale, id], texts) ? R.path([locale, id], texts) : '[' + id + ']'
40
55
  }, acc);
41
56
  }, [], titles);
42
- }, [R.split(';'), R.map(R.split(';'))])(title, texts);
57
+ }, [R.split(';'), R.map(R.pipe(R.split(';'), parseTexts))])(title, texts);
43
58
  };
44
59
  };
45
60
 
@@ -11,6 +11,8 @@ var R = _interopRequireWildcard(_ramda);
11
11
 
12
12
  var _src = require('../../rules/src');
13
13
 
14
+ var _constants = require('./constants');
15
+
14
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; } }
15
17
 
16
18
  var getHeaderCombinations = exports.getHeaderCombinations = function getHeaderCombinations(combinations, dimensions, attributes, display) {
@@ -25,7 +27,9 @@ var getHeaderCombinations = exports.getHeaderCombinations = function getHeaderCo
25
27
 
26
28
  var combinedDisplay = function combinedDisplay(_display, values) {
27
29
  if (_display === 'label') {
28
- return R.pipe(R.filter(R.propOr(true, 'display')), R.map((0, _src.dimensionValueDisplay)(_display)), R.join(', '))(values);
30
+ return R.pipe(R.filter(function (val) {
31
+ return R.propOr(true, 'display', val) && !R.includes(val.id, _constants.REJECTED_VALUE_IDS);
32
+ }), R.map((0, _src.dimensionValueDisplay)(_display)), R.join(', '))(values);
29
33
  }
30
34
  return R.pipe(R.map((0, _src.dimensionValueDisplay)(_display)), R.join(', '))(values);
31
35
  };
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.3.0",
4
+ "version": "17.4.0",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -1,8 +1,21 @@
1
1
  import * as R from 'ramda';
2
2
 
3
+ const parseTexts = texts => R.reduce(
4
+ (acc, text) => {
5
+ const splitted = R.split(':', text);
6
+ if (R.length(splitted) !== 2) {
7
+ return acc;
8
+ }
9
+ const [id, name] = splitted;
10
+ return R.assoc(id, name, acc);
11
+ },
12
+ {},
13
+ texts
14
+ );
15
+
3
16
  export const parseCombinationDefinition = (locale) => (title, texts) => R.useWith(
4
17
  (titles, texts) =>
5
- R.addIndex(R.reduce)((acc, title, index) => {
18
+ R.reduce((acc, title) => {
6
19
  const split = R.split(':', title);
7
20
  if (R.length(split) !== 2) {
8
21
  return acc;
@@ -14,12 +27,12 @@ export const parseCombinationDefinition = (locale) => (title, texts) => R.useWit
14
27
  return R.append({
15
28
  id,
16
29
  concepts: R.split(',', codes),
17
- name: R.has(locale, texts)
18
- ? R.pipe(R.prop(locale), R.nth(index), R.split(':'), R.last)(texts)
30
+ name: R.hasPath([locale, id], texts)
31
+ ? R.path([locale, id], texts)
19
32
  : `[${id}]`,
20
33
  }, acc);
21
34
  }, [], titles),
22
- [R.split(';'), R.map(R.split(';'))],
35
+ [R.split(';'), R.map(R.pipe(R.split(';'), parseTexts))],
23
36
  )(title, texts);
24
37
 
25
38
  export const getCombinationDefinitions = (annotations, locale) => {
@@ -1,5 +1,6 @@
1
1
  import * as R from 'ramda';
2
2
  import { dimensionValueDisplay } from '../../rules/src';
3
+ import { REJECTED_VALUE_IDS } from './constants';
3
4
 
4
5
  export const getHeaderCombinations = (combinations, dimensions, attributes, display) => {
5
6
  const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
@@ -14,7 +15,11 @@ export const getHeaderCombinations = (combinations, dimensions, attributes, disp
14
15
 
15
16
  const combinedDisplay = (_display, values) => {
16
17
  if (_display === 'label') {
17
- return R.pipe(R.filter(R.propOr(true, 'display')), R.map(dimensionValueDisplay(_display)), R.join(', '))(values);
18
+ return R.pipe(
19
+ R.filter(val => R.propOr(true, 'display', val) && !R.includes(val.id, REJECTED_VALUE_IDS)),
20
+ R.map(dimensionValueDisplay(_display)),
21
+ R.join(', ')
22
+ )(values);
18
23
  }
19
24
  return R.pipe(R.map(dimensionValueDisplay(_display)), R.join(', '))(values);
20
25
  };
@@ -85,4 +85,20 @@ describe('getCombinationDefinitions tests', () => {
85
85
  { id: 'COMB_2', name: '[COMB_2]', concepts: ['D3', 'D4', 'A2', 'A3'] },
86
86
  ]);
87
87
  });
88
+ it('mixed order texts', () => {
89
+ const annotations = [
90
+ { type: 'random', title: 'test' },
91
+ { type: 'NOT_DISPLAYED', title: 'FREQ=A' },
92
+ {
93
+ type: 'COMBINED_CONCEPTS',
94
+ texts: { en: 'COMB_2:Second Combination;COMB_1:First Combination' },
95
+ title: 'COMB_1:D1,D2,A1;COMB_2:D3,D4,A2,A3'
96
+ }
97
+ ];
98
+
99
+ expect(getCombinationDefinitions(annotations, 'en')).to.deep.equal([
100
+ { id: 'COMB_1', name: 'First Combination', concepts: ['D1', 'D2', 'A1'] },
101
+ { id: 'COMB_2', name: 'Second Combination', concepts: ['D3', 'D4', 'A2', 'A3'] },
102
+ ]);
103
+ });
88
104
  });
@@ -4,7 +4,7 @@ import { getHeaderCombinations } from '../src/rules2/src/';
4
4
  describe('getHeaderCombinations tests', () => {
5
5
  it('complete test', () => {
6
6
  const combinations = [
7
- { id: 'COMB1', name: 'comb 1', header: true, concepts: ['DIM1', 'DIM2', 'ATTR1'] },
7
+ { id: 'COMB1', name: 'comb 1', header: true, concepts: ['DIM1', 'DIM2', 'DIM4', 'ATTR1'] },
8
8
  { id: 'COMB2', name: 'comb 2', series: true, concepts: ['DIM3', 'ATTR2'] },
9
9
  { id: 'COMB3', name: 'comb 3', header: true, display: false, concepts: ['DIM3', 'ATTR2'] }
10
10
  ];
@@ -12,6 +12,7 @@ describe('getHeaderCombinations tests', () => {
12
12
  const dimensions = [
13
13
  { id: 'DIM1', name: 'dim 1', values: [{ id: 'v', name: 'dim 1 value' }] },
14
14
  { id: 'DIM3', name: 'dim 3', values: [{ id: 'v', name: 'dim 3 value' }] },
15
+ { id: 'DIM4', name: 'dim 4', values: [{ id: '_Z', name: 'Not applicable' }] },
15
16
  ];
16
17
 
17
18
  const attributes = [