@sis-cc/dotstatsuite-components 9.3.5 → 12.0.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/index.js +8 -3
- package/lib/rules/src/table/factories/getCells.js +22 -4
- package/lib/rules/src/table/factories/getLayoutWithFlags.js +32 -5
- package/lib/rules/src/table/factories/getTableData.js +9 -2
- package/lib/rules/src/table/preparators/prepareData.js +37 -2
- package/lib/rules/src/v8-transformer.js +5 -9
- package/lib/rules2/src/constants.js +7 -0
- package/lib/rules2/src/getAdvAttrSeriesAtCoordinates.js +39 -0
- package/lib/rules2/src/getAdvancedAttributes.js +126 -0
- package/lib/rules2/src/getMetadataCoordinates.js +38 -0
- package/lib/rules2/src/getMetadataStructureFromData.js +23 -0
- package/lib/rules2/src/getSidebarData.js +76 -0
- package/lib/rules2/src/hasCellMetadata.js +19 -0
- package/lib/rules2/src/hasLayoutEntryMetadata.js +18 -0
- package/lib/rules2/src/index.js +47 -0
- package/lib/rules2/src/parseMetadataSeries.js +83 -0
- package/lib/rules2/src/refineMetadataCoordinates.js +34 -0
- package/lib/rules2/src/sdmx3.0DataFormatPatch.js +20 -0
- package/lib/viewer/src/chart.js +48 -41
- package/lib/viewer/src/index.js +76 -56
- package/package.json +9 -10
- package/src/index.js +2 -0
- package/src/rules/src/table/factories/getCells.js +13 -4
- package/src/rules/src/table/factories/getLayoutWithFlags.js +36 -10
- package/src/rules/src/table/factories/getTableData.js +12 -3
- package/src/rules/src/table/preparators/prepareData.js +45 -4
- package/src/rules/src/v8-transformer.js +3 -8
- package/src/rules2/src/constants.js +2 -0
- package/src/rules2/src/getAdvAttrSeriesAtCoordinates.js +29 -0
- package/src/rules2/src/getAdvancedAttributes.js +113 -0
- package/src/rules2/src/getMetadataCoordinates.js +37 -0
- package/src/rules2/src/getMetadataStructureFromData.js +17 -0
- package/src/rules2/src/getSidebarData.js +73 -0
- package/src/rules2/src/hasCellMetadata.js +11 -0
- package/src/rules2/src/hasLayoutEntryMetadata.js +9 -0
- package/src/rules2/src/index.js +8 -0
- package/src/rules2/src/parseMetadataSeries.js +80 -0
- package/src/rules2/src/refineMetadataCoordinates.js +27 -0
- package/src/rules2/src/sdmx3.0DataFormatPatch.js +9 -0
- package/src/viewer/src/chart.js +15 -14
- package/src/viewer/src/index.js +35 -26
- package/test/advanced-attributes-parsing-perf.test.js +16 -0
- package/test/getCells.test.js +7 -5
- package/test/getDataflowAdvancedAttributes.test.js +32 -0
- package/test/getLayoutDataWithFlags.test.js +22 -12
- package/test/getMetadataCoordinates.test.js +0 -0
- package/test/getSeriesAdvancedAttributes.test.js +30 -0
- package/test/getSidebarData.test.js +116 -0
- package/test/getSubtitleFlags.test.js +1 -1
- package/test/getTableData.test.js +2 -1
- package/test/metadata-parsing-perf.test.js +487 -0
- package/test/mocks/OECD_SNA_TABLE1_1.0_-_AUS_V_metadata.json +152 -0
- package/test/mocks/large_metadata_series.json +701 -0
- package/test/mocks/observations-advanced-attributes.json +55382 -0
- package/test/parseMetadataSeries.test.js +55 -0
- package/test/prepareData.test.js +2 -0
package/src/viewer/src/chart.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { branch, compose, renderComponent, withProps } from 'recompose';
|
|
3
3
|
import * as R from 'ramda';
|
|
4
|
-
import
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
5
6
|
import { NoData } from '@sis-cc/dotstatsuite-visions';
|
|
6
7
|
import * as charts from '../../bridge-d3-react/src';
|
|
7
8
|
import { SCATTER } from '../../rules/src/constants';
|
|
@@ -9,15 +10,14 @@ import filterSeriesRegardingDimensions from './chartUtils/series';
|
|
|
9
10
|
import AxisLegend from './legends/AxisLegend';
|
|
10
11
|
import { isChartNoData } from './utils';
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return ({
|
|
13
|
+
const useStyles = makeStyles(() => ({
|
|
14
|
+
container: {
|
|
15
|
+
backgroundColor: 'none',
|
|
16
|
+
overflow: 'hidden',
|
|
17
|
+
position: 'relative',
|
|
18
|
+
direction: 'ltr !important',
|
|
19
|
+
},
|
|
20
|
+
chartContainer: {
|
|
21
21
|
'& .rcw-chart__chart__line--x:last-of-type': {
|
|
22
22
|
visibility: 'hidden',
|
|
23
23
|
},
|
|
@@ -34,13 +34,14 @@ const Container = glamorous.div({
|
|
|
34
34
|
visibility: 'hidden',
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
}
|
|
38
|
-
});
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
39
|
|
|
40
40
|
const Chart = ({ options, series, type, width, getAxisOptions }) => {
|
|
41
|
+
const classes = useStyles();
|
|
41
42
|
const ChartClass = charts[type];
|
|
42
43
|
return (
|
|
43
|
-
<
|
|
44
|
+
<div className={cx({ [classes.chartContainer]: !R.equals(SCATTER, type) })}>
|
|
44
45
|
<ChartClass
|
|
45
46
|
data={series}
|
|
46
47
|
options={options}
|
|
@@ -51,7 +52,7 @@ const Chart = ({ options, series, type, width, getAxisOptions }) => {
|
|
|
51
52
|
? null
|
|
52
53
|
: <AxisLegend axis="y" data={{ series }} type={type} />
|
|
53
54
|
}
|
|
54
|
-
</
|
|
55
|
+
</div>
|
|
55
56
|
);
|
|
56
57
|
};
|
|
57
58
|
|
package/src/viewer/src/index.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import * as R from 'ramda';
|
|
3
|
+
import cx from 'classnames';
|
|
3
4
|
import { compose, withState, withProps } from 'recompose';
|
|
4
5
|
import sizeMe from 'react-sizeme';
|
|
5
6
|
import { Loading, NoData, TableHtml5 } from '@sis-cc/dotstatsuite-visions';
|
|
6
|
-
import
|
|
7
|
-
import { useTheme } from '@material-ui/core/styles';
|
|
7
|
+
import { useTheme, makeStyles } from '@material-ui/core/styles';
|
|
8
8
|
import getChartOptions from './chartUtils/options';
|
|
9
9
|
import Header from './header';
|
|
10
10
|
import Chart from './chart';
|
|
11
11
|
import Footer from './footer';
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
13
|
+
const useStyles = makeStyles(theme => ({
|
|
14
|
+
container: {
|
|
15
|
+
borderColor: '#007bc7',
|
|
16
|
+
borderBottomWidth: 1,
|
|
17
|
+
borderLeftWidth: 0,
|
|
18
|
+
borderTopWidth: 1,
|
|
19
|
+
borderRightWidth: 0,
|
|
20
|
+
borderStyle: 'solid',
|
|
21
|
+
'& svg text::selection': {
|
|
22
|
+
background: 'none'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
tableContainer: {
|
|
26
|
+
minWidth: '100%',
|
|
27
|
+
minHeight: '100%'
|
|
28
|
+
},
|
|
29
|
+
chartContainer: {
|
|
30
|
+
width: ({ fixedWidth }) => fixedWidth || '100%',
|
|
31
|
+
height: ({ fixedHeight }) => fixedHeight || '100%',
|
|
32
|
+
overflow: 'hidden'
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
35
|
|
|
36
36
|
const ViewContent = ({ loading, noData = 'No Data', type, width, errorMessage, ...rest }) => {
|
|
37
37
|
if (loading) return <Loading message={loading} />;
|
|
@@ -60,6 +60,10 @@ const ViewContent = ({ loading, noData = 'No Data', type, width, errorMessage, .
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
const Viewer = ({ getResponsiveSize, setFooterOffset, setHeaderOffset, size, type, ...rest }) => {
|
|
63
|
+
const classes = useStyles({
|
|
64
|
+
fixedWidth: rest.fixedWidth,
|
|
65
|
+
fixedHeight: rest.fixedHeight
|
|
66
|
+
});
|
|
63
67
|
useEffect(() => {
|
|
64
68
|
if (R.is(Function, getResponsiveSize)) {
|
|
65
69
|
getResponsiveSize({
|
|
@@ -70,7 +74,12 @@ const Viewer = ({ getResponsiveSize, setFooterOffset, setHeaderOffset, size, typ
|
|
|
70
74
|
});
|
|
71
75
|
|
|
72
76
|
return (
|
|
73
|
-
<
|
|
77
|
+
<div
|
|
78
|
+
className={cx(classes.container, {
|
|
79
|
+
[classes.tableContainer]: type === 'table',
|
|
80
|
+
[classes.chartContainer]: type !== 'table'
|
|
81
|
+
})}
|
|
82
|
+
>
|
|
74
83
|
<Header
|
|
75
84
|
onSize={size => setHeaderOffset(size.height)}
|
|
76
85
|
{...R.propOr({}, 'headerProps', rest)}
|
|
@@ -83,7 +92,7 @@ const Viewer = ({ getResponsiveSize, setFooterOffset, setHeaderOffset, size, typ
|
|
|
83
92
|
chartOptions={R.prop('chartOptions', rest)}
|
|
84
93
|
{...R.prop('footerProps', rest)}
|
|
85
94
|
/>
|
|
86
|
-
</
|
|
95
|
+
</div>
|
|
87
96
|
);
|
|
88
97
|
};
|
|
89
98
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import {
|
|
3
|
+
getDataflowAdvancedAttributes,
|
|
4
|
+
getObservationsAdvancedAttributes,
|
|
5
|
+
getSeriesAdvancedAttributes
|
|
6
|
+
} from '../src/rules2/src/getAdvancedAttributes';
|
|
7
|
+
|
|
8
|
+
import obsMock from './mocks/table-prep-units--observations.json';
|
|
9
|
+
import obsAdvancedAttributes from './mocks/observations-advanced-attributes.json';
|
|
10
|
+
|
|
11
|
+
describe('advanced attributes parsing performance tests', () => {
|
|
12
|
+
it('1800 observations test', function() {
|
|
13
|
+
this.timeout(1500);
|
|
14
|
+
expect(getObservationsAdvancedAttributes(obsMock, ['CURRENCY', 'OBS_STATUS'])).to.deep.equal(obsAdvancedAttributes);
|
|
15
|
+
});
|
|
16
|
+
});
|
package/test/getCells.test.js
CHANGED
|
@@ -24,7 +24,7 @@ describe('getCells tests', () => {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}, 'label', customAttributes,
|
|
27
|
-
{ unitsDefinitionCodes: [], unitsSeries: {}, unitsDisplay: 'cells', unitDimension: {} })).to.deep.equal({
|
|
27
|
+
{ unitsDefinitionCodes: [], unitsSeries: {}, unitsDisplay: 'cells', unitDimension: {} }, [])).to.deep.equal({
|
|
28
28
|
a: {
|
|
29
29
|
value: '33',
|
|
30
30
|
intValue: 33,
|
|
@@ -33,7 +33,8 @@ describe('getCells tests', () => {
|
|
|
33
33
|
{ label: 'Footnote 1: Footnote 1 Value 1' },
|
|
34
34
|
{ label: 'Footnote 3: Footnote 3 Value 3' }
|
|
35
35
|
],
|
|
36
|
-
indexedDimValIds: {}
|
|
36
|
+
indexedDimValIds: {},
|
|
37
|
+
sideProps: null
|
|
37
38
|
}
|
|
38
39
|
})
|
|
39
40
|
});
|
|
@@ -48,10 +49,10 @@ describe('getCells tests', () => {
|
|
|
48
49
|
FT1: { id: 'FT1', name: 'Footnote 1', value: { id: 'FT1.1', name: 'Footnote 1 Value 1' } },
|
|
49
50
|
FT3: { id: 'FT3', name: 'Footnote 3', value: { id: 'FT3.3', name: 'Footnote 3 Value 3' } },
|
|
50
51
|
},
|
|
51
|
-
indexedDimValIds: {}
|
|
52
|
+
indexedDimValIds: {},
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
}, 'both', customAttributes)).to.deep.equal({
|
|
55
|
+
}, 'both', customAttributes, {}, [])).to.deep.equal({
|
|
55
56
|
a: {
|
|
56
57
|
value: '33',
|
|
57
58
|
intValue: 33,
|
|
@@ -60,7 +61,8 @@ describe('getCells tests', () => {
|
|
|
60
61
|
{ label: '(FT1) Footnote 1: (FT1.1) Footnote 1 Value 1' },
|
|
61
62
|
{ label: '(FT3) Footnote 3: (FT3.3) Footnote 3 Value 3' }
|
|
62
63
|
],
|
|
63
|
-
indexedDimValIds: {}
|
|
64
|
+
indexedDimValIds: {},
|
|
65
|
+
sideProps: null
|
|
64
66
|
}
|
|
65
67
|
})
|
|
66
68
|
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getDataflowAdvancedAttributes } from '../src/rules2/src/getAdvancedAttributes';
|
|
3
|
+
|
|
4
|
+
describe('getDataflowAdvancedAttributes tests', () => {
|
|
5
|
+
it('complete test', () => {
|
|
6
|
+
const advancedAttributesIds = ['a0', 'a2', 'a4', 'a6'];
|
|
7
|
+
const attributes = {
|
|
8
|
+
a0: { id: 'a0', relationship: { none: {} }, values: [{ id: 'v0' }] },
|
|
9
|
+
a1: { id: 'a1', relationship: { none: {} }, values: [{ id: 'v0' }] },
|
|
10
|
+
a2: { id: 'a2', relationship: { dimensions: ['d0'] }, values: [{ id: 'v0' }] },
|
|
11
|
+
a3: { id: 'a3', relationship: { dimensions: ['d0'] }, values: [{ id: 'v0' }] },
|
|
12
|
+
a4: { id: 'a4', relationship: { dimensions: ['d0', 'd1'] }, values: [{ id: 'v0' }] },
|
|
13
|
+
a5: { id: 'a5', relationship: { dimensions: ['d0', 'd1'] }, values: [{ id: 'v0' }] },
|
|
14
|
+
a6: { id: 'a6', relationship: { dimensions: ['d0', 'd1', 'd2'] }, values: [{ id: 'v0' }] },
|
|
15
|
+
};
|
|
16
|
+
const dimLength = 4;
|
|
17
|
+
const dimensions = {
|
|
18
|
+
d0: { id: 'd0', __index: 1, values: [{ id: 'v0' }] },
|
|
19
|
+
d1: { id: 'd1', __index: 2, values: [{ id: 'v0' }] },
|
|
20
|
+
d2: { id: 'd2', __index: 3, values: [{ id: 'v0' }] },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const expected = {
|
|
24
|
+
':::': { attributes: { a0: { id: 'a0', value: { id: 'v0' } } }, coordinates: {} },
|
|
25
|
+
':0::': { attributes: { a2: { id: 'a2', value: { id: 'v0' } } }, coordinates: { d0: 'v0' } },
|
|
26
|
+
':0:0:': { attributes: { a4: { id: 'a4', value: { id: 'v0' } } }, coordinates: { d0: 'v0', d1: 'v0' } },
|
|
27
|
+
':0:0:0': { attributes: { a6: { id: 'a6', value: { id: 'v0' } } }, coordinates: { d0: 'v0', d1: 'v0', d2: 'v0' } },
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
expect(getDataflowAdvancedAttributes(attributes, dimensions, advancedAttributesIds, dimLength)).to.deep.equal(expected);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import { getLayoutDataWithFlags } from '../src/rules/src/table/factories/getLayoutWithFlags';
|
|
3
3
|
|
|
4
|
-
const customAttributes = { flags: ['a1', 'a2'] };
|
|
4
|
+
const customAttributes = { flags: ['a1', 'a2'], footnotes: ['a3', 'a4'] };
|
|
5
5
|
|
|
6
6
|
const layoutData = {
|
|
7
7
|
headerData: [
|
|
@@ -41,7 +41,8 @@ const expected = {
|
|
|
41
41
|
{ dimension: { id: 'COL2', label: 'COL2', flags: [] }, value: { id: 'COL2V1', label: 'COL2V1', flags: [] } }
|
|
42
42
|
],
|
|
43
43
|
key: '0:0',
|
|
44
|
-
flags: [{ code: 'A1VAL', label: 'A1: A1VAL' }, { label: 'A3: A3VAL' }]
|
|
44
|
+
flags: [{ code: 'A1VAL', label: 'A1: A1VAL' }, { label: 'A3: A3VAL' }],
|
|
45
|
+
sideProps: null
|
|
45
46
|
},
|
|
46
47
|
{
|
|
47
48
|
data: [
|
|
@@ -49,7 +50,8 @@ const expected = {
|
|
|
49
50
|
{ dimension: { id: 'COL2', label: 'COL2', flags: [] }, value: { id: 'COL2V1', label: 'COL2V1', flags: [] } }
|
|
50
51
|
],
|
|
51
52
|
key: '1:0',
|
|
52
|
-
flags: []
|
|
53
|
+
flags: [],
|
|
54
|
+
sideProps: null
|
|
53
55
|
}
|
|
54
56
|
],
|
|
55
57
|
sectionsData: [
|
|
@@ -57,7 +59,8 @@ const expected = {
|
|
|
57
59
|
{
|
|
58
60
|
data: [{ dimension: { id: 'SEC', label: 'SEC', flags: [] }, value: { id: 'SECV1', label: 'SECV1', flags: [] } }],
|
|
59
61
|
key: '0',
|
|
60
|
-
flags: []
|
|
62
|
+
flags: [],
|
|
63
|
+
sideProps: null
|
|
61
64
|
},
|
|
62
65
|
[
|
|
63
66
|
{
|
|
@@ -66,7 +69,8 @@ const expected = {
|
|
|
66
69
|
{ dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V1', label: 'ROW2V1', flags: [] } }
|
|
67
70
|
],
|
|
68
71
|
key: '0:0',
|
|
69
|
-
flags: []
|
|
72
|
+
flags: [],
|
|
73
|
+
sideProps: null
|
|
70
74
|
},
|
|
71
75
|
{
|
|
72
76
|
data: [
|
|
@@ -74,7 +78,8 @@ const expected = {
|
|
|
74
78
|
{ dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V2', label: 'ROW2V2', flags: [] } }
|
|
75
79
|
],
|
|
76
80
|
key: '0:1',
|
|
77
|
-
flags: []
|
|
81
|
+
flags: [],
|
|
82
|
+
sideProps: null
|
|
78
83
|
},
|
|
79
84
|
{
|
|
80
85
|
data: [
|
|
@@ -82,7 +87,8 @@ const expected = {
|
|
|
82
87
|
{ dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V3', label: 'ROW2V3', flags: [] } }
|
|
83
88
|
],
|
|
84
89
|
key: '0:2',
|
|
85
|
-
flags: []
|
|
90
|
+
flags: [],
|
|
91
|
+
sideProps: null
|
|
86
92
|
},
|
|
87
93
|
]
|
|
88
94
|
],
|
|
@@ -90,7 +96,8 @@ const expected = {
|
|
|
90
96
|
{
|
|
91
97
|
data: [{ dimension: { id: 'SEC', label: 'SEC', flags: [] }, value: { id: 'SECV2', label: 'SECV2', flags: [] } }],
|
|
92
98
|
key: '1',
|
|
93
|
-
flags: []
|
|
99
|
+
flags: [],
|
|
100
|
+
sideProps: null
|
|
94
101
|
},
|
|
95
102
|
[
|
|
96
103
|
{
|
|
@@ -99,7 +106,8 @@ const expected = {
|
|
|
99
106
|
{ dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V1', label: 'ROW2V1', flags: [] } }
|
|
100
107
|
],
|
|
101
108
|
key: '0:0',
|
|
102
|
-
flags: []
|
|
109
|
+
flags: [],
|
|
110
|
+
sideProps: null
|
|
103
111
|
},
|
|
104
112
|
{
|
|
105
113
|
data: [
|
|
@@ -107,7 +115,8 @@ const expected = {
|
|
|
107
115
|
{ dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V2', label: 'ROW2V2', flags: [] } }
|
|
108
116
|
],
|
|
109
117
|
key: '0:1',
|
|
110
|
-
flags: [{ label: 'A4: A4VAL' }]
|
|
118
|
+
flags: [{ label: 'A4: A4VAL' }],
|
|
119
|
+
sideProps: null
|
|
111
120
|
},
|
|
112
121
|
{
|
|
113
122
|
data: [
|
|
@@ -115,7 +124,8 @@ const expected = {
|
|
|
115
124
|
{ dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V3', label: 'ROW2V3', flags: [] } }
|
|
116
125
|
],
|
|
117
126
|
key: '0:2',
|
|
118
|
-
flags: []
|
|
127
|
+
flags: [],
|
|
128
|
+
sideProps: null
|
|
119
129
|
},
|
|
120
130
|
]
|
|
121
131
|
]
|
|
@@ -127,6 +137,6 @@ describe('getLayoutDataWithFlags test', () => {
|
|
|
127
137
|
expect(getLayoutDataWithFlags({}, 'label', {})({ headerData: [], sectionsData: [] })).to.deep.equal({ headerData: [], sectionsData: [] });
|
|
128
138
|
});
|
|
129
139
|
it('multi cases', () => {
|
|
130
|
-
expect(getLayoutDataWithFlags(attributesValues, 'code', customAttributes)(layoutData)).to.deep.equal(expected);
|
|
140
|
+
expect(getLayoutDataWithFlags(attributesValues, 'code', customAttributes, [], [])(layoutData)).to.deep.equal(expected);
|
|
131
141
|
});
|
|
132
142
|
});
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getSeriesAdvancedAttributes } from '../src/rules2/src/getAdvancedAttributes';
|
|
3
|
+
|
|
4
|
+
describe('getSeriesAdvancedAttributes tests', () => {
|
|
5
|
+
it('complete case', () => {
|
|
6
|
+
const seriesAttributes = {
|
|
7
|
+
series: {
|
|
8
|
+
'0:0:x:x:x': { attributes: { a0: { id: 'a0' } } },
|
|
9
|
+
'0:1:0:x:x': { attributes: { a0: { id: 'a0' }, a1: { id: 'a1' } } },
|
|
10
|
+
},
|
|
11
|
+
dimensions: {
|
|
12
|
+
'3:0': { attributes: { a0: { id: 'a0' } } },
|
|
13
|
+
'4:1': { attributes: { a0: { id: 'a0' }, a1: { id: 'a1' } } },
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const advancedAttributesIds = ['a1'];
|
|
17
|
+
const dimensions = [
|
|
18
|
+
{ id: 'd0', values: [{ id: 'v0' }] },
|
|
19
|
+
{ id: 'd1', values: [{ id: 'v0' }, { id: 'v1' }] },
|
|
20
|
+
{ id: 'd2', values: [{ id: 'v0' }] },
|
|
21
|
+
{ id: 'd3', values: [{ id: 'v0' }] },
|
|
22
|
+
{ id: 'd4', values: [{ id: 'v0' }, { id: 'v1' }] },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
expect(getSeriesAdvancedAttributes(seriesAttributes, dimensions, advancedAttributesIds)).to.deep.equal({
|
|
26
|
+
'0:1:0::': { attributes: { a1: { id: 'a1' } }, coordinates: { d0: 'v0', d1: 'v1', d2: 'v0' } },
|
|
27
|
+
'::::1': { attributes: { a1: { id: 'a1' } }, coordinates: { d4: 'v1' } }
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getSidebarData } from '../src/rules2/src/getSidebarData';
|
|
3
|
+
|
|
4
|
+
describe('getSidebarData tests', () => {
|
|
5
|
+
it('complete case', () => {
|
|
6
|
+
const attributes = {
|
|
7
|
+
'::': [
|
|
8
|
+
{ id: 'aa0', label: 'advanced attribute 0', value: 'value' },
|
|
9
|
+
{ id: 'aa1', label: 'advanced attribute 1', value: 'value' },
|
|
10
|
+
],
|
|
11
|
+
'0::': [
|
|
12
|
+
{ id: 'aa2', label: 'advanced attribute 2', value: 'value' },
|
|
13
|
+
{ id: 'aa3', label: 'advanced attribute 3', value: 'value' },
|
|
14
|
+
]
|
|
15
|
+
};
|
|
16
|
+
const metadata = {
|
|
17
|
+
'0::': [
|
|
18
|
+
{ id: 'ma0', label: 'metadata attribute 0', value: 'value' },
|
|
19
|
+
{ id: 'ma1', label: 'metadata attribute 1', value: 'value' },
|
|
20
|
+
],
|
|
21
|
+
'0::0': [
|
|
22
|
+
{ id: 'ma2', label: 'metadata attribute 2', value: 'value' },
|
|
23
|
+
{ id: 'ma3', label: 'metadata attribute 3', value: 'value' },
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
const options = {
|
|
27
|
+
display: 'code',
|
|
28
|
+
attributesLabel: 'Advanced Attributes'
|
|
29
|
+
};
|
|
30
|
+
const dataflow = {
|
|
31
|
+
id: 'DF',
|
|
32
|
+
name: 'Dataflow'
|
|
33
|
+
};
|
|
34
|
+
const dimensions = [
|
|
35
|
+
{ id: 'd0', name: 'dimension 0', values: [{ id: 'd0v0', name: 'value 0' }] },
|
|
36
|
+
{ id: 'd1', name: 'dimension 1', values: [{ id: 'd1v0', name: 'value 0' }] },
|
|
37
|
+
{ id: 'd2', name: 'dimension 2', values: [{ id: 'd2v0', name: 'value 0' }] },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
expect(getSidebarData(attributes, metadata, dataflow, dimensions, options)).to.deep.equal([
|
|
41
|
+
{
|
|
42
|
+
id: '0::0',
|
|
43
|
+
label: 'd0: d0v0 - d2: d2v0',
|
|
44
|
+
splitCoord: ['0', '', '0'],
|
|
45
|
+
children: [
|
|
46
|
+
{
|
|
47
|
+
id: 'ma2',
|
|
48
|
+
label: 'metadata attribute 2',
|
|
49
|
+
value: 'value'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'ma3',
|
|
53
|
+
label: 'metadata attribute 3',
|
|
54
|
+
value: 'value'
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: '0::',
|
|
60
|
+
label: 'd0: d0v0',
|
|
61
|
+
splitCoord: ['0', '', ''],
|
|
62
|
+
children: [
|
|
63
|
+
{
|
|
64
|
+
id: '0::-attr',
|
|
65
|
+
label: 'Advanced Attributes',
|
|
66
|
+
children: [
|
|
67
|
+
{
|
|
68
|
+
id: 'aa2',
|
|
69
|
+
label: 'advanced attribute 2',
|
|
70
|
+
value: 'value'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 'aa3',
|
|
74
|
+
label: 'advanced attribute 3',
|
|
75
|
+
value: 'value'
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'ma0',
|
|
81
|
+
label: 'metadata attribute 0',
|
|
82
|
+
value: 'value'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'ma1',
|
|
86
|
+
label: 'metadata attribute 1',
|
|
87
|
+
value: 'value'
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: '::',
|
|
93
|
+
label: 'DF',
|
|
94
|
+
splitCoord: ['', '', ''],
|
|
95
|
+
children: [
|
|
96
|
+
{
|
|
97
|
+
id: '::-attr',
|
|
98
|
+
label: 'Advanced Attributes',
|
|
99
|
+
children: [
|
|
100
|
+
{
|
|
101
|
+
id: 'aa0',
|
|
102
|
+
label: 'advanced attribute 0',
|
|
103
|
+
value: 'value'
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: 'aa1',
|
|
107
|
+
label: 'advanced attribute 1',
|
|
108
|
+
value: 'value'
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
]);
|
|
115
|
+
});
|
|
116
|
+
});
|