@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
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getLayoutData = undefined;
|
|
7
|
-
|
|
8
|
-
var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
|
|
9
|
-
|
|
10
|
-
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
|
|
11
|
-
|
|
12
|
-
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
|
13
|
-
|
|
14
|
-
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
|
15
|
-
|
|
16
|
-
var _extends2 = require('babel-runtime/helpers/extends');
|
|
17
|
-
|
|
18
|
-
var _extends3 = _interopRequireDefault(_extends2);
|
|
19
|
-
|
|
20
|
-
var _ramda = require('ramda');
|
|
21
|
-
|
|
22
|
-
var R = _interopRequireWildcard(_ramda);
|
|
23
|
-
|
|
24
|
-
var _getFlagsAndNotes = require('./getFlagsAndNotes');
|
|
25
|
-
|
|
26
|
-
var _getCombinationDimensionsData = require('./getCombinationDimensionsData');
|
|
27
|
-
|
|
28
|
-
var _parseValueHierarchy = require('./parseValueHierarchy');
|
|
29
|
-
|
|
30
|
-
var _utils = require('../utils');
|
|
31
|
-
|
|
32
|
-
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; } }
|
|
33
|
-
|
|
34
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
-
|
|
36
|
-
var getSubLayoutData = function getSubLayoutData(series, _definition, _ref) {
|
|
37
|
-
var metadataCoordinates = _ref.metadataCoordinates,
|
|
38
|
-
attributesSeries = _ref.attributesSeries,
|
|
39
|
-
customAttributes = _ref.customAttributes,
|
|
40
|
-
_ref$topCoordinates = _ref.topCoordinates,
|
|
41
|
-
topCoordinates = _ref$topCoordinates === undefined ? {} : _ref$topCoordinates;
|
|
42
|
-
|
|
43
|
-
var getHasAdvancedAttributes = function getHasAdvancedAttributes(attrValues) {
|
|
44
|
-
return R.pipe(R.omit(R.concat(customAttributes.flags, customAttributes.notes)), R.isEmpty, R.not)(attrValues);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var combinationConceptIds = R.reduce(function (acc, def) {
|
|
48
|
-
var concepts = R.propOr([], 'concepts', def);
|
|
49
|
-
if (R.isEmpty(concepts)) {
|
|
50
|
-
return acc;
|
|
51
|
-
}
|
|
52
|
-
return R.concat(acc, concepts);
|
|
53
|
-
}, [], _definition);
|
|
54
|
-
|
|
55
|
-
var definition = R.map( //used for parseValueHierarchy ...
|
|
56
|
-
function (entry) {
|
|
57
|
-
if (R.has('dimensions', entry)) {
|
|
58
|
-
return (0, _extends3.default)({}, entry, {
|
|
59
|
-
dimensions: R.map(function (dim) {
|
|
60
|
-
return R.assoc('indexedValues', R.indexBy(R.prop('id'), dim.values || []), dim);
|
|
61
|
-
}, entry.dimensions)
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
return R.assoc('indexedValues', R.indexBy(R.prop('id'), entry.values || []), entry);
|
|
65
|
-
}, _definition);
|
|
66
|
-
|
|
67
|
-
var _R$reduce = R.reduce(function (acc, serie) {
|
|
68
|
-
var data = [];
|
|
69
|
-
var next = [];
|
|
70
|
-
var sameSerie = true;
|
|
71
|
-
var i = 0;
|
|
72
|
-
var hasAdvancedAttributes = false;
|
|
73
|
-
var coordinates = topCoordinates;
|
|
74
|
-
var ids = [];
|
|
75
|
-
while (i < serie.length) {
|
|
76
|
-
var entry = serie[i];
|
|
77
|
-
if (R.is(Array, entry)) {
|
|
78
|
-
var combination = definition[i];
|
|
79
|
-
var previousDimValues = R.nth(i, acc.previous);
|
|
80
|
-
var combData = (0, _getCombinationDimensionsData.getCombinationDimensionsData)(entry, combination, previousDimValues, sameSerie);
|
|
81
|
-
data = R.append({
|
|
82
|
-
dimension: R.pick(['id', 'name'], combination),
|
|
83
|
-
dimValues: combData.dimValues
|
|
84
|
-
}, data);
|
|
85
|
-
next = R.append(combData.dimValues, next);
|
|
86
|
-
hasAdvancedAttributes = !hasAdvancedAttributes ? combData.hasAdvancedAttributes : true;
|
|
87
|
-
sameSerie = combData.sameSerie;
|
|
88
|
-
coordinates = (0, _extends3.default)({}, coordinates, combData.coordinates);
|
|
89
|
-
ids = R.concat(ids, combData.ids);
|
|
90
|
-
} else {
|
|
91
|
-
var dimension = definition[i];
|
|
92
|
-
var value = R.nth(Math.abs(entry), dimension.values || []);
|
|
93
|
-
var previousValue = R.nth(i, acc.previous) || {};
|
|
94
|
-
coordinates = R.assoc(dimension.id, value.id, coordinates);
|
|
95
|
-
ids = R.append(dimension.id + '=' + value.id, ids);
|
|
96
|
-
if ((0, _parseValueHierarchy.isSameValueAsPrevious)(value, previousValue) && sameSerie) {
|
|
97
|
-
next = R.append(previousValue, next);
|
|
98
|
-
data = R.append({
|
|
99
|
-
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
100
|
-
value: previousValue
|
|
101
|
-
}, data);
|
|
102
|
-
} else {
|
|
103
|
-
hasAdvancedAttributes = !hasAdvancedAttributes ? value.hasAdvancedAttributes : true;
|
|
104
|
-
var parsedValue = (0, _parseValueHierarchy.parseValueHierarchy)(value, sameSerie ? previousValue || {} : {}, dimension.indexedValues);
|
|
105
|
-
next = R.append(parsedValue, next);
|
|
106
|
-
data = R.append({
|
|
107
|
-
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
108
|
-
value: parsedValue
|
|
109
|
-
}, data);
|
|
110
|
-
if (!R.isNil(acc.previous)) {
|
|
111
|
-
sameSerie = false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
i++;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
var coordinatesValidator = (0, _utils.getLayoutCoordinatesValidator)(coordinates, topCoordinates);
|
|
119
|
-
var attributesValues = R.reduce(function (acc, serie) {
|
|
120
|
-
var coordinates = R.path([0, 'coordinates'], R.values(serie));
|
|
121
|
-
var isValid = coordinatesValidator(coordinates);
|
|
122
|
-
if (!isValid) {
|
|
123
|
-
return acc;
|
|
124
|
-
}
|
|
125
|
-
var isSingleBounded = R.length(R.keys(coordinates)) === 1;
|
|
126
|
-
return (0, _extends3.default)({}, acc, isSingleBounded ? R.pick(combinationConceptIds, serie) : serie);
|
|
127
|
-
}, {}, R.values(attributesSeries));
|
|
128
|
-
|
|
129
|
-
data = R.addIndex(R.reduce)(function (acc, entry, ind) {
|
|
130
|
-
if (!R.has('dimValues', entry)) {
|
|
131
|
-
return R.append(entry, acc);
|
|
132
|
-
}
|
|
133
|
-
var dimValues = entry.dimValues,
|
|
134
|
-
dimension = entry.dimension;
|
|
135
|
-
|
|
136
|
-
var def = R.nth(ind, definition);
|
|
137
|
-
if (!R.propOr(true, 'display', def)) {
|
|
138
|
-
return acc;
|
|
139
|
-
}
|
|
140
|
-
var fixedDimValues = R.propOr([], 'fixedDimValues', def);
|
|
141
|
-
var values = R.reduce(function (_acc, id) {
|
|
142
|
-
if (R.has(id, dimValues)) {
|
|
143
|
-
var _value = R.prop(id, dimValues);
|
|
144
|
-
return R.append(_value, _acc);
|
|
145
|
-
}
|
|
146
|
-
if (R.has(id, fixedDimValues)) {
|
|
147
|
-
return R.append(R.prop(id, fixedDimValues), _acc);
|
|
148
|
-
}
|
|
149
|
-
if (!R.has(id, attributesValues)) {
|
|
150
|
-
return _acc;
|
|
151
|
-
}
|
|
152
|
-
return R.append(R.path([id, 'value'], attributesValues), _acc);
|
|
153
|
-
}, [], def.concepts);
|
|
154
|
-
return R.append({ dimension: dimension, values: values }, acc);
|
|
155
|
-
}, [], data);
|
|
156
|
-
|
|
157
|
-
var layoutAttrValues = R.reject(R.prop('isObs'), R.omit(combinationConceptIds, attributesValues));
|
|
158
|
-
|
|
159
|
-
var flags = (0, _getFlagsAndNotes.getFlagsAndNotes)(layoutAttrValues, customAttributes);
|
|
160
|
-
var hasMetadata = !R.isNil(R.find(coordinatesValidator, metadataCoordinates));
|
|
161
|
-
|
|
162
|
-
if (!hasAdvancedAttributes) {
|
|
163
|
-
hasAdvancedAttributes = getHasAdvancedAttributes(layoutAttrValues);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
var sideProps = hasMetadata || hasAdvancedAttributes ? { hasMetadata: hasMetadata, hasAdvancedAttributes: hasAdvancedAttributes, coordinates: coordinates } : null;
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
res: R.append({ data: data, key: R.join(':', ids), flags: flags, sideProps: sideProps, coordinates: coordinates }, acc.res),
|
|
170
|
-
previous: next
|
|
171
|
-
};
|
|
172
|
-
}, { res: [], previous: [] }, series),
|
|
173
|
-
res = _R$reduce.res;
|
|
174
|
-
|
|
175
|
-
return res;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
var getLayoutData = function getLayoutData(layoutIndexes, layout, _ref2) {
|
|
179
|
-
var metadataCoordinates = _ref2.metadataCoordinates,
|
|
180
|
-
attributesSeries = _ref2.attributesSeries,
|
|
181
|
-
customAttributes = _ref2.customAttributes,
|
|
182
|
-
_ref2$topCoordinates = _ref2.topCoordinates,
|
|
183
|
-
topCoordinates = _ref2$topCoordinates === undefined ? {} : _ref2$topCoordinates;
|
|
184
|
-
var header = layoutIndexes.header,
|
|
185
|
-
sections = layoutIndexes.sections,
|
|
186
|
-
rest = (0, _objectWithoutProperties3.default)(layoutIndexes, ['header', 'sections']);
|
|
187
|
-
|
|
188
|
-
var opts = { metadataCoordinates: metadataCoordinates, attributesSeries: attributesSeries, customAttributes: customAttributes, topCoordinates: topCoordinates };
|
|
189
|
-
var headerData = getSubLayoutData(header, layout.header, opts);
|
|
190
|
-
var sectionsData = R.pipe(R.transpose, function (_ref3) {
|
|
191
|
-
var _ref4 = (0, _slicedToArray3.default)(_ref3, 2),
|
|
192
|
-
sections = _ref4[0],
|
|
193
|
-
sectionsRows = _ref4[1];
|
|
194
|
-
|
|
195
|
-
if (R.isNil(sections)) {
|
|
196
|
-
return [];
|
|
197
|
-
}
|
|
198
|
-
var _sectionsData = getSubLayoutData(sections, layout.sections, opts);
|
|
199
|
-
var rowsData = R.addIndex(R.map)(function (rows, sectionIndex) {
|
|
200
|
-
var sectionCoordinates = R.path([sectionIndex, 'coordinates'], _sectionsData);
|
|
201
|
-
return getSubLayoutData(rows, layout.rows, R.assoc('topCoordinates', sectionCoordinates, opts));
|
|
202
|
-
}, sectionsRows);
|
|
203
|
-
|
|
204
|
-
return R.transpose([_sectionsData, rowsData]);
|
|
205
|
-
})(sections);
|
|
206
|
-
|
|
207
|
-
return (0, _extends3.default)({ headerData: headerData, sectionsData: sectionsData }, rest);
|
|
208
|
-
};
|
|
209
|
-
exports.getLayoutData = getLayoutData;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { dimensionValueDisplay } from '../../rules/src';
|
|
3
|
-
import { REJECTED_VALUE_IDS } from './constants';
|
|
4
|
-
|
|
5
|
-
const sortByCoordinates = (a, b) => {
|
|
6
|
-
const splitACoord = a.splitCoord;
|
|
7
|
-
const splitBCoord = b.splitCoord;
|
|
8
|
-
|
|
9
|
-
const aWeight = R.pipe(R.reject(R.isEmpty), R.length)(splitACoord);
|
|
10
|
-
const bWeight = R.pipe(R.reject(R.isEmpty), R.length)(splitBCoord);
|
|
11
|
-
if (aWeight !== bWeight) {
|
|
12
|
-
return bWeight - aWeight;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let ind = 0;
|
|
16
|
-
while (splitACoord[ind] === splitBCoord[ind]) {
|
|
17
|
-
ind++;
|
|
18
|
-
}
|
|
19
|
-
const _a = R.isEmpty(splitACoord[ind]) ? 0 : Number(splitACoord[ind]);
|
|
20
|
-
const _b = R.isEmpty(splitBCoord[ind]) ? 0 : Number(splitBCoord[ind]);
|
|
21
|
-
return _b - _a;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// options = { display, attributesLabel }
|
|
25
|
-
export const getSidebarData = (attributesSeries, metadataSeries, dataflow, dimensions, options) => {
|
|
26
|
-
const coordinates = R.uniq(R.concat(R.keys(attributesSeries), R.keys(metadataSeries)));
|
|
27
|
-
return R.pipe(
|
|
28
|
-
R.map(coordinate => {
|
|
29
|
-
const attributes = R.prop(coordinate, attributesSeries);
|
|
30
|
-
const metadata = R.prop(coordinate, metadataSeries);
|
|
31
|
-
const children = R.concat(
|
|
32
|
-
R.isNil(attributes) ? [] : [{ id: `${coordinate}-attr`, label: options.attributesLabel, children: attributes }],
|
|
33
|
-
R.isNil(metadata) ? [] : metadata,
|
|
34
|
-
);
|
|
35
|
-
const splitCoord = R.split(':', coordinate);
|
|
36
|
-
const { split, labels } = R.addIndex(R.reduce)(
|
|
37
|
-
(acc, valIndex, dimIndex) => {
|
|
38
|
-
if (R.isEmpty(valIndex)) {
|
|
39
|
-
return ({ ...acc, split: R.append('', acc.split) });
|
|
40
|
-
}
|
|
41
|
-
const dim = R.nth(dimIndex, dimensions);
|
|
42
|
-
const values = R.propOr([], 'values', dim || {});
|
|
43
|
-
const value = R.nth(Number(valIndex), values);
|
|
44
|
-
if (!value || !R.propOr(true, 'display', dim) || !R.propOr(true, 'display', value)
|
|
45
|
-
|| R.includes(R.prop('id', value), REJECTED_VALUE_IDS)) {
|
|
46
|
-
return ({ ...acc, split: R.append('', acc.split) });
|
|
47
|
-
}
|
|
48
|
-
const dimLabel = dimensionValueDisplay(options.display)(dim);
|
|
49
|
-
const valLabel = dimensionValueDisplay(options.display)(value);
|
|
50
|
-
return ({
|
|
51
|
-
labels: R.append(`${dimLabel}: ${valLabel}`, acc.labels),
|
|
52
|
-
split: R.append(valIndex, acc.split)
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
{ split: [], labels: [] },
|
|
56
|
-
splitCoord
|
|
57
|
-
);
|
|
58
|
-
const label = R.isEmpty(labels)
|
|
59
|
-
? dimensionValueDisplay(options.display)(dataflow)
|
|
60
|
-
: R.join(' - ', labels);
|
|
61
|
-
|
|
62
|
-
return ({
|
|
63
|
-
id: R.join(':', split),
|
|
64
|
-
splitCoord: split,
|
|
65
|
-
label,
|
|
66
|
-
children: R.filter(R.identity, children),
|
|
67
|
-
});
|
|
68
|
-
}),
|
|
69
|
-
series => { // after removed non displayed dim vals, some series might be duplicated
|
|
70
|
-
const grouped = R.groupBy(R.prop('id'), series);
|
|
71
|
-
return R.pipe(
|
|
72
|
-
R.map(entries => {
|
|
73
|
-
if (R.length(entries) === 1) {
|
|
74
|
-
return R.head(entries);
|
|
75
|
-
}
|
|
76
|
-
const head = R.head(entries);
|
|
77
|
-
const children = R.pipe(R.pluck('children'), R.unnest)(entries);
|
|
78
|
-
return R.assoc('children', children, head);
|
|
79
|
-
}),
|
|
80
|
-
R.values
|
|
81
|
-
)(grouped);
|
|
82
|
-
},
|
|
83
|
-
R.sort(sortByCoordinates),
|
|
84
|
-
)(coordinates);
|
|
85
|
-
};
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { getFlagsAndNotes } from './getFlagsAndNotes';
|
|
3
|
-
import { getCombinationDimensionsData } from './getCombinationDimensionsData';
|
|
4
|
-
import { parseValueHierarchy, isSameValueAsPrevious } from './parseValueHierarchy';
|
|
5
|
-
import { getLayoutCoordinatesValidator } from '../utils';
|
|
6
|
-
|
|
7
|
-
const getSubLayoutData = (series, _definition, { metadataCoordinates, attributesSeries, customAttributes, topCoordinates={} }) => {
|
|
8
|
-
const getHasAdvancedAttributes = (attrValues) => R.pipe(
|
|
9
|
-
R.omit(R.concat(customAttributes.flags, customAttributes.notes)),
|
|
10
|
-
R.isEmpty,
|
|
11
|
-
R.not
|
|
12
|
-
)(attrValues);
|
|
13
|
-
|
|
14
|
-
const combinationConceptIds = R.reduce(
|
|
15
|
-
(acc, def) => {
|
|
16
|
-
const concepts = R.propOr([], 'concepts', def);
|
|
17
|
-
if (R.isEmpty(concepts)) {
|
|
18
|
-
return acc;
|
|
19
|
-
}
|
|
20
|
-
return R.concat(acc, concepts);
|
|
21
|
-
},
|
|
22
|
-
[],
|
|
23
|
-
_definition
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
const definition = R.map( //used for parseValueHierarchy ...
|
|
27
|
-
(entry) => {
|
|
28
|
-
if (R.has('dimensions', entry)) {
|
|
29
|
-
return ({
|
|
30
|
-
...entry,
|
|
31
|
-
dimensions: R.map(
|
|
32
|
-
dim => R.assoc('indexedValues', R.indexBy(R.prop('id'), dim.values || []), dim),
|
|
33
|
-
entry.dimensions
|
|
34
|
-
)
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return R.assoc('indexedValues', R.indexBy(R.prop('id'), entry.values || []), entry);
|
|
38
|
-
},
|
|
39
|
-
_definition
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const { res } = R.reduce(
|
|
43
|
-
(acc, serie) => {
|
|
44
|
-
let data = [];
|
|
45
|
-
let next = [];
|
|
46
|
-
let sameSerie = true;
|
|
47
|
-
let i = 0;
|
|
48
|
-
let hasAdvancedAttributes = false;
|
|
49
|
-
let coordinates = topCoordinates;
|
|
50
|
-
let ids = [];
|
|
51
|
-
while (i < serie.length) {
|
|
52
|
-
const entry = serie[i];
|
|
53
|
-
if (R.is(Array, entry)) {
|
|
54
|
-
const combination = definition[i];
|
|
55
|
-
const previousDimValues = R.nth(i, acc.previous);
|
|
56
|
-
const combData = getCombinationDimensionsData(entry, combination, previousDimValues, sameSerie);
|
|
57
|
-
data = R.append({
|
|
58
|
-
dimension: R.pick(['id', 'name'], combination),
|
|
59
|
-
dimValues: combData.dimValues
|
|
60
|
-
}, data);
|
|
61
|
-
next = R.append(combData.dimValues, next);
|
|
62
|
-
hasAdvancedAttributes = !hasAdvancedAttributes ? combData.hasAdvancedAttributes : true;
|
|
63
|
-
sameSerie = combData.sameSerie;
|
|
64
|
-
coordinates = { ...coordinates, ...combData.coordinates };
|
|
65
|
-
ids = R.concat(ids, combData.ids);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
const dimension = definition[i];
|
|
69
|
-
const value = R.nth(Math.abs(entry), dimension.values || []);
|
|
70
|
-
const previousValue = R.nth(i, acc.previous) || {};
|
|
71
|
-
coordinates = R.assoc(dimension.id, value.id, coordinates);
|
|
72
|
-
ids = R.append(`${dimension.id}=${value.id}`, ids);
|
|
73
|
-
if (isSameValueAsPrevious(value, previousValue) && sameSerie) {
|
|
74
|
-
next = R.append(previousValue, next);
|
|
75
|
-
data = R.append({
|
|
76
|
-
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
77
|
-
value: previousValue,
|
|
78
|
-
}, data);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
hasAdvancedAttributes = !hasAdvancedAttributes ? value.hasAdvancedAttributes : true;
|
|
82
|
-
const parsedValue = parseValueHierarchy(value, sameSerie ? previousValue || {} : {}, dimension.indexedValues);
|
|
83
|
-
next = R.append(parsedValue, next);
|
|
84
|
-
data = R.append({
|
|
85
|
-
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
86
|
-
value: parsedValue,
|
|
87
|
-
}, data);
|
|
88
|
-
if (!R.isNil(acc.previous)) {
|
|
89
|
-
sameSerie = false;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
i++;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const coordinatesValidator = getLayoutCoordinatesValidator(coordinates, topCoordinates);
|
|
97
|
-
const attributesValues = R.reduce(
|
|
98
|
-
(acc, serie) => {
|
|
99
|
-
const coordinates = R.path([0, 'coordinates'], R.values(serie));
|
|
100
|
-
const isValid = coordinatesValidator(coordinates);
|
|
101
|
-
if (!isValid) {
|
|
102
|
-
return acc;
|
|
103
|
-
}
|
|
104
|
-
const isSingleBounded = R.length(R.keys(coordinates)) === 1;
|
|
105
|
-
return ({ ...acc, ...(isSingleBounded ? R.pick(combinationConceptIds, serie) : serie) });
|
|
106
|
-
},
|
|
107
|
-
{},
|
|
108
|
-
R.values(attributesSeries)
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
data = R.addIndex(R.reduce)(
|
|
112
|
-
(acc, entry, ind) => {
|
|
113
|
-
if (!R.has('dimValues', entry)) {
|
|
114
|
-
return R.append(entry, acc);
|
|
115
|
-
}
|
|
116
|
-
const { dimValues, dimension } = entry;
|
|
117
|
-
const def = R.nth(ind, definition);
|
|
118
|
-
if (!R.propOr(true, 'display', def)) {
|
|
119
|
-
return acc;
|
|
120
|
-
}
|
|
121
|
-
const fixedDimValues = R.propOr([], 'fixedDimValues', def);
|
|
122
|
-
const values = R.reduce(
|
|
123
|
-
(_acc, id) => {
|
|
124
|
-
if (R.has(id, dimValues)) {
|
|
125
|
-
const value = R.prop(id, dimValues);
|
|
126
|
-
return R.append(value, _acc);
|
|
127
|
-
}
|
|
128
|
-
if (R.has(id, fixedDimValues)) {
|
|
129
|
-
return R.append(R.prop(id, fixedDimValues), _acc);
|
|
130
|
-
}
|
|
131
|
-
if (!R.has(id, attributesValues)) {
|
|
132
|
-
return _acc;
|
|
133
|
-
}
|
|
134
|
-
return R.append(R.path([id, 'value'], attributesValues), _acc);
|
|
135
|
-
},
|
|
136
|
-
[],
|
|
137
|
-
def.concepts
|
|
138
|
-
);
|
|
139
|
-
return R.append({ dimension, values }, acc);
|
|
140
|
-
},
|
|
141
|
-
[],
|
|
142
|
-
data
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
const layoutAttrValues = R.reject(
|
|
146
|
-
R.prop('isObs'),
|
|
147
|
-
R.omit(combinationConceptIds, attributesValues)
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
const flags = getFlagsAndNotes(layoutAttrValues, customAttributes);
|
|
151
|
-
const hasMetadata = !R.isNil(R.find(coordinatesValidator, metadataCoordinates));
|
|
152
|
-
|
|
153
|
-
if (!hasAdvancedAttributes) {
|
|
154
|
-
hasAdvancedAttributes = getHasAdvancedAttributes(layoutAttrValues);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const sideProps = hasMetadata || hasAdvancedAttributes
|
|
158
|
-
? { hasMetadata, hasAdvancedAttributes, coordinates } : null;
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
res: R.append({ data, key: R.join(':', ids), flags, sideProps, coordinates }, acc.res),
|
|
162
|
-
previous: next,
|
|
163
|
-
};
|
|
164
|
-
},
|
|
165
|
-
{ res: [], previous: [] },
|
|
166
|
-
series
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
return res;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export const getLayoutData = (layoutIndexes, layout, { metadataCoordinates, attributesSeries, customAttributes, topCoordinates={} }) => {
|
|
173
|
-
const { header, sections, ...rest } = layoutIndexes;
|
|
174
|
-
const opts = { metadataCoordinates, attributesSeries, customAttributes, topCoordinates };
|
|
175
|
-
const headerData = getSubLayoutData(header, layout.header, opts);
|
|
176
|
-
const sectionsData = R.pipe(
|
|
177
|
-
R.transpose,
|
|
178
|
-
([sections, sectionsRows]) => {
|
|
179
|
-
if (R.isNil(sections)) {
|
|
180
|
-
return [];
|
|
181
|
-
}
|
|
182
|
-
const _sectionsData = getSubLayoutData(sections, layout.sections, opts);
|
|
183
|
-
const rowsData = R.addIndex(R.map)((rows, sectionIndex) => {
|
|
184
|
-
const sectionCoordinates = R.path([sectionIndex, 'coordinates'], _sectionsData);
|
|
185
|
-
return getSubLayoutData(rows, layout.rows, R.assoc('topCoordinates', sectionCoordinates, opts));
|
|
186
|
-
}, sectionsRows);
|
|
187
|
-
|
|
188
|
-
return R.transpose([_sectionsData, rowsData]);
|
|
189
|
-
}
|
|
190
|
-
)(sections);
|
|
191
|
-
|
|
192
|
-
return ({ headerData, sectionsData, ...rest });
|
|
193
|
-
};
|