@sis-cc/dotstatsuite-components 18.1.0 → 19.1.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/.gitlab-ci.yml +1 -1
- package/lib/app.js +3 -16
- package/lib/rules2/src/applyHierarchicalCodesToDim.js +69 -22
- package/lib/viewer/src/app/use-case-1.js +2 -21
- package/lib/viewer/src/app.js +17 -28
- package/package.json +11 -22
- package/src/app.js +4 -11
- package/src/rules2/src/applyHierarchicalCodesToDim.js +60 -12
- package/src/viewer/src/app/use-case-1.js +0 -18
- package/src/viewer/src/app.js +6 -9
- package/test/applyHierarchicalCodesToDim.test.js +13 -0
package/.gitlab-ci.yml
CHANGED
package/lib/app.js
CHANGED
|
@@ -6,29 +6,16 @@ var _react2 = _interopRequireDefault(_react);
|
|
|
6
6
|
|
|
7
7
|
var _client = require('react-dom/client');
|
|
8
8
|
|
|
9
|
-
var _app = require('./viewer/src/app');
|
|
10
|
-
|
|
11
|
-
var _app2 = _interopRequireDefault(_app);
|
|
12
|
-
|
|
13
|
-
var _dotstatsuiteVisions = require('@sis-cc/dotstatsuite-visions');
|
|
14
|
-
|
|
15
|
-
var _styles = require('@mui/material/styles');
|
|
16
|
-
|
|
17
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
10
|
|
|
19
|
-
var theme = (0, _styles.createTheme)((0, _dotstatsuiteVisions.sisccTheme)({ rtl: 'ltr' }));
|
|
20
11
|
var container = document.getElementById('root');
|
|
21
12
|
var root = (0, _client.createRoot)(container);
|
|
22
13
|
|
|
23
14
|
var App = function App() {
|
|
24
15
|
return _react2.default.createElement(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
_styles.ThemeProvider,
|
|
29
|
-
{ theme: theme },
|
|
30
|
-
_react2.default.createElement(_app2.default, null)
|
|
31
|
-
)
|
|
16
|
+
_react.StrictMode,
|
|
17
|
+
null,
|
|
18
|
+
'I\'m not groot, I\'m component'
|
|
32
19
|
);
|
|
33
20
|
};
|
|
34
21
|
|
|
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.applyHierarchicalCodesToDim = undefined;
|
|
7
7
|
|
|
8
|
-
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
|
9
|
-
|
|
10
|
-
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
|
11
|
-
|
|
12
8
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
13
9
|
|
|
14
10
|
var _extends3 = _interopRequireDefault(_extends2);
|
|
@@ -30,8 +26,57 @@ var addParentId = function addParentId(id, ids) {
|
|
|
30
26
|
return R.append(R.isNil(last) ? id : last + '.' + id, ids);
|
|
31
27
|
};
|
|
32
28
|
|
|
33
|
-
var
|
|
29
|
+
var refineUnconfirmedPaths = function refineUnconfirmedPaths(paths) {
|
|
30
|
+
var confirmedPaths = R.filter(function (p) {
|
|
31
|
+
return p.length === 1;
|
|
32
|
+
}, paths);
|
|
33
|
+
if (!R.isEmpty(confirmedPaths)) {
|
|
34
|
+
confirmedPaths = R.reduce(function (acc, k) {
|
|
35
|
+
if (R.has(k, acc)) {
|
|
36
|
+
return acc;
|
|
37
|
+
}
|
|
38
|
+
var ps = R.prop(k, paths);
|
|
39
|
+
var flatConfirmed = R.unnest(R.values(acc));
|
|
40
|
+
var filtered = R.filter(function (p) {
|
|
41
|
+
return !!R.find(function (cP) {
|
|
42
|
+
return R.includes(p, cP) || R.includes(cP, p);
|
|
43
|
+
}, flatConfirmed);
|
|
44
|
+
}, ps);
|
|
45
|
+
if (!R.isEmpty(filtered)) {
|
|
46
|
+
return R.assoc(k, [R.head(filtered)], acc);
|
|
47
|
+
}
|
|
48
|
+
return acc;
|
|
49
|
+
}, confirmedPaths, R.keys(paths));
|
|
50
|
+
}
|
|
51
|
+
var remainingIds = R.reject(function (id) {
|
|
52
|
+
return R.has(id, confirmedPaths);
|
|
53
|
+
}, R.keys(paths));
|
|
54
|
+
var getCommonPaths = function getCommonPaths(ids) {
|
|
55
|
+
var _R$reduce = R.reduce(function (acc, id) {
|
|
56
|
+
var ps = R.prop(id, paths);
|
|
57
|
+
if (R.isEmpty(acc.commonPaths)) {
|
|
58
|
+
return R.assoc('commonPaths', ps, acc);
|
|
59
|
+
}
|
|
60
|
+
var common = R.intersection(acc.commonPaths, ps);
|
|
61
|
+
return R.isEmpty(common) ? R.assoc('rejectedChildrenIds', id, acc) : R.assoc('commonPaths', common, acc);
|
|
62
|
+
}, { commonPaths: [], rejectedIds: [] })(ids),
|
|
63
|
+
commonPaths = _R$reduce.commonPaths,
|
|
64
|
+
rejectedIds = _R$reduce.rejectedIds;
|
|
65
|
+
|
|
66
|
+
if (!R.isEmpty(rejectedIds)) {
|
|
67
|
+
return R.append(R.head(commonPaths), getCommonPaths(rejectedIds));
|
|
68
|
+
}
|
|
69
|
+
return [R.head(commonPaths)];
|
|
70
|
+
};
|
|
71
|
+
var commons = getCommonPaths(remainingIds);
|
|
72
|
+
return R.reduce(function (acc, id) {
|
|
73
|
+
return R.assoc(id, R.intersection(commons, R.prop(id, paths)), acc);
|
|
74
|
+
}, confirmedPaths, remainingIds);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var applyHierarchicalCodesToDim = exports.applyHierarchicalCodesToDim = function applyHierarchicalCodesToDim(hCodes, dim) {
|
|
34
78
|
var confirmedHierarchisedChilds = new _set2.default([]);
|
|
79
|
+
var unconfirmedPaths = {};
|
|
35
80
|
|
|
36
81
|
var indexedValues = R.reduce(function (acc, val) {
|
|
37
82
|
if (!val.isSelected) {
|
|
@@ -52,13 +97,18 @@ var applyHierarchicalCodesToDim = function applyHierarchicalCodesToDim(hCodes, d
|
|
|
52
97
|
if (!hasInDim) {
|
|
53
98
|
return R.concat(acc, children);
|
|
54
99
|
}
|
|
100
|
+
var path = R.join('.', parentsDef);
|
|
55
101
|
var val = (0, _extends3.default)({}, R.prop(codeID, indexedValues), {
|
|
102
|
+
path: path,
|
|
56
103
|
parents: parentsInDim,
|
|
57
104
|
parent: R.last(parentsInDim),
|
|
58
105
|
children: children
|
|
59
106
|
});
|
|
60
107
|
|
|
61
108
|
if (isUnconfirmed) {
|
|
109
|
+
unconfirmedPaths = R.over(R.lensProp(val.id), function (paths) {
|
|
110
|
+
return R.append(path, paths || []);
|
|
111
|
+
}, unconfirmedPaths);
|
|
62
112
|
val = R.assoc('unconfirmed', true, val);
|
|
63
113
|
return R.append(val, acc);
|
|
64
114
|
}
|
|
@@ -69,34 +119,33 @@ var applyHierarchicalCodesToDim = function applyHierarchicalCodesToDim(hCodes, d
|
|
|
69
119
|
|
|
70
120
|
var parsed = parseHCodes([], [])(hCodes);
|
|
71
121
|
|
|
122
|
+
var _unconfirmedPaths = R.pipe(R.reject(function (id) {
|
|
123
|
+
return confirmedHierarchisedChilds.has(id);
|
|
124
|
+
}), function (ids) {
|
|
125
|
+
return R.pick(ids, unconfirmedPaths);
|
|
126
|
+
})(R.keys(unconfirmedPaths));
|
|
127
|
+
|
|
128
|
+
var refinedUnconfirmedPaths = refineUnconfirmedPaths(_unconfirmedPaths);
|
|
129
|
+
|
|
72
130
|
var flattenDescendants = R.reduce(function (acc, val) {
|
|
73
131
|
var children = flattenDescendants(val.children || []);
|
|
74
132
|
return R.concat(acc, R.prepend(val, children));
|
|
75
133
|
}, []);
|
|
76
134
|
|
|
77
135
|
var isValid = function isValid(val) {
|
|
78
|
-
return !val.unconfirmed ||
|
|
136
|
+
return !val.unconfirmed || R.includes(val.path, R.propOr([], val.id, refinedUnconfirmedPaths));
|
|
79
137
|
};
|
|
80
138
|
|
|
81
139
|
var refineCodes = R.reduce(function (acc, hC) {
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
unconfirmed = _hC$unconfirmed === undefined ? false : _hC$unconfirmed,
|
|
85
|
-
val = (0, _objectWithoutProperties3.default)(hC, ['children', 'unconfirmed']);
|
|
86
|
-
|
|
87
|
-
if (isValid(hC)) {
|
|
88
|
-
var _children = refineCodes(children || []);
|
|
89
|
-
confirmedHierarchisedChilds.add(val.id);
|
|
90
|
-
return R.concat(acc, R.prepend(val, _children));
|
|
91
|
-
}
|
|
92
|
-
var flatDescendants = flattenDescendants(children);
|
|
140
|
+
var _flatDescendants = flattenDescendants(hC.children);
|
|
141
|
+
var flatDescendants = R.prepend(hC, _flatDescendants);
|
|
93
142
|
var validDescendant = R.find(isValid, flatDescendants);
|
|
94
143
|
if (!validDescendant) {
|
|
95
144
|
return acc;
|
|
96
145
|
}
|
|
97
|
-
var refined = R.pipe(R.
|
|
146
|
+
var refined = R.pipe(R.map(function (v) {
|
|
98
147
|
confirmedHierarchisedChilds.add(v.id);
|
|
99
|
-
return R.omit(['unconfirmed', 'children'], v);
|
|
148
|
+
return R.omit(['unconfirmed', 'children', 'path'], v);
|
|
100
149
|
}))(flatDescendants);
|
|
101
150
|
return R.concat(acc, refined);
|
|
102
151
|
}, []);
|
|
@@ -112,7 +161,6 @@ var applyHierarchicalCodesToDim = function applyHierarchicalCodesToDim(hCodes, d
|
|
|
112
161
|
}), R.sortBy(R.propOr(-1, '__indexPosition')))(indexedValues);
|
|
113
162
|
|
|
114
163
|
var hierarchicalIndexes = {};
|
|
115
|
-
|
|
116
164
|
return R.pipe(R.concat, R.addIndex(R.map)(function (v, ind) {
|
|
117
165
|
var parents = R.props(v.parents, hierarchicalIndexes);
|
|
118
166
|
var hierId = R.last(v.parents) ? R.last(v.parents) + '.' + v.id : v.id;
|
|
@@ -124,5 +172,4 @@ var applyHierarchicalCodesToDim = function applyHierarchicalCodesToDim(hCodes, d
|
|
|
124
172
|
}), function (values) {
|
|
125
173
|
return (0, _extends3.default)({}, dim, { values: values });
|
|
126
174
|
})(missingValues, refined);
|
|
127
|
-
};
|
|
128
|
-
exports.applyHierarchicalCodesToDim = applyHierarchicalCodesToDim;
|
|
175
|
+
};
|
|
@@ -26,29 +26,11 @@ var _oecdHEALTH_PROT = require('../../../rules/test/oecd-HEALTH_PROT.json');
|
|
|
26
26
|
|
|
27
27
|
var _oecdHEALTH_PROT2 = _interopRequireDefault(_oecdHEALTH_PROT);
|
|
28
28
|
|
|
29
|
-
var _dotstatsuiteVisions = require('@sis-cc/dotstatsuite-visions');
|
|
30
|
-
|
|
31
29
|
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; } }
|
|
32
30
|
|
|
33
31
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
<div style={{display: 'flex', flexWrap: 'wrap'}}>
|
|
37
|
-
{R.map(([key, value]) => (
|
|
38
|
-
<React.Fragment key={key}>
|
|
39
|
-
<div style={{width: value - 1, margin: 10}}>
|
|
40
|
-
<h5>{key}: {value}px</h5>
|
|
41
|
-
<Viewer {...rowData()} chartOptions={options} type="RowChart" />
|
|
42
|
-
</div>
|
|
43
|
-
<div style={{width: value - 1, margin: 10}}>
|
|
44
|
-
<h5>{key}: {value}px</h5>
|
|
45
|
-
<Viewer {...stackData()} chartOptions={options} type="StackedBarChart" />
|
|
46
|
-
</div>
|
|
47
|
-
</React.Fragment>
|
|
48
|
-
), R.toPairs(T4_BREAKPOINTS))}
|
|
49
|
-
</div>
|
|
50
|
-
);*/
|
|
51
|
-
|
|
33
|
+
//import stackData from '../../mocks/stack';
|
|
52
34
|
exports.default = function (_ref) {
|
|
53
35
|
var config = _ref.config,
|
|
54
36
|
style = _ref.style,
|
|
@@ -75,5 +57,4 @@ exports.default = function (_ref) {
|
|
|
75
57
|
},
|
|
76
58
|
type: type
|
|
77
59
|
});
|
|
78
|
-
};
|
|
79
|
-
//import stackData from '../../mocks/stack';
|
|
60
|
+
};
|
package/lib/viewer/src/app.js
CHANGED
|
@@ -12,10 +12,6 @@ var _react = require('react');
|
|
|
12
12
|
|
|
13
13
|
var _react2 = _interopRequireDefault(_react);
|
|
14
14
|
|
|
15
|
-
var _reactHelmet = require('react-helmet');
|
|
16
|
-
|
|
17
|
-
var _core = require('@blueprintjs/core');
|
|
18
|
-
|
|
19
15
|
var _styles = require('@mui/material/styles');
|
|
20
16
|
|
|
21
17
|
var _dotstatsuiteVisions = require('@sis-cc/dotstatsuite-visions');
|
|
@@ -62,9 +58,9 @@ var AppTab = function AppTab(_ref) {
|
|
|
62
58
|
var label = _ref.label,
|
|
63
59
|
iconName = _ref.iconName;
|
|
64
60
|
return _react2.default.createElement(
|
|
65
|
-
|
|
66
|
-
{ content: label, position:
|
|
67
|
-
_react2.default.createElement(
|
|
61
|
+
Tooltip,
|
|
62
|
+
{ content: label, position: Position.RIGHT },
|
|
63
|
+
_react2.default.createElement(Icon, { iconName: iconName })
|
|
68
64
|
);
|
|
69
65
|
};
|
|
70
66
|
|
|
@@ -149,25 +145,18 @@ exports.default = function () {
|
|
|
149
145
|
|
|
150
146
|
*/
|
|
151
147
|
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
_react2.default.createElement(_core.Tab2, {
|
|
167
|
-
id: 'uc1',
|
|
168
|
-
title: _react2.default.createElement(AppTab, { label: 'full screen resizable chart', iconName: 'fullscreen' }),
|
|
169
|
-
panel: _react2.default.createElement(_useCase2.default, { isRtl: isRtl, config: config, style: style, options: options })
|
|
170
|
-
})
|
|
171
|
-
)
|
|
172
|
-
);
|
|
148
|
+
return {/* <div style={{ padding: 10 }}>
|
|
149
|
+
<StyledEngineProvider injectFirst>
|
|
150
|
+
<ThemeProvider theme={theme}>
|
|
151
|
+
<button onClick={() => setRtl(!isRtl)}>{isRtl ? 'left to right' : 'right to left'}</button>
|
|
152
|
+
<Tabs2 renderActiveTabPanelOnly={false}>
|
|
153
|
+
<Tab2
|
|
154
|
+
id="uc1"
|
|
155
|
+
title={<AppTab label="full screen resizable chart" iconName="fullscreen" />}
|
|
156
|
+
panel={<UseCase1 isRtl={isRtl} config={config} style={style} options={options} />}
|
|
157
|
+
/>
|
|
158
|
+
</Tabs2>
|
|
159
|
+
</ThemeProvider>
|
|
160
|
+
</StyledEngineProvider>
|
|
161
|
+
</div> */};
|
|
173
162
|
};
|
package/package.json
CHANGED
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sis-cc/dotstatsuite-components",
|
|
3
3
|
"description": "Set components based on React.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "19.1.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"author": "OECD",
|
|
7
8
|
"license": "MIT",
|
|
8
9
|
"scripts": {
|
|
9
10
|
"build": "wce build",
|
|
10
11
|
"start": "wce start",
|
|
11
|
-
"test": "wce test"
|
|
12
|
-
"demo": "wce bundle --app --relative && mv dist public"
|
|
12
|
+
"test": "wce test"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@blueprintjs/core": "^1.22.0",
|
|
16
|
-
"@mui/material": "^5.16.5",
|
|
17
|
-
"@mui/styles": "^5.16.5",
|
|
18
|
-
"@sis-cc/dotstatsuite-sdmxjs": "*",
|
|
19
|
-
"@sis-cc/dotstatsuite-visions": "*",
|
|
20
|
-
"react": "^18",
|
|
21
|
-
"react-dom": "^18",
|
|
22
|
-
"react-addons-css-transition-group": "^15.6.2",
|
|
23
|
-
"react-helmet": "^5.2.1",
|
|
24
15
|
"web-component-env": "^2.0.0"
|
|
25
16
|
},
|
|
26
17
|
"dependencies": {
|
|
27
|
-
"@emotion/react": "^11.13.3",
|
|
28
|
-
"@emotion/styled": "^11.13.0",
|
|
29
|
-
"@mui/icons-material": "^5.16.5",
|
|
30
|
-
"@mui/material": "^5.16.5",
|
|
31
|
-
"@mui/styles": "^5.16.5",
|
|
32
18
|
"@react-hook/size": "^2.1.1",
|
|
33
|
-
"@sis-cc/dotstatsuite-d3-charts": "
|
|
19
|
+
"@sis-cc/dotstatsuite-d3-charts": "~8.3.0",
|
|
20
|
+
"@sis-cc/dotstatsuite-sdmxjs": "~10.1.0",
|
|
21
|
+
"@sis-cc/dotstatsuite-visions": "~12.2.0",
|
|
34
22
|
"date-fns": "^1.30.1",
|
|
35
23
|
"lodash": "^4.17.2",
|
|
36
24
|
"lodash.compose": "^2.4.1",
|
|
@@ -40,10 +28,11 @@
|
|
|
40
28
|
"ramda": "^0.26.1"
|
|
41
29
|
},
|
|
42
30
|
"peerDependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
31
|
+
"@emotion/react": "^11",
|
|
32
|
+
"@emotion/styled": "^11",
|
|
33
|
+
"@mui/icons-material": "^5",
|
|
34
|
+
"@mui/material": "^5",
|
|
35
|
+
"@mui/styles": "^5",
|
|
47
36
|
"react": "^18",
|
|
48
37
|
"react-dom": "^18"
|
|
49
38
|
}
|
package/src/app.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { StrictMode } from 'react';
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import ViewerApp from './viewer/src/app';
|
|
4
|
-
import { sisccTheme } from '@sis-cc/dotstatsuite-visions';
|
|
5
|
-
import { ThemeProvider, StyledEngineProvider } from '@mui/material/styles';
|
|
6
|
-
import { createTheme } from '@mui/material/styles';
|
|
7
3
|
|
|
8
|
-
const theme = createTheme(sisccTheme({ rtl: 'ltr' }));
|
|
9
4
|
const container = document.getElementById('root');
|
|
10
5
|
const root = createRoot(container);
|
|
11
6
|
|
|
12
7
|
const App = () => (
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</ThemeProvider>
|
|
17
|
-
</StyledEngineProvider>
|
|
8
|
+
<StrictMode>
|
|
9
|
+
I'm not groot, I'm component
|
|
10
|
+
</StrictMode>
|
|
18
11
|
);
|
|
19
12
|
|
|
20
13
|
root.render(<App />);
|
|
@@ -5,8 +5,53 @@ const addParentId = (id, ids) => {
|
|
|
5
5
|
return R.append(R.isNil(last) ? id : `${last}.${id}`, ids);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
const refineUnconfirmedPaths = (paths) => {
|
|
9
|
+
let confirmedPaths = R.filter(p => p.length === 1, paths);
|
|
10
|
+
if (!R.isEmpty(confirmedPaths)) {
|
|
11
|
+
confirmedPaths = R.reduce((acc, k) => {
|
|
12
|
+
if (R.has(k, acc)) {
|
|
13
|
+
return acc;
|
|
14
|
+
}
|
|
15
|
+
const ps = R.prop(k, paths);
|
|
16
|
+
const flatConfirmed = R.unnest(R.values(acc));
|
|
17
|
+
const filtered = R.filter(p => !!R.find(cP => R.includes(p, cP) || R.includes(cP, p), flatConfirmed), ps);
|
|
18
|
+
if (!R.isEmpty(filtered)) {
|
|
19
|
+
return R.assoc(k, [R.head(filtered)], acc);
|
|
20
|
+
}
|
|
21
|
+
return acc;
|
|
22
|
+
}, confirmedPaths, R.keys(paths));
|
|
23
|
+
}
|
|
24
|
+
const remainingIds = R.reject(id => R.has(id, confirmedPaths), R.keys(paths));
|
|
25
|
+
const getCommonPaths = ids => {
|
|
26
|
+
const { commonPaths, rejectedIds } = R.reduce(
|
|
27
|
+
(acc, id) => {
|
|
28
|
+
const ps = R.prop(id, paths);
|
|
29
|
+
if (R.isEmpty(acc.commonPaths)) {
|
|
30
|
+
return R.assoc('commonPaths', ps, acc);
|
|
31
|
+
}
|
|
32
|
+
const common = R.intersection(acc.commonPaths, ps);
|
|
33
|
+
return R.isEmpty(common)
|
|
34
|
+
? R.assoc('rejectedChildrenIds', id, acc)
|
|
35
|
+
: R.assoc('commonPaths', common, acc);
|
|
36
|
+
},
|
|
37
|
+
{ commonPaths: [], rejectedIds: [] }
|
|
38
|
+
)(ids);
|
|
39
|
+
if (!R.isEmpty(rejectedIds)) {
|
|
40
|
+
return R.append(R.head(commonPaths), getCommonPaths(rejectedIds));
|
|
41
|
+
}
|
|
42
|
+
return [R.head(commonPaths)];
|
|
43
|
+
};
|
|
44
|
+
const commons = getCommonPaths(remainingIds);
|
|
45
|
+
return R.reduce(
|
|
46
|
+
(acc, id) => R.assoc(id, R.intersection(commons, R.prop(id, paths)), acc),
|
|
47
|
+
confirmedPaths,
|
|
48
|
+
remainingIds
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
8
52
|
export const applyHierarchicalCodesToDim = (hCodes, dim) => {
|
|
9
|
-
|
|
53
|
+
const confirmedHierarchisedChilds = new Set([]);
|
|
54
|
+
let unconfirmedPaths = {};
|
|
10
55
|
|
|
11
56
|
const indexedValues = R.reduce((acc, val) => {
|
|
12
57
|
if (!val.isSelected) {
|
|
@@ -26,14 +71,17 @@ export const applyHierarchicalCodesToDim = (hCodes, dim) => {
|
|
|
26
71
|
if (!hasInDim) {
|
|
27
72
|
return R.concat(acc, children);
|
|
28
73
|
}
|
|
74
|
+
const path = R.join('.', parentsDef);
|
|
29
75
|
let val = {
|
|
30
76
|
...R.prop(codeID, indexedValues),
|
|
77
|
+
path,
|
|
31
78
|
parents: parentsInDim,
|
|
32
79
|
parent: R.last(parentsInDim),
|
|
33
80
|
children
|
|
34
81
|
};
|
|
35
82
|
|
|
36
83
|
if (isUnconfirmed) {
|
|
84
|
+
unconfirmedPaths = R.over(R.lensProp(val.id), paths => R.append(path, paths || []), unconfirmedPaths);
|
|
37
85
|
val = R.assoc('unconfirmed', true, val);
|
|
38
86
|
return R.append(val, acc);
|
|
39
87
|
}
|
|
@@ -43,30 +91,31 @@ export const applyHierarchicalCodesToDim = (hCodes, dim) => {
|
|
|
43
91
|
|
|
44
92
|
const parsed = parseHCodes([], [])(hCodes);
|
|
45
93
|
|
|
94
|
+
const _unconfirmedPaths = R.pipe(
|
|
95
|
+
R.reject(id => confirmedHierarchisedChilds.has(id)),
|
|
96
|
+
ids => R.pick(ids, unconfirmedPaths)
|
|
97
|
+
)(R.keys(unconfirmedPaths));
|
|
98
|
+
|
|
99
|
+
const refinedUnconfirmedPaths = refineUnconfirmedPaths(_unconfirmedPaths);
|
|
100
|
+
|
|
46
101
|
const flattenDescendants = R.reduce((acc, val ) => {
|
|
47
102
|
const children = flattenDescendants(val.children || []);
|
|
48
103
|
return R.concat(acc, R.prepend(val, children));
|
|
49
104
|
}, []);
|
|
50
105
|
|
|
51
|
-
const isValid = val => !val.unconfirmed ||
|
|
106
|
+
const isValid = val => !val.unconfirmed || R.includes(val.path, R.propOr([], val.id, refinedUnconfirmedPaths));
|
|
52
107
|
|
|
53
108
|
const refineCodes = R.reduce((acc, hC) => {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
const _children = refineCodes(children || []);
|
|
57
|
-
confirmedHierarchisedChilds.add(val.id);
|
|
58
|
-
return R.concat(acc, R.prepend(val, _children));
|
|
59
|
-
}
|
|
60
|
-
const flatDescendants = flattenDescendants(children);
|
|
109
|
+
const _flatDescendants = flattenDescendants(hC.children);
|
|
110
|
+
const flatDescendants = R.prepend(hC, _flatDescendants);
|
|
61
111
|
const validDescendant = R.find(isValid, flatDescendants);
|
|
62
112
|
if (!validDescendant) {
|
|
63
113
|
return acc;
|
|
64
114
|
}
|
|
65
115
|
const refined = R.pipe(
|
|
66
|
-
R.prepend(hC),
|
|
67
116
|
R.map(v => {
|
|
68
117
|
confirmedHierarchisedChilds.add(v.id);
|
|
69
|
-
return R.omit(['unconfirmed', 'children'], v);
|
|
118
|
+
return R.omit(['unconfirmed', 'children', 'path'], v);
|
|
70
119
|
})
|
|
71
120
|
)(flatDescendants);
|
|
72
121
|
return R.concat(acc, refined);
|
|
@@ -83,7 +132,6 @@ export const applyHierarchicalCodesToDim = (hCodes, dim) => {
|
|
|
83
132
|
)(indexedValues);
|
|
84
133
|
|
|
85
134
|
let hierarchicalIndexes = {};
|
|
86
|
-
|
|
87
135
|
return R.pipe(
|
|
88
136
|
R.concat,
|
|
89
137
|
R.addIndex(R.map)((v, ind) => {
|
|
@@ -5,24 +5,6 @@ import rowData from '../../mocks/row';
|
|
|
5
5
|
//import stackData from '../../mocks/stack';
|
|
6
6
|
import { series } from '../../../rules/src';
|
|
7
7
|
import data from '../../../rules/test/oecd-HEALTH_PROT.json';
|
|
8
|
-
import { T4_BREAKPOINTS } from '@sis-cc/dotstatsuite-visions';
|
|
9
|
-
|
|
10
|
-
/*return (
|
|
11
|
-
<div style={{display: 'flex', flexWrap: 'wrap'}}>
|
|
12
|
-
{R.map(([key, value]) => (
|
|
13
|
-
<React.Fragment key={key}>
|
|
14
|
-
<div style={{width: value - 1, margin: 10}}>
|
|
15
|
-
<h5>{key}: {value}px</h5>
|
|
16
|
-
<Viewer {...rowData()} chartOptions={options} type="RowChart" />
|
|
17
|
-
</div>
|
|
18
|
-
<div style={{width: value - 1, margin: 10}}>
|
|
19
|
-
<h5>{key}: {value}px</h5>
|
|
20
|
-
<Viewer {...stackData()} chartOptions={options} type="StackedBarChart" />
|
|
21
|
-
</div>
|
|
22
|
-
</React.Fragment>
|
|
23
|
-
), R.toPairs(T4_BREAKPOINTS))}
|
|
24
|
-
</div>
|
|
25
|
-
);*/
|
|
26
8
|
|
|
27
9
|
export default ({ config, style, options }) => {
|
|
28
10
|
const type = 'StackedRowChart';
|
package/src/viewer/src/app.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { Helmet } from 'react-helmet';
|
|
3
|
-
import { Tab2, Tabs2, Intent, Icon, Tooltip, Position } from '@blueprintjs/core';
|
|
4
2
|
import { ThemeProvider, StyledEngineProvider } from '@mui/material/styles';
|
|
5
3
|
import { createTheme } from '@mui/material/styles';
|
|
6
4
|
import { sisccTheme } from '@sis-cc/dotstatsuite-visions';
|
|
@@ -100,10 +98,9 @@ export default () => {
|
|
|
100
98
|
*/
|
|
101
99
|
|
|
102
100
|
return (
|
|
103
|
-
<div style={{ padding: 10 }}>
|
|
104
|
-
|
|
105
|
-
<ThemeProvider theme={theme}>
|
|
106
|
-
<Helmet htmlAttributes={{ dir: isRtl ? 'rtl' : 'ltr' }} />
|
|
101
|
+
{/* <div style={{ padding: 10 }}>
|
|
102
|
+
<StyledEngineProvider injectFirst>
|
|
103
|
+
<ThemeProvider theme={theme}>
|
|
107
104
|
<button onClick={() => setRtl(!isRtl)}>{isRtl ? 'left to right' : 'right to left'}</button>
|
|
108
105
|
<Tabs2 renderActiveTabPanelOnly={false}>
|
|
109
106
|
<Tab2
|
|
@@ -112,8 +109,8 @@ export default () => {
|
|
|
112
109
|
panel={<UseCase1 isRtl={isRtl} config={config} style={style} options={options} />}
|
|
113
110
|
/>
|
|
114
111
|
</Tabs2>
|
|
115
|
-
|
|
116
|
-
</StyledEngineProvider>
|
|
117
|
-
</div>
|
|
112
|
+
</ThemeProvider>
|
|
113
|
+
</StyledEngineProvider>
|
|
114
|
+
</div> */}
|
|
118
115
|
);
|
|
119
116
|
};
|
|
@@ -144,4 +144,17 @@ describe('refineHierarchicalCodelist tests', () => {
|
|
|
144
144
|
};
|
|
145
145
|
expect(applyHierarchicalCodesToDim(hCodes, partialDim)).to.deep.equal(expected);
|
|
146
146
|
});
|
|
147
|
+
it('partial test 6', () => {
|
|
148
|
+
const partialDim = deselectedDim([0, 1, 3, 4, 6]);
|
|
149
|
+
|
|
150
|
+
const expected = {
|
|
151
|
+
id: 'DIM',
|
|
152
|
+
values: [
|
|
153
|
+
{ id: 'ITEM', parents: [], parent: undefined, isSelected: true, __indexPosition: 0 },
|
|
154
|
+
{ id: 'CHILD_A', parents: [0], parent: 'ITEM', isSelected: true, __indexPosition: 1 },
|
|
155
|
+
{ id: 'CHILD_C', parents: [0], parent: 'ITEM', isSelected: true, __indexPosition: 2 },
|
|
156
|
+
]
|
|
157
|
+
};
|
|
158
|
+
expect(applyHierarchicalCodesToDim(hCodes, partialDim)).to.deep.equal(expected);
|
|
159
|
+
});
|
|
147
160
|
});
|