@sis-cc/dotstatsuite-components 14.3.2 → 14.3.5
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/rules/src/v8-transformer.js +1 -1
- package/lib/rules2/src/hierarchiseDimensionWithAdvancedHierarchy.js +40 -21
- package/lib/viewer/src/index.js +13 -2
- package/package.json +1 -1
- package/src/rules/src/v8-transformer.js +1 -1
- package/src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy.js +51 -37
- package/src/viewer/src/index.js +13 -5
- package/test/hierarchiseDimensionWithAdvancedHierarchy.test.js +61 -1
|
@@ -131,7 +131,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
|
|
|
131
131
|
var attrAnnotations = R.props(attr.annotations || [], annotations);
|
|
132
132
|
return (0, _extends3.default)({}, attr, {
|
|
133
133
|
display: !R.has(attr.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(attrAnnotations),
|
|
134
|
-
name: (0, _dotstatsuiteSdmxjs.getRefinedName)(
|
|
134
|
+
name: (0, _dotstatsuiteSdmxjs.getRefinedName)(attr),
|
|
135
135
|
values: getValues(attr.values || [], attr.id)
|
|
136
136
|
});
|
|
137
137
|
}, R.propOr([], 'dataSet', attributes));
|
|
@@ -17,32 +17,51 @@ 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 uniq = R.pipe(R.reduce(function (_ref, id) {
|
|
21
|
+
var ids = _ref.ids,
|
|
22
|
+
list = _ref.list;
|
|
23
|
+
|
|
24
|
+
if (R.has(id, list)) {
|
|
25
|
+
return { ids: ids, list: list };
|
|
26
|
+
}
|
|
27
|
+
return { ids: R.append(id, ids), list: R.assoc(id, id, list) };
|
|
28
|
+
}, { ids: [], list: {} }), R.prop('ids'));
|
|
29
|
+
|
|
20
30
|
var refinePartialHierarchy = exports.refinePartialHierarchy = function refinePartialHierarchy(hier, indexed) {
|
|
21
|
-
|
|
22
|
-
var
|
|
31
|
+
var _R$pipe = R.pipe(R.keys, R.reduce(function (_ref2, key) {
|
|
32
|
+
var intact = _ref2.intact,
|
|
33
|
+
broken = _ref2.broken;
|
|
34
|
+
|
|
35
|
+
var ids = R.filter(function (id) {
|
|
36
|
+
return R.has(id, indexed);
|
|
37
|
+
}, hier[key]);
|
|
23
38
|
if (key === '#ROOT') {
|
|
24
|
-
return R.assoc(key, ids,
|
|
39
|
+
return { broken: broken, intact: R.assoc(key, ids, intact) };
|
|
25
40
|
}
|
|
26
|
-
var
|
|
41
|
+
var splitKey = R.split('.', key);
|
|
42
|
+
var filtered = R.takeLastWhile(function (id) {
|
|
27
43
|
return R.has(id, indexed);
|
|
28
|
-
}
|
|
29
|
-
if (R.
|
|
30
|
-
return
|
|
44
|
+
}, splitKey);
|
|
45
|
+
if (R.length(filtered) === R.length(splitKey)) {
|
|
46
|
+
return { broken: broken, intact: R.assoc(key, ids, intact) };
|
|
31
47
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
var refinedKey = R.isEmpty(filtered) ? '#ROOT' : R.join('.', filtered);
|
|
49
|
+
return {
|
|
50
|
+
intact: intact,
|
|
51
|
+
broken: R.over(R.lensProp(refinedKey), R.ifElse(R.isNil, R.always([ids]), R.append(ids)))(broken)
|
|
52
|
+
};
|
|
53
|
+
}, { intact: {}, broken: {} }))(hier),
|
|
54
|
+
intact = _R$pipe.intact,
|
|
55
|
+
broken = _R$pipe.broken;
|
|
56
|
+
|
|
57
|
+
var intactIds = R.pipe(R.values, R.unnest)(intact);
|
|
58
|
+
var refinedBroken = R.pipe(R.omit(intactIds), R.over(R.lensProp('#ROOT'), R.pipe(function (i) {
|
|
59
|
+
return R.isNil(i) ? [] : i;
|
|
60
|
+
}, R.unnest, R.reject(R.flip(R.includes)(intactIds)))), R.map(R.pipe(R.unnest, uniq)))(broken);
|
|
61
|
+
|
|
62
|
+
return (0, _extends3.default)({}, refinedBroken, intact, {
|
|
63
|
+
'#ROOT': R.concat(refinedBroken['#ROOT'], intact['#ROOT'])
|
|
64
|
+
});
|
|
46
65
|
};
|
|
47
66
|
|
|
48
67
|
var hierarchiseDimensionWithAdvancedHierarchy = exports.hierarchiseDimensionWithAdvancedHierarchy = function hierarchiseDimensionWithAdvancedHierarchy(dimension, _hierarchy) {
|
package/lib/viewer/src/index.js
CHANGED
|
@@ -38,6 +38,10 @@ var _dotstatsuiteVisions = require('@sis-cc/dotstatsuite-visions');
|
|
|
38
38
|
|
|
39
39
|
var _styles = require('@material-ui/core/styles');
|
|
40
40
|
|
|
41
|
+
var _HourglassEmpty = require('@material-ui/icons/HourglassEmpty');
|
|
42
|
+
|
|
43
|
+
var _HourglassEmpty2 = _interopRequireDefault(_HourglassEmpty);
|
|
44
|
+
|
|
41
45
|
var _options = require('./chartUtils/options');
|
|
42
46
|
|
|
43
47
|
var _options2 = _interopRequireDefault(_options);
|
|
@@ -100,8 +104,15 @@ var ViewContent = function ViewContent(_ref3) {
|
|
|
100
104
|
errorMessage = _ref3.errorMessage,
|
|
101
105
|
rest = (0, _objectWithoutProperties3.default)(_ref3, ['loading', 'loadingProps', 'noData', 'type', 'width', 'errorMessage']);
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
if (
|
|
107
|
+
var theme = (0, _styles.useTheme)();
|
|
108
|
+
if (loading) return _react2.default.createElement(_dotstatsuiteVisions.NoData, {
|
|
109
|
+
message: loading,
|
|
110
|
+
icon: _react2.default.createElement(_HourglassEmpty2.default, { style: { fontSize: 50, color: loadingProps.isWarning ? theme.palette.warning.main : theme.palette.primary.main } })
|
|
111
|
+
});
|
|
112
|
+
if (!width) return _react2.default.createElement(_dotstatsuiteVisions.NoData, {
|
|
113
|
+
message: loading,
|
|
114
|
+
icon: _react2.default.createElement(_HourglassEmpty2.default, { style: { fontSize: 50, color: loadingProps.isWarning ? theme.palette.warning.main : theme.palette.primary.main } })
|
|
115
|
+
});
|
|
105
116
|
if (errorMessage) return _react2.default.createElement(_dotstatsuiteVisions.NoData, { message: errorMessage });
|
|
106
117
|
|
|
107
118
|
if (type === 'table') {
|
package/package.json
CHANGED
|
@@ -128,7 +128,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
128
128
|
return ({
|
|
129
129
|
...attr,
|
|
130
130
|
display: !R.has(attr.id, hiddenIds) && !getIsHidden(attrAnnotations),
|
|
131
|
-
name: getRefinedName(
|
|
131
|
+
name: getRefinedName(attr),
|
|
132
132
|
values: getValues(attr.values || [], attr.id)
|
|
133
133
|
});
|
|
134
134
|
},
|
|
@@ -1,50 +1,64 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
R.keys,
|
|
3
|
+
const uniq = R.pipe(
|
|
5
4
|
R.reduce(
|
|
6
|
-
(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return R.assoc(key, ids, acc);
|
|
5
|
+
({ ids, list }, id) => {
|
|
6
|
+
if (R.has(id, list)) {
|
|
7
|
+
return ({ ids, list });
|
|
10
8
|
}
|
|
11
|
-
|
|
12
|
-
R.split('.'),
|
|
13
|
-
R.takeLastWhile(id => R.has(id, indexed)),
|
|
14
|
-
R.join('.')
|
|
15
|
-
)(key);
|
|
16
|
-
if (R.isEmpty(refinedKey)) {
|
|
17
|
-
return R.over(R.lensProp('#ROOT0'), R.ifElse(R.isNil, R.always([ids]), R.append(ids)))(acc)
|
|
18
|
-
}
|
|
19
|
-
return R.over(R.lensProp(refinedKey), R.ifElse(R.isNil, R.always([ids]), R.append(ids)))(acc);
|
|
9
|
+
return ({ ids: R.append(id, ids), list: R.assoc(id, id, list) });
|
|
20
10
|
},
|
|
21
|
-
{}
|
|
11
|
+
{ ids: [], list: {} }
|
|
22
12
|
),
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
13
|
+
R.prop('ids')
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const refinePartialHierarchy = (hier, indexed) => {
|
|
17
|
+
const { intact, broken } = R.pipe(
|
|
18
|
+
R.keys,
|
|
19
|
+
R.reduce(
|
|
20
|
+
({ intact, broken }, key) => {
|
|
21
|
+
const ids = R.filter(id => R.has(id, indexed), hier[key]);
|
|
22
|
+
if (key === '#ROOT') {
|
|
23
|
+
return ({ broken, intact: R.assoc(key, ids, intact) });
|
|
24
|
+
}
|
|
25
|
+
const splitKey = R.split('.', key);
|
|
26
|
+
const filtered = R.takeLastWhile(id => R.has(id, indexed), splitKey);
|
|
27
|
+
if (R.length(filtered) === R.length(splitKey)) {
|
|
28
|
+
return ({ broken, intact: R.assoc(key, ids, intact) });
|
|
29
|
+
}
|
|
30
|
+
const refinedKey = R.isEmpty(filtered) ? '#ROOT' : R.join('.', filtered);
|
|
31
|
+
return ({
|
|
32
|
+
intact,
|
|
33
|
+
broken: R.over(R.lensProp(refinedKey), R.ifElse(R.isNil, R.always([ids]), R.append(ids)))(broken)
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
{ intact: {}, broken: {} }
|
|
37
|
+
)
|
|
38
|
+
)(hier);
|
|
39
|
+
const intactIds = R.pipe(R.values, R.unnest)(intact);
|
|
40
|
+
const refinedBroken = R.pipe(
|
|
41
|
+
R.omit(intactIds),
|
|
42
|
+
R.over(
|
|
43
|
+
R.lensProp('#ROOT'),
|
|
44
|
+
R.pipe(
|
|
45
|
+
i => R.isNil(i) ? [] : i,
|
|
46
|
+
R.unnest,
|
|
47
|
+
R.reject(R.flip(R.includes)(intactIds)))
|
|
48
|
+
),
|
|
49
|
+
R.map(R.pipe(R.unnest, uniq))
|
|
50
|
+
)(broken);
|
|
51
|
+
|
|
52
|
+
return ({
|
|
53
|
+
...refinedBroken,
|
|
54
|
+
...intact,
|
|
55
|
+
'#ROOT': R.concat(refinedBroken['#ROOT'], intact['#ROOT'])
|
|
56
|
+
})
|
|
57
|
+
};
|
|
43
58
|
|
|
44
59
|
export const hierarchiseDimensionWithAdvancedHierarchy = (dimension, _hierarchy) => {
|
|
45
60
|
const indexed = R.indexBy(R.prop('id'), dimension.values);
|
|
46
61
|
const hierarchy = refinePartialHierarchy(_hierarchy, indexed);
|
|
47
|
-
|
|
48
62
|
|
|
49
63
|
let rest = indexed;
|
|
50
64
|
const getChildren = (parents, hier) => R.pipe(
|
package/src/viewer/src/index.js
CHANGED
|
@@ -3,8 +3,9 @@ import * as R from 'ramda';
|
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
import { compose, withState, withProps } from 'recompose';
|
|
5
5
|
import sizeMe from 'react-sizeme';
|
|
6
|
-
import {
|
|
6
|
+
import { NoData as IconMessage, TableHtml5 } from '@sis-cc/dotstatsuite-visions';
|
|
7
7
|
import { useTheme, makeStyles } from '@material-ui/core/styles';
|
|
8
|
+
import HourglassEmptyIcon from '@material-ui/icons/HourglassEmpty';
|
|
8
9
|
import getChartOptions from './chartUtils/options';
|
|
9
10
|
import Header from './header';
|
|
10
11
|
import Chart from './chart';
|
|
@@ -34,14 +35,21 @@ const useStyles = makeStyles(() => ({
|
|
|
34
35
|
}));
|
|
35
36
|
|
|
36
37
|
const ViewContent = ({ loading, loadingProps={}, noData = 'No Data', type, width, errorMessage, ...rest }) => {
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
38
|
+
const theme = useTheme();
|
|
39
|
+
if (loading) return <IconMessage
|
|
40
|
+
message={loading}
|
|
41
|
+
icon={<HourglassEmptyIcon style={{ fontSize: 50, color: loadingProps.isWarning ? theme.palette.warning.main : theme.palette.primary.main }} />}
|
|
42
|
+
/>;
|
|
43
|
+
if (!width) return <IconMessage
|
|
44
|
+
message={loading}
|
|
45
|
+
icon={<HourglassEmptyIcon style={{ fontSize: 50, color: loadingProps.isWarning ? theme.palette.warning.main : theme.palette.primary.main }} />}
|
|
46
|
+
/>;
|
|
47
|
+
if (errorMessage) return <IconMessage message={errorMessage} />;
|
|
40
48
|
|
|
41
49
|
if (type === 'table') {
|
|
42
50
|
const tableProps = R.propOr({}, 'tableProps', rest);
|
|
43
51
|
const hasNoObs = R.pipe(R.prop('cells'), R.anyPass([R.isNil, R.isEmpty]))(tableProps);
|
|
44
|
-
if (hasNoObs) return <
|
|
52
|
+
if (hasNoObs) return <IconMessage message={noData} />;
|
|
45
53
|
|
|
46
54
|
return <TableHtml5 isRtl={R.prop('isRtl', rest)} {...tableProps} />;
|
|
47
55
|
}
|
|
@@ -71,8 +71,8 @@ describe('hierarchiseDimensionWithAdvancedHierarchy tests', () => {
|
|
|
71
71
|
id: 'test',
|
|
72
72
|
values: [
|
|
73
73
|
{ id: 'AFK', parent: undefined, parents: [], __indexPosition: 3 },
|
|
74
|
-
{ id: 'CAN', parent: undefined, parents: [], __indexPosition: 1 },
|
|
75
74
|
{ id: 'USA', parent: undefined, parents: [], __indexPosition: 2 },
|
|
75
|
+
{ id: 'CAN', parent: undefined, parents: [], __indexPosition: 1 },
|
|
76
76
|
{ id: 'W', parent: undefined, parents: [], __indexPosition: 8 },
|
|
77
77
|
{ id: 'EA', parent: 'W', parents: ['W'], __indexPosition: 6 },
|
|
78
78
|
{ id: 'FRA', parent: 'EA', parents: ['W', 'EA'], __indexPosition: 5 },
|
|
@@ -131,4 +131,64 @@ describe('hierarchiseDimensionWithAdvancedHierarchy tests', () => {
|
|
|
131
131
|
|
|
132
132
|
expect(hierarchiseDimensionWithAdvancedHierarchy(dimension, hierarchy)).to.deep.equal(expected);
|
|
133
133
|
});
|
|
134
|
+
it('non duplicates case 1', () => {
|
|
135
|
+
const hierarchy = {
|
|
136
|
+
'#ROOT': ['ONU', 'OECD'],
|
|
137
|
+
'OECD': ['FRA', 'USA'],
|
|
138
|
+
'ONU': ['USA', 'FRA'],
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const dimension = {
|
|
142
|
+
id: 'REF_AREA',
|
|
143
|
+
values: [
|
|
144
|
+
{ id: 'FRA' },
|
|
145
|
+
{ id: 'USA' }
|
|
146
|
+
]
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const expected = {
|
|
150
|
+
id: 'REF_AREA',
|
|
151
|
+
values: [
|
|
152
|
+
{ id: 'FRA', parents: [], parent: undefined },
|
|
153
|
+
{ id: 'USA', parents: [], parent: undefined }
|
|
154
|
+
]
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
expect(hierarchiseDimensionWithAdvancedHierarchy(dimension, hierarchy)).to.deep.equal(expected);
|
|
158
|
+
});
|
|
159
|
+
it('non duplicates case 2', () => {
|
|
160
|
+
const hierarchy = {
|
|
161
|
+
'#ROOT': ['ONU', 'OECD'],
|
|
162
|
+
'ONU': ['USA', 'FRA'],
|
|
163
|
+
'OECD': ['FRA', 'USA'],
|
|
164
|
+
'ONU.USA': ['NY', 'LA'],
|
|
165
|
+
'ONU.FRA': ['PA', 'LY']
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const dimension = {
|
|
169
|
+
id: 'REF_AREA',
|
|
170
|
+
values: [
|
|
171
|
+
{ id: 'OECD' },
|
|
172
|
+
{ id: 'FRA' },
|
|
173
|
+
{ id: 'PA' },
|
|
174
|
+
{ id: 'LY' },
|
|
175
|
+
{ id: 'USA' },
|
|
176
|
+
{ id: 'NY' },
|
|
177
|
+
{ id: 'LA' },
|
|
178
|
+
]
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const expected = {
|
|
182
|
+
id: 'REF_AREA',
|
|
183
|
+
values: [
|
|
184
|
+
{ id: 'OECD', parents: [], parent: undefined },
|
|
185
|
+
{ id: 'FRA', parents: ['OECD'], parent: 'OECD' },
|
|
186
|
+
{ id: 'PA', parents: ['OECD.FRA'], parent: 'FRA' },
|
|
187
|
+
{ id: 'LY', parents: ['OECD.FRA'], parent: 'FRA' },
|
|
188
|
+
{ id: 'USA', parents: ['OECD'], parent: 'OECD' },
|
|
189
|
+
{ id: 'NY', parents: ['OECD.USA'], parent: 'USA' },
|
|
190
|
+
{ id: 'LA', parents: ['OECD.USA'], parent: 'USA' },
|
|
191
|
+
]
|
|
192
|
+
};
|
|
193
|
+
});
|
|
134
194
|
});
|