@sis-cc/dotstatsuite-components 15.0.0 → 15.0.3

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.getTimePeriodLabel = exports.getReportedTimePeriodNote = exports.getReportedTimePeriod = exports.getReportedTimePeriodLabel = exports.getLocale = undefined;
6
+ exports.getTimePeriodLabel = exports.getReportedTimePeriodNote = exports.getReportedTimePeriod = exports.getReportedTimePeriodLabel = exports.getLocale = exports.dateWithoutTZ = undefined;
7
7
 
8
8
  var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
9
9
 
@@ -59,6 +59,10 @@ var isValidDate = function isValidDate(period) {
59
59
  })(new Date(period));
60
60
  };
61
61
 
62
+ var dateWithoutTZ = exports.dateWithoutTZ = function dateWithoutTZ(date) {
63
+ return _dateFns2.default.addMinutes(date, date.getTimezoneOffset());
64
+ };
65
+
62
66
  var getLocale = exports.getLocale = R.cond([[R.equals('fr'), R.always(_fr2.default)], [R.equals('de'), R.always(_de2.default)], [R.equals('es'), R.always(_es2.default)], [R.equals('ar'), R.always(_ar2.default)], [R.equals('it'), R.always(_it2.default)], [R.equals('nl'), R.always(_nl2.default)], [R.equals('th'), R.always(_th2.default)], [R.T, R.always(_en2.default)]]);
63
67
 
64
68
  var formaterPeriod = function formaterPeriod(locale, format) {
@@ -120,8 +124,8 @@ var getReportedTimePeriodLabel = exports.getReportedTimePeriodLabel = function g
120
124
  };
121
125
 
122
126
  var getReportedTimePeriod = exports.getReportedTimePeriod = function getReportedTimePeriod(reportYearStart, value, freq) {
123
- var start = new Date(R.prop('start', value));
124
- var end = new Date(R.prop('end', value));
127
+ var start = dateWithoutTZ(new Date(R.prop('start', value)));
128
+ var end = dateWithoutTZ(new Date(R.prop('end', value)));
125
129
  if (reportYearStart.month === '01' && reportYearStart.day === '01') {
126
130
  return { start: start, end: end };
127
131
  }
@@ -86,9 +86,7 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
86
86
  //------------------------------------------------------------------
87
87
  var unitsArtefacts = (0, _getUnitsArtefacts.getUnitsArtefacts)({ unitsDefinitionCodes: unitsDefinitionCodes, data: sdmxJson });
88
88
  var headerUnits = (0, _getHeaderUnits.getHeaderUnits)({ unitsArtefacts: unitsArtefacts, unitsDefinitionCodes: unitsDefinitionCodes, rejectedValueIds: rejectedValueIds });
89
- var _dimensions = R.pipe(R.pathOr([], ['data', 'structure', 'dimensions', 'observation']), R.addIndex(R.map)(function (dim, index) {
90
- return R.assoc('index', index, dim);
91
- }), R.indexBy(R.prop('id')))(sdmxJson);
89
+ var _dimensions = R.pipe(R.pathOr([], ['data', 'structure', 'dimensions', 'observation']), R.indexBy(R.prop('id')))(sdmxJson);
92
90
  var attachmentSeriesIndexes = (0, _getAttachmentSeriesIndexes.getAttachmentSeriesIndexes)({ dimensions: _dimensions, unitsArtefacts: unitsArtefacts });
93
91
  //------------------------------------------------------------------
94
92
 
@@ -21,5 +21,5 @@ var getAttachmentSeriesIndexes = exports.getAttachmentSeriesIndexes = function g
21
21
 
22
22
  return R.pipe(R.props(R.concat(unitsDimensionsCodes, targettedDimensionsCodes)), R.filter(function (dim) {
23
23
  return !R.isNil(dim);
24
- }), R.pluck('index'), R.uniq, R.sortBy(R.identity))(dimensions);
24
+ }), R.pluck('__index'), R.uniq, R.sortBy(R.identity))(dimensions);
25
25
  };
@@ -86,7 +86,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
86
86
  return (0, _extends3.default)({}, value, {
87
87
  id: R.pipe(R.when(R.isNil, R.always(parent + '-' + __index)), R.when(R.always(isTimeDimension), R.replace(/M/g, '')))(value.id),
88
88
  display: !isHidden,
89
- name: R.when(R.always(isTimeDimension), R.always((0, _date.getReportedTimePeriodLabel)(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start: value.start })))(name),
89
+ name: R.when(R.always(isTimeDimension), R.always((0, _date.getReportedTimePeriodLabel)(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start: (0, _date.dateWithoutTZ)(new Date(value.start)) })))(name),
90
90
  start: start ? start.toISOString() : null,
91
91
  notes: notes,
92
92
  __indexPosition: __indexPosition,
@@ -12,6 +12,10 @@ var R = _interopRequireWildcard(_ramda);
12
12
  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
13
 
14
14
  var duplicateObs = exports.duplicateObs = function duplicateObs(dims, observations) {
15
+ var obsValues = R.values(observations);
16
+ if (R.length(obsValues) < 2 || R.length(dims) === 0) {
17
+ return observations;
18
+ }
15
19
  var duplicated = R.reduce(function (obs, dim) {
16
20
  var groupedObs = R.groupBy(function (o) {
17
21
  return R.prop(dim.id, o.indexedDimValIds);
@@ -29,7 +33,7 @@ var duplicateObs = exports.duplicateObs = function duplicateObs(dims, observatio
29
33
  }, matchingObs);
30
34
  }, dim.values);
31
35
  return R.unnest(enhancedObs);
32
- }, R.values(observations), dims);
36
+ }, obsValues, dims);
33
37
  var res = R.indexBy(R.pipe(R.prop('orderedDimIndexes'), R.join(':')), duplicated);
