@sis-cc/dotstatsuite-components 17.12.5 → 17.13.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.
Files changed (31) hide show
  1. package/lib/rules2/src/{hierarchiseDimensionWithAdvancedHierarchy.js → hierarchiseDimensionWithAdvancedHierarchy2.js} +22 -17
  2. package/lib/rules2/src/{hierarchiseDimensionWithNativeHierarchy.js → hierarchiseDimensionWithNativeHierarchy2.js} +10 -5
  3. package/lib/rules2/src/index.js +21 -12
  4. package/lib/rules2/src/parseCombinations.js +26 -3
  5. package/lib/rules2/src/prepareData.js +2 -2
  6. package/lib/rules2/src/refineDimensions.js +3 -6
  7. package/lib/rules2/src/table/getLayoutData2.js +218 -0
  8. package/lib/rules2/src/table/getTableProps.js +6 -9
  9. package/lib/rules2/src/table/parseSeriesIndexesHierarchies.js +96 -0
  10. package/lib/rules2/src/table/{refineLayoutSize.js → refineLayoutSize2.js} +53 -34
  11. package/package.json +1 -1
  12. package/src/rules2/src/{hierarchiseDimensionWithAdvancedHierarchy.js → hierarchiseDimensionWithAdvancedHierarchy2.js} +24 -23
  13. package/src/rules2/src/{hierarchiseDimensionWithNativeHierarchy.js → hierarchiseDimensionWithNativeHierarchy2.js} +31 -28
  14. package/src/rules2/src/index.js +5 -5
  15. package/src/rules2/src/parseCombinations.js +84 -42
  16. package/src/rules2/src/prepareData.js +2 -2
  17. package/src/rules2/src/refineDimensions.js +3 -6
  18. package/src/rules2/src/table/getLayoutData2.js +175 -0
  19. package/src/rules2/src/table/getTableProps.js +8 -4
  20. package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +62 -0
  21. package/src/rules2/src/table/{refineLayoutSize.js → refineLayoutSize2.js} +50 -21
  22. package/test/getLayoutData2.test.js +268 -0
  23. package/test/{hierarchiseDimensionWithAdvancedHierarchy.test.js → hierarchiseDimensionWithAdvancedHierarchy2.test.js} +34 -69
  24. package/test/{hierarchiseDimensionWithNativeHierarchy.test.js → hierarchiseDimensionWithNativeHierarchy2.test.js} +14 -14
  25. package/test/parseCombinations.test.js +134 -20
  26. package/test/parseSeriesIndexesHierarchies.test.js +104 -0
  27. package/test/{refineLayoutSize.test.js → refineLayoutSize2.test.js} +63 -64
  28. package/test/refinedDimensions.test.js +8 -8
  29. package/lib/rules2/src/table/getLayoutData.js +0 -209
  30. package/src/rules2/src/table/getLayoutData.js +0 -193
  31. package/test/getLayoutData.test.js +0 -284
@@ -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 _defineProperty2 = require('babel-runtime/helpers/defineProperty');
8
+ var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
9
9
 
10
- var _defineProperty3 = _interopRequireDefault(_defineProperty2);
10
+ var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
11
11
 
12
- var _extends4 = require('babel-runtime/helpers/extends');
12
+ var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
13
13
 
14
- var _extends5 = _interopRequireDefault(_extends4);
14
+ var _defineProperty3 = _interopRequireDefault(_defineProperty2);
15
15
 
16
- var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
16
+ var _extends3 = require('babel-runtime/helpers/extends');
17
17
 
18
- var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
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 (rowData) {
67
- var rowKey = toKey(rowData);
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 sectionKey = toKey(R.head(lastSection));
94
- if (rowsLength > _n) {
95
- var _R$splitAt = R.splitAt(R.negate(_n), rows),
96
- _R$splitAt2 = (0, _slicedToArray3.default)(_R$splitAt, 2),
97
- rest = _R$splitAt2[0],
98
- extracted = _R$splitAt2[1];
99
-
100
- var updatedSection = R.set(R.lensIndex(1), rest)(lastSection);
101
- truncated = R.set(R.lensIndex(-1), updatedSection)(truncated);
102
- extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(toKey, extracted)));
103
- _n = 0;
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
- extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(toKey, rows)));
107
- _n = _n - rowsLength;
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 _R$splitAt3 = R.splitAt(R.negate(n))(headerData),
115
- _R$splitAt4 = (0, _slicedToArray3.default)(_R$splitAt3, 2),
116
- truncated = _R$splitAt4[0],
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
- return { truncated: truncated, extractedKeys: R.map(toKey, extracted) };
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([])), R.length // number of dims
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.length, R.when(R.equals(0), R.always(1)))(header);
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.length, R.add(1))(sections);
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@sis-cc/dotstatsuite-components",
3
3
  "description": "Set components based on React.",
