@sis-cc/dotstatsuite-components 15.0.18 → 15.0.20

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.
@@ -124,7 +124,7 @@ var getReportedTimePeriodLabel = exports.getReportedTimePeriodLabel = function g
124
124
  };
125
125
 
126
126
  var getReportedTimePeriod = exports.getReportedTimePeriod = function getReportedTimePeriod(reportYearStart, value, freq) {
127
- var start = dateWithoutTZ(new Date(R.prop('start', value)));
127
+ var start = new Date(R.prop('start', value));
128
128
  var end = dateWithoutTZ(new Date(R.prop('end', value)));
129
129
  if (reportYearStart.month === '01' && reportYearStart.day === '01') {
130
130
  return { start: start, end: end };
@@ -27,9 +27,10 @@ var getUnitsSeries = exports.getUnitsSeries = function getUnitsSeries(observatio
27
27
  R.map(function (obs) {
28
28
  series = R.over(R.lensProp(obs.units.serieKey), R.ifElse(R.isNil, R.always([obs.units]), R.append(obs.units)))(series);
29
29
  }, observations);
30
+ return R.reduce(function (_acc, key) {
31
+ var serie = series[key];
30
32
 
31
- return R.map(function (serie) {
32
- return R.reduce(function (acc, units) {
33
+ var _R$reduce = R.reduce(function (acc, units) {
33
34
  var unitsKeys = R.keys(units);
34
35
  if (R.isEmpty(acc.unitsKeys)) return { units: units, unitsKeys: unitsKeys };
35
36
  var communKeys = R.intersection(acc.unitsKeys, unitsKeys);
@@ -37,6 +38,12 @@ var getUnitsSeries = exports.getUnitsSeries = function getUnitsSeries(observatio
37
38
  units: getUnits(R.pick(communKeys, acc.units), R.pick(communKeys, units)),
38
39
  unitsKeys: communKeys
39
40
  };
40
- }, { unitsKeys: [], units: {} }, serie).units;
41
- })(series);
41
+ }, { unitsKeys: [], units: {} }, serie),
42
+ units = _R$reduce.units;
43
+
44
+ if (R.isEmpty(R.dissoc('serieKey', units))) {
45
+ return _acc;
46
+ }
47
+ return R.assoc(key, units, _acc);
48
+ }, {})(R.keys(series));
42
49
  };
@@ -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: (0, _date.dateWithoutTZ)(new Date(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: new Date(value.start) })))(name),
90
90
  start: start ? start.toISOString() : null,
91
91
  notes: notes,
92
92
  __indexPosition: __indexPosition,
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.18",
4
+ "version": "15.0.20",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -60,7 +60,7 @@ export const getReportedTimePeriodLabel = (freq, _format, locale) => (reportYear
60
60
  };
61
61
 
62
62
  export const getReportedTimePeriod = (reportYearStart, value, freq) => {
63
- let start = dateWithoutTZ(new Date(R.prop('start', value)));
63
+ let start = new Date(R.prop('start', value));
64
64
  let end = dateWithoutTZ(new Date(R.prop('end', value)));
65
65
  if(reportYearStart.month === '01' && reportYearStart.day === '01') {
66
66
  return ({ start, end });
@@ -15,17 +15,27 @@ export const getUnitsSeries = (observations) => {
15
15
  R.ifElse(R.isNil, R.always([obs.units]), R.append(obs.units))
16
16
  )(series);
17
17
  }, observations);
18
-
19
- return R.map(
20
- serie => R.reduce(
21
- (acc, units) => {
22
- const unitsKeys = R.keys(units);
23
- if (R.isEmpty(acc.unitsKeys)) return { units, unitsKeys }
24
- const communKeys = R.intersection(acc.unitsKeys, unitsKeys);
25
- return {
26
- units: getUnits(R.pick(communKeys, acc.units), R.pick(communKeys, units)),
27
- unitsKeys: communKeys,
28
- };
29
- }, { unitsKeys: [], units: {} }, serie).units
30
- )(series);
18
+ return R.reduce(
19
+ (_acc, key) => {
20
+ const serie = series[key];
21
+ const { units } = R.reduce(
22
+ (acc, units) => {
23
+ const unitsKeys = R.keys(units);
24
+ if (R.isEmpty(acc.unitsKeys)) return { units, unitsKeys }
25
+ const communKeys = R.intersection(acc.unitsKeys, unitsKeys);
26
+ return {
27
+ units: getUnits(R.pick(communKeys, acc.units), R.pick(communKeys, units)),
28
+ unitsKeys: communKeys,
29
+ };
30
+ },
31
+ { unitsKeys: [], units: {} },
32
+ serie
33
+ );
34
+ if (R.isEmpty(R.dissoc('serieKey', units))) {
35
+ return _acc;
36
+ }
37
+ return R.assoc(key, units, _acc);
38
+ },
39
+ {}
40
+ )(R.keys(series));
31
41
  };
@@ -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, dateWithoutTZ } from './date';
6
+ import { getReportedTimePeriodLabel, getReportedTimePeriodNote, getReportedTimePeriod } 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: dateWithoutTZ(new Date(value.start)) }))
78
+ R.always(getReportedTimePeriodLabel(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start: new Date(value.start) }))
79
79
  )(name),
80
80
  start: start ? start.toISOString() : null,
81
81
  notes,
@@ -61,6 +61,31 @@ describe('getUnitsSeries tests', () => {
61
61
  '2:0:x:x': { A: { value: { index: 2 } }, B: { value: { index: 0 } }, C: { value: { index: 0 } }, serieKey: '2:0:x:x' }
62
62
  });
63
63
  });
64
+ it('empty units test', () => {
65
+ const obs = {
66
+ 0: {
67
+ key: '0:0:0:0',
68
+ units: { serieKey: '0:0:x:x' }
69
+ },
70
+ 1: {
71
+ key: '0:0:1:0',
72
+ units: { serieKey: '0:0:x:x' }
73
+ },
74
+ 2: {
75
+ key: '1:0:0:0',
76
+ units: { serieKey: '1:0:x:x' }
77
+ },
78
+ 3: {
79
+ key: '1:0:1:0',
80
+ units: { serieKey: '1:0:x:x' }
81
+ },
82
+ 4: {
83
+ key: '2:0:0:0',
84
+ units: { serieKey: '2:0:x:x' }
85
+ }
86
+ };
87
+ expect(getUnitsSeries(obs)).to.deep.equal({});
88
+ });
64
89
  });
65
90
 
66
91
  describe('getUnitsSeries tests keys difference', () => {