@sis-cc/dotstatsuite-components 13.1.0 → 13.3.1

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.OBS_TYPE_STRING = exports.OBS_TYPE_NUMERICAL_STRING = exports.OBS_TYPE_NUMBER = exports.V8_SDMX_JSON = exports.DEFAULT_MAJOR_ATTRIBUTES = exports.DIMENSION_DISPLAY_PARTS = exports.DEFAULT_REJECTED_SUBTITLE_IDS = exports.DEFAULT_REJECTED_UPR_VALUES_IDS = exports.DEFAULT_UPR_IDS = exports.FREQ_M = exports.FREQ_Q = exports.FREQ_S = exports.FREQ_A = exports.TYPES = exports.VALUES = exports.PERCENT = exports.CHORO = exports.STACKED_ROW = exports.STACKED_BAR = exports.V_SYMBOL = exports.H_SYMBOL = exports.TIMELINE = exports.SCATTER = exports.ROW = exports.BAR = undefined;
6
+ exports.REPYEARSTART = exports.REPORTING_YEAR_START_DAY = exports.OBS_TYPE_STRING = exports.OBS_TYPE_NUMERICAL_STRING = exports.OBS_TYPE_NUMBER = exports.V8_SDMX_JSON = exports.DEFAULT_MAJOR_ATTRIBUTES = exports.DIMENSION_DISPLAY_PARTS = exports.DEFAULT_REJECTED_SUBTITLE_IDS = exports.DEFAULT_REJECTED_UPR_VALUES_IDS = exports.DEFAULT_UPR_IDS = exports.FREQ_M = exports.FREQ_Q = exports.FREQ_S = exports.FREQ_A = exports.TYPES = exports.VALUES = exports.PERCENT = exports.CHORO = exports.STACKED_ROW = exports.STACKED_BAR = exports.V_SYMBOL = exports.H_SYMBOL = exports.TIMELINE = exports.SCATTER = exports.ROW = exports.BAR = undefined;
7
7
 
8
8
  var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
9
9
 
@@ -63,4 +63,6 @@ var V8_SDMX_JSON = exports.V8_SDMX_JSON = "application/vnd.sdmx.data+json;versio
63
63
 
64
64
  var OBS_TYPE_NUMBER = exports.OBS_TYPE_NUMBER = 'OBS_TYPE_NUMBER';
65
65
  var OBS_TYPE_NUMERICAL_STRING = exports.OBS_TYPE_NUMERICAL_STRING = 'OBS_TYPE_NUMERICAL_STRING';
66
- var OBS_TYPE_STRING = exports.OBS_TYPE_STRING = 'OBS_TYPE_STRING';
66
+ var OBS_TYPE_STRING = exports.OBS_TYPE_STRING = 'OBS_TYPE_STRING';
67
+ var REPORTING_YEAR_START_DAY = exports.REPORTING_YEAR_START_DAY = 'REPORTING_YEAR_START_DAY';
68
+ var REPYEARSTART = exports.REPYEARSTART = 'REPYEARSTART';
@@ -48,12 +48,6 @@ var _findIndex2 = require('lodash/findIndex');
48
48
 
49
49
  var _findIndex3 = _interopRequireDefault(_findIndex2);
50
50
 
51
- var _concat2 = require('lodash/concat');
52
-
53
- var _concat3 = _interopRequireDefault(_concat2);
54
-
55
- var _constants = require('../constants');
56
-
57
51
  var _dotstatsuiteSdmxjs = require('@sis-cc/dotstatsuite-sdmxjs');
58
52
 
59
53
  var _dimensionUtils = require('../dimension-utils');
@@ -62,26 +56,6 @@ var _observationFormater = require('../observation-formater');
62
56
 
63
57
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
64
58
 
65
- var getLineCategory = function getLineCategory(oDimensionValuesIndexes, dimensions, timePeriodDimensionIndex, dimensionsWithValuesIndexedById) {
66
- return (0, _reduce3.default)(oDimensionValuesIndexes, function (memo, dimensionValueIndex, dimensionIndex) {
67
- var dimension = (0, _get3.default)(dimensions, '[' + dimensionIndex + ']', {});
68
- if (dimensionIndex !== timePeriodDimensionIndex && (0, _has3.default)(dimensionsWithValuesIndexedById, dimension.id)) {
69
- return (0, _concat3.default)(memo, (0, _get3.default)(dimensions, '[' + dimensionIndex + '].values[' + dimensionValueIndex + '].name', ''));
70
- }
71
- return memo;
72
- }, []).join(' - ');
73
- };
74
-
75
- var getLineCategoryId = function getLineCategoryId(oDimensionValuesIndexes, dimensions, timePeriodDimensionIndex, dimensionsWithValuesIndexedById) {
76
- return (0, _reduce3.default)(oDimensionValuesIndexes, function (memo, dimensionValueIndex, dimensionIndex) {
77
- var dimension = (0, _get3.default)(dimensions, '[' + dimensionIndex + ']', {});
78
- if (dimensionIndex !== timePeriodDimensionIndex && (0, _has3.default)(dimensionsWithValuesIndexedById, dimension.id)) {
79
- return (0, _concat3.default)(memo, (0, _get3.default)(dimensions, '[' + dimensionIndex + '].values[' + dimensionValueIndex + '].id', ''));
80
- }
81
- return memo;
82
- }, []).join(' - ');
83
- };
84
-
85
59
  var getDimensionValues = function getDimensionValues(splitObservationKey, dimensions, dimensionsWithValuesIndexedById, rejectedId, display) {
86
60
  return (0, _reduce3.default)(splitObservationKey, function (memo, dimensionValueIndex, dimensionIndex) {
87
61
  var dimension = (0, _get3.default)(dimensions, '[' + dimensionIndex + ']', {});
@@ -17,6 +17,8 @@ var _ramda = require('ramda');
17
17
 
18
18
  var R = _interopRequireWildcard(_ramda);
19
19
 
20
+ var _constants = require('../constants');
21
+
20
22
  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
23
 
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -32,7 +34,11 @@ var getReportingYearStart = exports.getReportingYearStart = function getReportin
32
34
  return [].concat((0, _toConsumableArray3.default)(dataSet), (0, _toConsumableArray3.default)(observation), (0, _toConsumableArray3.default)(series));
33
35
  })(sdmxJson);
34
36
 
35
- var reportYearStartAttr = R.find(R.propEq('id', 'REPORTING_YEAR_START_DAY'), attributes) || {};
37
+ var reportYearStartAttr = R.find(function (_ref2) {
38
+ var id = _ref2.id;
39
+
40
+ return id === _constants.REPORTING_YEAR_START_DAY || id === _constants.REPYEARSTART;
41
+ }, attributes) || {};
36
42
  var reportYearStart = R.pathOr('--01-01', ['values', 0, 'name'], reportYearStartAttr);
37
43
 
38
44
  var _R$match = R.match(/[\d]{2}/g, reportYearStart),
@@ -9,6 +9,8 @@ var _ramda = require('ramda');
9
9
 
10
10
  var R = _interopRequireWildcard(_ramda);
11
11
 
12
+ var _constants = require('../../constants');
13
+
12
14
  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; } }