4
- "version": "17.12.5",
4
+ "version": "17.13.0",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -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
- let rest = indexed;
64
- const getChildren = (parents, hier) => R.pipe(
65
- ids => {
66
- rest = R.omit(ids, rest);
67
- return R.props(ids, indexed)
68
- },
69
- R.filter(R.identity),
70
- R.map(
71
- (val) => {
72
- const _val = {
73
- ...val,
74
- parent: R.last(parents),
75
- parents
76
- };
77
- const children = getChildren(R.append(val.id, parents), hier);
78
- return R.prepend(_val, children);
79
- },
80
- )
81
- )(R.propOr([], R.isEmpty(parents) ? '#ROOT' : R.join('.', parents), hier));
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.values,
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
- )([], hierarchy)
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
- const getChildren = (parents) => {
9
- const childs = R.propOr([], R.defaultTo('#ROOT', R.last(parents)), grouped);
10
- return R.reduce(
11
- (acc, child) => {
12
- const refined = R.pipe(
13
- R.assoc('parents', parents),
14
- R.assoc('parent', R.last(parents)),
15
- )(child);
16
- const children = getChildren(R.append(child.id, parents));
17
- return R.concat(acc, R.prepend(refined, children));
18
- },
19
- [],
20
- childs
21
- );
22
- }
23
-
24
- return R.set(
25
- R.lensProp('values'),
26
- getChildren([])
27
- )(dimension);
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
+ };
@@ -11,11 +11,10 @@ export { getMSDInformations } from './getMSDInformations';
11
11
  export { getNotDisplayedIds } from './getNotDisplayedIds';
12
12
  export { getHCodelistsRefs, getHCodelistsRefsInData } from './getHCodelistsRefsInData';
13
13
  export { parseHierarchicalCodelist } from './parseHierarchicalCodelist';
