@sis-cc/dotstatsuite-components 17.12.6 → 17.14.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.
- package/lib/rules/src/get-values-enhanced.js +1 -1
- package/lib/rules/src/v8-transformer.js +6 -6
- package/lib/rules2/src/{hierarchiseDimensionWithAdvancedHierarchy.js → hierarchiseDimensionWithAdvancedHierarchy2.js} +22 -17
- package/lib/rules2/src/{hierarchiseDimensionWithNativeHierarchy.js → hierarchiseDimensionWithNativeHierarchy2.js} +10 -5
- package/lib/rules2/src/index.js +21 -21
- package/lib/rules2/src/parseMetadataSeries.js +1 -3
- package/lib/rules2/src/prepareData.js +2 -2
- package/lib/rules2/src/refineDimensions.js +3 -6
- package/lib/rules2/src/table/getLayoutData2.js +218 -0
- package/lib/rules2/src/table/getTableProps.js +6 -9
- package/lib/rules2/src/table/parseSeriesIndexesHierarchies.js +96 -0
- package/lib/rules2/src/table/{refineLayoutSize.js → refineLayoutSize2.js} +53 -34
- package/package.json +1 -1
- package/src/rules/src/get-values-enhanced.js +33 -33
- package/src/rules/src/v8-transformer.js +6 -7
- package/src/rules2/src/{hierarchiseDimensionWithAdvancedHierarchy.js → hierarchiseDimensionWithAdvancedHierarchy2.js} +24 -23
- package/src/rules2/src/{hierarchiseDimensionWithNativeHierarchy.js → hierarchiseDimensionWithNativeHierarchy2.js} +31 -28
- package/src/rules2/src/index.js +5 -6
- package/src/rules2/src/parseMetadataSeries.js +5 -6
- package/src/rules2/src/prepareData.js +2 -2
- package/src/rules2/src/refineDimensions.js +3 -6
- package/src/rules2/src/table/getLayoutData2.js +175 -0
- package/src/rules2/src/table/getTableProps.js +8 -4
- package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +62 -0
- package/src/rules2/src/table/{refineLayoutSize.js → refineLayoutSize2.js} +50 -21
- package/test/getLayoutData2.test.js +268 -0
- package/test/{hierarchiseDimensionWithAdvancedHierarchy.test.js → hierarchiseDimensionWithAdvancedHierarchy2.test.js} +34 -69
- package/test/{hierarchiseDimensionWithNativeHierarchy.test.js → hierarchiseDimensionWithNativeHierarchy2.test.js} +14 -14
- package/test/parseSeriesIndexesHierarchies.test.js +104 -0
- package/test/{refineLayoutSize.test.js → refineLayoutSize2.test.js} +63 -64
- package/test/refinedDimensions.test.js +8 -8
- package/lib/rules2/src/getSidebarData.js +0 -92
- package/lib/rules2/src/table/getLayoutData.js +0 -209
- package/src/rules2/src/getSidebarData.js +0 -85
- package/src/rules2/src/table/getLayoutData.js +0 -193
- package/test/getLayoutData.test.js +0 -284
- package/test/getSidebarData.test.js +0 -322
|
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.refineLayoutSize = exports.truncateHeader = exports.truncateSectionRows = exports.refineHeader = exports.refineSections = exports.getCuratedCells = undefined;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _extends3 = require('babel-runtime/helpers/extends');
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _extends4 = _interopRequireDefault(_extends3);
|
|
19
19
|
|
|
20
20
|
var _ramda = require('ramda');
|
|
21
21
|
|
|
@@ -62,9 +62,9 @@ var getCuratedCells = exports.getCuratedCells = function getCuratedCells(_ref) {
|
|
|
62
62
|
|
|
63
63
|
var refineSections = exports.refineSections = function refineSections(sections, extractedKeys, curatedObs) {
|
|
64
64
|
return R.pipe(R.map(function (section) {
|
|
65
|
-
var sectionKey = toKey(R.head(section)
|
|
66
|
-
return R.over(R.lensIndex(1), R.filter(function (
|
|
67
|
-
var rowKey = toKey(
|
|
65
|
+
var sectionKey = toKey(R.propOr([], 'indexes', R.head(section)));
|
|
66
|
+
return R.over(R.lensIndex(1), R.filter(function (row) {
|
|
67
|
+
var rowKey = toKey(R.prop('indexes', row));
|
|
68
68
|
return R.pipe(R.path([sectionKey, rowKey]), R.omit(extractedKeys), R.isEmpty, R.not)(curatedObs);
|
|
69
69
|
}))(section);
|
|
70
70
|
}), R.filter(R.pipe(R.nth(1), R.isEmpty, R.not)))(sections);
|
|
@@ -73,7 +73,7 @@ var refineSections = exports.refineSections = function refineSections(sections,
|
|
|
73
73
|
var refineHeader = exports.refineHeader = function refineHeader(header, extractedKeys, curatedObs) {
|
|
74
74
|
return R.filter( // extracted : { [sectionKey]: [...rowKeys] }
|
|
75
75
|
function (header) {
|
|
76
|
-
var headerKey = toKey(header);
|
|
76
|
+
var headerKey = toKey(R.prop('indexes', header));
|
|
77
77
|
return R.pipe(R.prop(headerKey), function (sections) {
|
|
78
78
|
return R.pickBy(function (rows, section) {
|
|
79
79
|
return R.pipe(R.omit(R.propOr([], section, extractedKeys)), R.isEmpty, R.not)(rows);
|
|
@@ -82,6 +82,12 @@ var refineHeader = exports.refineHeader = function refineHeader(header, extracte
|
|
|
82
82
|
})(header);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
var getSerieLinesCount = function getSerieLinesCount(serie) {
|
|
86
|
+
var missingParents = R.propOr([], 'missingParents', serie);
|
|
87
|
+
var missingParentsRowsCount = R.pipe(R.flatten, R.length)(missingParents);
|
|
88
|
+
return missingParentsRowsCount + 1;
|
|
89
|
+
};
|
|
90
|
+
|
|
85
91
|
var truncateSectionRows = exports.truncateSectionRows = function truncateSectionRows(n, sectionsData) {
|
|
86
92
|
var truncated = sectionsData;
|
|
87
93
|
var extractedKeys = {};
|
|
@@ -90,33 +96,40 @@ var truncateSectionRows = exports.truncateSectionRows = function truncateSection
|
|
|
90
96
|
var lastSection = R.last(truncated);
|
|
91
97
|
var rows = lastSection[1];
|
|
92
98
|
var rowsLength = R.length(rows);
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
} else {
|
|
99
|
+
var truncatedRowsCount = 0;
|
|
100
|
+
while (_n > 0 && truncatedRowsCount !== rowsLength) {
|
|
101
|
+
var rowsCount = getSerieLinesCount(R.nth(-1 * truncatedRowsCount, rows));
|
|
102
|
+
_n = _n - rowsCount;
|
|
103
|
+
truncatedRowsCount++;
|
|
104
|
+
}
|
|
105
|
+
var sectionKey = R.pipe(R.head, R.prop('indexes'), toKey)(lastSection);
|
|
106
|
+
extractedKeys = (0, _extends4.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.pipe(R.takeLast(truncatedRowsCount), R.map(function (r) {
|
|
107
|
+
return toKey(R.prop('indexes', r));
|
|
108
|
+
}))(rows)));
|
|
109
|
+
if (_n > 0) {
|
|
105
110
|
truncated = R.dropLast(1, truncated);
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
} else {
|
|
112
|
+
truncated = R.over(R.lensIndex(-1), R.over(R.lensIndex(1), R.dropLast(truncatedRowsCount)))(truncated);
|
|
108
113
|
}
|
|
109
114
|
}
|
|
110
115
|
return { truncated: truncated, extractedKeys: extractedKeys };
|
|
111
116
|
};
|
|
112
117
|
|
|
113
118
|
var truncateHeader = exports.truncateHeader = function truncateHeader(n, headerData) {
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
extracted = _R$splitAt4[1];
|
|
119
|
+
var _truncated$extractedK = { truncated: headerData, extractedKeys: [] },
|
|
120
|
+
truncated = _truncated$extractedK.truncated,
|
|
121
|
+
extractedKeys = _truncated$extractedK.extractedKeys;
|
|
118
122
|
|
|
119
|
-
|
|
123
|
+
var _n = n;
|
|
124
|
+
while (_n > 0) {
|
|
125
|
+
var lastHeader = R.last(truncated);
|
|
126
|
+
var columnsCount = getSerieLinesCount(lastHeader);
|
|
127
|
+
var extractedKey = toKey(R.prop('indexes', lastHeader));
|
|
128
|
+
extractedKeys = R.append(extractedKey, extractedKeys);
|
|
129
|
+
truncated = R.dropLast(1, truncated);
|
|
130
|
+
_n = _n - columnsCount;
|
|
131
|
+
}
|
|
132
|
+
return { truncated: truncated, extractedKeys: extractedKeys };
|
|
120
133
|
};
|
|
121
134
|
|
|
122
135
|
var truncateLayout = function truncateLayout(isVertical) {
|
|
@@ -153,11 +166,14 @@ var refineLayoutSize = exports.refineLayoutSize = function refineLayoutSize(_ref
|
|
|
153
166
|
|
|
154
167
|
//number of dimensions in header
|
|
155
168
|
var headerDimCount = R.pipe(R.head, // first column
|
|
156
|
-
R.when(R.isNil, R.always([])
|
|
169
|
+
R.when(R.isNil, R.always({})), R.propOr([], 'indexes'), R.length // number of dims
|
|
157
170
|
)(header);
|
|
158
171
|
|
|
159
172
|
//number of columns for values
|
|
160
|
-
var headerValuesCount = R.pipe(R.
|
|
173
|
+
var headerValuesCount = R.pipe(R.reduce(function (acc, header) {
|
|
174
|
+
var columnsCount = getSerieLinesCount(header);
|
|
175
|
+
return acc + columnsCount;
|
|
176
|
+
}, 0), R.when(R.equals(0), R.always(1)))(header);
|
|
161
177
|
|
|
162
178
|
//total of cells in header
|
|
163
179
|
var headerCellsCount = headerDimCount * (headerValuesCount + 1);
|
|
@@ -166,19 +182,22 @@ var refineLayoutSize = exports.refineLayoutSize = function refineLayoutSize(_ref
|
|
|
166
182
|
var rowDimCount = R.pipe(R.head, // firstSection
|
|
167
183
|
R.last, // rows,
|
|
168
184
|
R.head, // first row
|
|
169
|
-
R.length)(sections);
|
|
185
|
+
R.propOr([], 'indexes'), R.length)(sections);
|
|
170
186
|
|
|
171
187
|
// number of cells in a row
|
|
172
188
|
var rowCellsCount = rowDimCount + headerValuesCount + 1;
|
|
173
189
|
|
|
174
190
|
// number of rows
|
|
175
|
-
var rowsCount = R.pipe(R.map(R.last), R.unnest, R.
|
|
191
|
+
var rowsCount = R.pipe(R.map(R.last), R.unnest, R.reduce(function (acc, row) {
|
|
192
|
+
var rowsCount = getSerieLinesCount(row);
|
|
193
|
+
return acc + rowsCount;
|
|
194
|
+
}, 1))(sections);
|
|
176
195
|
|
|
177
196
|
// total of cells in all rows
|
|
178
197
|
var rowsCellsCount = rowCellsCount * rowsCount;
|
|
179
198
|
|
|
180
199
|
// number of sections cells
|
|
181
|
-
var sectionsCellsCount = R.ifElse(R.pipe(R.head, R.head, R.length, R.equals(0)), R.always(0), R.length)(sections);
|
|
200
|
+
var sectionsCellsCount = R.ifElse(R.pipe(R.head, R.head, R.propOr([], 'indexes'), R.length, R.equals(0)), R.always(0), R.length)(sections);
|
|
182
201
|
|
|
183
202
|
var total = rowsCellsCount + sectionsCellsCount + headerCellsCount;
|
|
184
203
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import dateFns from 'date-fns';
|
|
3
|
-
import { getCodeOrder
|
|
3
|
+
import { getCodeOrder } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
4
4
|
import { getIsHidden } from './sdmx-data';
|
|
5
5
|
import {
|
|
6
6
|
getReportedTimePeriodLabel,
|
|
@@ -21,18 +21,18 @@ const getId = (value, fallbackId) => {
|
|
|
21
21
|
|
|
22
22
|
const getName =
|
|
23
23
|
({ isTimeDimension, options, locale, start, reportYearStart }) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
(value) => {
|
|
25
|
+
if (!isTimeDimension) return R.prop('name')(value);
|
|
26
|
+
return getReportedTimePeriodLabel(
|
|
27
|
+
options.frequency,
|
|
28
|
+
options.timeFormat,
|
|
29
|
+
locale,
|
|
30
|
+
)(reportYearStart, {
|
|
31
|
+
id: value.id,
|
|
32
|
+
reportedStart: start,
|
|
33
|
+
start: new Date(value.start),
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
36
|
|
|
37
37
|
export const getValuesEnhanced = ({
|
|
38
38
|
locale = '',
|
|
@@ -115,23 +115,23 @@ const defaultSorts = [byIndexPosition, byOrder];
|
|
|
115
115
|
|
|
116
116
|
const getTimePeriodAttributes =
|
|
117
117
|
({ reportYearStart, options }) =>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
118
|
+
(value) => {
|
|
119
|
+
const reported = getReportedTimePeriod(
|
|
120
|
+
reportYearStart,
|
|
121
|
+
value,
|
|
122
|
+
options.frequency,
|
|
123
|
+
);
|
|
124
|
+
const start = reported.start;
|
|
125
|
+
const end = reported.end;
|
|
126
|
+
const reportTimeNote = getReportedTimePeriodNote(
|
|
127
|
+
reportYearStart,
|
|
128
|
+
start,
|
|
129
|
+
end,
|
|
130
|
+
options.frequency,
|
|
131
|
+
options.isRtl,
|
|
132
|
+
);
|
|
133
|
+
const notes = R.isNil(reportTimeNote)
|
|
134
|
+
? []
|
|
135
|
+
: R.append(reportTimeNote, []);
|
|
136
|
+
return { start, notes };
|
|
137
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import {
|
|
3
|
-
getRefinedName,
|
|
4
3
|
isTimePeriodDimension,
|
|
5
4
|
} from '@sis-cc/dotstatsuite-sdmxjs';
|
|
6
5
|
import {
|
|
@@ -17,7 +16,7 @@ const TIME_PERIOD_ID = 'TIME_PERIOD';
|
|
|
17
16
|
export const dataTransformer = (dataNew, options = {}) => {
|
|
18
17
|
const { locale, hiddenIds: _hiddenIds } = options;
|
|
19
18
|
const reportYearStart = getReportingYearStart(dataNew);
|
|
20
|
-
|
|
19
|
+
const getName = R.prop('name')
|
|
21
20
|
//---------------------------------------------------------------------------------------Annotations
|
|
22
21
|
const getStructure = R.pathOr({}, ['data', 'structure']);
|
|
23
22
|
const structure = getStructure(dataNew);
|
|
@@ -42,7 +41,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
42
41
|
|
|
43
42
|
const resHeader = {
|
|
44
43
|
...meta,
|
|
45
|
-
sender: { ...sender, name:
|
|
44
|
+
sender: { ...sender, name: getName(sender) },
|
|
46
45
|
};
|
|
47
46
|
|
|
48
47
|
//----------------------------------------------------------------------------------------Attributes
|
|
@@ -59,7 +58,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
59
58
|
__index: index,
|
|
60
59
|
display:
|
|
61
60
|
!R.has(observation.id, hiddenIds) && !getIsHidden(obsAnnotations),
|
|
62
|
-
name:
|
|
61
|
+
name: getName(observation),
|
|
63
62
|
values: getValuesEnhanced({
|
|
64
63
|
locale,
|
|
65
64
|
annotations,
|
|
@@ -78,7 +77,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
78
77
|
return {
|
|
79
78
|
...attr,
|
|
80
79
|
display: !R.has(attr.id, hiddenIds) && !getIsHidden(attrAnnotations),
|
|
81
|
-
name:
|
|
80
|
+
name: getName(attr),
|
|
82
81
|
values: getValuesEnhanced({
|
|
83
82
|
locale,
|
|
84
83
|
annotations,
|
|
@@ -131,7 +130,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
131
130
|
...observation,
|
|
132
131
|
display: !isHidden,
|
|
133
132
|
__index: obsIndex,
|
|
134
|
-
name:
|
|
133
|
+
name: getName(observation),
|
|
135
134
|
values: _idHidden ? [] : values,
|
|
136
135
|
role: isTimeDimension
|
|
137
136
|
? TIME_PERIOD_ID
|
|
@@ -151,7 +150,7 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
151
150
|
getObservations(locale)(dimObservations);
|
|
152
151
|
const resStructure = {
|
|
153
152
|
...structure,
|
|
154
|
-
name:
|
|
153
|
+
name: getName({ ...structure, id: options.dataflowId }),
|
|
155
154
|
annotations,
|
|
156
155
|
attributes: resAttributes,
|
|
157
156
|
dimensions: { observation },
|
|
@@ -60,25 +60,27 @@ export const hierarchiseDimensionWithAdvancedHierarchy = (dimension, _hierarchy)
|
|
|
60
60
|
const indexed = R.indexBy(R.prop('id'), dimension.values);
|
|
61
61
|
const hierarchy = refinePartialHierarchy(_hierarchy, indexed);
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
)
|
|
81
|
-
|
|
63
|
+
const rest = R.pipe(
|
|
64
|
+
R.values,
|
|
65
|
+
R.unnest,
|
|
66
|
+
R.flip(R.omit)(indexed),
|
|
67
|
+
R.values,
|
|
68
|
+
)(hierarchy);
|
|
69
|
+
let index = R.length(rest) - 1;
|
|
70
|
+
const getChildren = ({ parentsIndexes, parentId }) => {
|
|
71
|
+
const childrenIds = R.propOr([], parentId, hierarchy);
|
|
72
|
+
const children = R.reduce((acc, childId) => {
|
|
73
|
+
if (!R.has(childId, indexed)) {
|
|
74
|
+
return acc;
|
|
75
|
+
}
|
|
76
|
+
index = index + 1;
|
|
77
|
+
const child = { ...R.prop(childId, indexed), __indexPosition: index, parents: parentsIndexes, parent: R.isEmpty(parentsIndexes) ? undefined : R.pipe(R.split('.'), R.last)(parentId) };
|
|
78
|
+
const descendants = getChildren({ parentsIndexes: R.append(index, parentsIndexes), parentId: R.isEmpty(parentsIndexes) ? child.id : `${parentId}.${child.id}` });
|
|
79
|
+
return R.append(R.prepend(child, descendants), acc);
|
|
80
|
+
}, [], childrenIds);
|
|
81
|
+
|
|
82
|
+
return children;
|
|
83
|
+
}
|
|
82
84
|
|
|
83
85
|
return R.set(
|
|
84
86
|
R.lensProp('values'),
|
|
@@ -90,12 +92,11 @@ export const hierarchiseDimensionWithAdvancedHierarchy = (dimension, _hierarchy)
|
|
|
90
92
|
return values;
|
|
91
93
|
}
|
|
92
94
|
const sortedRest = R.pipe(
|
|
93
|
-
R.
|
|
94
|
-
R.map(val => ({ ...val, parent: undefined, parents: [] })),
|
|
95
|
-
R.sortBy(R.prop('__indexPosition'))
|
|
95
|
+
R.sortBy(R.prop('__indexPosition')),
|
|
96
|
+
R.addIndex(R.map)((val, ind) => ({ ...val, __indexPosition: ind, parent: undefined, parents: [] })),
|
|
96
97
|
)(rest);
|
|
97
98
|
return R.concat(sortedRest, values);
|
|
98
99
|
}
|
|
99
|
-
)([],
|
|
100
|
+
)({ parentsIndexes: [], parentId: '#ROOT' })
|
|
100
101
|
)(dimension);
|
|
101
102
|
};
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
export const hierarchiseDimensionWithNativeHierarchy = (dimension) => {
|
|
4
|
-
const values = R.sortBy(R.prop('__indexPosition'), dimension.values || []);
|
|
5
|
-
const indexed = R.indexBy(R.prop('id'), values);
|
|
6
|
-
const grouped = R.groupBy(val => val.parent && R.has(val.parent, indexed) ? val.parent : '#ROOT', values);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const hierarchiseDimensionWithNativeHierarchy = (dimension) => {
|
|
4
|
+
const values = R.sortBy(R.prop('__indexPosition'), dimension.values || []);
|
|
5
|
+
const indexed = R.indexBy(R.prop('id'), values);
|
|
6
|
+
const grouped = R.groupBy(val => val.parent && R.has(val.parent, indexed) ? val.parent : '#ROOT', values);
|
|
7
|
+
|
|
8
|
+
let index = -1;
|
|
9
|
+
const getChildren = ({ parentsIndexes, parentId }) => {
|
|
10
|
+
const childs = R.propOr([], parentId, grouped);
|
|
11
|
+
return R.reduce(
|
|
12
|
+
(acc, child) => {
|
|
13
|
+
index = index + 1;
|
|
14
|
+
const refined = R.pipe(
|
|
15
|
+
R.assoc('__indexPosition', index),
|
|
16
|
+
R.assoc('parents', parentsIndexes),
|
|
17
|
+
R.assoc('parent', R.isEmpty(parentsIndexes) ? undefined : parentId),
|
|
18
|
+
)(child);
|
|
19
|
+
const children = getChildren({ parentsIndexes: R.append(index, parentsIndexes), parentId: child.id });
|
|
20
|
+
return R.concat(acc, R.prepend(refined, children));
|
|
21
|
+
},
|
|
22
|
+
[],
|
|
23
|
+
childs
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return R.set(
|
|
28
|
+
R.lensProp('values'),
|
|
29
|
+
getChildren({ parentsIndexes: [], parentId: '#ROOT' })
|
|
30
|
+
)(dimension);
|
|
31
|
+
};
|
package/src/rules2/src/index.js
CHANGED
|
@@ -3,7 +3,6 @@ export {
|
|
|
3
3
|
SDMX_3_0_CSV_DATA_FORMAT
|
|
4
4
|
} from './constants';
|
|
5
5
|
|
|
6
|
-
export { getSidebarData } from './getSidebarData';
|
|
7
6
|
export { parseMetadataSeries } from './parseMetadataSeries';
|
|
8
7
|
export { sdmx_3_0_DataFormatPatch } from './sdmx3.0DataFormatPatch';
|
|
9
8
|
export { getDataflowTooltipAttributesIds } from './getDataflowTooltipAttributesIds';
|
|
@@ -11,11 +10,10 @@ export { getMSDInformations } from './getMSDInformations';
|
|
|
11
10
|
export { getNotDisplayedIds } from './getNotDisplayedIds';
|
|
12
11
|
export { getHCodelistsRefs, getHCodelistsRefsInData } from './getHCodelistsRefsInData';
|
|
13
12
|
export { parseHierarchicalCodelist } from './parseHierarchicalCodelist';
|
|
14
|
-
export { refinePartialHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy';
|
|
15
13
|
export { getMetadataCoordinates } from './getMetadataCoordinates';
|
|
16
14
|
export { duplicateObs } from './duplicateObservations';
|
|
17
|
-
export { hierarchiseDimensionWithAdvancedHierarchy } from './
|
|
18
|
-
export { hierarchiseDimensionWithNativeHierarchy } from './
|
|
15
|
+
export { refinePartialHierarchy, hierarchiseDimensionWithAdvancedHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy2';
|
|
16
|
+
export { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy2';
|
|
19
17
|
export { getDimensionValuesIndexes } from './getDimensionValuesIndexes';
|
|
20
18
|
export { getCombinationDefinitions } from './getCombinationDefinitions';
|
|
21
19
|
export { refineDimensions } from './refineDimensions';
|
|
@@ -34,9 +32,9 @@ export { getHeaderCombinations } from './getHeaderCombinations';
|
|
|
34
32
|
export { getHeaderCoordinates } from './getHeaderCoordinates';
|
|
35
33
|
export { getLayout } from './table/getLayout';
|
|
36
34
|
export { getSortedLayoutIndexes } from './table/getSortedLayoutIndexes';
|
|
37
|
-
export { refineLayoutSize } from './table/
|
|
35
|
+
export { refineLayoutSize } from './table/refineLayoutSize2';
|
|
38
36
|
export { getFlagsAndNotes } from './table/getFlagsAndNotes';
|
|
39
|
-
export { getLayoutData } from './table/
|
|
37
|
+
export { getLayoutData } from './table/getLayoutData2';
|
|
40
38
|
export { getCellsAttributesIds } from './table/getCellsAttributesIds';
|
|
41
39
|
export { getCellsMetadataCoordinates } from './table/getCellsMetadataCoordinates';
|
|
42
40
|
export { getIndexedCombinationsByDisplay } from './table/getIndexedCombinationsByDisplay';
|
|
@@ -46,3 +44,4 @@ export { prepareData } from './prepareData';
|
|
|
46
44
|
export { getTableProps } from './table/getTableProps';
|
|
47
45
|
export { getTableLabelAccessor } from './table/getTableLabelAccessor';
|
|
48
46
|
export { parseValueHierarchy } from './table/parseValueHierarchy';
|
|
47
|
+
export { parseLayoutIndexesHierarchies } from './table/parseSeriesIndexesHierarchies';
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
|
-
import { getRefinedName } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
3
2
|
import { EMPTY_ATTACHMENT_LEVEL_CHAR } from './constants';
|
|
4
3
|
|
|
5
4
|
const dimensionValueDisplay = (display) => data => {
|
|
6
5
|
if (display === 'code') {
|
|
7
6
|
return R.prop('id', data);
|
|
8
7
|
}
|
|
9
|
-
const name =
|
|
10
|
-
if (display ===
|
|
8
|
+
const name = R.prop('name')(data);
|
|
9
|
+
if (display === 'both') {
|
|
11
10
|
return `${R.prop('id', data)}: ${name}`;
|
|
12
11
|
}
|
|
13
12
|
return name;
|
|
@@ -110,9 +109,9 @@ export const parseMetadataSeries = (metadataJson, options) => {
|
|
|
110
109
|
|
|
111
110
|
return R.assoc(evolvedKey, attributes, acc);
|
|
112
111
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
{},
|
|
113
|
+
R.keys(series)
|
|
114
|
+
))(metadataJson);
|
|
116
115
|
|
|
117
116
|
return metadataSeries;
|
|
118
117
|
};
|
|
@@ -11,8 +11,8 @@ import { getMetadataCoordinates } from './getMetadataCoordinates';
|
|
|
11
11
|
import { getAttributesSeries } from './getAttributesSeries';
|
|
12
12
|
import { getManyValuesDimensions } from './getManyValuesDimensions';
|
|
13
13
|
import { getOneValueDimensions } from './getOneValueDimensions';
|
|
14
|
-
import { hierarchiseDimensionWithNativeHierarchy } from './
|
|
15
|
-
import { hierarchiseDimensionWithAdvancedHierarchy } from './
|
|
14
|
+
import { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy2';
|
|
15
|
+
import { hierarchiseDimensionWithAdvancedHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy2';
|
|
16
16
|
import { getDataflowAttributes } from './getDataflowAttributes';
|
|
17
17
|
import { getHeaderTitle } from './getHeaderTitle';
|
|
18
18
|
import { getHeaderSubtitle } from './getHeaderSubtitle';
|
|
@@ -5,15 +5,12 @@ export const refineDimensions = (dimensions=[], dataquery='') => {
|
|
|
5
5
|
|
|
6
6
|
return R.addIndex(R.map)((dim, index) => {
|
|
7
7
|
const selection = R.nth(index, selectionIds);
|
|
8
|
-
if (R.isNil(selection) || R.length(selection) === 0 || R.isEmpty(R.head(selection))) {
|
|
9
|
-
return { ...dim, header: R.length(dim.values || []) <= 1 };
|
|
10
|
-
}
|
|
11
8
|
const values = R.map(val => {
|
|
12
|
-
if (R.includes(val.id, selection)) {
|
|
13
|
-
return val;
|
|
9
|
+
if (R.includes(val.id, selection || []) || R.isNil(selection) || R.length(selection) === 0 || R.isEmpty(R.head(selection))) {
|
|
10
|
+
return R.assoc('isSelected', true, val);
|
|
14
11
|
}
|
|
15
12
|
return R.assoc('empty', true, val);
|
|
16
13
|
}, dim.values || []);
|
|
17
|
-
return { ...dim, values, header: R.length(values) <= 1 || R.length(selection) === 1 };
|
|
14
|
+
return { ...dim, values, header: R.length(values) <= 1 || (R.length(selection) === 1 && !R.isEmpty(R.head(selection))) };
|
|
18
15
|
}, dimensions);
|
|
19
16
|
};
|