@sis-cc/dotstatsuite-components 17.0.0 → 17.1.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.
|
@@ -20,22 +20,25 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
20
|
var parseCombinationDefinition = exports.parseCombinationDefinition = function parseCombinationDefinition(locale) {
|
|
21
21
|
return function (title, texts) {
|
|
22
22
|
return R.useWith(function (titles, texts) {
|
|
23
|
-
return R.addIndex(R.
|
|
23
|
+
return R.addIndex(R.reduce)(function (acc, title, index) {
|
|
24
24
|
var split = R.split(':', title);
|
|
25
|
-
if (R.length(split !== 2)
|
|
26
|
-
return
|
|
25
|
+
if (R.length(split) !== 2) {
|
|
26
|
+
return acc;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
var _split = (0, _slicedToArray3.default)(split, 2),
|
|
30
30
|
id = _split[0],
|
|
31
31
|
codes = _split[1];
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
if (R.isEmpty(codes)) {
|
|
34
|
+
return acc;
|
|
35
|
+
}
|
|
36
|
+
return R.append({
|
|
34
37
|
id: id,
|
|
35
38
|
concepts: R.split(',', codes),
|
|
36
39
|
name: R.has(locale, texts) ? R.pipe(R.prop(locale), R.nth(index), R.split(':'), R.last)(texts) : '[' + id + ']'
|
|
37
|
-
};
|
|
38
|
-
}, titles);
|
|
40
|
+
}, acc);
|
|
41
|
+
}, [], titles);
|
|
39
42
|
}, [R.split(';'), R.map(R.split(';'))])(title, texts);
|
|
40
43
|
};
|
|
41
44
|
};
|
package/package.json
CHANGED
|
@@ -2,20 +2,23 @@ import * as R from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
export const parseCombinationDefinition = (locale) => (title, texts) => R.useWith(
|
|
4
4
|
(titles, texts) =>
|
|
5
|
-
R.addIndex(R.
|
|
5
|
+
R.addIndex(R.reduce)((acc, title, index) => {
|
|
6
6
|
const split = R.split(':', title);
|
|
7
|
-
if (R.length(split !== 2)
|
|
8
|
-
return
|
|
7
|
+
if (R.length(split) !== 2) {
|
|
8
|
+
return acc;
|
|
9
9
|
}
|
|
10
10
|
const [id, codes] = split;
|
|
11
|
-
|
|
11
|
+
if (R.isEmpty(codes)) {
|
|
12
|
+
return acc;
|
|
13
|
+
}
|
|
14
|
+
return R.append({
|
|
12
15
|
id,
|
|
13
16
|
concepts: R.split(',', codes),
|
|
14
17
|
name: R.has(locale, texts)
|
|
15
18
|
? R.pipe(R.prop(locale), R.nth(index), R.split(':'), R.last)(texts)
|
|
16
19
|
: `[${id}]`,
|
|
17
|
-
};
|
|
18
|
-
}, titles),
|
|
20
|
+
}, acc);
|
|
21
|
+
}, [], titles),
|
|
19
22
|
[R.split(';'), R.map(R.split(';'))],
|
|
20
23
|
)(title, texts);
|
|
21
24
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getCombinationDefinitions } from '../src/rules2/src';
|
|
3
|
+
|
|
4
|
+
describe('getCombinationDefinitions tests', () => {
|
|
5
|
+
it('no annotations', () => {
|
|
6
|
+
const annotations = [
|
|
7
|
+
{ type: 'random', title: 'test' },
|
|
8
|
+
{ type: 'NOT_DISPLAYED', title: 'FREQ=A' }
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
expect(getCombinationDefinitions(annotations, 'en')).to.deep.equal([]);
|
|
12
|
+
});
|
|
13
|
+
it('basic case', () => {
|
|
14
|
+
const annotations = [
|
|
15
|
+
{ type: 'random', title: 'test' },
|
|
16
|
+
{ type: 'NOT_DISPLAYED', title: 'FREQ=A' },
|
|
17
|
+
{
|
|
18
|
+
type: 'COMBINED_CONCEPTS',
|
|
19
|
+
texts: { en: 'COMB_1:First Combination;COMB_2:Second Combination' },
|
|
20
|
+
title: 'COMB_1:D1,D2,A1;COMB_2:D3,D4,A2,A3'
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
expect(getCombinationDefinitions(annotations, 'en')).to.deep.equal([
|
|
25
|
+
{ id: 'COMB_1', name: 'First Combination', concepts: ['D1', 'D2', 'A1'] },
|
|
26
|
+
{ id: 'COMB_2', name: 'Second Combination', concepts: ['D3', 'D4', 'A2', 'A3'] },
|
|
27
|
+
]);
|
|
28
|
+
});
|
|
29
|
+
it('bad formatted test 1', () => {
|
|
30
|
+
const annotations = [
|
|
31
|
+
{ type: 'random', title: 'test' },
|
|
32
|
+
{ type: 'NOT_DISPLAYED', title: 'FREQ=A' },
|
|
33
|
+
{
|
|
34
|
+
type: 'COMBINED_CONCEPTS',
|
|
35
|
+
texts: { en: 'COMB_1:First Combination;COMB_2:Second Combination' },
|
|
36
|
+
title: 'COMB_1:D1,D2,A1;D3,D4,A2,A3'
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
expect(getCombinationDefinitions(annotations, 'en')).to.deep.equal([
|
|
41
|
+
{ id: 'COMB_1', name: 'First Combination', concepts: ['D1', 'D2', 'A1'] },
|
|
42
|
+
]);
|
|
43
|
+
});
|
|
44
|
+
it('bad formatted test 2', () => {
|
|
45
|
+
const annotations = [
|
|
46
|
+
{ type: 'random', title: 'test' },
|
|
47
|
+
{ type: 'NOT_DISPLAYED', title: 'FREQ=A' },
|
|
48
|
+
{
|
|
49
|
+
type: 'COMBINED_CONCEPTS',
|
|
50
|
+
texts: { en: 'COMB_1:First Combination;COMB_2:Second Combination' },
|
|
51
|
+
title: 'COMB_1:D1,D2,A1;COMB_2:'
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
expect(getCombinationDefinitions(annotations, 'en')).to.deep.equal([
|
|
56
|
+
{ id: 'COMB_1', name: 'First Combination', concepts: ['D1', 'D2', 'A1'] },
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
it('bad formatted test 3', () => {
|
|
60
|
+
const annotations = [
|
|
61
|
+
{ type: 'random', title: 'test' },
|
|
62
|
+
{ type: 'NOT_DISPLAYED', title: 'FREQ=A' },
|
|
63
|
+
{
|
|
64
|
+
type: 'COMBINED_CONCEPTS',
|
|
65
|
+
texts: { en: 'First Combination;Second Combination' },
|
|
66
|
+
title: 'D1,D2,A1;D3,D4,A2,A3'
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
expect(getCombinationDefinitions(annotations, 'en')).to.deep.equal([]);
|
|
71
|
+
});
|
|
72
|
+
it('missing localised text', () => {
|
|
73
|
+
const annotations = [
|
|
74
|
+
{ type: 'random', title: 'test' },
|
|
75
|
+
{ type: 'NOT_DISPLAYED', title: 'FREQ=A' },
|
|
76
|
+
{
|
|
77
|
+
type: 'COMBINED_CONCEPTS',
|
|
78
|
+
texts: { en: 'COMB_1:First Combination;COMB_2:Second Combination' },
|
|
79
|
+
title: 'COMB_1:D1,D2,A1;COMB_2:D3,D4,A2,A3'
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
expect(getCombinationDefinitions(annotations, 'fr')).to.deep.equal([
|
|
84
|
+
{ id: 'COMB_1', name: '[COMB_1]', concepts: ['D1', 'D2', 'A1'] },
|
|
85
|
+
{ id: 'COMB_2', name: '[COMB_2]', concepts: ['D3', 'D4', 'A2', 'A3'] },
|
|
86
|
+
]);
|
|
87
|
+
});
|
|
88
|
+
});
|