@sis-cc/dotstatsuite-components 17.3.0 → 17.5.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.
- package/lib/rules2/src/combinedValuesDisplay.js +68 -0
- package/lib/rules2/src/getCombinationDefinitions.js +18 -3
- package/lib/rules2/src/getHeaderCombinations.js +9 -12
- package/lib/rules2/src/table/getTableLabelAccessor.js +3 -40
- package/package.json +1 -1
- package/src/rules2/src/combinedValuesDisplay.js +66 -0
- package/src/rules2/src/getCombinationDefinitions.js +17 -4
- package/src/rules2/src/getHeaderCombinations.js +8 -14
- package/src/rules2/src/table/getTableLabelAccessor.js +5 -49
- package/test/getCombinationDefinitions.test.js +16 -0
- package/test/getHeaderCombinations.test.js +37 -1
- package/test/getTableLabelAccessor.test.js +25 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.combinedValuesDisplay = exports.singleValueDisplay = 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 singleValueDisplay = exports.singleValueDisplay = function singleValueDisplay(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 '(' + singleValueDisplay('code', value) + ') ' + singleValueDisplay('label', value);
|
|
32
|
+
}
|
|
33
|
+
return (0, _src.dimensionValueDisplay)(display)(value);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var _combinedValuesDisplay = function _combinedValuesDisplay(_display) {
|
|
37
|
+
return function (values) {
|
|
38
|
+
return R.pipe(R.reduce(function (acc, val) {
|
|
39
|
+
if ((!R.propOr(true, 'display', val) || R.includes(val.id, _constants.REJECTED_VALUE_IDS)) && _display === 'label') {
|
|
40
|
+
return acc;
|
|
41
|
+
}
|
|
42
|
+
return R.append(singleValueDisplay(_display, val), acc);
|
|
43
|
+
}, []), function (labels) {
|
|
44
|
+
if (!R.isEmpty(labels) || _display !== 'label') {
|
|
45
|
+
return R.join(', ', labels);
|
|
46
|
+
}
|
|
47
|
+
var totalValue = R.find(R.propEq('id', '_T'), values);
|
|
48
|
+
if (!R.isNil(totalValue)) {
|
|
49
|
+
return (0, _src.dimensionValueDisplay)('label')(totalValue);
|
|
50
|
+
}
|
|
51
|
+
if (R.isEmpty(values)) {
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
var firstValue = R.head(values);
|
|
55
|
+
return (0, _src.dimensionValueDisplay)('label')(firstValue);
|
|
56
|
+
})(values);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var combinedValuesDisplay = exports.combinedValuesDisplay = function combinedValuesDisplay(display, values) {
|
|
61
|
+
if (display === 'both') {
|
|
62
|
+
return R.converge(function (_ids, labels) {
|
|
63
|
+
var ids = R.isEmpty(_ids) ? _ids : '(' + _ids + ')';
|
|
64
|
+
return R.isEmpty(ids) ? labels : ids + ' ' + labels;
|
|
65
|
+
}, [_combinedValuesDisplay('code'), _combinedValuesDisplay('label')])(values);
|
|
66
|
+
}
|
|
67
|
+
return _combinedValuesDisplay(display)(values);
|
|
68
|
+
};
|
|
@@ -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.
|
|
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.
|
|
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,10 @@ var R = _interopRequireWildcard(_ramda);
|
|
|
11
11
|
|
|
12
12
|
var _src = require('../../rules/src');
|
|
13
13
|
|
|
14
|
+
var _combinedValuesDisplay = require('./combinedValuesDisplay');
|
|
15
|
+
|
|
16
|
+
var _constants = require('./constants');
|
|
17
|
+
|
|
14
18
|
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
19
|
|
|
16
20
|
var getHeaderCombinations = exports.getHeaderCombinations = function getHeaderCombinations(combinations, dimensions, attributes, display) {
|
|
@@ -23,28 +27,21 @@ var getHeaderCombinations = exports.getHeaderCombinations = function getHeaderCo
|
|
|
23
27
|
|
|
24
28
|
var header = (0, _src.dimensionValueDisplay)(display)(comb) + ':';
|
|
25
29
|
|
|
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
30
|
var label = R.pipe(R.reduce(function (_acc, concept) {
|
|
34
31
|
var artefact = R.has(concept, indexedDimensions) ? R.prop(concept, indexedDimensions) : R.prop(concept, indexedAttributes);
|
|
35
|
-
if (R.isNil(artefact)
|
|
32
|
+
if (R.isNil(artefact)) {
|
|
36
33
|
return _acc;
|
|
37
34
|
}
|
|
38
35
|
var value = R.path(['values', 0], artefact);
|
|
39
36
|
if (R.isNil(value)) {
|
|
40
37
|
return _acc;
|
|
41
38
|
}
|
|
39
|
+
if (R.has(concept, indexedAttributes) && (!R.propOr(true, 'display', value) || !R.propOr(true, 'artefact', value) || R.includes(value.id, _constants.REJECTED_VALUE_IDS))) {
|
|
40
|
+
return _acc;
|
|
41
|
+
}
|
|
42
42
|
return R.append(value, _acc);
|
|
43
43
|
}, []), function (values) {
|
|
44
|
-
|
|
45
|
-
return '(' + combinedDisplay('code', values) + ') ' + combinedDisplay('label', values);
|
|
46
|
-
}
|
|
47
|
-
return combinedDisplay(display, values);
|
|
44
|
+
return (0, _combinedValuesDisplay.combinedValuesDisplay)(display, values);
|
|
48
45
|
})(comb.concepts || []);
|
|
49
46
|
if (R.isEmpty(label)) {
|
|
50
47
|
return acc;
|
|
@@ -9,49 +9,12 @@ var _ramda = require('ramda');
|
|
|
9
9
|
|
|
10
10
|
var R = _interopRequireWildcard(_ramda);
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var _constants = require('../constants');
|
|
12
|
+
var _combinedValuesDisplay = require('../combinedValuesDisplay');
|
|
15
13
|
|
|
16
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; } }
|
|
17
15
|
|
|
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
16
|
var getTableLabelAccessor = exports.getTableLabelAccessor = function getTableLabelAccessor(display) {
|
|
46
|
-
return function (
|
|
47
|
-
|
|
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);
|
|
17
|
+
return function (content) {
|
|
18
|
+
return R.is(Array, content) ? (0, _combinedValuesDisplay.combinedValuesDisplay)(display, content) : (0, _combinedValuesDisplay.singleValueDisplay)(display, content);
|
|
56
19
|
};
|
|
57
20
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
export const singleValueDisplay = (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 `(${singleValueDisplay('code', value)}) ${singleValueDisplay('label', value)}`;
|
|
27
|
+
}
|
|
28
|
+
return dimensionValueDisplay(display)(value);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const _combinedValuesDisplay = _display => values => 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(singleValueDisplay(_display, val), acc);
|
|
38
|
+
}, []),
|
|
39
|
+
labels => {
|
|
40
|
+
if (!R.isEmpty(labels) || _display !== 'label') {
|
|
41
|
+
return R.join(', ', labels);
|
|
42
|
+
}
|
|
43
|
+
const totalValue = R.find(R.propEq('id', '_T'), values);
|
|
44
|
+
if (!R.isNil(totalValue)) {
|
|
45
|
+
return dimensionValueDisplay('label')(totalValue);
|
|
46
|
+
}
|
|
47
|
+
if (R.isEmpty(values)) {
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
const firstValue = R.head(values);
|
|
51
|
+
return dimensionValueDisplay('label')(firstValue);
|
|
52
|
+
},
|
|
53
|
+
)(values);
|
|
54
|
+
|
|
55
|
+
export const combinedValuesDisplay = (display, values) => {
|
|
56
|
+
if (display === 'both') {
|
|
57
|
+
return R.converge((_ids, labels) => {
|
|
58
|
+
const ids = R.isEmpty(_ids) ? _ids : `(${_ids})`;
|
|
59
|
+
return R.isEmpty(ids) ? labels : `${ids} ${labels}`;
|
|
60
|
+
}, [
|
|
61
|
+
_combinedValuesDisplay('code'),
|
|
62
|
+
_combinedValuesDisplay('label'),
|
|
63
|
+
])(values);
|
|
64
|
+
}
|
|
65
|
+
return _combinedValuesDisplay(display)(values);
|
|
66
|
+
};
|
|
@@ -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.
|
|
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.
|
|
18
|
-
? R.
|
|
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,7 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import { dimensionValueDisplay } from '../../rules/src';
|
|
3
|
+
import { combinedValuesDisplay } from './combinedValuesDisplay';
|
|
4
|
+
import { REJECTED_VALUE_IDS } from './constants';
|
|
3
5
|
|
|
4
6
|
export const getHeaderCombinations = (combinations, dimensions, attributes, display) => {
|
|
5
7
|
const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
|
|
@@ -12,36 +14,28 @@ export const getHeaderCombinations = (combinations, dimensions, attributes, disp
|
|
|
12
14
|
|
|
13
15
|
const header = `${dimensionValueDisplay(display)(comb)}:`;
|
|
14
16
|
|
|
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
17
|
const label = R.pipe(
|
|
23
18
|
R.reduce(
|
|
24
19
|
(_acc, concept) => {
|
|
25
20
|
const artefact = R.has(concept, indexedDimensions)
|
|
26
21
|
? R.prop(concept, indexedDimensions)
|
|
27
22
|
: R.prop(concept, indexedAttributes);
|
|
28
|
-
if (R.isNil(artefact)
|
|
23
|
+
if (R.isNil(artefact)) {
|
|
29
24
|
return _acc;
|
|
30
25
|
}
|
|
31
26
|
const value = R.path(['values', 0], artefact);
|
|
32
27
|
if (R.isNil(value)) {
|
|
33
28
|
return _acc;
|
|
34
29
|
}
|
|
30
|
+
if (R.has(concept, indexedAttributes) && (!R.propOr(true, 'display', value)
|
|
31
|
+
|| !R.propOr(true, 'artefact', value) || R.includes(value.id, REJECTED_VALUE_IDS))) {
|
|
32
|
+
return _acc;
|
|
33
|
+
}
|
|
35
34
|
return R.append(value, _acc);
|
|
36
35
|
},
|
|
37
36
|
[]
|
|
38
37
|
),
|
|
39
|
-
values =>
|
|
40
|
-
if (display === 'both') {
|
|
41
|
-
return `(${combinedDisplay('code', values)}) ${combinedDisplay('label', values)}`
|
|
42
|
-
}
|
|
43
|
-
return combinedDisplay(display, values);
|
|
44
|
-
}
|
|
38
|
+
values => combinedValuesDisplay(display, values)
|
|
45
39
|
)(comb.concepts || []);
|
|
46
40
|
if (R.isEmpty(label)) {
|
|
47
41
|
return acc;
|
|
@@ -1,53 +1,9 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
|
-
import {
|
|
3
|
-
import { REJECTED_VALUE_IDS } from '../constants';
|
|
2
|
+
import { combinedValuesDisplay, singleValueDisplay } from '../combinedValuesDisplay'
|
|
4
3
|
|
|
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
4
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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);
|
|
5
|
+
export const getTableLabelAccessor = display => content => {
|
|
6
|
+
return R.is(Array, content)
|
|
7
|
+
? combinedValuesDisplay(display, content)
|
|
8
|
+
: singleValueDisplay(display, content);
|
|
53
9
|
};
|
|
@@ -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 = [
|
|
@@ -23,4 +24,39 @@ describe('getHeaderCombinations tests', () => {
|
|
|
23
24
|
{ header: 'comb 1:', label: 'dim 1 value' }
|
|
24
25
|
]);
|
|
25
26
|
});
|
|
27
|
+
it('not display usecases', () => {
|
|
28
|
+
const dimensions = [
|
|
29
|
+
{ id: 'd0', values: [{ id: 'd0v', name: 'd0 value', display: false }] },
|
|
30
|
+
{ id: 'd1', values: [{ id: '_T', name: 'Total' }] },
|
|
31
|
+
{ id: 'd2', values: [{ id: 'd2v', name: 'd2 value', display: false }] },
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const attributes = [
|
|
35
|
+
{ id: 'a0', values: [{ id: 'a0v', name: 'a0 value', display: false }] },
|
|
36
|
+
{ id: 'a1', values: [{ id: 'a1v', name: 'a1 value', display: false }] },
|
|
37
|
+
{ id: 'a2', values: [{ id: '_T', name: 'Total' }] },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const combinations = [
|
|
41
|
+
{ id: 'comb0', name: 'combination 0', header: true, concepts: ['a0', 'a1', 'd0'] },
|
|
42
|
+
{ id: 'comb1', name: 'combination 1', header: true, concepts: ['d0', 'd2', 'a3'] },
|
|
43
|
+
{ id: 'comb2', name: 'combination 2', header: true, concepts: ['d0', 'd1', 'd2'] },
|
|
44
|
+
{ id: 'comb3', name: 'combination 3', header: true, concepts: ['a0', 'a1', 'a2'] },
|
|
45
|
+
];
|
|
46
|
+
expect(getHeaderCombinations(combinations, dimensions, attributes, 'label')).to.deep.equal([
|
|
47
|
+
{ header: 'combination 0:', label: 'd0 value' },
|
|
48
|
+
{ header: 'combination 1:', label: 'd0 value' },
|
|
49
|
+
{ header: 'combination 2:', label: 'Total' },
|
|
50
|
+
]);
|
|
51
|
+
expect(getHeaderCombinations(combinations, dimensions, attributes, 'code')).to.deep.equal([
|
|
52
|
+
{ header: 'comb0:', label: 'd0v' },
|
|
53
|
+
{ header: 'comb1:', label: 'd0v, d2v' },
|
|
54
|
+
{ header: 'comb2:', label: 'd0v, _T, d2v' },
|
|
55
|
+
]);
|
|
56
|
+
expect(getHeaderCombinations(combinations, dimensions, attributes, 'both')).to.deep.equal([
|
|
57
|
+
{ header: '(comb0) combination 0:', label: '(d0v) d0 value' },
|
|
58
|
+
{ header: '(comb1) combination 1:', label: '(d0v, d2v) d0 value' },
|
|
59
|
+
{ header: '(comb2) combination 2:', label: '(d0v, _T, d2v) Total' },
|
|
60
|
+
]);
|
|
61
|
+
})
|
|
26
62
|
});
|
|
@@ -22,4 +22,29 @@ describe('getTableLabelAccessor tests', () => {
|
|
|
22
22
|
it('not displayed single value', () => {
|
|
23
23
|
expect(getTableLabelAccessor('both')(values[0])).to.deep.equal('(V0) Value 0');
|
|
24
24
|
});
|
|
25
|
+
it('display _T label if all hidden', () => {
|
|
26
|
+
const _values = [
|
|
27
|
+
{ id: 'v0', name: 'value 0', display: false },
|
|
28
|
+
{ id: 'v1', name: 'value 1', display: false },
|
|
29
|
+
{ id: '_T', name: 'Total' },
|
|
30
|
+
{ id: 'v3', name: 'value 3', display: false },
|
|
31
|
+
];
|
|
32
|
+
expect(getTableLabelAccessor('label')(_values)).to.deep.equal('Total');
|
|
33
|
+
expect(getTableLabelAccessor('both')(_values)).to.deep.equal('(v0, v1, _T, v3) Total');
|
|
34
|
+
});
|
|
35
|
+
it('display label first value if all hidden and no _T', () => {
|
|
36
|
+
const _values = [
|
|
37
|
+
{ id: 'v0', name: 'value 0', display: false },
|
|
38
|
+
{ id: 'v1', name: 'value 1', display: false },
|
|
39
|
+
{ id: 'v2', name: 'value 2', display: false },
|
|
40
|
+
{ id: 'v3', name: 'value 3', display: false },
|
|
41
|
+
];
|
|
42
|
+
expect(getTableLabelAccessor('label')(_values)).to.deep.equal('value 0');
|
|
43
|
+
expect(getTableLabelAccessor('both')(_values)).to.deep.equal('(v0, v1, v2, v3) value 0');
|
|
44
|
+
});
|
|
45
|
+
it('empty case', () => {
|
|
46
|
+
expect(getTableLabelAccessor('label')([])).to.deep.equal('');
|
|
47
|
+
expect(getTableLabelAccessor('code')([])).to.deep.equal('');
|
|
48
|
+
expect(getTableLabelAccessor('both')([])).to.deep.equal('');
|
|
49
|
+
});
|
|
25
50
|
});
|