@sis-cc/dotstatsuite-components 13.5.6 → 14.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.
|
@@ -31,6 +31,8 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
31
31
|
|
|
32
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
33
|
|
|
34
|
+
var TIME_PERIOD_ID = 'TIME_PERIOD';
|
|
35
|
+
|
|
34
36
|
var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew) {
|
|
35
37
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
36
38
|
var locale = options.locale;
|
|
@@ -142,14 +144,15 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
|
|
|
142
144
|
|
|
143
145
|
var getDimObservations = R.propOr([], 'observation');
|
|
144
146
|
var dimObservations = getDimObservations(dimensions);
|
|
147
|
+
var timePeriodDimension = (0, _dotstatsuiteSdmxjs.getTimePeriodObservation)(dimObservations);
|
|
148
|
+
var timePeriodId = timePeriodDimension.id;
|
|
145
149
|
|
|
146
150
|
var getObservations = function getObservations(locale) {
|
|
147
151
|
return R.addIndex(R.reduce)(function (acc, observation, obsIndex) {
|
|
148
152
|
var id = R.prop('id')(observation);
|
|
149
153
|
var dimAnnotations = (0, _sdmxData.getRelationnalAnnotations)(R.propOr([], 'annotations')(observation))(annotations);
|
|
150
154
|
var isHidden = R.has(id, hiddenIds) || (0, _sdmxData.getIsHidden)(dimAnnotations);
|
|
151
|
-
var isTime =
|
|
152
|
-
|
|
155
|
+
var isTime = observation.id === timePeriodId;
|
|
153
156
|
var values = getValuesEnhanced(locale, annotations, isTime, id)(R.propOr([], 'values', observation));
|
|
154
157
|
var ids = R.pipe(R.pluck('id'), R.indexBy(R.identity))(values);
|
|
155
158
|
var groupedByParentsValues = R.groupBy(function (val) {
|
|
@@ -178,7 +181,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
|
|
|
178
181
|
__index: obsIndex,
|
|
179
182
|
name: (0, _dotstatsuiteSdmxjs.getRefinedName)(observation),
|
|
180
183
|
values: sortedValues,
|
|
181
|
-
role:
|
|
184
|
+
role: isTime ? TIME_PERIOD_ID : R.head(R.propOr([], 'roles', observation))
|
|
182
185
|
}))(acc.observation),
|
|
183
186
|
dimensionsLayout: (0, _sdmxData.setAnnotationsLayout)(id, acc.dimensionsLayout)(dimAnnotations)
|
|
184
187
|
};
|
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": "
|
|
4
|
+
"version": "14.0.0",
|
|
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": "^
|
|
40
|
+
"@sis-cc/dotstatsuite-sdmxjs": "^7.x",
|
|
41
41
|
"react": "16.x"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import dateFns from 'date-fns';
|
|
3
|
-
import { getCodeOrder, getRefinedName,
|
|
3
|
+
import { getCodeOrder, getRefinedName, getTimePeriodObservation } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
4
4
|
import {
|
|
5
5
|
getRelationnalAnnotations, setAnnotationsLayout, getIsHidden } from './sdmx-data';
|
|
6
6
|
import { getReportedTimePeriodLabel, getReportedTimePeriodNote, getReportedTimePeriod } from './date';
|
|
7
7
|
import { getReportingYearStart } from './preparators/getReportingYearStart';
|
|
8
8
|
import { getNotDisplayedIds } from '../../rules2/src';
|
|
9
9
|
|
|
10
|
+
const TIME_PERIOD_ID = 'TIME_PERIOD';
|
|
11
|
+
|
|
10
12
|
export const dataTransformer = (dataNew, options = {}) => {
|
|
11
13
|
const { locale } = options;
|
|
12
14
|
const reportYearStart = getReportingYearStart(dataNew);
|
|
@@ -136,13 +138,14 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
136
138
|
|
|
137
139
|
const getDimObservations = R.propOr([], 'observation');
|
|
138
140
|
const dimObservations = getDimObservations(dimensions);
|
|
141
|
+
const timePeriodDimension = getTimePeriodObservation(dimObservations);
|
|
142
|
+
const timePeriodId = timePeriodDimension.id;
|
|
139
143
|
|
|
140
144
|
const getObservations = locale => R.addIndex(R.reduce)((acc, observation, obsIndex) => {
|
|
141
145
|
const id = R.prop('id')(observation);
|
|
142
146
|
const dimAnnotations = getRelationnalAnnotations(R.propOr([],'annotations')(observation))(annotations)
|
|
143
147
|
const isHidden = R.has(id, hiddenIds) || getIsHidden(dimAnnotations);
|
|
144
|
-
const isTime =
|
|
145
|
-
|
|
148
|
+
const isTime = observation.id === timePeriodId;
|
|
146
149
|
const values = getValuesEnhanced(locale, annotations, isTime, id)(R.propOr([],'values', observation));
|
|
147
150
|
const ids = R.pipe(R.pluck('id'), R.indexBy(R.identity))(values);
|
|
148
151
|
const groupedByParentsValues = R.groupBy(val => {
|
|
@@ -176,7 +179,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
176
179
|
__index: obsIndex,
|
|
177
180
|
name: getRefinedName(observation),
|
|
178
181
|
values: sortedValues,
|
|
179
|
-
role:
|
|
182
|
+
role: isTime ? TIME_PERIOD_ID : R.head(R.propOr([], 'roles', observation)),
|
|
180
183
|
})(acc.observation),
|
|
181
184
|
dimensionsLayout: setAnnotationsLayout(id, acc.dimensionsLayout)(dimAnnotations),
|
|
182
185
|
});
|