@sis-cc/dotstatsuite-components 9.2.1 → 9.2.2
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.
|
@@ -31,6 +31,24 @@ var indexesToLayoutData = function indexesToLayoutData(dimensions, indexes) {
|
|
|
31
31
|
}, indexes);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
var parseParents = function parseParents(value, previous) {
|
|
35
|
+
var previousParents = R.pathOr([], ['value', 'parents'], previous);
|
|
36
|
+
var indexedParents = R.indexBy(R.identity, value.parents);
|
|
37
|
+
|
|
38
|
+
var refinedParents = R.reduce(function (acc, id) {
|
|
39
|
+
if (R.has(id, indexedParents)) {
|
|
40
|
+
return R.append(id, acc);
|
|
41
|
+
}
|
|
42
|
+
return acc;
|
|
43
|
+
}, [], R.append(R.path(['value', 'id'], previous), previousParents));
|
|
44
|
+
var lastParent = R.last(refinedParents);
|
|
45
|
+
var missingParents = R.takeLastWhile(function (id) {
|
|
46
|
+
return id !== lastParent;
|
|
47
|
+
}, value.parents);
|
|
48
|
+
|
|
49
|
+
return { parents: refinedParents, missingIds: missingParents };
|
|
50
|
+
};
|
|
51
|
+
|
|
34
52
|
var getRowData = function getRowData(indexes, dimension) {
|
|
35
53
|
return R.pipe(R.propOr([], 'values'), R.props(indexes), R.reduce(function (_ref, _value) {
|
|
36
54
|
var data = _ref.data,
|
|
@@ -44,7 +62,6 @@ var getRowData = function getRowData(indexes, dimension) {
|
|
|
44
62
|
return { data: R.append([raw], data), missingParents: {} };
|
|
45
63
|
}
|
|
46
64
|
var previous = R.head(R.last(data) || []);
|
|
47
|
-
|
|
48
65
|
if (R.last(_value.parents) === R.path(['value', 'id'], previous)) {
|
|
49
66
|
//previous is parent
|
|
50
67
|
var _value2 = R.set(R.lensPath(['value', 'parents']), R.append(R.path(['value', 'id'], previous), R.pathOr([], ['value', 'parents'], previous)))(raw);
|
|
@@ -61,9 +78,10 @@ var getRowData = function getRowData(indexes, dimension) {
|
|
|
61
78
|
return { data: R.append([_value3], data), missingParents: missingParents };
|
|
62
79
|
}
|
|
63
80
|
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
81
|
+
var _parseParents = parseParents(_value, previous),
|
|
82
|
+
parents = _parseParents.parents,
|
|
83
|
+
missingIds = _parseParents.missingIds;
|
|
84
|
+
|
|
67
85
|
var _missingParents = R.reduce(function (acc, value) {
|
|
68
86
|
if (value.id !== R.head(acc.missingIds)) {
|
|
69
87
|
return acc;
|
|
@@ -79,11 +97,11 @@ var getRowData = function getRowData(indexes, dimension) {
|
|
|
79
97
|
}, { name: '', missingIds: missingIds }, dimension.values);
|
|
80
98
|
|
|
81
99
|
var value = R.set(R.lensProp('value'), (0, _extends3.default)({}, _value, {
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
parents: parents,
|
|
101
|
+
name: R.isEmpty(missingIds) ? _value.name : _missingParents.name + ' > ' + _value.name
|
|
84
102
|
}))(raw);
|
|
85
103
|
|
|
86
|
-
return { data: R.append([value], data), missingParents: _missingParents };
|
|
104
|
+
return { data: R.append([value], data), missingParents: R.isEmpty(missingIds) ? {} : _missingParents };
|
|
87
105
|
}, { data: [], missingParents: {} }), R.prop('data'))(dimension);
|
|
88
106
|
};
|
|
89
107
|
|
package/package.json
CHANGED
|
@@ -11,6 +11,26 @@ const indexesToLayoutData = (dimensions, indexes) => R.addIndex(R.map)(
|
|
|
11
11
|
indexes
|
|
12
12
|
);
|
|
13
13
|
|
|
14
|
+
const parseParents = (value, previous) => {
|
|
15
|
+
const previousParents = R.pathOr([], ['value', 'parents'], previous);
|
|
16
|
+
const indexedParents = R.indexBy(R.identity, value.parents);
|
|
17
|
+
|
|
18
|
+
const refinedParents = R.reduce(
|
|
19
|
+
(acc, id) => {
|
|
20
|
+
if (R.has(id, indexedParents)) {
|
|
21
|
+
return R.append(id, acc);
|
|
22
|
+
}
|
|
23
|
+
return acc;
|
|
24
|
+
},
|
|
25
|
+
[],
|
|
26
|
+
R.append(R.path(['value', 'id'], previous), previousParents)
|
|
27
|
+
);
|
|
28
|
+
const lastParent = R.last(refinedParents);
|
|
29
|
+
const missingParents = R.takeLastWhile(id => id !== lastParent, value.parents);
|
|
30
|
+
|
|
31
|
+
return ({ parents: refinedParents, missingIds: missingParents });
|
|
32
|
+
};
|
|
33
|
+
|
|
14
34
|
const getRowData = (indexes, dimension) => {
|
|
15
35
|
return R.pipe(
|
|
16
36
|
R.propOr([], 'values'),
|
|
@@ -25,7 +45,6 @@ const getRowData = (indexes, dimension) => {
|
|
|
25
45
|
return ({ data: R.append([raw], data), missingParents: {} });
|
|
26
46
|
}
|
|
27
47
|
const previous = R.head(R.last(data) || []);
|
|
28
|
-
|
|
29
48
|
if (R.last(_value.parents) === R.path(['value', 'id'], previous)) { //previous is parent
|
|
30
49
|
const value = R.set(
|
|
31
50
|
R.lensPath(['value', 'parents']),
|
|
@@ -49,8 +68,7 @@ const getRowData = (indexes, dimension) => {
|
|
|
49
68
|
)(raw);
|
|
50
69
|
return ({ data: R.append([value], data), missingParents });
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
const missingIds = R.takeLastWhile(id => id !== R.path(['value', 'id'], previous), _value.parents);
|
|
71
|
+
const { parents, missingIds } = parseParents(_value, previous);
|
|
54
72
|
const _missingParents = R.reduce(
|
|
55
73
|
(acc, value) => {
|
|
56
74
|
if (value.id !== R.head(acc.missingIds)) {
|
|
@@ -73,14 +91,12 @@ const getRowData = (indexes, dimension) => {
|
|
|
73
91
|
R.lensProp('value'),
|
|
74
92
|
{
|
|
75
93
|
..._value,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
? []
|
|
79
|
-
: R.append(R.path(['value', 'id'], previous), R.pathOr([], ['value', 'parents'], previous))
|
|
94
|
+
parents,
|
|
95
|
+
name: R.isEmpty(missingIds) ? _value.name : `${_missingParents.name} > ${_value.name}`,
|
|
80
96
|
}
|
|
81
97
|
)(raw);
|
|
82
98
|
|
|
83
|
-
return ({ data: R.append([value], data), missingParents: _missingParents });
|
|
99
|
+
return ({ data: R.append([value], data), missingParents: R.isEmpty(missingIds) ? {} : _missingParents });
|
|
84
100
|
},
|
|
85
101
|
{ data: [], missingParents: {} }
|
|
86
102
|
),
|
|
@@ -151,4 +167,3 @@ export const getLayoutData = (layoutIndexes, layout) => {
|
|
|
151
167
|
|
|
152
168
|
return ({ headerData, sectionsData, truncated });
|
|
153
169
|
};
|
|
154
|
-
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import { getLayoutData } from '../src/rules/src/table/factories/getLayoutData';
|
|
3
3
|
|
|
4
|
-
describe('
|
|
4
|
+
describe('getLayoutData tests', () => {
|
|
5
5
|
it ('simple single row diension case', () => {
|
|
6
6
|
const layout = {
|
|
7
7
|
header: [],
|
|
@@ -46,7 +46,9 @@ describe('getLayoutData2 tests', () => {
|
|
|
46
46
|
{ id: '3v0', name: '3V0' },
|
|
47
47
|
{ id: '3v0.0', name: '3V0.0', parents: ['3v0'] },
|
|
48
48
|
{ id: '3v0.0.0', name: '3V0.0.0', parents: ['3v0', '3v0.0'] },
|
|
49
|
-
{ id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] }
|
|
49
|
+
{ id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] },
|
|
50
|
+
{ id: '3v0.1', name: '3V0.1', parents: ['3v0'] },
|
|
51
|
+
{ id: '3v0.1.0', name: '3V0.1.0', parents: ['3v0', '3v0.1'] }
|
|
50
52
|
]
|
|
51
53
|
},
|
|
52
54
|
]
|
|
@@ -74,7 +76,9 @@ describe('getLayoutData2 tests', () => {
|
|
|
74
76
|
[3, 0],
|
|
75
77
|
[3, 1],
|
|
76
78
|
[3, 2],
|
|
77
|
-
[3, 3]
|
|
79
|
+
[3, 3],
|
|
80
|
+
[3, 4],
|
|
81
|
+
[3, 5]
|
|
78
82
|
]
|
|
79
83
|
],
|
|
80
84
|
[
|
|
@@ -162,6 +166,14 @@ describe('getLayoutData2 tests', () => {
|
|
|
162
166
|
[
|
|
163
167
|
{ dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] } },
|
|
164
168
|
{ dimension: { id: 'd3' }, value: { id: '3v0.0.1', name: '3V0.0.1', parents: ['3v0', '3v0.0'] } }
|
|
169
|
+
],
|
|
170
|
+
[
|
|
171
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] } },
|
|
172
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.1', name: '3V0.1', parents: ['3v0'] } }
|
|
173
|
+
],
|
|
174
|
+
[
|
|
175
|
+
{ dimension: { id: 'd2' }, value: { id: '2v0.0.1', name: '2V0.0.1', parents: ['2v0', '2v0.0'] } },
|
|
176
|
+
{ dimension: { id: 'd3' }, value: { id: '3v0.1.0', name: '3V0.1.0', parents: ['3v0', '3v0.1'] } }
|
|
165
177
|
]
|
|
166
178
|
]
|
|
167
179
|
],
|