@sis-cc/dotstatsuite-components 19.1.0 → 19.3.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/getAttributesSeries.js +1 -1
- package/lib/rules2/src/parseCombinations.js +1 -2
- package/lib/rules2/src/table/getCells.js +8 -2
- package/lib/rules2/src/table/getLayoutData2.js +2 -2
- package/package.json +1 -1
- package/src/rules2/src/getAttributesSeries.js +1 -1
- package/src/rules2/src/parseCombinations.js +1 -2
- package/src/rules2/src/table/getCells.js +10 -4
- package/src/rules2/src/table/getLayoutData2.js +2 -2
- package/test/getAttributesSeries.test.js +6 -0
- package/test/getCells.test.js +20 -3
- package/test/getLayoutData2.test.js +48 -0
- package/test/parseCombinations.test.js +14 -0
|
@@ -18,7 +18,7 @@ var getAttributesSeries = exports.getAttributesSeries = function getAttributesSe
|
|
|
18
18
|
var res = acc.res;
|
|
19
19
|
var rejected = acc.rejected;
|
|
20
20
|
R.forEachObjIndexed(function (attribute) {
|
|
21
|
-
if (!R.isNil(attribute.serieKey)) {
|
|
21
|
+
if (!R.isNil(attribute.serieKey) && !attribute.isObs) {
|
|
22
22
|
if (R.isNil(attribute.value)) {
|
|
23
23
|
res = R.dissocPath([attribute.serieKey, attribute.id], res);
|
|
24
24
|
rejected = R.assocPath([attribute.serieKey, attribute.id], true, rejected);
|
|
@@ -35,7 +35,6 @@ var hasInvalidValues = R.pipe(R.prop('values'), R.anyPass([R.isNil, R.complement
|
|
|
35
35
|
var isConceptInvalid = R.anyPass([hasInvalidValues /* add more... */]);
|
|
36
36
|
var filterValidConcepts = R.reject(isConceptInvalid);
|
|
37
37
|
// concepts is an array of ids... (misnamed!)
|
|
38
|
-
var conceptIdsLens = R.lensProp('concepts');
|
|
39
38
|
var rejectInvalidConceptIds = function rejectInvalidConceptIds() {
|
|
40
39
|
var concepts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
41
40
|
return function () {
|
|
@@ -44,7 +43,7 @@ var rejectInvalidConceptIds = function rejectInvalidConceptIds() {
|
|
|
44
43
|
var validConceptIds = R.pluck('id', filterValidConcepts(concepts));
|
|
45
44
|
return R.reduce(function (acc, comb) {
|
|
46
45
|
var refinedConcepts = R.intersection(validConceptIds, comb.concepts);
|
|
47
|
-
if (R.length(refinedConcepts) <
|
|
46
|
+
if (R.length(refinedConcepts) < 1) {
|
|
48
47
|
return acc;
|
|
49
48
|
}
|
|
50
49
|
return R.append((0, _extends4.default)({}, comb, { concepts: refinedConcepts }), acc);
|
|
@@ -69,13 +69,19 @@ var getCells = exports.getCells = function getCells(customAttributes, cellsAttri
|
|
|
69
69
|
var relevantAttributes = isAttrCell ? [] : getCellRelevantAttributes(obs.attributes, attributesSeries, cellsAttributesId);
|
|
70
70
|
var flagsAndNotes = isAttrCell ? [] : (0, _getFlagsAndNotes.getFlagsAndNotes)(R.omit(attributesInCellsCombination, relevantAttributes), _customAttributes);
|
|
71
71
|
var combinedSeries = isAttrCell ? [] : getCellCombinedSeries(relevantAttributes, combinations.cells || []);
|
|
72
|
-
var hasAdvancedAttributes = isAttrCell ? false : R.pipe(R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination])),
|
|
72
|
+
var hasAdvancedAttributes = isAttrCell ? false : R.pipe(R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination])), function (res) {
|
|
73
|
+
return !R.isEmpty(res);
|
|
74
|
+
})(relevantAttributes);
|
|
75
|
+
|
|
76
|
+
var advancedAttributes = R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination]), R.filter(function (attr) {
|
|
77
|
+
return !R.isNil(attr.value);
|
|
78
|
+
}, obs.attributes));
|
|
73
79
|
|
|
74
80
|
var hasMetadata = isAttrCell ? false : (0, _hasCellMetadata.hasCellMetadata)(metadataCoordinates, obs.indexedDimValIds);
|
|
75
81
|
|
|
76
82
|
return (0, _extends3.default)({}, R.pick(['indexedDimValIds', 'key'], obs), {
|
|
77
83
|
flags: R.concat(flagsAndNotes, combinedSeries),
|
|
78
|
-
sideProps: hasAdvancedAttributes || hasMetadata ? {
|
|
84
|
+
sideProps: hasAdvancedAttributes || hasMetadata ? { hasMetadata: hasMetadata, coordinates: obs.indexedDimValIds, advancedAttributes: advancedAttributes } : null,
|
|
79
85
|
intValue: R.is(Number, obs.value) ? obs.value : null,
|
|
80
86
|
value: obs.formattedValue
|
|
81
87
|
});
|
|
@@ -90,7 +90,7 @@ var getCoordinates = function getCoordinates(indexes, topCoordinates, definition
|
|
|
90
90
|
|
|
91
91
|
var getAttributesSeries = function getAttributesSeries(validator, attributesSeries) {
|
|
92
92
|
return R.reduce(function (acc, attrs) {
|
|
93
|
-
var attr = R.head(R.values(attrs));
|
|
93
|
+
var attr = R.head(R.values(attrs)) || {};
|
|
94
94
|
if (R.length(attr.relationship || []) === 1 && !attr.combined) {
|
|
95
95
|
return acc;
|
|
96
96
|
}
|
|
@@ -130,7 +130,7 @@ var getSerieFlagsAndSideProps = function getSerieFlagsAndSideProps(coordinates,
|
|
|
130
130
|
var flags = (0, _getFlagsAndNotes.getFlagsAndNotes)(layoutAttrValues, customAttributes);
|
|
131
131
|
var hasMetadata = !R.isNil(R.find(validator, metadataCoordinates));
|
|
132
132
|
var hasDataAdvancedAttributes = R.any(function (d) {
|
|
133
|
-
return R.has('value', d) ?
|
|
133
|
+
return R.has('value', d) ? R.prop('hasAdvancedAttributes', d.value) : R.any(R.prop('hasAdvancedAttributes'), d.values);
|
|
134
134
|
}, data);
|
|
135
135
|
var hasAdvancedAttributes = hasDataAdvancedAttributes || getHasAdvancedAttributes(layoutAttrValues, customAttributes);
|
|
136
136
|
var sideProps = hasMetadata || hasAdvancedAttributes ? { hasMetadata: hasMetadata, hasAdvancedAttributes: hasAdvancedAttributes, coordinates: coordinates } : null;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ export const getAttributesSeries = observations => R.pipe(
|
|
|
8
8
|
let rejected = acc.rejected;
|
|
9
9
|
R.forEachObjIndexed(
|
|
10
10
|
(attribute) => {
|
|
11
|
-
if (!R.isNil(attribute.serieKey)) {
|
|
11
|
+
if (!R.isNil(attribute.serieKey) && !attribute.isObs) {
|
|
12
12
|
if (R.isNil(attribute.value)) {
|
|
13
13
|
res = R.dissocPath([attribute.serieKey, attribute.id], res);
|
|
14
14
|
rejected = R.assocPath([attribute.serieKey, attribute.id], true, rejected);
|
|
@@ -18,14 +18,13 @@ const hasInvalidValues = R.pipe(
|
|
|
18
18
|
const isConceptInvalid = R.anyPass([hasInvalidValues /* add more... */]);
|
|
19
19
|
const filterValidConcepts = R.reject(isConceptInvalid);
|
|
20
20
|
// concepts is an array of ids... (misnamed!)
|
|
21
|
-
const conceptIdsLens = R.lensProp('concepts');
|
|
22
21
|
const rejectInvalidConceptIds =
|
|
23
22
|
(concepts = []) =>
|
|
24
23
|
(combinations = []) => {
|
|
25
24
|
const validConceptIds = R.pluck('id', filterValidConcepts(concepts));
|
|
26
25
|
return R.reduce((acc, comb) => {
|
|
27
26
|
const refinedConcepts = R.intersection(validConceptIds, comb.concepts);
|
|
28
|
-
if (R.length(refinedConcepts) <
|
|
27
|
+
if (R.length(refinedConcepts) < 1) {
|
|
29
28
|
return acc;
|
|
30
29
|
}
|
|
31
30
|
return R.append({ ...comb, concepts: refinedConcepts }, acc);
|
|
@@ -66,18 +66,24 @@ export const getCells = (customAttributes, cellsAttributesId, combinations, attr
|
|
|
66
66
|
const relevantAttributes = isAttrCell ? [] : getCellRelevantAttributes(obs.attributes, attributesSeries, cellsAttributesId);
|
|
67
67
|
const flagsAndNotes = isAttrCell ? [] : getFlagsAndNotes(R.omit(attributesInCellsCombination, relevantAttributes), _customAttributes);
|
|
68
68
|
const combinedSeries = isAttrCell ? [] : getCellCombinedSeries(relevantAttributes, combinations.cells || []);
|
|
69
|
-
const hasAdvancedAttributes = isAttrCell
|
|
69
|
+
const hasAdvancedAttributes = isAttrCell
|
|
70
|
+
? false : R.pipe(
|
|
70
71
|
R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination])),
|
|
71
|
-
R.isEmpty
|
|
72
|
-
R.not
|
|
72
|
+
res => !R.isEmpty(res)
|
|
73
73
|
)(relevantAttributes);
|
|
74
74
|
|
|
75
|
+
const advancedAttributes = R.omit(
|
|
76
|
+
R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination]),
|
|
77
|
+
R.filter(attr => !R.isNil(attr.value), obs.attributes),
|
|
78
|
+
);
|
|
79
|
+
|
|
75
80
|
const hasMetadata = isAttrCell ? false : hasCellMetadata(metadataCoordinates, obs.indexedDimValIds);
|
|
76
81
|
|
|
77
82
|
return ({
|
|
78
83
|
...R.pick(['indexedDimValIds', 'key'], obs),
|
|
79
84
|
flags: R.concat(flagsAndNotes, combinedSeries),
|
|
80
|
-
sideProps: hasAdvancedAttributes || hasMetadata
|
|
85
|
+
sideProps: hasAdvancedAttributes || hasMetadata
|
|
86
|
+
? { hasMetadata, coordinates: obs.indexedDimValIds, advancedAttributes } : null,
|
|
81
87
|
intValue: R.is(Number, obs.value) ? obs.value : null,
|
|
82
88
|
value: obs.formattedValue,
|
|
83
89
|
});
|
|
@@ -51,7 +51,7 @@ const getCoordinates = (indexes, topCoordinates, definition) => R.addIndex(R.red
|
|
|
51
51
|
}, topCoordinates, definition);
|
|
52
52
|
|
|
53
53
|
const getAttributesSeries = (validator, attributesSeries) => R.reduce((acc, attrs) => {
|
|
54
|
-
const attr = R.head(R.values(attrs));
|
|
54
|
+
const attr = R.head(R.values(attrs)) || {};
|
|
55
55
|
if (R.length(attr.relationship || []) === 1 && !attr.combined) {
|
|
56
56
|
return acc;
|
|
57
57
|
}
|
|
@@ -87,7 +87,7 @@ const getSerieFlagsAndSideProps = (coordinates, validator, attributesValues, cus
|
|
|
87
87
|
const flags = getFlagsAndNotes(layoutAttrValues, customAttributes);
|
|
88
88
|
const hasMetadata = !R.isNil(R.find(validator, metadataCoordinates));
|
|
89
89
|
const hasDataAdvancedAttributes = R.any(
|
|
90
|
-
d => R.has('value', d) ?
|
|
90
|
+
d => R.has('value', d) ? R.prop('hasAdvancedAttributes', d.value) : R.any(R.prop('hasAdvancedAttributes'), d.values)
|
|
91
91
|
, data);
|
|
92
92
|
const hasAdvancedAttributes = hasDataAdvancedAttributes || getHasAdvancedAttributes(layoutAttrValues, customAttributes);
|
|
93
93
|
const sideProps = hasMetadata || hasAdvancedAttributes
|
|
@@ -9,30 +9,35 @@ describe('getAttributesSeries tests', () => {
|
|
|
9
9
|
A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
|
|
10
10
|
B: { id: 'B', value: { id: 'B0' }, serieKey: 'd1=v0' },
|
|
11
11
|
C: { id: 'C', value: null, serieKey: 'd2=v0' },
|
|
12
|
+
D: { id: 'D', value: { id: 'D0' }, serieKey: 'd2=v0', isObs: true }
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
b: {
|
|
15
16
|
attributes: {
|
|
16
17
|
A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
|
|
17
18
|
B: { id: 'B', value: { id: 'B1' }, serieKey: 'd1=v0' },
|
|
19
|
+
D: { id: 'D', value: { id: 'D0' }, serieKey: 'd2=v0', isObs: true }
|
|
18
20
|
}
|
|
19
21
|
},
|
|
20
22
|
c: {
|
|
21
23
|
attributes: {
|
|
22
24
|
A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
|
|
23
25
|
B: { id: 'B', value: { id: 'B1' }, serieKey: 'd1=v1' },
|
|
26
|
+
D: { id: 'D', value: { id: 'D0' }, serieKey: 'd2=v0', isObs: true }
|
|
24
27
|
}
|
|
25
28
|
},
|
|
26
29
|
d: {
|
|
27
30
|
attributes: {
|
|
28
31
|
A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
|
|
29
32
|
B: { id: 'B', value: { id: 'B1' }, serieKey: 'd1=v1' },
|
|
33
|
+
D: { id: 'D', value: { id: 'D0' }, serieKey: 'd2=v0', isObs: true }
|
|
30
34
|
}
|
|
31
35
|
},
|
|
32
36
|
e: {
|
|
33
37
|
attributes: {
|
|
34
38
|
A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
|
|
35
39
|
B: { id: 'B', value: { id: 'B3' }, serieKey: 'd1=v2' },
|
|
40
|
+
D: { id: 'D', value: { id: 'D0' }, serieKey: 'd2=v0', isObs: true }
|
|
36
41
|
}
|
|
37
42
|
},
|
|
38
43
|
f: {
|
|
@@ -40,6 +45,7 @@ describe('getAttributesSeries tests', () => {
|
|
|
40
45
|
A: { id: 'A', value: { id: 'A0' }, serieKey: 'd0=v0' },
|
|
41
46
|
B: { id: 'B', value: { id: 'B3' }, serieKey: 'd1=v2' },
|
|
42
47
|
C: { id: 'C', value: { id: 'C0' }, serieKey: 'd2=v0' },
|
|
48
|
+
D: { id: 'D', value: { id: 'D0' }, serieKey: 'd2=v0', isObs: true }
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
51
|
};
|
package/test/getCells.test.js
CHANGED
|
@@ -138,7 +138,13 @@ describe('getCells tests', () => {
|
|
|
138
138
|
formattedValue: 'attr val',
|
|
139
139
|
attributes: {},
|
|
140
140
|
indexedDimValIds: { d0: 'v0', d1: 'v0', OBS_ATTRIBUTES: 'A' }
|
|
141
|
-
}
|
|
141
|
+
},
|
|
142
|
+
'c': {
|
|
143
|
+
value: 'val',
|
|
144
|
+
formattedValue: 'val',
|
|
145
|
+
attributes: { ADV_ATTR: { id: 'ADV_ATTR', value: { id: 'v' } } },
|
|
146
|
+
indexedDimValIds: { d0: 'v1', d1: 'v0', OBS_ATTRIBUTES: 'OBS_VALUE' }
|
|
147
|
+
},
|
|
142
148
|
};
|
|
143
149
|
const metadataCoordinates = [{ d0: 'v0', d1: 'v0' }];
|
|
144
150
|
expect(getCells(_customAttributes, {}, combinations, {}, metadataCoordinates)(observations)).to.deep.equal({
|
|
@@ -146,7 +152,7 @@ describe('getCells tests', () => {
|
|
|
146
152
|
value: 'val',
|
|
147
153
|
intValue: null,
|
|
148
154
|
indexedDimValIds: { d0: 'v0', d1: 'v0', OBS_ATTRIBUTES: 'OBS_VALUE' },
|
|
149
|
-
sideProps: {
|
|
155
|
+
sideProps: { advancedAttributes: {}, hasMetadata: true, coordinates: { d0: 'v0', d1: 'v0', OBS_ATTRIBUTES: 'OBS_VALUE' } },
|
|
150
156
|
flags: []
|
|
151
157
|
},
|
|
152
158
|
'b': {
|
|
@@ -155,7 +161,18 @@ describe('getCells tests', () => {
|
|
|
155
161
|
indexedDimValIds: { d0: 'v0', d1: 'v0', OBS_ATTRIBUTES: 'A' },
|
|
156
162
|
sideProps: null,
|
|
157
163
|
flags: []
|
|
158
|
-
}
|
|
164
|
+
},
|
|
165
|
+
'c': {
|
|
166
|
+
value: 'val',
|
|
167
|
+
intValue: null,
|
|
168
|
+
indexedDimValIds: { d0: 'v1', d1: 'v0', OBS_ATTRIBUTES: 'OBS_VALUE' },
|
|
169
|
+
flags: [],
|
|
170
|
+
sideProps: {
|
|
171
|
+
advancedAttributes: { ADV_ATTR: { id: 'ADV_ATTR', value: { id: 'v' } } },
|
|
172
|
+
hasMetadata: false,
|
|
173
|
+
coordinates: { d0: 'v1', d1: 'v0', OBS_ATTRIBUTES: 'OBS_VALUE' }
|
|
174
|
+
},
|
|
175
|
+
},
|
|
159
176
|
});
|
|
160
177
|
});
|
|
161
178
|
});
|
|
@@ -439,4 +439,52 @@ describe('getLayoutData 2 tests', () => {
|
|
|
439
439
|
}
|
|
440
440
|
});
|
|
441
441
|
});
|
|
442
|
+
it('getSerieDataWithMissingLines, advanced attributes as dim level plus enpty series', () => {
|
|
443
|
+
const dimensions = [
|
|
444
|
+
{
|
|
445
|
+
id: 'D0',
|
|
446
|
+
values: [
|
|
447
|
+
{ id: 'D0V0', flags: [], hasAdvancedAttributes: true },
|
|
448
|
+
{ id: 'D0V1' }
|
|
449
|
+
]
|
|
450
|
+
}
|
|
451
|
+
];
|
|
452
|
+
|
|
453
|
+
const attributesSeries = {
|
|
454
|
+
'D1=D1V0': {},
|
|
455
|
+
'D0=D0V0:D1=D1V0': {},
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
const topCoordinates = {};
|
|
459
|
+
|
|
460
|
+
const serie = {
|
|
461
|
+
indexes: [0],
|
|
462
|
+
parentsIndexes: [[]],
|
|
463
|
+
missingIndexes: [[]],
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
const customAttributes = {
|
|
467
|
+
flags: [],
|
|
468
|
+
notes: ['A0', 'A2']
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
expect(getSerieDataWithMissingLines(serie, dimensions, topCoordinates, attributesSeries, customAttributes, {})).to.deep.equal([{
|
|
472
|
+
data: [
|
|
473
|
+
{
|
|
474
|
+
dimension: { id: 'D0' },
|
|
475
|
+
value: { id: 'D0V0', missingParents: [], parents: [], flags: [], hasAdvancedAttributes: true }
|
|
476
|
+
},
|
|
477
|
+
],
|
|
478
|
+
coordinates: { D0: 'D0V0' },
|
|
479
|
+
key: 'D0=D0V0',
|
|
480
|
+
flags: [],
|
|
481
|
+
sideProps: {
|
|
482
|
+
coordinates: {
|
|
483
|
+
D0: 'D0V0',
|
|
484
|
+
},
|
|
485
|
+
hasAdvancedAttributes: true,
|
|
486
|
+
hasMetadata: false
|
|
487
|
+
}
|
|
488
|
+
}]);
|
|
489
|
+
});
|
|
442
490
|
});
|
|
@@ -146,6 +146,20 @@ describe('parseCombinations tests', () => {
|
|
|
146
146
|
relationship: ['DIM4'],
|
|
147
147
|
display: true,
|
|
148
148
|
},
|
|
149
|
+
{
|
|
150
|
+
id: 'COMB11',
|
|
151
|
+
concepts: ['DIM4'],
|
|
152
|
+
relationship: ['DIM4'],
|
|
153
|
+
series: true,
|
|
154
|
+
display: true
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: 'COMB12',
|
|
158
|
+
concepts: ['DIM4'],
|
|
159
|
+
relationship: ['DIM4'],
|
|
160
|
+
series: true,
|
|
161
|
+
display: true
|
|
162
|
+
},
|
|
149
163
|
{
|
|
150
164
|
id: 'COMB14',
|
|
151
165
|
concepts: ['DIM3', 'ATTR5', 'ATTR8'],
|