13
15
 
14
16
  var registerAttrId = function registerAttrId(path, id) {
@@ -63,6 +65,7 @@ var parseAttributes = exports.parseAttributes = function parseAttributes(_ref) {
63
65
  if (R.isEmpty(values) || !R.propOr(true, 'display', attribute) || R.includes(attribute.id, R.propOr([], 'units', customAttributes))) {
64
66
  return acc;
65
67
  }
68
+ if (R.includes(attribute.id, [_constants.REPORTING_YEAR_START_DAY, _constants.REPYEARSTART])) return acc;
66
69
 
67
70
  var registers = getAttributeRegisters(R.pipe(R.assoc('index', attributeIndex), R.over(R.lensProp('values'), R.map(function (value) {
68
71
  if (!R.propOr(true, 'display', value)) {
@@ -33,16 +33,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
33
33
 
34
34
  var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew) {
35
35
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
36
+ var locale = options.locale;
36
37
 
37
- var getLanguage = R.pipe(R.pathOr('', ['meta', 'contentLanguages']), R.head());
38
- var locale = getLanguage(dataNew);
39
38
  var reportYearStart = (0, _getReportingYearStart.getReportingYearStart)(dataNew);
40
- var getProp = function getProp(prop, locale) {
41
- return R.pathOr(null, [prop, locale]);
42
- };
43
- var getLocalisedProp = R.curry(function (prop, collection) {
44
- return getProp(prop, locale)(collection);
45
- });
46
39
 
47
40
  //---------------------------------------------------------------------------------------Annotations
48
41
  var getStructure = R.pathOr({}, ['data', 'structure']);
@@ -62,7 +55,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
62
55
  var valAnnotations = R.props(value.annotations || [], annotations);
63
56
  return (0, _extends3.default)({}, value, {
64
57
  display: !R.has(parent + '.' + value.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(valAnnotations),
65
- name: getLocalisedProp('names', value)
58
+ name: (0, _dotstatsuiteSdmxjs.getRefinedName)(value)
66
59
  });
67
60
  }, values);
68
61
  };
@@ -71,7 +64,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
71
64
  return R.pipe(R.addIndex(R.map)(function (value, __index) {
72
65
  var valueAnnotations = R.pipe(R.propOr([], 'annotations'), R.flip(R.props)(annotations))(value);
73
66
  var isHidden = R.has(parent + '.' + value.id, hiddenIds) || (0, _sdmxData.getIsHidden)(valueAnnotations);
74
- var name = getLocalisedProp('names')(value);
67
+ var name = (0, _dotstatsuiteSdmxjs.getRefinedName)(value);
75
68
  var __indexPosition = NaN;
76
69
  var start = null;
77
70
  if (isTimeDimension) {
@@ -82,7 +75,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
82
75
  __indexPosition = _dateFns2.default.getTime(new Date(R.prop('start', value)));
83
76
  }
84
77
  if (isNaN(__indexPosition)) {
85
- __indexPosition = (0, _dotstatsuiteSdmxjs.getCodeOrder)(locale)({ annotations: valueAnnotations });
78
+ __indexPosition = (0, _dotstatsuiteSdmxjs.getCodeOrder)({ annotations: valueAnnotations });
86
79
  }
87
80
  var timeFormat = R.prop('timeFormat', options);
88
81
  return (0, _extends3.default)({}, value, {
@@ -106,7 +99,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
106
99
  var sender = getSender(meta);
107
100
 
108
101
  var resHeader = (0, _extends3.default)({}, meta, {
109
- sender: (0, _extends3.default)({}, sender, { name: getLocalisedProp('names', sender) })
102
+ sender: (0, _extends3.default)({}, sender, { name: (0, _dotstatsuiteSdmxjs.getRefinedName)(sender) })
110
103
  });
111
104
 
112
105
  //----------------------------------------------------------------------------------------Attributes
@@ -120,7 +113,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
120
113
  var obsAnnotations = R.props(observation.annotations || [], annotations);
121
114
  return (0, _extends3.default)({}, observation, {
122
115
  display: !R.has(observation.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(obsAnnotations),
123
- name: getLocalisedProp('names', observation),
116
+ name: (0, _dotstatsuiteSdmxjs.getRefinedName)(observation),
124
117
  values: getValues(observation.values || [], observation.id),
125
118
  roles: !R.isNil(observation.role) ? R.head(observation.role) : null
126
119
  });
@@ -130,7 +123,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
130
123
  var attrAnnotations = R.props(attr.annotations || [], annotations);
131
124
  return (0, _extends3.default)({}, attr, {
132
125
  display: !R.has(attr.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(attrAnnotations),
133
- name: getLocalisedProp('names', observation),
126
+ name: (0, _dotstatsuiteSdmxjs.getRefinedName)(observation),
134
127
  values: getValues(attr.values || [], attr.id)
135
128
  });
136
129
  }, R.propOr([], 'dataSet', attributes));
@@ -179,7 +172,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
179
172
  observation: R.append((0, _extends3.default)({}, observation, {
180
173
  display: !isHidden,
181
174
  __index: obsIndex,
182
- name: getLocalisedProp('names', observation),
175
+ name: (0, _dotstatsuiteSdmxjs.getRefinedName)(observation),
183
176
  values: sortedValues,
184
177
  role: R.isNil(observation.roles) ? null : R.head(observation.roles)
185
178
  }))(acc.observation),
@@ -195,7 +188,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
195
188
  observation = _getObservations.observation;
196
189
 
197
190
  var resStructure = (0, _extends3.default)({}, structure, {
198
- name: getLocalisedProp('names', structure),
191
+ name: (0, _dotstatsuiteSdmxjs.getRefinedName)((0, _extends3.default)({}, structure, { id: options.dataflowId })),
199
192
  annotations: annotations,
200
193
  attributes: resAttributes,
201
194
  dimensions: { observation: observation }
@@ -13,15 +13,16 @@ var _dotstatsuiteSdmxjs = require('@sis-cc/dotstatsuite-sdmxjs');
13
13
 
14
14
  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; } }
15
15
 
16
- var dimensionValueDisplay = function dimensionValueDisplay(locale, display) {
16
+ var dimensionValueDisplay = function dimensionValueDisplay(display) {
17
17
  return function (data) {
18
18
  if (display === 'code') {
19
19
  return R.prop('id', data);
20
20
  }
21
+ var name = (0, _dotstatsuiteSdmxjs.getRefinedName)(data);
21
22
  if (display === 'both') {
22
- return R.prop('id', data) + ': ' + (0, _dotstatsuiteSdmxjs.getLocalisedName)(locale)(data);
23
+ return R.prop('id', data) + ': ' + name;
23
24
  }
24
- return (0, _dotstatsuiteSdmxjs.getLocalisedName)(locale)(data);
25
+ return name;
25
26
  };
26
27
  };
27
28
  // options = { locale, display, dimensions = [], attributes = { [id]: { format, parent } } };
@@ -64,7 +65,7 @@ var parseMetadataSeries = exports.parseMetadataSeries = function parseMetadataSe
64
65
  return acc;
65
66
  }
66
67
  var attribute = R.nth(attrIndex, metadataAttributes);
67
- var label = dimensionValueDisplay(options.locale, options.display)(attribute);
68
+ var label = dimensionValueDisplay(options.display)(attribute);
68
69
 
69
70
  var value = R.prop('value', R.nth(valueIndex, attribute.values || []));
70
71
 
@@ -91,15 +91,17 @@ var useStyles = (0, _styles.makeStyles)(function () {
91
91
 
92
92
  var ViewContent = function ViewContent(_ref3) {
93
93
  var loading = _ref3.loading,
94
+ _ref3$loadingProps = _ref3.loadingProps,
95
+ loadingProps = _ref3$loadingProps === undefined ? {} : _ref3$loadingProps,
94
96
  _ref3$noData = _ref3.noData,
95
97
  noData = _ref3$noData === undefined ? 'No Data' : _ref3$noData,
96
98
  type = _ref3.type,
97
99
  width = _ref3.width,
98
100
  errorMessage = _ref3.errorMessage,
99
- rest = (0, _objectWithoutProperties3.default)(_ref3, ['loading', 'noData', 'type', 'width', 'errorMessage']);
101
+ rest = (0, _objectWithoutProperties3.default)(_ref3, ['loading', 'loadingProps', 'noData', 'type', 'width', 'errorMessage']);
100
102
 
101
- if (loading) return _react2.default.createElement(_dotstatsuiteVisions.Loading, { message: loading });
102
- if (!width) return _react2.default.createElement(_dotstatsuiteVisions.Loading, { message: loading });
103
+ if (loading) return _react2.default.createElement(_dotstatsuiteVisions.Loading, (0, _extends3.default)({ message: loading }, loadingProps));
104
+ if (!width) return _react2.default.createElement(_dotstatsuiteVisions.Loading, (0, _extends3.default)({ message: loading }, loadingProps));
103
105
  if (errorMessage) return _react2.default.createElement(_dotstatsuiteVisions.NoData, { message: errorMessage });
104
106
 
105
107
  if (type === 'table') {
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": "13.1.0",
4
+ "version": "13.3.1",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "peerDependencies": {
38
38
  "@material-ui/core": "^4.x",
39
39
  "@sis-cc/dotstatsuite-visions": "^7.x",
40
- "@sis-cc/dotstatsuite-sdmxjs": "^5.x",
40
+ "@sis-cc/dotstatsuite-sdmxjs": "^6.x",
41
41
  "react": "16.x"
42
42
  }
43
43
  }
@@ -59,3 +59,6 @@ export const V8_SDMX_JSON = "application/vnd.sdmx.data+json;version=1.0.0-wd";
59
59
  export const OBS_TYPE_NUMBER = 'OBS_TYPE_NUMBER';
60
60
  export const OBS_TYPE_NUMERICAL_STRING = 'OBS_TYPE_NUMERICAL_STRING';
61
61
  export const OBS_TYPE_STRING = 'OBS_TYPE_STRING';
62
+ export const REPORTING_YEAR_START_DAY = 'REPORTING_YEAR_START_DAY';
63
+ export const REPYEARSTART = 'REPYEARSTART';
64
+
@@ -1,4 +1,4 @@
1
- import { find, findIndex, get, groupBy, has, head, isUndefined, map, reduce, split, transform } from 'lodash';
1
+ import { get, has, head, isUndefined, map, split, transform } from 'lodash';
2
2
  import { getRefAreaDimension } from '@sis-cc/dotstatsuite-sdmxjs';
3
3
  import { categoryDisplay, dimensionValueDisplay } from '../dimension-utils';
4
4
 
@@ -1,47 +1,8 @@
1
- import {
2
- concat, filter, findIndex, get, has, head, isEmpty, isNil, map, reduce, size, sortBy, split, keys, includes
3
- } from 'lodash';
4
- import { FREQ_A, FREQ_Q, FREQ_M } from '../constants';
1
+ import { findIndex, get, has, head, isEmpty, isNil, map, reduce, sortBy, split } from 'lodash';
5
2
  import { getTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
6
3
  import { categoryDisplay, dimensionValueDisplayAt } from '../dimension-utils';
7
4
  import { getFormatedObservation } from '../observation-formater';
8
5
 
9
- const getLineCategory = (
10
- oDimensionValuesIndexes, dimensions, timePeriodDimensionIndex, dimensionsWithValuesIndexedById
11
- ) => (
12
- reduce(
13
- oDimensionValuesIndexes,
14
- (memo, dimensionValueIndex, dimensionIndex) => {
15
- const dimension = get(dimensions, `[${dimensionIndex}]`, {});
16
- if ((dimensionIndex !== timePeriodDimensionIndex) && (has(dimensionsWithValuesIndexedById, dimension.id))) {
17
- return concat(
18
- memo, get(dimensions, `[${dimensionIndex}].values[${dimensionValueIndex}].name`, '')
19
- );
20
- }
21
- return memo;
22
- },
23
- []
24
- ).join(' - ')
25
- );
26
-
27
- const getLineCategoryId = (
28
- oDimensionValuesIndexes, dimensions, timePeriodDimensionIndex, dimensionsWithValuesIndexedById
29
- ) => (
30
- reduce(
31
- oDimensionValuesIndexes,
32
- (memo, dimensionValueIndex, dimensionIndex) => {
33
- const dimension = get(dimensions, `[${dimensionIndex}]`, {});
34
- if ((dimensionIndex !== timePeriodDimensionIndex) && (has(dimensionsWithValuesIndexedById, dimension.id))) {
35
- return concat(
36
- memo, get(dimensions, `[${dimensionIndex}].values[${dimensionValueIndex}].id`, '')
37
- );
38
- }
39
- return memo;
40
- },
41
- []
42
- ).join(' - ')
43
- );
44
-
45
6
  const getDimensionValues = (splitObservationKey, dimensions, dimensionsWithValuesIndexedById, rejectedId, display) => (
46
7
  reduce(
47
8
  splitObservationKey,
@@ -1,4 +1,5 @@
1
1
  import * as R from 'ramda';
2
+ import { REPORTING_YEAR_START_DAY, REPYEARSTART } from '../constants';
2
3
 
3
4
  export const getReportingYearStart = (sdmxJson) => {
4
5
  const attributes = R.pipe(
@@ -6,7 +7,9 @@ export const getReportingYearStart = (sdmxJson) => {
6
7
  ({ dataSet=[], observation=[], series=[] }) => [...dataSet, ...observation, ...series]
7
8
  )(sdmxJson);
8
9
 
9
- const reportYearStartAttr = R.find(R.propEq('id', 'REPORTING_YEAR_START_DAY'), attributes) || {};
10
+ const reportYearStartAttr = R.find(({ id }) => {
11
+ return id === REPORTING_YEAR_START_DAY || id === REPYEARSTART;
12
+ }, attributes) || {};
10
13
  const reportYearStart = R.pathOr('--01-01', ['values', 0, 'name'], reportYearStartAttr);
11
14
  const [month, day] = R.match(/[\d]{2}/g, reportYearStart);
12
15
  return ({ month, day });
@@ -3,7 +3,6 @@ import { isRefAreaDimension } from '@sis-cc/dotstatsuite-sdmxjs';
3
3
  import { SCATTER } from '../constants';
4
4
  import {
5
5
  artefactToOption,
6
- chartDimensionOptions,
7
6
  getDimensionsWithValues,
8
7
  getPropertyDimension,
9
8
  toState,
@@ -1,4 +1,5 @@
1
1
  import * as R from 'ramda';
2
+ import { REPORTING_YEAR_START_DAY, REPYEARSTART } from '../../constants';
2
3
 
3
4
  const registerAttrId = (path, id) => R.over(
4
5
  R.lensPath(R.prepend('attributesIdsIndexedByTargets', path)),
@@ -85,6 +86,7 @@ export const parseAttributes = ({ attributes, parsedDimensionsIds, customAttribu
85
86
  if (R.isEmpty(values) || !R.propOr(true, 'display', attribute) || R.includes(attribute.id, R.propOr([], 'units', customAttributes))) {
86
87
  return acc;
87
88
  }
89
+ if (R.includes(attribute.id, [REPORTING_YEAR_START_DAY, REPYEARSTART])) return acc;
88
90
 
89
91
  const registers = getAttributeRegisters(
90
92
  R.pipe(
@@ -1,18 +1,15 @@
1
1
  import * as R from 'ramda';
2
2
  import dateFns from 'date-fns';
3
- import { getCodeOrder, isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
3
+ import { getCodeOrder, getRefinedName, isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
4
4
  import {
5
- getRelationnalAnnotations, setAnnotationsLayout, getIsHidden, hiddenFormat } from './sdmx-data';
5
+ getRelationnalAnnotations, setAnnotationsLayout, getIsHidden } from './sdmx-data';
6
6
  import { getReportedTimePeriodLabel } from './date';
7
7
  import { getReportingYearStart } from './preparators/getReportingYearStart';
8
8
  import { getNotDisplayedIds } from '../../rules2/src';
9
9
 
10
10
  export const dataTransformer = (dataNew, options = {}) => {
11
- const getLanguage = R.pipe(R.pathOr('', ['meta', 'contentLanguages']), R.head());
12
- const locale = getLanguage(dataNew);
11
+ const { locale } = options;
13
12
  const reportYearStart = getReportingYearStart(dataNew);
14
- const getProp = (prop, locale) => R.pathOr(null,[prop, locale]);
15
- const getLocalisedProp = R.curry((prop, collection) => getProp(prop, locale)(collection));
16
13
 
17
14
  //---------------------------------------------------------------------------------------Annotations
18
15
  const getStructure = R.pathOr({},['data', 'structure']);
@@ -32,7 +29,7 @@ export const dataTransformer = (dataNew, options = {}) => {
32
29
  return ({
33
30
  ...value,
34
31
  display: !R.has(`${parent}.${value.id}`, hiddenIds) && !getIsHidden(valAnnotations),
35
- name: getLocalisedProp('names', value)
32
+ name: getRefinedName(value)
36
33
  });
37
34
  }, values);
38
35
 
@@ -44,7 +41,7 @@ export const dataTransformer = (dataNew, options = {}) => {
44
41
  R.flip(R.props)(annotations)
45
42
  )(value);
46
43
  const isHidden = R.has(`${parent}.${value.id}`, hiddenIds) || getIsHidden(valueAnnotations);
47
- const name = getLocalisedProp('names')(value);
44
+ const name = getRefinedName(value);
48
45
  let __indexPosition = NaN;
49
46
  let start = null;
50
47
  if (isTimeDimension) {
@@ -55,7 +52,7 @@ export const dataTransformer = (dataNew, options = {}) => {
55
52
  __indexPosition = dateFns.getTime(new Date(R.prop('start', value)));
56
53
  }
57
54
  if (isNaN(__indexPosition)) {
58
- __indexPosition = getCodeOrder(locale)({ annotations: valueAnnotations });
55
+ __indexPosition = getCodeOrder({ annotations: valueAnnotations });
59
56
  }
60
57
  const timeFormat = R.prop('timeFormat', options);
61
58
  return ({
@@ -90,7 +87,7 @@ export const dataTransformer = (dataNew, options = {}) => {
90
87
 
91
88
  const resHeader = {
92
89
  ...meta,
93
- sender: {...sender, name: getLocalisedProp('names', sender)},
90
+ sender: {...sender, name: getRefinedName(sender)},
94
91
  };
95
92
 
96
93
  //----------------------------------------------------------------------------------------Attributes
@@ -105,7 +102,7 @@ export const dataTransformer = (dataNew, options = {}) => {
105
102
  return ({
106
103
  ...observation,
107
104
  display: !R.has(observation.id, hiddenIds) && !getIsHidden(obsAnnotations),
108
- name: getLocalisedProp('names', observation),
105
+ name: getRefinedName(observation),
109
106
  values: getValues(observation.values || [], observation.id),
110
107
  roles: !R.isNil(observation.role) ? R.head(observation.role) : null,
111
108
  });
@@ -117,7 +114,7 @@ export const dataTransformer = (dataNew, options = {}) => {
117
114
  return ({
118
115
  ...attr,
119
116
  display: !R.has(attr.id, hiddenIds) && !getIsHidden(attrAnnotations),
120
- name: getLocalisedProp('names', observation),
117
+ name: getRefinedName(observation),
121
118
  values: getValues(attr.values || [], attr.id)
122
119
  });
123
120
  },
@@ -173,7 +170,7 @@ export const dataTransformer = (dataNew, options = {}) => {
173
170
  ...observation,
174
171
  display: !isHidden,
175
172
  __index: obsIndex,
176
- name: getLocalisedProp('names', observation),
173
+ name: getRefinedName(observation),
177
174
  values: sortedValues,
178
175
  role: R.isNil(observation.roles) ? null : R.head(observation.roles),
179
176
  })(acc.observation),
@@ -185,7 +182,7 @@ export const dataTransformer = (dataNew, options = {}) => {
185
182
  const { dimensionsLayout, observation } = getObservations(locale)(dimObservations);
186
183
  const resStructure = {
187
184
  ...structure,
188
- name: getLocalisedProp('names', structure),
185
+ name: getRefinedName({ ...structure, id: options.dataflowId }),
189
186
  annotations,
190
187
  attributes: resAttributes,
191
188
  dimensions: { observation },
@@ -1,14 +1,15 @@
1
1
  import * as R from 'ramda';
2
- import { getLocalisedName } from '@sis-cc/dotstatsuite-sdmxjs';
2
+ import { getRefinedName } from '@sis-cc/dotstatsuite-sdmxjs';
3
3
 
4
- const dimensionValueDisplay = (locale, display) => data => {
4
+ const dimensionValueDisplay = (display) => data => {
5
5
  if (display === 'code') {
6
6
  return R.prop('id', data);
7
7
  }
8
+ const name = getRefinedName(data);
8
9
  if (display === 'both') {
9
- return `${R.prop('id', data)}: ${getLocalisedName(locale)(data)}`;
10
+ return `${R.prop('id', data)}: ${name}`;
10
11
  }
11
- return getLocalisedName(locale)(data);
12
+ return name;
12
13
  };
13
14
  // options = { locale, display, dimensions = [], attributes = { [id]: { format, parent } } };
14
15
  export const parseMetadataSeries = (metadataJson, options) => {
@@ -56,7 +57,7 @@ export const parseMetadataSeries = (metadataJson, options) => {
56
57
  return acc;
57
58
  }
58
59
  const attribute = R.nth(attrIndex, metadataAttributes);
59
- const label = dimensionValueDisplay(options.locale, options.display)(attribute);
60
+ const label = dimensionValueDisplay(options.display)(attribute);
60
61
 
61
62
  const value = R.prop('value', R.nth(valueIndex, attribute.values || []));
62
63
 
@@ -33,11 +33,11 @@ const useStyles = makeStyles(() => ({
33
33
  }
34
34
  }));
35
35
 
36
- const ViewContent = ({ loading, noData = 'No Data', type, width, errorMessage, ...rest }) => {
37
- if (loading) return <Loading message={loading} />;
38
- if (!width) return <Loading message={loading} />;
36
+ const ViewContent = ({ loading, loadingProps={}, noData = 'No Data', type, width, errorMessage, ...rest }) => {
37
+ if (loading) return <Loading message={loading} {...loadingProps} />;
38
+ if (!width) return <Loading message={loading} {...loadingProps} />;
39
39
  if (errorMessage) return <NoData message={errorMessage} />;
40
-
40
+
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);
@@ -60,8 +60,8 @@ 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,
63
+ const classes = useStyles({
64
+ fixedWidth: rest.fixedWidth,
65
65
  fixedHeight: rest.fixedHeight
66
66
  });
67
67
  useEffect(() => {
@@ -74,7 +74,7 @@ const Viewer = ({ getResponsiveSize, setFooterOffset, setHeaderOffset, size, typ
74
74
  });
75
75
 
76
76
  return (
77
- <div
77
+ <div
78
78
  className={cx(classes.container, {
79
79
  [classes.tableContainer]: type === 'table',
80
80
  [classes.chartContainer]: type !== 'table'
@@ -0,0 +1,43 @@
1
+ import { expect } from 'chai';
2
+ import { getReportingYearStart } from '../src/rules/src/preparators/getReportingYearStart';
3
+
4
+ describe('getReportingYearStart tests', () => {
5
+ it('no data', () => {
6
+ expect(getReportingYearStart()).to.deep.equal({ month: '01', day: '01' });
7
+ });
8
+ it('REPORTING_YEAR_START_DAY', () => {
9
+ const dataReportingYearStartDay = {
10
+ data: {
11
+ structure: {
12
+ attributes: {
13
+ observation: [
14
+ {
15
+ "id": "REPORTING_YEAR_START_DAY",
16
+ "values": [{"name": "--07-01", "names": { "en": "--07-01" }}]
17
+ }
18
+ ]
19
+ }
20
+ }
21
+ }
22
+ };
23
+
24
+ expect(getReportingYearStart(dataReportingYearStartDay)).to.deep.equal({ month: '07', day: '01' });
25
+ });
26
+ it('REPYEARSTART', () => {
27
+ const dataReportingYearStart = {
28
+ data: {
29
+ structure: {
30
+ attributes: {
31
+ observation: [
32
+ {
33
+ "id": "REPYEARSTART",
34
+ "values": [{"name": "--08-09", "names": { "en": "--08-09" }}]
35
+ }
36
+ ]
37
+ }
38
+ }
39
+ }
40
+ };
41
+ expect(getReportingYearStart(dataReportingYearStart)).to.deep.equal({ month: '08', day: '09' });
42
+ });
43
+ });
@@ -157,7 +157,7 @@
157
157
  "dimensionGroup": [
158
158
  {
159
159
  "id": "METADATA_ATTR_0",
160
- "names": {"en": "Metadata Attribute 0"},
160
+ "name": "Metadata Attribute 0",
161
161
  "values": [
162
162
  { "value": "v0" },
163
163
  { "value": "v1" },
@@ -183,7 +183,7 @@
183
183
  },
184
184
  {
185
185
  "id": "METADATA_ATTR_1",
186
- "names": {"en": "Metadata Attribute 1"},
186
+ "name": "Metadata Attribute 1",
187
187
  "values": [
188
188
  { "value": "v0" },
189
189
  { "value": "v1" },
@@ -209,7 +209,7 @@
209
209
  },
210
210
  {
211
211
  "id": "METADATA_ATTR_2",
212
- "names": {"en": "Metadata Attribute 2"},
212
+ "name": "Metadata Attribute 2",
213
213
  "values": [
214
214
  { "value": "v0" },
215
215
  { "value": "v1" },
@@ -235,7 +235,7 @@
235
235
  },
236
236
  {
237
237
  "id": "METADATA_ATTR_3",
238
- "names": {"en": "Metadata Attribute 3"},
238
+ "name": "Metadata Attribute 3",
239
239
  "values": [
240
240
  { "value": "v0" },
241
241
  { "value": "v1" },
@@ -261,7 +261,7 @@
261
261
  },
262
262
  {
263
263
  "id": "METADATA_ATTR_4",
264
- "names": {"en": "Metadata Attribute 4"},
264
+ "name": "Metadata Attribute 4",
265
265
  "values": [
266
266
  { "value": "v0" },
267
267
  { "value": "v1" },
@@ -287,7 +287,7 @@
287
287
  },
288
288
  {
289
289
  "id": "METADATA_ATTR_5",
290
- "names": {"en": "Metadata Attribute 5"},
290
+ "name": "Metadata Attribute 5",
291
291
  "values": [
292
292
  { "value": "v0" },
293
293
  { "value": "v1" },
@@ -313,7 +313,7 @@
313
313
  },
314
314
  {
315
315
  "id": "METADATA_ATTR_6",
316
- "names": {"en": "Metadata Attribute 6"},
316
+ "name": "Metadata Attribute 6",
317
317
  "values": [
318
318
  { "value": "v0" },
319
319
  { "value": "v1" },
@@ -339,7 +339,7 @@
339
339
  },
340
340
  {
341
341
  "id": "METADATA_ATTR_7",
342
- "names": {"en": "Metadata Attribute 7"},
342
+ "name": "Metadata Attribute 7",
343
343
  "values": [
344
344
  { "value": "v0" },
345
345
  { "value": "v1" },
@@ -365,7 +365,7 @@
365
365
  },
366
366
  {
367
367
  "id": "METADATA_ATTR_8",
368
- "names": {"en": "Metadata Attribute 8"},
368
+ "name": "Metadata Attribute 8",
369
369
  "values": [
370
370
  { "value": "v0" },
371
371
  { "value": "v1" },
@@ -391,7 +391,7 @@
391
391
  },
392
392
  {
393
393
  "id": "METADATA_ATTR_9",
394
- "names": {"en": "Metadata Attribute 9"},
394
+ "name": "Metadata Attribute 9",
395
395
  "values": [
396
396
  { "value": "v0" },
397
397
  { "value": "v1" },
@@ -417,7 +417,7 @@
417
417
  },
418
418
  {
419
419
  "id": "METADATA_ATTR_10",
420
- "names": {"en": "Metadata Attribute 10"},
420
+ "name": "Metadata Attribute 10",
421
421
  "values": [
422
422
  { "value": "v0" },
423
423
  { "value": "v1" },
@@ -443,7 +443,7 @@
443
443
  },
444
444
  {
445
445
  "id": "METADATA_ATTR_11",
446
- "names": {"en": "Metadata Attribute 11"},
446
+ "name": "Metadata Attribute 11",
447
447
  "values": [
448
448
  { "value": "v0" },
449
449
  { "value": "v1" },
@@ -469,7 +469,7 @@
469
469
  },
470
470
  {
471
471
  "id": "METADATA_ATTR_12",
472
- "names": {"en": "Metadata Attribute 12"},
472
+ "name": "Metadata Attribute 12",
473
473
  "values": [
474
474
  { "value": "v0" },
475
475
  { "value": "v1" },
@@ -495,7 +495,7 @@
495
495
  },
496
496
  {
497
497
  "id": "METADATA_ATTR_13",
498
- "names": {"en": "Metadata Attribute 13"},
498
+ "name": "Metadata Attribute 13",
499
499
  "values": [
500
500
  { "value": "v0" },
501
501
  { "value": "v1" },
@@ -521,7 +521,7 @@
521
521
  },
522
522
  {
523
523
  "id": "METADATA_ATTR_14",
524
- "names": {"en": "Metadata Attribute 14"},
524
+ "name": "Metadata Attribute 14",
525
525
  "values": [
526
526
  { "value": "v0" },
527
527
  { "value": "v1" },
@@ -547,7 +547,7 @@
547
547
  },
548
548
  {
549
549
  "id": "METADATA_ATTR_15",
550
- "names": {"en": "Metadata Attribute 15"},
550
+ "name": "Metadata Attribute 15",
551
551
  "values": [
552
552
  { "value": "v0" },
553
553
  { "value": "v1" },
@@ -573,7 +573,7 @@
573
573
  },
574
574
  {
575
575
  "id": "METADATA_ATTR_16",
576
- "names": {"en": "Metadata Attribute 16"},
576
+ "name": "Metadata Attribute 16",
577
577
  "values": [
578
578
  { "value": "v0" },
579
579
  { "value": "v1" },
@@ -599,7 +599,7 @@
599
599
  },
600
600
  {
601
601
  "id": "METADATA_ATTR_17",
602
- "names": {"en": "Metadata Attribute 17"},
602
+ "name": "Metadata Attribute 17",
603
603
  "values": [
604
604
  { "value": "v0" },
605
605
  { "value": "v1" },
@@ -625,7 +625,7 @@
625
625
  },
626
626
  {
627
627
  "id": "METADATA_ATTR_18",
628
- "names": {"en": "Metadata Attribute 18"},
628
+ "name": "Metadata Attribute 18",
629
629
  "values": [
630
630
  { "value": "v0" },
631
631
  { "value": "v1" },
@@ -651,7 +651,7 @@
651
651
  },
652
652
  {
653
653
  "id": "METADATA_ATTR_19",
654
- "names": {"en": "Metadata Attribute 19"},
654
+ "name": "Metadata Attribute 19",
655
655
  "values": [
656
656
  { "value": "v0" },
657
657
  { "value": "v1" },
@@ -25,6 +25,8 @@ const attributes = [
25
25
  { id: 'a20', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a20v1' }] }, // units attribute
26
26
  { id: 'a21', relationship: { dataflow: {} }, values: [{ id: 'a21v0' }] }, // alternative dataflow relationship
27
27
  { id: 'a22', relationship: { observation: {} }, values: [{ id: 'a22v0' }] }, // alternative observation relationship
28
+ { id: 'REPORTING_YEAR_START_DAY', relationship: { observation: {} }, values: [{ id: 'a22v0' }]},
29
+ { id: 'REPYEARSTART', relationship: { observation: {} }, values: [{ id: 'a22v0' }]},
28
30
  ];
29
31
 
30
32
  const customAttributes = {
@@ -1,55 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getDimensions = exports.isDisplayedFromOwnAnnotations = undefined;
7
-
8
- var _extends2 = require('babel-runtime/helpers/extends');
9
-
10
- var _extends3 = _interopRequireDefault(_extends2);
11
-
12
- var _ramda = require('ramda');
13
-
14
- var R = _interopRequireWildcard(_ramda);
15
-
16
- var _dotstatsuiteSdmxjs = require('@sis-cc/dotstatsuite-sdmxjs');
17
-
18
- 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; } }
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- var isDisplayedFromOwnAnnotations = exports.isDisplayedFromOwnAnnotations = function isDisplayedFromOwnAnnotations(artefact) {
23
- var artefactAnnotations = R.propOr([], 'annotations', artefact);
24
- return R.pipe(R.propOr([], 'annotations'), R.find(R.propEq('type', 'NOT_DISPLAYED')), R.isNil)(artefact);
25
- };
26
-
27
- // sdmxJson
28
-
29
- var getDimensions = exports.getDimensions = function getDimensions(sdmxJson) {
30
- var annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
31
- var locale = R.path([], ['meta', 'contentLanguage'], sdmxJson);
32
-
33
- var enhanceValues = R.addIndex(R.map)(function (val, __index) {
34
- var annotationsIndexes = R.propOr([], 'annotations', val);
35
- var valueAnnotations = R.props(annotationsIndexes, annotations);
36
-
37
- return (0, _extends3.default)({}, value, {
38
- __index: __index,
39
- annotations: valueAnnotations,
40
- name: R.pathOr('[' + val.id + ']', ['names', locale], val)
41
- });
42
- });
43
-
44
- return R.pipe(R.pathOr([], ['data', 'structure', 'dimensions']), R.addIndex(R.map)(function (dimension, __index) {
45
- var annotationsIndexes = R.propOr([], 'annotations', dimension);
46
- var dimensionAnnotations = R.props(annotationsIndexes, annotations);
47
-
48
- return (0, _extends3.default)({}, dimension, {
49
- __index: __index,
50
- name: R.pathOr('[' + val.id + ']', ['names', locale], val),
51
- annotations: dimensionAnnotations,
52
- values: enhanceValues(R.propOr([], 'values', dimension))
53
- });
54
- }))(sdmxJson);
55
- };
@@ -1,49 +0,0 @@
1
- import * as R from 'ramda';
2
- import {
3
- getCodeOrder,
4
- isTimePeriodDimension
5
- } from '@sis-cc/dotstatsuite-sdmxjs';
6
-
7
- export const isDisplayedFromOwnAnnotations = artefact => {
8
- const artefactAnnotations = R.propOr([], 'annotations', artefact);
9
- return R.pipe(
10
- R.propOr([], 'annotations'),
11
- R.find(R.propEq('type', 'NOT_DISPLAYED')),
12
- R.isNil
13
- )(artefact);
14
- };
15
-
16
- // sdmxJson
17
-
18
- export const getDimensions = sdmxJson => {
19
- const annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
20
- const locale = R.path([], ['meta', 'contentLanguage'], sdmxJson);
21
-
22
- const enhanceValues = R.addIndex(R.map)((val, __index) => {
23
- const annotationsIndexes = R.propOr([], 'annotations', val);
24
- const valueAnnotations = R.props(annotationsIndexes, annotations);
25
-
26
- return ({
27
- ...value,
28
- __index,
29
- annotations: valueAnnotations,
30
- name: R.pathOr(`[${val.id}]`, ['names', locale], val),
31
- });
32
- });
33
-
34
- return R.pipe(
35
- R.pathOr([], ['data', 'structure', 'dimensions']),
36
- R.addIndex(R.map)((dimension, __index) => {
37
- const annotationsIndexes = R.propOr([], 'annotations', dimension);
38
- const dimensionAnnotations = R.props(annotationsIndexes, annotations);
39
-
40
- return ({
41
- ...dimension,
42
- __index,
43
- name: R.pathOr(`[${val.id}]`, ['names', locale], val),
44
- annotations: dimensionAnnotations,
45
- values: enhanceValues(R.propOr([], 'values', dimension))
46
- });
47
- })
48
- )(sdmxJson);
49
- };