14
- export { refinePartialHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy';
15
14
  export { getMetadataCoordinates } from './getMetadataCoordinates';
16
15
  export { duplicateObs } from './duplicateObservations';
17
- export { hierarchiseDimensionWithAdvancedHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy';
18
- export { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy';
16
+ export { refinePartialHierarchy, hierarchiseDimensionWithAdvancedHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy2';
17
+ export { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy2';
19
18
  export { getDimensionValuesIndexes } from './getDimensionValuesIndexes';
20
19
  export { getCombinationDefinitions } from './getCombinationDefinitions';
21
20
  export { refineDimensions } from './refineDimensions';
@@ -34,9 +33,9 @@ export { getHeaderCombinations } from './getHeaderCombinations';
34
33
  export { getHeaderCoordinates } from './getHeaderCoordinates';
35
34
  export { getLayout } from './table/getLayout';
36
35
  export { getSortedLayoutIndexes } from './table/getSortedLayoutIndexes';
37
- export { refineLayoutSize } from './table/refineLayoutSize';
36
+ export { refineLayoutSize } from './table/refineLayoutSize2';
38
37
  export { getFlagsAndNotes } from './table/getFlagsAndNotes';
39
- export { getLayoutData } from './table/getLayoutData';
38
+ export { getLayoutData } from './table/getLayoutData2';
40
39
  export { getCellsAttributesIds } from './table/getCellsAttributesIds';
41
40
  export { getCellsMetadataCoordinates } from './table/getCellsMetadataCoordinates';
42
41
  export { getIndexedCombinationsByDisplay } from './table/getIndexedCombinationsByDisplay';
@@ -46,3 +45,4 @@ export { prepareData } from './prepareData';
46
45
  export { getTableProps } from './table/getTableProps';
47
46
  export { getTableLabelAccessor } from './table/getTableLabelAccessor';
48
47
  export { parseValueHierarchy } from './table/parseValueHierarchy';
48
+ export { parseLayoutIndexesHierarchies } from './table/parseSeriesIndexesHierarchies';
@@ -1,58 +1,100 @@
1
1
  import * as R from 'ramda';
2
2
  import { REJECTED_VALUE_IDS } from './constants';
3
3
 
4
- const getDisplayableValues = values => R.filter(
5
- val => !R.includes(R.prop('id', val), REJECTED_VALUE_IDS) && R.propOr(true, 'display', val),
6
- values
4
+ const getDisplayableValues = (values) =>
5
+ R.filter(
6
+ (val) =>
7
+ !R.includes(R.prop('id', val), REJECTED_VALUE_IDS) &&
8
+ R.propOr(true, 'display', val),
9
+ values,
10
+ );
11
+
12
+ // invalid concepts:
13
+ // - empty/null/undefined/!array values (so far)
14
+ const hasInvalidValues = R.pipe(
15
+ R.prop('values'),
16
+ R.anyPass([R.isNil, R.complement(R.is(Array)), R.isEmpty]),
7
17
  );
18
+ const isConceptInvalid = R.anyPass([hasInvalidValues /* add more... */]);
19
+ const filterInvalidConcepts = R.filter(isConceptInvalid);
20
+ // concepts is an array of ids... (misnamed!)
21
+ const conceptIdsLens = R.lensProp('concepts');
22
+ const rejectInvalidConceptIds =
23
+ (concepts = []) =>
24
+ (combinations = []) => {
25
+ const invalidConceptIds = R.pluck('id', filterInvalidConcepts(concepts));
26
+ return R.map(
27
+ R.over(conceptIdsLens, R.without(invalidConceptIds)),
28
+ combinations,
29
+ );
30
+ };
31
+
32
+ export const parseCombinations = (
33
+ combinations,
34
+ parsedAttributes,
35
+ dimensions,
36
+ ) => {
37
+ const concepts = R.concat(dimensions, parsedAttributes);
8
38
 
9
- export const parseCombinations = (combinations, parsedAttributes, dimensions) => {
10
39
  const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
11
40
  const indexedAttributes = R.indexBy(R.prop('id'), parsedAttributes);
12
41
 
13
- return R.reduce(
14
- (acc, comb) => {
42
+ return R.pipe(
43
+ rejectInvalidConceptIds(concepts),
44
+ R.reduce((acc, comb) => {
15
45
  let relationship = [];
16
46
  let ids = {};
17
47
  let displayable_values_count = 0;
18
- const seriesConcepts = R.filter(
19
- concept => {
20
- if (R.has(concept, ids)) {
21
- return false;
22
- }
23
- if (R.has(concept, indexedDimensions)) {
24
- const dimension = R.prop(concept, indexedDimensions);
25
- relationship = !dimension.header ? R.append(concept, relationship) : relationship;
26
- ids = { ...ids, [concept]: concept };
27
- displayable_values_count += R.length(dimension.values || []);
28
- return !dimension.header;
29
- }
30
- else if (!R.has(concept, indexedAttributes)) {
31
- return false;
32
- }
33
- const attribute = R.prop(concept, indexedAttributes);
34
- const displayableValues = getDisplayableValues(attribute.values || []);
35
- const isDisplayable = R.length(displayableValues) !== 0 && R.propOr(true, 'display', attribute);
36
- relationship = attribute.series && isDisplayable
37
- ? R.pipe(
38
- R.reject(id => R.has(id, ids)),
48
+ const seriesConcepts = R.filter((concept) => {
49
+ if (R.has(concept, ids)) {
50
+ return false;
51
+ }
52
+ if (R.has(concept, indexedDimensions)) {
53
+ const dimension = R.prop(concept, indexedDimensions);
54
+ relationship = !dimension.header
55
+ ? R.append(concept, relationship)
56
+ : relationship;
57
+ ids = { ...ids, [concept]: concept };
58
+ displayable_values_count += R.length(dimension.values || []);
59
+ return !dimension.header;
60
+ } else if (!R.has(concept, indexedAttributes)) {
61
+ return false;
62
+ }
63
+ const attribute = R.prop(concept, indexedAttributes);
64
+ const displayableValues = getDisplayableValues(attribute.values || []);
65
+ const isDisplayable =
66
+ R.length(displayableValues) !== 0 &&
67
+ R.propOr(true, 'display', attribute);
68
+ relationship =
69
+ attribute.series && isDisplayable
70
+ ? R.pipe(
71
+ R.reject((id) => R.has(id, ids)),
39
72
  R.concat(relationship),
40
73
  )(attribute.relationship)
41
- : relationship;
42
- ids = attribute.series ? { ...ids, ...R.indexBy(R.identity, attribute.relationship) } : ids;
43
- displayable_values_count = isDisplayable
44
- ? displayable_values_count + R.length(displayableValues)
45
- : displayable_values_count;
46
- return attribute.series && isDisplayable;
47
- },
48
- comb.concepts
49
- );
74
+ : relationship;
75
+ ids = attribute.series
76
+ ? { ...ids, ...R.indexBy(R.identity, attribute.relationship) }
77
+ : ids;
78
+ displayable_values_count = isDisplayable
79
+ ? displayable_values_count + R.length(displayableValues)
80
+ : displayable_values_count;
81
+ return attribute.series && isDisplayable;
82
+ }, comb.concepts);
50
83
  if (R.isEmpty(seriesConcepts)) {
51
- return R.append({ ...comb, header: true, display: displayable_values_count > 0 }, acc);
84
+ return R.append(
85
+ { ...comb, header: true, display: displayable_values_count > 0 },
86
+ acc,
87
+ );
52
88
  }
53
- return R.append({ ...comb, series: true, relationship, display: displayable_values_count > 0 }, acc);
54
- },
55
- [],
56
- combinations
57
- );
89
+ return R.append(
90
+ {
91
+ ...comb,
92
+ series: true,
93
+ relationship,
94
+ display: displayable_values_count > 0,
95
+ },
96
+ acc,
97
+ );
98
+ }, []),
99
+ )(combinations);
58
100
  };
@@ -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 './hierarchiseDimensionWithNativeHierarchy';
15
- import { hierarchiseDimensionWithAdvancedHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy';
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
  };