@sis-cc/dotstatsuite-components 17.12.3 → 17.12.5
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,9 +36,10 @@ var singleValueDisplay = exports.singleValueDisplay = function singleValueDispla
|
|
|
36
36
|
var _combinedValuesDisplay = function _combinedValuesDisplay(_display) {
|
|
37
37
|
return function (values) {
|
|
38
38
|
return R.pipe(R.reduce(function (acc, val) {
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
if (R.isNil(val)) return acc;
|
|
40
|
+
var isDisplayed = R.propOr(true, 'display', val);
|
|
41
|
+
var isRejected = R.includes(val.id, _constants.REJECTED_VALUE_IDS);
|
|
42
|
+
if ((!isDisplayed || isRejected) && _display === 'label') return acc;
|
|
42
43
|
return R.append(singleValueDisplay(_display, val), acc);
|
|
43
44
|
}, []), function (labels) {
|
|
44
45
|
if (!R.isEmpty(labels) || _display !== 'label') {
|
|
@@ -60,8 +61,10 @@ var _combinedValuesDisplay = function _combinedValuesDisplay(_display) {
|
|
|
60
61
|
var combinedValuesDisplay = exports.combinedValuesDisplay = function combinedValuesDisplay(display, values) {
|
|
61
62
|
if (display === 'both') {
|
|
62
63
|
return R.converge(function (_ids, labels) {
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
return (0, _src.dimensionValueDisplay)('both')({
|
|
65
|
+
id: _ids,
|
|
66
|
+
name: labels
|
|
67
|
+
});
|
|
65
68
|
}, [_combinedValuesDisplay('code'), _combinedValuesDisplay('label')])(values);
|
|
66
69
|
}
|
|
67
70
|
return _combinedValuesDisplay(display)(values);
|
package/package.json
CHANGED
|
@@ -5,7 +5,10 @@ import { REJECTED_VALUE_IDS } from './constants';
|
|
|
5
5
|
const getRefinedMissinParentsLabels = R.pipe(
|
|
6
6
|
R.propOr([], 'missingParents'),
|
|
7
7
|
R.reduce((acc, par) => {
|
|
8
|
-
if (
|
|
8
|
+
if (
|
|
9
|
+
!R.propOr(true, 'display', par) ||
|
|
10
|
+
R.includes(par.id, REJECTED_VALUE_IDS)
|
|
11
|
+
) {
|
|
9
12
|
return acc;
|
|
10
13
|
}
|
|
11
14
|
return R.append(dimensionValueDisplay('label')(par), acc);
|
|
@@ -13,54 +16,59 @@ const getRefinedMissinParentsLabels = R.pipe(
|
|
|
13
16
|
);
|
|
14
17
|
|
|
15
18
|
export const singleValueDisplay = (display, value) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
19
|
+
if (display === 'label') {
|
|
20
|
+
return R.converge(
|
|
21
|
+
(missingParents, label) =>
|
|
22
|
+
R.isEmpty(missingParents)
|
|
23
|
+
? label
|
|
24
|
+
: R.join(' > ', R.append(label, missingParents)),
|
|
25
|
+
[getRefinedMissinParentsLabels, dimensionValueDisplay(display)],
|
|
26
|
+
)(value);
|
|
27
|
+
} else if (display === 'both') {
|
|
28
|
+
return `(${singleValueDisplay('code', value)}) ${singleValueDisplay(
|
|
29
|
+
'label',
|
|
30
|
+
value,
|
|
31
|
+
)}`;
|
|
32
|
+
}
|
|
33
|
+
return dimensionValueDisplay(display)(value);
|
|
34
|
+
};
|
|
30
35
|
|
|
31
|
-
const _combinedValuesDisplay = _display => values =>
|
|
32
|
-
R.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
const _combinedValuesDisplay = (_display) => (values) =>
|
|
37
|
+
R.pipe(
|
|
38
|
+
R.reduce((acc, val) => {
|
|
39
|
+
if (R.isNil(val)) return acc;
|
|
40
|
+
const isDisplayed = R.propOr(true, 'display', val);
|
|
41
|
+
const isRejected = R.includes(val.id, REJECTED_VALUE_IDS);
|
|
42
|
+
if ((!isDisplayed || isRejected) && _display === 'label') return acc;
|
|
43
|
+
return R.append(singleValueDisplay(_display, val), acc);
|
|
44
|
+
}, []),
|
|
45
|
+
(labels) => {
|
|
46
|
+
if (!R.isEmpty(labels) || _display !== 'label') {
|
|
47
|
+
return R.join(', ', labels);
|
|
48
|
+
}
|
|
49
|
+
const totalValue = R.find(R.propEq('id', '_T'), values);
|
|
50
|
+
if (!R.isNil(totalValue)) {
|
|
51
|
+
return dimensionValueDisplay('label')(totalValue);
|
|
52
|
+
}
|
|
53
|
+
if (R.isEmpty(values)) {
|
|
54
|
+
return '';
|
|
55
|
+
}
|
|
56
|
+
const firstValue = R.head(values);
|
|
57
|
+
return dimensionValueDisplay('label')(firstValue);
|
|
58
|
+
},
|
|
59
|
+
)(values);
|
|
54
60
|
|
|
55
61
|
export const combinedValuesDisplay = (display, values) => {
|
|
56
62
|
if (display === 'both') {
|
|
57
|
-
return R.converge(
|
|
58
|
-
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
return R.converge(
|
|
64
|
+
(_ids, labels) => {
|
|
65
|
+
return dimensionValueDisplay('both')({
|
|
66
|
+
id: _ids,
|
|
67
|
+
name: labels,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
[_combinedValuesDisplay('code'), _combinedValuesDisplay('label')],
|
|
71
|
+
)(values);
|
|
64
72
|
}
|
|
65
73
|
return _combinedValuesDisplay(display)(values);
|
|
66
74
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import * as R from 'ramda';
|
|
3
|
+
import { combinedValuesDisplay } from '../src/rules2/src/combinedValuesDisplay';
|
|
4
|
+
|
|
5
|
+
describe('combinedValuesDisplay tests', () => {
|
|
6
|
+
const values = [
|
|
7
|
+
{
|
|
8
|
+
id: 'F3RES',
|
|
9
|
+
order: 424,
|
|
10
|
+
name: 'Debt securities issued by residents',
|
|
11
|
+
annotations: [21],
|
|
12
|
+
display: true,
|
|
13
|
+
start: null,
|
|
14
|
+
notes: [],
|
|
15
|
+
__indexPosition: 0,
|
|
16
|
+
__index: 0,
|
|
17
|
+
parents: [],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'W',
|
|
21
|
+
order: 440,
|
|
22
|
+
name: 'World',
|
|
23
|
+
annotations: [11, 12],
|
|
24
|
+
display: false,
|
|
25
|
+
start: null,
|
|
26
|
+
notes: [],
|
|
27
|
+
__indexPosition: 0,
|
|
28
|
+
__index: 0,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'S11',
|
|
32
|
+
order: 2,
|
|
33
|
+
name: 'Non financial corporations',
|
|
34
|
+
parent: 'S1',
|
|
35
|
+
parents: ['S1'],
|
|
36
|
+
annotations: [18, 19],
|
|
37
|
+
display: true,
|
|
38
|
+
start: null,
|
|
39
|
+
notes: [],
|
|
40
|
+
__indexPosition: 1,
|
|
41
|
+
__index: 0,
|
|
42
|
+
},
|
|
43
|
+
null,
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const testdata = [
|
|
47
|
+
{
|
|
48
|
+
display: 'label',
|
|
49
|
+
expected: 'Debt securities issued by residents, Non financial corporations',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
display: 'code',
|
|
53
|
+
expected: 'F3RES, W, S11'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
display: 'both',
|
|
57
|
+
expected: '(F3RES, W, S11) Debt securities issued by residents, Non financial corporations',
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
R.forEach(({display, expected}) => {
|
|
62
|
+
it(`should pass with display ${display}`, () => {
|
|
63
|
+
expect(combinedValuesDisplay(display, values)).to.deep.equal(expected);
|
|
64
|
+
});
|
|
65
|
+
}, testdata);
|
|
66
|
+
});
|