@sis-cc/dotstatsuite-components 16.1.5 → 16.1.6
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.
|
@@ -25,11 +25,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
|
|
26
26
|
var getOneValueDimensions = exports.getOneValueDimensions = function getOneValueDimensions(dimensions, attributes) {
|
|
27
27
|
var indexedRelevantAttributes = R.reduce(function (acc, attr) {
|
|
28
|
-
if (!attr.header || !
|
|
28
|
+
if (!attr.header || !R.propOr(true, 'display', attr) || R.length(attr.relationship || []) !== 1) {
|
|
29
29
|
return acc;
|
|
30
30
|
}
|
|
31
31
|
var value = R.path(['values', 0], attr);
|
|
32
|
-
if (R.isNil(value) || !R.
|
|
32
|
+
if (R.isNil(value) || !R.propOr(true, 'display', value) || R.includes(R.prop('id', value), _constants.REJECTED_VALUE_IDS)) {
|
|
33
33
|
return acc;
|
|
34
34
|
}
|
|
35
35
|
var dim = R.head(attr.relationship);
|
|
@@ -39,7 +39,7 @@ var getOneValueDimensions = exports.getOneValueDimensions = function getOneValue
|
|
|
39
39
|
})(acc);
|
|
40
40
|
}, {}, attributes);
|
|
41
41
|
return R.reduce(function (acc, dim) {
|
|
42
|
-
if (R.length(dim.values || []) !== 1) {
|
|
42
|
+
if (R.length(dim.values || []) !== 1 || !R.propOr(true, 'display', dim) || !R.pathOr(true, ['values', 0, 'display'], dim) || R.includes(R.path(['values', 0, 'id'], dim), _constants.REJECTED_VALUE_IDS)) {
|
|
43
43
|
return acc;
|
|
44
44
|
}
|
|
45
45
|
var attrValues = R.propOr({}, dim.id, indexedRelevantAttributes);
|
package/package.json
CHANGED
|
@@ -4,11 +4,11 @@ import { REJECTED_VALUE_IDS } from './constants';
|
|
|
4
4
|
export const getOneValueDimensions = (dimensions, attributes) => {
|
|
5
5
|
const indexedRelevantAttributes = R.reduce(
|
|
6
6
|
(acc, attr) => {
|
|
7
|
-
if (!attr.header || !
|
|
7
|
+
if (!attr.header || !R.propOr(true, 'display', attr) || R.length(attr.relationship || []) !== 1) {
|
|
8
8
|
return acc;
|
|
9
9
|
}
|
|
10
10
|
const value = R.path(['values', 0], attr);
|
|
11
|
-
if (R.isNil(value) || !R.
|
|
11
|
+
if (R.isNil(value) || !R.propOr(true, 'display', value) || R.includes(R.prop('id', value), REJECTED_VALUE_IDS)) {
|
|
12
12
|
return acc;
|
|
13
13
|
}
|
|
14
14
|
const dim = R.head(attr.relationship);
|
|
@@ -22,7 +22,8 @@ export const getOneValueDimensions = (dimensions, attributes) => {
|
|
|
22
22
|
);
|
|
23
23
|
return R.reduce(
|
|
24
24
|
(acc, dim) => {
|
|
25
|
-
if (R.length(dim.values || []) !== 1)
|
|
25
|
+
if (R.length(dim.values || []) !== 1 || !R.propOr(true, 'display', dim) || !R.pathOr(true, ['values', 0, 'display'], dim)
|
|
26
|
+
|| R.includes(R.path(['values', 0, 'id'], dim), REJECTED_VALUE_IDS)) {
|
|
26
27
|
return acc;
|
|
27
28
|
}
|
|
28
29
|
const attrValues = R.propOr({}, dim.id, indexedRelevantAttributes);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getOneValueDimensions } from '../src/rules2/src/';
|
|
3
|
+
|
|
4
|
+
describe('getOneValueDimensions tests', () => {
|
|
5
|
+
it('basic case', () => {
|
|
6
|
+
const attributes = [
|
|
7
|
+
{ id: 'a0', header: true, values: [{ id: 'v' }] },
|
|
8
|
+
{ id: 'a1', header: true, values: [{ id: 'v' }], relationship: ['d0'] },
|
|
9
|
+
{ id: 'a2', header: true, values: [{ id: 'v' }], relationship: ['d0', 'd1'] },
|
|
10
|
+
{ id: 'a3', display: false, header: true, values: [{ id: 'v' }], relationship: ['d0'] },
|
|
11
|
+
{ id: 'a4', header: true, values: [{ id: 'v', display: false }], relationship: ['d0'] },
|
|
12
|
+
{ id: 'a5', header: true, values: [{ id: '_Z' }], relationship: ['d0'] },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const dimensions = [
|
|
16
|
+
{ id: 'd0', values: [{ id: 'v' }] },
|
|
17
|
+
{ id: 'd1', values: [{ id: 'v' }] },
|
|
18
|
+
{ id: 'd2', display: false, values: [{ id: 'v' }] },
|
|
19
|
+
{ id: 'd3', values: [{ id: 'v', display: false }] },
|
|
20
|
+
{ id: 'd4', values: [{ id: '_T' }] },
|
|
21
|
+
{ id: 'd5', values: [{ id: 'v0' }, { id: 'v1' }] },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
expect(getOneValueDimensions(dimensions, attributes)).to.deep.equal([
|
|
25
|
+
{ id: 'd0', values: [{ id: 'v' }], attrValues: { a1: { id: 'a1', header: true, values: [{ id: 'v' }], relationship: ['d0'], value: { id: 'v' } } } },
|
|
26
|
+
{ id: 'd1', values: [{ id: 'v' }], attrValues: {} },
|
|
27
|
+
])
|
|
28
|
+
});
|
|
29
|
+
});
|