@sis-cc/dotstatsuite-components 12.1.2 → 12.2.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/getMSDInformations.js +40 -0
- package/lib/rules2/src/getSidebarData.js +3 -2
- package/lib/rules2/src/index.js +9 -0
- package/lib/rules2/src/parseMetadataSeries.js +3 -2
- package/lib/viewer/src/footer.js +4 -3
- package/lib/viewer/src/index.js +1 -1
- package/package.json +2 -2
- package/src/rules2/src/getMSDInformations.js +20 -0
- package/src/rules2/src/getSidebarData.js +3 -2
- package/src/rules2/src/index.js +1 -0
- package/src/rules2/src/parseMetadataSeries.js +3 -2
- package/src/viewer/src/footer.js +2 -1
- package/src/viewer/src/index.js +1 -1
- package/test/getMSDInformations.test.js +35 -0
- package/test/metadata-parsing-perf.test.js +400 -400
- package/test/mocks/MSD_TEST.json +484 -0
- package/test/parseMetadataSeries.test.js +13 -6
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getMSDInformations = undefined;
|
|
7
|
+
|
|
8
|
+
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
|
9
|
+
|
|
10
|
+
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
|
11
|
+
|
|
12
|
+
var _extends3 = require('babel-runtime/helpers/extends');
|
|
13
|
+
|
|
14
|
+
var _extends4 = _interopRequireDefault(_extends3);
|
|
15
|
+
|
|
16
|
+
var _ramda = require('ramda');
|
|
17
|
+
|
|
18
|
+
var R = _interopRequireWildcard(_ramda);
|
|
19
|
+
|
|
20
|
+
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; } }
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
var getMSDInformations = exports.getMSDInformations = function getMSDInformations(msdJson) {
|
|
25
|
+
var attributesDefinitions = R.pathOr([], ['data', 'metadataStructures', 0, 'metadataStructureComponents', 'reportStructures', 0, 'metadataAttributes'], msdJson);
|
|
26
|
+
|
|
27
|
+
var parseAttributes = function parseAttributes(parent) {
|
|
28
|
+
return R.reduce(function (acc, attribute) {
|
|
29
|
+
var id = attribute.id;
|
|
30
|
+
var format = R.path(['localRepresentation', 'textFormat', 'textType'], attribute);
|
|
31
|
+
if (R.has('metadataAttributes', attribute)) {
|
|
32
|
+
var collection = parseAttributes(attribute.id)(attribute.metadataAttributes);
|
|
33
|
+
return (0, _extends4.default)({}, acc, collection, (0, _defineProperty3.default)({}, id, { format: format, parent: parent }));
|
|
34
|
+
}
|
|
35
|
+
return R.assoc(id, { format: format, parent: parent }, acc);
|
|
36
|
+
}, {});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return { attributes: parseAttributes('#ROOT')(attributesDefinitions) };
|
|
40
|
+
};
|
|
@@ -13,13 +13,14 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
13
13
|
|
|
14
14
|
var dimensionValueDisplay = function dimensionValueDisplay(display) {
|
|
15
15
|
return function (data) {
|
|
16
|
+
var name = R.isNil(data.name) ? '[' + data.id + ']' : data.name;
|
|
16
17
|
if (display === 'code') {
|
|
17
18
|
return R.prop('id', data);
|
|
18
19
|
}
|
|
19
20
|
if (display === 'both') {
|
|
20
|
-
return R.prop('id', data) + ': ' +
|
|
21
|
+
return R.prop('id', data) + ': ' + name;
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
+
return name;
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
26
|
|
package/lib/rules2/src/index.js
CHANGED
|
@@ -44,4 +44,13 @@ Object.defineProperty(exports, 'sdmx_3_0_DataFormatPatch', {
|
|
|
44
44
|
get: function get() {
|
|
45
45
|
return _sdmx.sdmx_3_0_DataFormatPatch;
|
|
46
46
|
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
var _getMSDInformations = require('./getMSDInformations');
|
|
50
|
+
|
|
51
|
+
Object.defineProperty(exports, 'getMSDInformations', {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function get() {
|
|
54
|
+
return _getMSDInformations.getMSDInformations;
|
|
55
|
+
}
|
|
47
56
|
});
|
|
@@ -24,7 +24,7 @@ var dimensionValueDisplay = function dimensionValueDisplay(locale, display) {
|
|
|
24
24
|
return (0, _dotstatsuiteSdmxjs.getLocalisedName)(locale)(data);
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
// options = { locale, display, dimensions = [] };
|
|
27
|
+
// options = { locale, display, dimensions = [], attributes = { [id]: { format, parent } } };
|
|
28
28
|
var parseMetadataSeries = exports.parseMetadataSeries = function parseMetadataSeries(metadataJson, options) {
|
|
29
29
|
var metadataAttributes = R.pathOr([], ['data', 'structures', 0, 'attributes', 'dimensionGroup'], metadataJson);
|
|
30
30
|
var metaAttrLength = R.length(metadataAttributes);
|
|
@@ -71,7 +71,8 @@ var parseMetadataSeries = exports.parseMetadataSeries = function parseMetadataSe
|
|
|
71
71
|
return R.append({
|
|
72
72
|
id: attribute.id,
|
|
73
73
|
label: label,
|
|
74
|
-
value: R.is(Object, value) ? R.prop(options.locale, value) : value
|
|
74
|
+
value: R.is(Object, value) ? R.prop(options.locale, value) : value,
|
|
75
|
+
handlerProps: R.pathOr({}, ['attributes', attribute.id], options)
|
|
75
76
|
}, acc);
|
|
76
77
|
}, [], metaIndexes);
|
|
77
78
|
|
package/lib/viewer/src/footer.js
CHANGED
|
@@ -35,12 +35,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
35
35
|
var Footer = function Footer(_ref) {
|
|
36
36
|
var type = _ref.type,
|
|
37
37
|
chartData = _ref.chartData,
|
|
38
|
-
options = _ref.options,
|
|
39
38
|
source = _ref.source,
|
|
40
39
|
logo = _ref.logo,
|
|
41
40
|
copyright = _ref.copyright,
|
|
42
41
|
onSize = _ref.onSize,
|
|
43
|
-
chartOptions = _ref.chartOptions
|
|
42
|
+
chartOptions = _ref.chartOptions,
|
|
43
|
+
isSticky = _ref.isSticky;
|
|
44
44
|
|
|
45
45
|
var target = _react2.default.useRef(null);
|
|
46
46
|
|
|
@@ -63,7 +63,8 @@ var Footer = function Footer(_ref) {
|
|
|
63
63
|
source: source,
|
|
64
64
|
logo: logo,
|
|
65
65
|
copyright: copyright,
|
|
66
|
-
legend: legend
|
|
66
|
+
legend: legend,
|
|
67
|
+
isSticky: isSticky
|
|
67
68
|
})
|
|
68
69
|
);
|
|
69
70
|
};
|
package/lib/viewer/src/index.js
CHANGED
|
@@ -58,7 +58,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
58
58
|
|
|
59
59
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
60
60
|
|
|
61
|
-
var useStyles = (0, _styles.makeStyles)(function (
|
|
61
|
+
var useStyles = (0, _styles.makeStyles)(function () {
|
|
62
62
|
return {
|
|
63
63
|
container: {
|
|
64
64
|
borderColor: '#007bc7',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sis-cc/dotstatsuite-components",
|
|
3
3
|
"description": "Set components based on React.",
|
|
4
|
-
"version": "12.
|
|
4
|
+
"version": "12.2.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "OECD",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@react-hook/size": "^2.1.1",
|
|
25
|
-
"@sis-cc/dotstatsuite-d3-charts": "^8.0.
|
|
25
|
+
"@sis-cc/dotstatsuite-d3-charts": "^8.0.1",
|
|
26
26
|
"date-fns": "^1.30.1",
|
|
27
27
|
"lodash": "^4.17.2",
|
|
28
28
|
"lodash.compose": "^2.4.1",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const getMSDInformations = (msdJson) => {
|
|
4
|
+
const attributesDefinitions = R.pathOr([], ['data', 'metadataStructures', 0, 'metadataStructureComponents', 'reportStructures', 0, 'metadataAttributes'], msdJson);
|
|
5
|
+
|
|
6
|
+
const parseAttributes = (parent) => R.reduce(
|
|
7
|
+
(acc, attribute) => {
|
|
8
|
+
const id = attribute.id;
|
|
9
|
+
const format = R.path(['localRepresentation', 'textFormat', 'textType'], attribute);
|
|
10
|
+
if (R.has('metadataAttributes', attribute)) {
|
|
11
|
+
const collection = parseAttributes(attribute.id)(attribute.metadataAttributes);
|
|
12
|
+
return ({ ...acc, ...collection, [id]: { format, parent } });
|
|
13
|
+
}
|
|
14
|
+
return R.assoc(id, { format, parent }, acc);
|
|
15
|
+
},
|
|
16
|
+
{}
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
return ({ attributes: parseAttributes('#ROOT')(attributesDefinitions) });
|
|
20
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
3
|
const dimensionValueDisplay = (display) => data => {
|
|
4
|
+
const name = R.isNil(data.name) ? `[${data.id}]` : data.name;
|
|
4
5
|
if (display === 'code') {
|
|
5
6
|
return R.prop('id', data);
|
|
6
7
|
}
|
|
7
8
|
if (display === 'both') {
|
|
8
|
-
return `${R.prop('id', data)}: ${
|
|
9
|
+
return `${R.prop('id', data)}: ${name}`;
|
|
9
10
|
}
|
|
10
|
-
return
|
|
11
|
+
return name;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
const sortByCoordinates = (a, b) => {
|
package/src/rules2/src/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const dimensionValueDisplay = (locale, display) => data => {
|
|
|
10
10
|
}
|
|
11
11
|
return getLocalisedName(locale)(data);
|
|
12
12
|
};
|
|
13
|
-
// options = { locale, display, dimensions = [] };
|
|
13
|
+
// options = { locale, display, dimensions = [], attributes = { [id]: { format, parent } } };
|
|
14
14
|
export const parseMetadataSeries = (metadataJson, options) => {
|
|
15
15
|
const metadataAttributes = R.pathOr([], ['data', 'structures', 0, 'attributes', 'dimensionGroup'], metadataJson);
|
|
16
16
|
const metaAttrLength = R.length(metadataAttributes);
|
|
@@ -63,7 +63,8 @@ export const parseMetadataSeries = (metadataJson, options) => {
|
|
|
63
63
|
return R.append({
|
|
64
64
|
id: attribute.id,
|
|
65
65
|
label,
|
|
66
|
-
value: R.is(Object, value) ? R.prop(options.locale, value) : value
|
|
66
|
+
value: R.is(Object, value) ? R.prop(options.locale, value) : value,
|
|
67
|
+
handlerProps: R.pathOr({}, ['attributes', attribute.id], options)
|
|
67
68
|
}, acc);
|
|
68
69
|
},
|
|
69
70
|
[],
|
package/src/viewer/src/footer.js
CHANGED
|
@@ -5,7 +5,7 @@ import { DataFooter } from '@sis-cc/dotstatsuite-visions';
|
|
|
5
5
|
import ChartLegends from './legends/ChartLegends';
|
|
6
6
|
import { isChartNoData } from './utils';
|
|
7
7
|
|
|
8
|
-
const Footer = ({ type, chartData,
|
|
8
|
+
const Footer = ({ type, chartData, source, logo, copyright, onSize, chartOptions, isSticky }) => {
|
|
9
9
|
const target = React.useRef(null);
|
|
10
10
|
const [width, height] = useSize(target);
|
|
11
11
|
|
|
@@ -23,6 +23,7 @@ const Footer = ({ type, chartData, options, source, logo, copyright, onSize, cha
|
|
|
23
23
|
logo={logo}
|
|
24
24
|
copyright={copyright}
|
|
25
25
|
legend={legend}
|
|
26
|
+
isSticky={isSticky}
|
|
26
27
|
/>
|
|
27
28
|
</div>
|
|
28
29
|
);
|
package/src/viewer/src/index.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getMSDInformations } from '../src/rules2/src/getMSDInformations';
|
|
3
|
+
import msd from './mocks/MSD_TEST.json';
|
|
4
|
+
|
|
5
|
+
describe('getMSDInformations tests', () => {
|
|
6
|
+
it('complete test', () => {
|
|
7
|
+
const expected = {
|
|
8
|
+
attributes: {
|
|
9
|
+
STRING_TYPE: { format: 'String', parent: '#ROOT' },
|
|
10
|
+
STRING_MULTILANG_TYPE: { format: 'String', parent: '#ROOT' },
|
|
11
|
+
ALPHANUMERIC_TYPE: { format: 'AlphaNumeric', parent: '#ROOT' },
|
|
12
|
+
ALPHANUMERIC_MULTILANG_TYPE: { format: 'AlphaNumeric', parent: '#ROOT' },
|
|
13
|
+
BOOLEAN_TYPE: { format: 'Boolean', parent: '#ROOT' },
|
|
14
|
+
XHTML_TYPE: { format: 'XHTML', parent: '#ROOT' },
|
|
15
|
+
XHTML_MULTILANG_TYPE: { format: 'XHTML', parent: '#ROOT' },
|
|
16
|
+
INTEGER_TYPE: { format: 'Integer', parent: '#ROOT' },
|
|
17
|
+
INTEGER_MULTILANG_TYPE: { format: 'Integer', parent: '#ROOT' },
|
|
18
|
+
DECIMAL_TYPE: { format: 'Decimal', parent: '#ROOT' },
|
|
19
|
+
DECIMAL_MULTILANG_TYPE: { format: 'Decimal', parent: '#ROOT' },
|
|
20
|
+
DATETIME_TYPE: { format: 'DateTime', parent: '#ROOT' },
|
|
21
|
+
TIME_TYPE: { format: 'Time', parent: '#ROOT' },
|
|
22
|
+
GREGORIANDAY_TYPE: { format: 'GregorianDay', parent: '#ROOT' },
|
|
23
|
+
GREGORIAN_YEAR_TYPE: { format: 'GregorianYear', parent: '#ROOT' },
|
|
24
|
+
GREGORIAN_YEARMONTH_TYPE: { format: 'GregorianYearMonth', parent: '#ROOT' },
|
|
25
|
+
CONTACT: { format: 'String', parent: '#ROOT' },
|
|
26
|
+
CONTACT_NAME: { format: 'String', parent: 'CONTACT' },
|
|
27
|
+
CONTACT_EMAIL: { format: 'String', parent: 'CONTACT' },
|
|
28
|
+
CONTACT_PHONE: { format: 'Numeric', parent: 'CONTACT' },
|
|
29
|
+
CONTACT_ORGANISATION: { format: 'String', parent: 'CONTACT' }
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
expect(getMSDInformations(msd)).to.deep.equal(expected);
|
|
34
|
+
});
|
|
35
|
+
});
|