@sis-cc/dotstatsuite-components 15.0.6 → 15.0.8

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.
@@ -43,9 +43,7 @@ var getUnitsArtefacts = exports.getUnitsArtefacts = function getUnitsArtefacts(_
43
43
 
44
44
  var keyedDimensions = R.indexBy(R.prop('id'), dimensions);
45
45
 
46
- var parsedUnitsAttributes = R.converge(function (datasetLevel, observationLevel) {
47
- return R.over(R.lensProp('header'), R.merge(datasetLevel))(observationLevel);
48
- }, [R.pipe(R.pathOr([], ['data', 'structure', 'attributes', 'dataSet']), R.filter(R.pipe(R.propOr([], 'values'), R.length, R.equals(1))), R.indexBy(R.prop('id')), R.pick(unitsDefinitionCodes), R.filter(R.propOr(true, 'display')), R.mapObjIndexed(R.assoc('datasetLevel', true))), R.pipe(R.pathOr([], ['data', 'structure', 'attributes', 'observation']), R.addIndex(R.reduce)(function (acc, attr, index) {
46
+ var parsedUnitsAttributes = R.pipe(R.pathOr([], ['data', 'structure', 'attributes', 'observation']), R.addIndex(R.reduce)(function (acc, attr, index) {
49
47
  if (!R.includes(attr.id, unitsDefinitionCodes) || R.length(R.propOr([], 'values', attr)) === 0 || !R.propOr(true, 'display', attr)) {
50
48
  return acc;
51
49
  }
@@ -53,6 +51,9 @@ var getUnitsArtefacts = exports.getUnitsArtefacts = function getUnitsArtefacts(_
53
51
  if (length === 0) {
54
52
  return acc;
55
53
  }
54
+ if (R.hasPath(['relationship', 'none'], attr) || R.hasPath(['relationship', 'dataflow'], attr)) {
55
+ return R.assocPath(['header', attr.id], (0, _extends3.default)({}, attr, { index: index, datasetLevel: true }), acc);
56
+ }
56
57
  if (R.path(['relationship', 'primaryMeasure'], attr) === 'OBS_VALUE' || R.hasPath(['relationship', 'observation'], attr)) {
57
58
  return R.assocPath(['series', attr.id], (0, _extends3.default)({}, attr, { index: index, observations: true }), acc);
58
59
  }
@@ -67,7 +68,7 @@ var getUnitsArtefacts = exports.getUnitsArtefacts = function getUnitsArtefacts(_
67
68
  }, attachedDimensions);
68
69
  var level = R.isEmpty(filteredAttachedDimensions) ? 'header' : 'series';
69
70
  return R.assocPath([level, attr.id], (0, _extends3.default)({}, attr, { index: index, relationship: { dimensions: filteredAttachedDimensions } }), acc);
70
- }, { header: {}, series: {} }))])(data);
71
+ }, { header: {}, series: {} }))(data);
71
72
 
72
73
  var hasSeries = R.pipe(R.all(R.isEmpty), R.not)([parsedUnitsDimensions.series, parsedUnitsAttributes.series]);
73
74
 
@@ -93,12 +93,10 @@ var ViewContent = function ViewContent(_ref3) {
93
93
  var loading = _ref3.loading,
94
94
  _ref3$loadingProps = _ref3.loadingProps,
95
95
  loadingProps = _ref3$loadingProps === undefined ? {} : _ref3$loadingProps,
96
- _ref3$noData = _ref3.noData,
97
- noData = _ref3$noData === undefined ? 'No Data' : _ref3$noData,
98
96
  type = _ref3.type,
99
97
  width = _ref3.width,
100
98
  errorMessage = _ref3.errorMessage,
101
- rest = (0, _objectWithoutProperties3.default)(_ref3, ['loading', 'loadingProps', 'noData', 'type', 'width', 'errorMessage']);
99
+ rest = (0, _objectWithoutProperties3.default)(_ref3, ['loading', 'loadingProps', 'type', 'width', 'errorMessage']);
102
100
 
103
101
  if (loading) return _react2.default.createElement(_dotstatsuiteVisions.Loading, (0, _extends3.default)({ message: loading }, loadingProps));
104
102
  if (!width) return _react2.default.createElement(_dotstatsuiteVisions.Loading, (0, _extends3.default)({ message: loading }, loadingProps));
@@ -107,7 +105,7 @@ var ViewContent = function ViewContent(_ref3) {
107
105
  if (type === 'table') {
108
106
  var tableProps = R.propOr({}, 'tableProps', rest);
109
107
  var hasNoObs = R.pipe(R.prop('cells'), R.anyPass([R.isNil, R.isEmpty]))(tableProps);
110
- if (hasNoObs) return _react2.default.createElement(_dotstatsuiteVisions.NoData, { message: noData });
108
+ if (hasNoObs) return _react2.default.createElement(_dotstatsuiteVisions.Loading, null);
111
109
 
112
110
  return _react2.default.createElement(_dotstatsuiteVisions.TableHtml5, (0, _extends3.default)({ isRtl: R.prop('isRtl', rest) }, tableProps));
113
111
  }
@@ -116,7 +114,6 @@ var ViewContent = function ViewContent(_ref3) {
116
114
  fixedHeight: R.prop('fixedHeight', rest),
117
115
  getAxisOptions: R.prop('getAxisOptions', rest),
118
116
  heightOffsets: R.prop('heightOffsets', rest),
119
- noData: noData,
120
117
  options: R.prop('chartOptions', rest),
121
118
  type: type,
122
119
  width: width
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": "15.0.6",
4
+ "version": "15.0.8",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -28,61 +28,48 @@ export const getUnitsArtefacts = ({ unitsDefinitionCodes=[], data }) => {
28
28
 
29
29
  const keyedDimensions = R.indexBy(R.prop('id'), dimensions);
30
30
 
31
- const parsedUnitsAttributes = R.converge(
32
- (datasetLevel, observationLevel) => R.over(
33
- R.lensProp('header'),
34
- R.merge(datasetLevel)
35
- )(observationLevel),
36
- [
37
- R.pipe(
38
- R.pathOr([], ['data', 'structure', 'attributes', 'dataSet']),
39
- R.filter(R.pipe(R.propOr([], 'values'), R.length, R.equals(1))),
40
- R.indexBy(R.prop('id')),
41
- R.pick(unitsDefinitionCodes),
42
- R.filter(R.propOr(true, 'display')),
43
- R.mapObjIndexed(R.assoc('datasetLevel', true))
44
- ),
45
- R.pipe(
46
- R.pathOr([], ['data', 'structure', 'attributes', 'observation']),
47
- R.addIndex(R.reduce)(
48
- (acc, attr, index) => {
49
- if(!R.includes(attr.id, unitsDefinitionCodes) || R.length(R.propOr([], 'values', attr)) === 0
50
- || !R.propOr(true, 'display', attr)) {
51
- return acc;
52
- }
53
- const length = getRelevantLength(attr);
54
- if (length === 0) {
55
- return acc;
56
- }
57
- if ((R.path(['relationship', 'primaryMeasure'], attr) === 'OBS_VALUE')
58
- || (R.hasPath(['relationship', 'observation'], attr))) {
59
- return R.assocPath(['series', attr.id], { ...attr, index, observations: true }, acc);
60
- }
61
- const attachedDimensions = R.path(['relationship', 'dimensions'], attr);
62
- if (R.isNil(attachedDimensions)) {
63
- return acc;
64
- }
65
- const filteredAttachedDimensions = R.filter(
66
- (id) => {
67
- const dimension = R.propOr({}, id, keyedDimensions);
68
- const nValues = R.pipe(R.propOr([], 'values'), R.length)(dimension);
69
- return nValues > 1;
70
- },
71
- attachedDimensions
72
- );
73
- const level = R.isEmpty(filteredAttachedDimensions)
74
- ? 'header'
75
- : 'series';
76
- return R.assocPath(
77
- [level, attr.id],
78
- { ...attr, index, relationship: { dimensions: filteredAttachedDimensions } },
79
- acc
80
- );
31
+ const parsedUnitsAttributes = R.pipe(
32
+ R.pathOr([], ['data', 'structure', 'attributes', 'observation']),
33
+ R.addIndex(R.reduce)(
34
+ (acc, attr, index) => {
35
+ if(!R.includes(attr.id, unitsDefinitionCodes) || R.length(R.propOr([], 'values', attr)) === 0
36
+ || !R.propOr(true, 'display', attr)) {
37
+ return acc;
38
+ }
39
+ const length = getRelevantLength(attr);
40
+ if (length === 0) {
41
+ return acc;
42
+ }
43
+ if (R.hasPath(['relationship', 'none'], attr) || R.hasPath(['relationship', 'dataflow'], attr)) {
44
+ return R.assocPath(['header', attr.id], { ...attr, index, datasetLevel: true }, acc);
45
+ }
46
+ if ((R.path(['relationship', 'primaryMeasure'], attr) === 'OBS_VALUE')
47
+ || (R.hasPath(['relationship', 'observation'], attr))) {
48
+ return R.assocPath(['series', attr.id], { ...attr, index, observations: true }, acc);
49
+ }
50
+ const attachedDimensions = R.path(['relationship', 'dimensions'], attr);
51
+ if (R.isNil(attachedDimensions)) {
52
+ return acc;
53
+ }
54
+ const filteredAttachedDimensions = R.filter(
55
+ (id) => {
56
+ const dimension = R.propOr({}, id, keyedDimensions);
57
+ const nValues = R.pipe(R.propOr([], 'values'), R.length)(dimension);
58
+ return nValues > 1;
81
59
  },
82
- { header: {}, series: {} }
83
- )
84
- )
85
- ]
60
+ attachedDimensions
61
+ );
62
+ const level = R.isEmpty(filteredAttachedDimensions)
63
+ ? 'header'
64
+ : 'series';
65
+ return R.assocPath(
66
+ [level, attr.id],
67
+ { ...attr, index, relationship: { dimensions: filteredAttachedDimensions } },
68
+ acc
69
+ );
70
+ },
71
+ { header: {}, series: {} }
72
+ )
86
73
  )(data);
87
74
 
88
75
  const hasSeries = R.pipe(
@@ -33,7 +33,7 @@ const useStyles = makeStyles(() => ({
33
33
  }
34
34
  }));
35
35
 
36
- const ViewContent = ({ loading, loadingProps={}, noData = 'No Data', type, width, errorMessage, ...rest }) => {
36
+ const ViewContent = ({ loading, loadingProps={}, type, width, errorMessage, ...rest }) => {
37
37
  if (loading) return <Loading message={loading} {...loadingProps} />;
38
38
  if (!width) return <Loading message={loading} {...loadingProps} />;
39
39
  if (errorMessage) return <NoData message={errorMessage} />;
@@ -41,7 +41,7 @@ const ViewContent = ({ loading, loadingProps={}, noData = 'No Data', type, width
41
41
  if (type === 'table') {
42
42
  const tableProps = R.propOr({}, 'tableProps', rest);
43
43
  const hasNoObs = R.pipe(R.prop('cells'), R.anyPass([R.isNil, R.isEmpty]))(tableProps);
44
- if (hasNoObs) return <NoData message={noData} />;
44
+ if (hasNoObs) return <Loading />;
45
45
 
46
46
  return <TableHtml5 isRtl={R.prop('isRtl', rest)} {...tableProps} />;
47
47
  }
@@ -51,7 +51,6 @@ const ViewContent = ({ loading, loadingProps={}, noData = 'No Data', type, width
51
51
  fixedHeight={R.prop('fixedHeight', rest)}
52
52
  getAxisOptions={R.prop('getAxisOptions', rest)}
53
53
  heightOffsets={R.prop('heightOffsets', rest)}
54
- noData={noData}
55
54
  options={R.prop('chartOptions', rest)}
56
55
  type={type}
57
56
  width={width}
@@ -4,11 +4,6 @@ import { getUnitsArtefacts } from '../src/rules/src/table/units/getUnitsArtefact
4
4
  const data = {
5
5
  structure: {
6
6
  attributes: {
7
- dataSet: [
8
- { id: 'A0', values: [] },
9
- { id: 'A1', values: [{ id: 'V1' }] },
10
- { id: 'A2', values: [{ id: 'V1' }, { id: 'V2' }] },
11
- ],
12
7
  observation: [
13
8
  { id: 'A3', values: [] },
14
9
  { id: 'A4', relationship: { dimensions: ['D2'] }, values: [{ id: 'V1' }] },
@@ -18,6 +13,9 @@ const data = {
18
13
  { id: 'A8', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }] },
19
14
  { id: 'A9', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }], display: false },
20
15
  { id: 'A10', relationship: { observation: {} }, values: [{ id: 'V1' }, { id: 'V2' }] },
16
+ { id: 'A0', relationship: { none: {} }, values: [] },
17
+ { id: 'A1', relationship: { none: {} }, values: [{ id: 'V1' }] },
18
+ { id: 'A2', relationship: { dataflow: {} }, values: [{ id: 'V1' }, { id: 'V2' }] },
21
19
  ]
22
20
  },
23
21
  dimensions: {
@@ -45,7 +43,7 @@ describe('getUnitsArtefacts tests', () => {
45
43
  });
46
44
  it('full header', () => {
47
45
  expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A1', 'D1'] })).to.deep.equal({
48
- attributes: { header: { A1: { id: 'A1', datasetLevel: true, values: [{ id: 'V1' }] } }, series: {} },
46
+ attributes: { header: { A1: { id: 'A1', relationship: { none: {} }, index: 9, datasetLevel: true, values: [{ id: 'V1' }] } }, series: {} },
49
47
  dimensions: { header: { D1: { id: 'D1', header: true, index: 1, values: [{ id: 'V1' }] } }, series: {} },
50
48
  });
51
49
  });
@@ -83,7 +81,7 @@ describe('getUnitsArtefacts tests', () => {
83
81
  expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A1', 'A4', 'A5', 'D2'] })).to.deep.equal({
84
82
  attributes: {
85
83
  series: {
86
- A1: { id: 'A1', datasetLevel: true, values: [{ id: 'V1' }] },
84
+ A1: { id: 'A1', relationship: { none: {} }, index: 9, datasetLevel: true, values: [{ id: 'V1' }] },
87
85
  A4: { id: 'A4', index: 1, relationship: { dimensions: ['D2'] }, values: [{ id: 'V1' }] },
88
86
  A5: { id: 'A5', index: 2, relationship: { dimensions: ['D2'] }, values: [{ id: 'V1' }, { id: 'V2' }] }
89
87
  },