34
38
  return res;
35
39
  };
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.0",
4
+ "version": "15.0.3",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -12,6 +12,8 @@ import th from 'date-fns/locale/th';
12
12
  const isValidDate = period =>
13
13
  R.and(dateFns.isDate, date => R.not(R.equals(date.getTime(date), NaN)))(new Date(period));
14
14
 
15
+ export const dateWithoutTZ = date => dateFns.addMinutes(date, date.getTimezoneOffset());
16
+
15
17
  export const getLocale = R.cond([
16
18
  [R.equals('fr'), R.always(fr)],
17
19
  [R.equals('de'), R.always(de)],
@@ -58,8 +60,8 @@ export const getReportedTimePeriodLabel = (freq, _format, locale) => (reportYear
58
60
  };
59
61
 
60
62
  export const getReportedTimePeriod = (reportYearStart, value, freq) => {
61
- let start = new Date(R.prop('start', value));
62
- let end = new Date(R.prop('end', value));
63
+ let start = dateWithoutTZ(new Date(R.prop('start', value)));
64
+ let end = dateWithoutTZ(new Date(R.prop('end', value)));
63
65
  if(reportYearStart.month === '01' && reportYearStart.day === '01') {
64
66
  return ({ start, end });
65
67
  }
@@ -50,7 +50,6 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}, _options=
50
50
  const headerUnits = getHeaderUnits({ unitsArtefacts, unitsDefinitionCodes, rejectedValueIds });
51
51
  const _dimensions = R.pipe(
52
52
  R.pathOr([], ['data', 'structure', 'dimensions', 'observation']),
53
- R.addIndex(R.map)((dim, index) => R.assoc('index', index, dim)),
54
53
  R.indexBy(R.prop('id'))
55
54
  )(sdmxJson);
56
55
  const attachmentSeriesIndexes = getAttachmentSeriesIndexes({ dimensions: _dimensions, unitsArtefacts });
@@ -2,7 +2,7 @@ import * as R from 'ramda';
2
2
 
3
3
  export const getAttachmentSeriesIndexes = ({
4
4
  unitsArtefacts,
5
- dimensions // { id: { index, ...dim } }
5
+ dimensions // { id: { __index, ...dim } }
6
6
  }) => {
7
7
  const targettedDimensionsCodes = R.pipe(
8
8
  R.pathOr({}, ['attributes', 'series']),
@@ -20,7 +20,7 @@ export const getAttachmentSeriesIndexes = ({
20
20
  return R.pipe(
21
21
  R.props(R.concat(unitsDimensionsCodes, targettedDimensionsCodes)),
22
22
  R.filter(dim => !R.isNil(dim)),
23
- R.pluck('index'),
23
+ R.pluck('__index'),
24
24
  R.uniq,
25
25
  R.sortBy(R.identity)
26
26
  )(dimensions);
@@ -3,7 +3,7 @@ import dateFns from 'date-fns';
3
3
  import { getCodeOrder, getRefinedName, isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
4
4
  import {
5
5
  getRelationnalAnnotations, setAnnotationsLayout, getIsHidden } from './sdmx-data';
6
- import { getReportedTimePeriodLabel, getReportedTimePeriodNote, getReportedTimePeriod } from './date';
6
+ import { getReportedTimePeriodLabel, getReportedTimePeriodNote, getReportedTimePeriod, dateWithoutTZ } from './date';
7
7
  import { getReportingYearStart } from './preparators/getReportingYearStart';
8
8
  import { getNotDisplayedIds } from '../../rules2/src';
9
9
 
@@ -75,7 +75,7 @@ export const dataTransformer = (dataNew, options = {}) => {
75
75
  display: !isHidden,
76
76
  name: R.when(
77
77
  R.always(isTimeDimension),
78
- R.always(getReportedTimePeriodLabel(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start:value.start }))
78
+ R.always(getReportedTimePeriodLabel(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start: dateWithoutTZ(new Date(value.start)) }))
79
79
  )(name),
80
80
  start: start ? start.toISOString() : null,
81
81
  notes,
@@ -1,6 +1,10 @@
1
1
  import * as R from 'ramda';
2
2
 
3
3
  export const duplicateObs = (dims, observations) => {
4
+ const obsValues = R.values(observations);
5
+ if ((R.length(obsValues) < 2) || R.length(dims) === 0) {
6
+ return observations;
7
+ }
4
8
  const duplicated = R.reduce(
5
9
  (obs, dim) => {
6
10
  const groupedObs = R.groupBy(o => R.prop(dim.id, o.indexedDimValIds), obs);
@@ -23,7 +27,7 @@ export const duplicateObs = (dims, observations) => {
23
27
  );
24
28
  return R.unnest(enhancedObs);
25
29
  },
26
- R.values(observations),
30
+ obsValues,
27
31
  dims
28
32
  );
29
33
  const res = R.indexBy(R.pipe(R.prop('orderedDimIndexes'), R.join(':')), duplicated);