@sis-cc/dotstatsuite-components 17.22.0 → 17.24.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.
@@ -65,8 +65,6 @@ var getValuesEnhanced = exports.getValuesEnhanced = function getValuesEnhanced(_
65
65
  _ref2$parent = _ref2.parent,
66
66
  parent = _ref2$parent === undefined ? '' : _ref2$parent,
67
67
  reportYearStart = _ref2.reportYearStart,
68
- _ref2$_hiddenIds = _ref2._hiddenIds,
69
- _hiddenIds = _ref2$_hiddenIds === undefined ? {} : _ref2$_hiddenIds,
70
68
  _ref2$hiddenIds = _ref2.hiddenIds,
71
69
  hiddenIds = _ref2$hiddenIds === undefined ? {} : _ref2$hiddenIds,
72
70
  _ref2$options = _ref2.options,
@@ -77,7 +75,7 @@ var getValuesEnhanced = exports.getValuesEnhanced = function getValuesEnhanced(_
77
75
 
78
76
  var valueAnnotations = R.pipe(R.propOr([], 'annotations'), R.flip(R.props)(annotations))(value);
79
77
 
80
- var isHidden = _hiddenIds[parent] && R.includes(value.id, _hiddenIds[parent]) || R.has(parent + '.' + value.id, hiddenIds) || (0, _sdmxData.getIsHidden)(valueAnnotations);
78
+ var isHidden = R.has(parent + '.' + id, hiddenIds) || (0, _sdmxData.getIsHidden)(valueAnnotations);
81
79
 
82
80
  var _ref3 = isTimeDimension ? getTimePeriodAttributes({ reportYearStart: reportYearStart, options: options })(value) : { notes: [] },
83
81
  start = _ref3.start,
@@ -31,8 +31,7 @@ var TIME_PERIOD_ID = 'TIME_PERIOD';
31
31
 
32
32
  var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew) {
33
33
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
34
- var locale = options.locale,
35
- _hiddenIds = options.hiddenIds;
34
+ var locale = options.locale;
36
35
 
37
36
  var reportYearStart = (0, _getReportingYearStart.getReportingYearStart)(dataNew);
38
37
  var getName = R.prop('name');
@@ -46,7 +45,25 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
46
45
 
47
46
  var dataSetsAnnotations = R.props(R.pathOr([], [0, 'annotations'], dataSets), annotations);
48
47
 
49
- var hiddenIds = (0, _src.getNotDisplayedIds)(dataSetsAnnotations);
48
+ /*
49
+ hiddenValues => codelistIds or codelistValuesIds for display computation
50
+ hiddenCombinations => used only for dimensions, if dimension values match the provided set, all dimension is removed
51
+ */
52
+
53
+ var _getNotDisplayedIds = (0, _src.getNotDisplayedIds)(dataSetsAnnotations),
54
+ hiddenValues = _getNotDisplayedIds.hiddenValues,
55
+ hiddenCombinations = _getNotDisplayedIds.hiddenCombinations;
56
+
57
+ var getIsAllDimHidden = function getIsAllDimHidden(_ref) {
58
+ var id = _ref.id,
59
+ values = _ref.values;
60
+
61
+ if (!R.has(id, hiddenCombinations)) {
62
+ return false;
63
+ }
64
+ var valuesIds = R.pluck('id', values);
65
+ return R.isEmpty(R.difference(valuesIds), hiddenCombinations[id]);
66
+ };
50
67
 
51
68
  //--------------------------------------------------------------------------------------------Header
52
69
  var getMeta = R.propOr({}, 'meta');
@@ -70,15 +87,14 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
70
87
  var obsAnnotations = R.props(observation.annotations || [], annotations);
71
88
  return (0, _extends3.default)({}, observation, {
72
89
  __index: index,
73
- display: !R.has(observation.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(obsAnnotations),
90
+ display: !R.has(observation.id, hiddenValues) && !(0, _sdmxData.getIsHidden)(obsAnnotations),
74
91
  name: getName(observation),
75
92
  values: (0, _getValuesEnhanced.getValuesEnhanced)({
76
93
  locale: locale,
77
94
  annotations: annotations,
78
95
  parent: observation.id,
79
96
  reportYearStart: reportYearStart,
80
- _hiddenIds: _hiddenIds,
81
- hiddenIds: hiddenIds,
97
+ hiddenIds: hiddenValues,
82
98
  options: options
83
99
  })(R.propOr([], 'values', observation)),
84
100
  roles: !R.isNil(observation.role) ? R.head(observation.role) : null
@@ -88,14 +104,13 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
88
104
  var datasetAttributes = R.map(function (attr) {
89
105
  var attrAnnotations = R.props(attr.annotations || [], annotations);
90
106
  return (0, _extends3.default)({}, attr, {
91
- display: !R.has(attr.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(attrAnnotations),
107
+ display: !R.has(attr.id, hiddenValues) && !(0, _sdmxData.getIsHidden)(attrAnnotations),
92
108
  name: getName(attr),
93
109
  values: (0, _getValuesEnhanced.getValuesEnhanced)({
94
110
  locale: locale,
95
111
  annotations: annotations,
96
112
  parent: attr.id,
97
- _hiddenIds: _hiddenIds,
98
- hiddenIds: hiddenIds,
113
+ hiddenIds: hiddenValues,
99
114
  options: options,
100
115
  reportYearStart: reportYearStart
101
116
  })(R.propOr([], 'values', attr))
@@ -124,18 +139,17 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
124
139
  isTimeDimension: isTimeDimension,
125
140
  reportYearStart: reportYearStart,
126
141
  parent: id,
127
- _hiddenIds: _hiddenIds,
128
- hiddenIds: hiddenIds,
142
+ hiddenIds: hiddenValues,
129
143
  options: options
130
144
  })(R.propOr([], 'values', observation));
131
- var _idHidden = _hiddenIds[id] && R.isEmpty(R.difference(R.pluck('id')(values), _hiddenIds[id]));
132
- var isHidden = _idHidden || R.has(id, hiddenIds) || (0, _sdmxData.getIsHidden)(dimAnnotations);
145
+ var isAllDimHidden = getIsAllDimHidden({ id: id, values: values });
146
+ var isHidden = isAllDimHidden || R.has(id, hiddenValues) || (0, _sdmxData.getIsHidden)(dimAnnotations);
133
147
  return {
134
148
  observation: R.append((0, _extends3.default)({}, observation, {
135
149
  display: !isHidden,
136
150
  __index: obsIndex,
137
151
  name: getName(observation),
138
- values: _idHidden ? [] : values,
152
+ values: isAllDimHidden ? [] : values,
139
153
  role: isTimeDimension ? TIME_PERIOD_ID : R.head(R.propOr([], 'roles', observation))
140
154
  }))(acc.observation),
141
155
  dimensionsLayout: (0, _sdmxData.setAnnotationsLayout)(id, acc.dimensionsLayout)(dimAnnotations)
@@ -9,38 +9,50 @@ var _ramda = require('ramda');
9
9
 
10
10
  var R = _interopRequireWildcard(_ramda);
11
11
 
12
+ var _dotstatsuiteSdmxjs = require('@sis-cc/dotstatsuite-sdmxjs');
13
+
12
14
  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; } }
13
15
 
14
- var getNotDisplayedIds = exports.getNotDisplayedIds = function getNotDisplayedIds(annotations) {
15
- return R.pipe(R.find(R.propEq('type', 'NOT_DISPLAYED')), function (annot) {
16
- if (R.isNil(annot)) {
17
- return {};
16
+ var getNotDisplayedValues = function getNotDisplayedValues(annot) {
17
+ if (R.isNil(annot)) {
18
+ return {};
19
+ }
20
+ var ids = R.split(',', annot.title || '');
21
+ return R.reduce(function (acc, entry) {
22
+ if (R.isEmpty(entry)) {
23
+ return acc;
18
24
  }
19
- var ids = R.split(',', annot.title || '');
20
- return R.reduce(function (acc, entry) {
21
- if (R.isEmpty(entry)) {
22
- return acc;
23
- }
24
- var parsed = R.split('=', entry);
25
- var dimensionId = parsed[0];
26
- if (R.length(parsed) === 1) {
27
- return R.assoc(dimensionId, dimensionId, acc);
25
+ var parsed = R.split('=', entry);
26
+ var dimensionId = parsed[0];
27
+ if (R.length(parsed) === 1) {
28
+ return R.assoc(dimensionId, dimensionId, acc);
29
+ }
30
+ var values = R.split('+', parsed[1]);
31
+ if (R.length(values) === 1 && R.isEmpty(values[0])) {
32
+ return R.assoc(dimensionId, dimensionId, acc);
33
+ }
34
+ return R.reduce(function (_acc, val) {
35
+ var _val = val;
36
+ if (R.isEmpty(val)) {
37
+ return _acc;
28
38
  }
29
- var values = R.split('+', parsed[1]);
30
- if (R.length(values) === 1 && R.isEmpty(values[0])) {
31
- return R.assoc(dimensionId, dimensionId, acc);
39
+ if (R.test('/[()]/')) {
40
+ _val = R.replace(/[()]/g, '')(val);
32
41
  }
33
- return R.reduce(function (_acc, val) {
34
- var _val = val;
35
- if (R.isEmpty(val)) {
36
- return _acc;
37
- }
38
- if (R.test('/[()]/')) {
39
- _val = R.replace(/[()]/g, '')(val);
40
- }
41
- var key = R.isEmpty(_val) ? dimensionId : dimensionId + '.' + _val;
42
- return R.assoc(key, key, _acc);
43
- }, acc, values);
44
- }, {}, ids);
45
- })(annotations);
42
+ var key = R.isEmpty(_val) ? dimensionId : dimensionId + '.' + _val;
43
+ return R.assoc(key, key, _acc);
44
+ }, acc, values);
45
+ }, {}, ids);
46
+ };
47
+
48
+ var getNotDisplayedIds = exports.getNotDisplayedIds = function getNotDisplayedIds(annotations) {
49
+ return R.pipe(R.find(R.propEq('type', 'NOT_DISPLAYED')), R.converge(function (hiddenValues, hiddenCombinations) {
50
+ return {
51
+ hiddenValues: hiddenValues,
52
+ hiddenCombinations: hiddenCombinations
53
+ };
54
+ }, [getNotDisplayedValues, function () {
55
+ var annot = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { title: '' };
56
+ return (0, _dotstatsuiteSdmxjs.getNotDisplayedCombinations)(annot);
57
+ }]))(annotations);
46
58
  };
@@ -168,7 +168,7 @@ var getLayoutCombinations = exports.getLayoutCombinations = function getLayoutCo
168
168
  layoutConcepts = _R$reduce3.layoutConcepts,
169
169
  relationship = _R$reduce3.relationship;
170
170
 
171
- if (R.isEmpty(layoutConcepts)) {
171
+ if (R.isEmpty(relationship)) {
172
172
  return acc;
173
173
  }
174
174
  return R.append((0, _extends3.default)({}, comb, { relationship: relationship, concepts: layoutConcepts }), acc);
@@ -182,41 +182,59 @@ var getTableLayoutIds = exports.getTableLayoutIds = function getTableLayoutIds(d
182
182
  var filteredLayoutIds = R.map(R.filter(function (id) {
183
183
  return R.has(id, indexedCombinations) || layoutDimsIds.has(id);
184
184
  }), defaultLayoutIds);
185
-
186
185
  var layoutWithCombs = injectCombinationsInLayout(layoutCombinations, filteredLayoutIds);
187
- var layoutRelationshipsSets = R.map(function (ids) {
188
- return R.pipe(R.pick(ids, indexedCombsRelationships), R.values, R.unnest, function (i) {
189
- return new _set2.default(i);
190
- })(ids);
191
- }, layoutWithCombs);
186
+ var layoutRelationshipsSets = R.map(R.pipe(function (ids) {
187
+ return R.pick(ids, indexedCombinations);
188
+ }, R.values, R.pluck('relationship'), R.unnest, function (i) {
189
+ return new _set2.default(i);
190
+ }), layoutWithCombs);
192
191
  var layoutConceptsSets = R.pipe(R.map(R.reduce(function (acc, id) {
193
192
  if (R.has(id, indexedCombinations)) {
194
- return R.concat(acc, R.path([id, 'relationship'], indexedCombinations));
193
+ return R.concat(acc, R.path([id, 'concepts'], indexedCombinations));
195
194
  }
196
195
  return R.append(id, acc);
197
196
  }, [])), R.values, R.unnest, function (ids) {
198
197
  return new _set2.default(ids);
199
198
  })(layoutWithCombs);
200
199
 
201
- return R.reduce(function (acc, dim) {
202
- if (layoutConceptsSets.has(id) || !dim.series) {
200
+ var _R$reduce4 = R.reduce(function (acc, dim) {
201
+ if (layoutConceptsSets.has(dim.id) || dim.header) {
203
202
  return acc;
204
203
  }
205
204
  if (layoutRelationshipsSets.header.has(dim.id)) {
206
- return R.over(R.lensProp('header'), R.append(dim.id))(acc);
205
+ return R.over(R.lensPath(['nextLayout', 'header']), R.append(dim.id))(acc);
207
206
  }
208
207
  if (layoutRelationshipsSets.sections.has(dim.id)) {
209
- return R.over(R.lensProp('sections'), R.append(dim.id))(acc);
208
+ return R.over(R.lensPath(['nextLayout', 'sections']), R.append(dim.id))(acc);
210
209
  }
211
210
  if (layoutRelationshipsSets.rows.has(dim.id)) {
212
- return R.over(R.lensProp('rows'), R.append(dim.id))(acc);
211
+ return R.over(R.lensPath(['nextLayout', 'rows']), R.append(dim.id))(acc);
213
212
  }
214
213
  if ((0, _dotstatsuiteSdmxjs.isTimePeriodDimension)(dim)) {
215
- return R.over(R.lensProp('header'), R.append(dim.id))(acc);
214
+ return R.over(R.lensPath(['nextLayout', 'header']), R.append(dim.id))(acc);
216
215
  }
217
216
  if ((0, _dotstatsuiteSdmxjs.isRefAreaDimension)(dim)) {
218
- return R.over(R.lensProp('rows'), R.append(dim.id))(acc);
217
+ return R.over(R.lensPath(['nextLayout', 'rows']), R.append(dim.id))(acc);
219
218
  }
220
- return R.over(R.lensProp('sections'), R.append(dim.id))(acc);
221
- }, layoutWithCombs, dimensions);
219
+ return R.over(R.lensProp('remaining'), R.append(dim.id))(acc);
220
+ }, { nextLayout: layoutWithCombs, remaining: [] }, dimensions),
221
+ nextLayout = _R$reduce4.nextLayout,
222
+ remaining = _R$reduce4.remaining;
223
+
224
+ var _remaining = remaining;
225
+ return R.pipe(R.when(function (l) {
226
+ return R.isEmpty(l.rows) && !R.isEmpty(_remaining);
227
+ }, function (l) {
228
+ var nextL = R.over(R.lensProp('rows'), R.append(R.head(_remaining)))(l);
229
+ _remaining = R.tail(_remaining);
230
+ return nextL;
231
+ }), R.when(function (l) {
232
+ return R.isEmpty(l.header) && !R.isEmpty(_remaining);
233
+ }, function (l) {
234
+ var nextL = R.over(R.lensProp('header'), R.append(R.head(_remaining)))(l);
235
+ _remaining = R.tail(_remaining);
236
+ return nextL;
237
+ }), R.when(R.always(!R.isEmpty(_remaining)), function (l) {
238
+ return R.over(R.lensProp('sections'), R.flip(R.concat)(_remaining))(l);;
239
+ }))(nextLayout);
222
240
  };
@@ -269,6 +269,9 @@ var refineLayoutSize = exports.refineLayoutSize = function refineLayoutSize(_ref
269
269
 
270
270
  var cutLength = R.pipe(R.ifElse(R.identity, R.always(rowCellsCount), R.always(columnCellsCount)), R.divide(excess), Math.ceil)(isVertical);
271
271
 
272
+ var maxCutLength = isVertical ? rowsCount - 2 : headerValuesCount - 1;
273
+ cutLength = cutLength > maxCutLength ? maxCutLength : cutLength;
274
+
272
275
  var _truncateLayout = truncateLayout(isVertical)(cutLength, toTruncate),
273
276
  truncated = _truncateLayout.truncated,
274
277
  extractedKeys = _truncateLayout.extractedKeys;
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.22.0",
4
+ "version": "17.24.0",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -40,7 +40,6 @@ export const getValuesEnhanced = ({
40
40
  isTimeDimension = false,
41
41
  parent = '',
42
42
  reportYearStart,
43
- _hiddenIds = {},
44
43
  hiddenIds = {},
45
44
  options = {},
46
45
  }) => {
@@ -53,9 +52,7 @@ export const getValuesEnhanced = ({
53
52
  R.flip(R.props)(annotations),
54
53
  )(value);
55
54
 
56
- const isHidden =
57
- (_hiddenIds[parent] && R.includes(value.id, _hiddenIds[parent])) ||
58
- R.has(`${parent}.${value.id}`, hiddenIds) ||
55
+ const isHidden = R.has(`${parent}.${id}`, hiddenIds) ||
59
56
  getIsHidden(valueAnnotations);
60
57
 
61
58
  const { start, notes } = isTimeDimension
@@ -14,7 +14,7 @@ import { getValuesEnhanced } from './get-values-enhanced';
14
14
  const TIME_PERIOD_ID = 'TIME_PERIOD';
15
15
 
16
16
  export const dataTransformer = (dataNew, options = {}) => {
17
- const { locale, hiddenIds: _hiddenIds } = options;
17
+ const { locale } = options;
18
18
  const reportYearStart = getReportingYearStart(dataNew);
19
19
  const getName = R.prop('name')
20
20
  //---------------------------------------------------------------------------------------Annotations
@@ -30,7 +30,18 @@ export const dataTransformer = (dataNew, options = {}) => {
30
30
  annotations,
31
31
  );
32
32
 
33
- const hiddenIds = getNotDisplayedIds(dataSetsAnnotations);
33
+ /*
34
+ hiddenValues => codelistIds or codelistValuesIds for display computation
35
+ hiddenCombinations => used only for dimensions, if dimension values match the provided set, all dimension is removed
36
+ */
37
+ const { hiddenValues, hiddenCombinations } = getNotDisplayedIds(dataSetsAnnotations);
38
+ const getIsAllDimHidden = ({ id, values }) => {
39
+ if (!R.has(id, hiddenCombinations)) {
40
+ return false;
41
+ }
42
+ const valuesIds = R.pluck('id', values);
43
+ return R.isEmpty(R.difference(valuesIds), hiddenCombinations[id]);
44
+ }
34
45
 
35
46
  //--------------------------------------------------------------------------------------------Header
36
47
  const getMeta = R.propOr({}, 'meta');
@@ -57,15 +68,14 @@ export const dataTransformer = (dataNew, options = {}) => {
57
68
  ...observation,
58
69
  __index: index,
59
70
  display:
60
- !R.has(observation.id, hiddenIds) && !getIsHidden(obsAnnotations),
71
+ !R.has(observation.id, hiddenValues) && !getIsHidden(obsAnnotations),
61
72
  name: getName(observation),
62
73
  values: getValuesEnhanced({
63
74
  locale,
64
75
  annotations,
65
76
  parent: observation.id,
66
77
  reportYearStart,
67
- _hiddenIds,
68
- hiddenIds,
78
+ hiddenIds: hiddenValues,
69
79
  options,
70
80
  })(R.propOr([], 'values', observation)),
71
81
  roles: !R.isNil(observation.role) ? R.head(observation.role) : null,
@@ -76,14 +86,13 @@ export const dataTransformer = (dataNew, options = {}) => {
76
86
  const attrAnnotations = R.props(attr.annotations || [], annotations);
77
87
  return {
78
88
  ...attr,
79
- display: !R.has(attr.id, hiddenIds) && !getIsHidden(attrAnnotations),
89
+ display: !R.has(attr.id, hiddenValues) && !getIsHidden(attrAnnotations),
80
90
  name: getName(attr),
81
91
  values: getValuesEnhanced({
82
92
  locale,
83
93
  annotations,
84
94
  parent: attr.id,
85
- _hiddenIds,
86
- hiddenIds,
95
+ hiddenIds: hiddenValues,
87
96
  options,
88
97
  reportYearStart,
89
98
  })(R.propOr([], 'values', attr)),
@@ -116,22 +125,19 @@ export const dataTransformer = (dataNew, options = {}) => {
116
125
  isTimeDimension,
117
126
  reportYearStart,
118
127
  parent: id,
119
- _hiddenIds,
120
- hiddenIds,
128
+ hiddenIds: hiddenValues,
121
129
  options,
122
130
  })(R.propOr([], 'values', observation));
123
- const _idHidden =
124
- _hiddenIds[id] &&
125
- R.isEmpty(R.difference(R.pluck('id')(values), _hiddenIds[id]));
126
- const isHidden =
127
- _idHidden || R.has(id, hiddenIds) || getIsHidden(dimAnnotations);
131
+ const isAllDimHidden = getIsAllDimHidden({ id, values });
132
+ const isHidden = isAllDimHidden || R.has(id, hiddenValues)
133
+ || getIsHidden(dimAnnotations);
128
134
  return {
129
135
  observation: R.append({
130
136
  ...observation,
131
137
  display: !isHidden,
132
138
  __index: obsIndex,
133
139
  name: getName(observation),
134
- values: _idHidden ? [] : values,
140
+ values: isAllDimHidden ? [] : values,
135
141
  role: isTimeDimension
136
142
  ? TIME_PERIOD_ID
137
143
  : R.head(R.propOr([], 'roles', observation)),
@@ -1,44 +1,53 @@
1
1
  import * as R from 'ramda';
2
+ import { getNotDisplayedCombinations } from '@sis-cc/dotstatsuite-sdmxjs';
3
+
4
+ const getNotDisplayedValues = annot => {
5
+ if (R.isNil(annot)) {
6
+ return {};
7
+ }
8
+ const ids = R.split(',', annot.title || '');
9
+ return R.reduce(
10
+ (acc, entry) => {
11
+ if (R.isEmpty(entry)) {
12
+ return acc;
13
+ }
14
+ const parsed = R.split('=', entry);
15
+ const dimensionId = parsed[0];
16
+ if (R.length(parsed) === 1) {
17
+ return R.assoc(dimensionId, dimensionId, acc);
18
+ }
19
+ const values = R.split('+', parsed[1]);
20
+ if (R.length(values) === 1 && R.isEmpty(values[0])) {
21
+ return R.assoc(dimensionId, dimensionId, acc);
22
+ }
23
+ return R.reduce(
24
+ (_acc, val) => {
25
+ let _val = val
26
+ if (R.isEmpty(val)) {
27
+ return _acc;
28
+ }
29
+ if (R.test('/[()]/')) {
30
+ _val = R.replace(/[()]/g, '')(val)
31
+ }
32
+ const key = R.isEmpty(_val) ? dimensionId : `${dimensionId}.${_val}`;
33
+ return R.assoc(key, key, _acc);
34
+ },
35
+ acc,
36
+ values
37
+ );
38
+ },
39
+ {},
40
+ ids
41
+ );
42
+ };
2
43
 
3
44
  export const getNotDisplayedIds = (annotations) => R.pipe(
4
45
  R.find(R.propEq('type', 'NOT_DISPLAYED')),
5
- annot => {
6
- if (R.isNil(annot)) {
7
- return {};
8
- }
9
- const ids = R.split(',', annot.title || '');
10
- return R.reduce(
11
- (acc, entry) => {
12
- if (R.isEmpty(entry)) {
13
- return acc;
14
- }
15
- const parsed = R.split('=', entry);
16
- const dimensionId = parsed[0];
17
- if (R.length(parsed) === 1) {
18
- return R.assoc(dimensionId, dimensionId, acc);
19
- }
20
- const values = R.split('+', parsed[1]);
21
- if (R.length(values) === 1 && R.isEmpty(values[0])) {
22
- return R.assoc(dimensionId, dimensionId, acc);
23
- }
24
- return R.reduce(
25
- (_acc, val) => {
26
- let _val = val
27
- if (R.isEmpty(val)) {
28
- return _acc;
29
- }
30
- if (R.test('/[()]/')) {
31
- _val = R.replace(/[()]/g, '')(val)
32
- }
33
- const key = R.isEmpty(_val) ? dimensionId : `${dimensionId}.${_val}`;
34
- return R.assoc(key, key, _acc);
35
- },
36
- acc,
37
- values
38
- );
39
- },
40
- {},
41
- ids
42
- );
43
- }
46
+ R.converge((hiddenValues, hiddenCombinations) => ({
47
+ hiddenValues,
48
+ hiddenCombinations
49
+ }), [
50
+ getNotDisplayedValues,
51
+ (annot={ title: '' }) => getNotDisplayedCombinations(annot)
52
+ ])
44
53
  )(annotations);
@@ -113,7 +113,7 @@ export const getLayoutCombinations = (combinations, layoutDimsIds, attributes) =
113
113
  { layoutConcepts: [], relationship: [] },
114
114
  comb.concepts || [],
115
115
  );
116
- if (R.isEmpty(layoutConcepts)) {
116
+ if (R.isEmpty(relationship)) {
117
117
  return acc;
118
118
  }
119
119
  return R.append({ ...comb, relationship, concepts: layoutConcepts }, acc);
@@ -140,19 +140,19 @@ export const getTableLayoutIds = (
140
140
  R.filter(id => R.has(id, indexedCombinations) || layoutDimsIds.has(id)),
141
141
  defaultLayoutIds,
142
142
  );
143
-
144
143
  const layoutWithCombs = injectCombinationsInLayout(layoutCombinations, filteredLayoutIds);
145
- const layoutRelationshipsSets = R.map(ids => R.pipe(
146
- R.pick(ids, indexedCombsRelationships),
144
+ const layoutRelationshipsSets = R.map(R.pipe(
145
+ ids => R.pick(ids, indexedCombinations),
147
146
  R.values,
147
+ R.pluck('relationship'),
148
148
  R.unnest,
149
149
  i => new Set(i)
150
- )(ids),layoutWithCombs);
150
+ ), layoutWithCombs);
151
151
  const layoutConceptsSets = R.pipe(
152
152
  R.map(
153
153
  R.reduce((acc, id) => {
154
154
  if (R.has(id, indexedCombinations)) {
155
- return R.concat(acc, R.path([id, 'relationship'], indexedCombinations));
155
+ return R.concat(acc, R.path([id, 'concepts'], indexedCombinations));
156
156
  }
157
157
  return R.append(id, acc);
158
158
  }, []),
@@ -162,25 +162,51 @@ export const getTableLayoutIds = (
162
162
  ids => new Set(ids)
163
163
  )(layoutWithCombs);
164
164
 
165
- return R.reduce((acc, dim) => {
166
- if (layoutConceptsSets.has(id) || !dim.series) {
165
+ const { nextLayout, remaining } = R.reduce((acc, dim) => {
166
+ if (layoutConceptsSets.has(dim.id) || dim.header) {
167
167
  return acc;
168
168
  }
169
169
  if (layoutRelationshipsSets.header.has(dim.id)) {
170
- return R.over(R.lensProp('header'), R.append(dim.id))(acc);
170
+ return R.over(R.lensPath(['nextLayout', 'header']), R.append(dim.id))(acc);
171
171
  }
172
172
  if (layoutRelationshipsSets.sections.has(dim.id)) {
173
- return R.over(R.lensProp('sections'), R.append(dim.id))(acc);
173
+ return R.over(R.lensPath(['nextLayout', 'sections']), R.append(dim.id))(acc);
174
174
  }
175
175
  if (layoutRelationshipsSets.rows.has(dim.id)) {
176
- return R.over(R.lensProp('rows'), R.append(dim.id))(acc);
176
+ return R.over(R.lensPath(['nextLayout','rows']), R.append(dim.id))(acc);
177
177
  }
178
178
  if (isTimePeriodDimension(dim)) {
179
- return R.over(R.lensProp('header'), R.append(dim.id))(acc);
179
+ return R.over(R.lensPath(['nextLayout','header']), R.append(dim.id))(acc);
180
180
  }
181
181
  if (isRefAreaDimension(dim)) {
182
- return R.over(R.lensProp('rows'), R.append(dim.id))(acc);
182
+ return R.over(R.lensPath(['nextLayout','rows']), R.append(dim.id))(acc);
183
183
  }
184
- return R.over(R.lensProp('sections'), R.append(dim.id))(acc);
185
- }, layoutWithCombs, dimensions);
184
+ return R.over(R.lensProp('remaining'), R.append(dim.id))(acc);
185
+ }, { nextLayout: layoutWithCombs, remaining: [] }, dimensions);
186
+
187
+ let _remaining = remaining;
188
+ return R.pipe(
189
+ R.when(
190
+ l => R.isEmpty(l.rows) && !R.isEmpty(_remaining),
191
+ l => {
192
+ const nextL = R.over(R.lensProp('rows'), R.append(R.head(_remaining)))(l);
193
+ _remaining = R.tail(_remaining)
194
+ return nextL;
195
+ }
196
+ ),
197
+ R.when(
198
+ l => R.isEmpty(l.header) && !R.isEmpty(_remaining),
199
+ l => {
200
+ const nextL = R.over(R.lensProp('header'), R.append(R.head(_remaining)))(l);
201
+ _remaining = R.tail(_remaining)
202
+ return nextL;
203
+ }
204
+ ),
205
+ R.when(
206
+ R.always(!R.isEmpty(_remaining)),
207
+ l => {
208
+ return R.over(R.lensProp('sections'), R.flip(R.concat)(_remaining))(l);;
209
+ }
210
+ ),
211
+ )(nextLayout);
186
212
  };
@@ -288,12 +288,15 @@ export const refineLayoutSize = ({ layout, observations, limit }) => layoutIndex
288
288
 
289
289
  const [toTruncate, toRefine] = segregateLayout(isVertical)(layoutIndexes);
290
290
 
291
- const cutLength = R.pipe(
291
+ let cutLength = R.pipe(
292
292
  R.ifElse(R.identity, R.always(rowCellsCount), R.always(columnCellsCount)),
293
293
  R.divide(excess),
294
294
  Math.ceil
295
295
  )(isVertical);
296
296
 
297
+ const maxCutLength = isVertical ? rowsCount - 2 : headerValuesCount - 1;
298
+ cutLength = cutLength > maxCutLength ? maxCutLength : cutLength;
299
+
297
300
  const { truncated, extractedKeys } = truncateLayout(isVertical)(cutLength, toTruncate);
298
301
 
299
302
  const curatedObs = R.pipe(
@@ -9,7 +9,7 @@ describe('getNotDisplayedIds tests', () => {
9
9
  { type: 'NOT_DISPLAYED', title: '' },
10
10
  { type: 'test2' },
11
11
  ];
12
- expect(getNotDisplayedIds(annotations)).to.deep.equal({});
12
+ expect(getNotDisplayedIds(annotations)).to.deep.equal({ hiddenValues: {}, hiddenCombinations: {} });
13
13
  });
14
14
  it('complete case', () => {
15
15
  const annotations = [
@@ -19,25 +19,28 @@ describe('getNotDisplayedIds tests', () => {
19
19
  { type: 'test2' },
20
20
  ];
21
21
  const expected = {
22
- d0: 'd0',
23
- d1: 'd1',
24
- 'd2.v0': 'd2.v0',
25
- 'd3.v0': 'd3.v0',
26
- 'd4.v0': 'd4.v0',
27
- 'd4.v1': 'd4.v1',
28
- 'd5.v0': 'd5.v0',
29
- 'd5.v1': 'd5.v1',
30
- 'd5.v2': 'd5.v2',
31
- 'd6.v0': 'd6.v0',
32
- 'd6.v1': 'd6.v1',
33
- 'd7.v0': 'd7.v0',
34
- 'd7.v1': 'd7.v1',
35
- 'd8.v0': 'd8.v0',
36
- 'd8.v1': 'd8.v1',
37
- d9: 'd9',
38
-
39
-
40
-
22
+ hiddenValues: {
23
+ d0: 'd0',
24
+ d1: 'd1',
25
+ 'd2.v0': 'd2.v0',
26
+ 'd3.v0': 'd3.v0',
27
+ 'd4.v0': 'd4.v0',
28
+ 'd4.v1': 'd4.v1',
29
+ 'd5.v0': 'd5.v0',
30
+ 'd5.v1': 'd5.v1',
31
+ 'd5.v2': 'd5.v2',
32
+ 'd6.v0': 'd6.v0',
33
+ 'd6.v1': 'd6.v1',
34
+ 'd7.v0': 'd7.v0',
35
+ 'd7.v1': 'd7.v1',
36
+ 'd8.v0': 'd8.v0',
37
+ 'd8.v1': 'd8.v1',
38
+ d9: 'd9',
39
+ },
40
+ hiddenCombinations: {
41
+ d5: ['v0', 'v1'],
42
+ d6: ['v0', 'v1'],
43
+ }
41
44
  };
42
45
  expect(getNotDisplayedIds(annotations)).to.deep.equal(expected);
43
46
  });
@@ -1,8 +1,21 @@
1
1
  import { expect } from 'chai';
2
- import { injectCombinationsInLayout } from '../src/rules2/src/table/getTableLayoutIds';
2
+ import { injectCombinationsInLayout, getTableLayoutIds } from '../src/rules2/src/table/getTableLayoutIds';
3
3
 
4
4
  describe('injectCombinationsInLayout', () => {
5
- it('complete test', () => {
5
+ it('no combinations', () => {
6
+ const layoutIds = {
7
+ header: ['D1'],
8
+ sections: ['D2'],
9
+ rows: ['D3']
10
+ };
11
+ const combinations = [];
12
+ expect(injectCombinationsInLayout(combinations, layoutIds)).to.deep.equal({
13
+ header: ['D1'],
14
+ sections: ['D2'],
15
+ rows: ['D3']
16
+ });
17
+ });
18
+ it('partial start', () => {
6
19
  const layoutIds = {
7
20
  header: ['D1', 'C1', 'D2'],
8
21
  sections: ['C5', 'D5', 'D3'],
@@ -29,3 +42,72 @@ describe('injectCombinationsInLayout', () => {
29
42
  });
30
43
  });
31
44
  });
45
+
46
+ describe('getTableLayoutIds tests', () => {
47
+ it('simple case blank start', () => {
48
+ const layoutIds = {
49
+ header: [],
50
+ sections: [],
51
+ rows: []
52
+ };
53
+ const combinations = [];
54
+ const attributes = [];
55
+ const dimensions = [
56
+ { id: 'REF_AREA' },
57
+ { id: 'MEASURE' },
58
+ { id: 'REF_SECTOR' },
59
+ { id: 'TIME_PERIOD' },
60
+ ];
61
+
62
+ expect(getTableLayoutIds(layoutIds, dimensions, attributes, combinations)).to.deep.equal({
63
+ header: ['TIME_PERIOD'],
64
+ sections: ['MEASURE', 'REF_SECTOR'],
65
+ rows: ['REF_AREA']
66
+ });
67
+ });
68
+ it('blank start with combinations', () => {
69
+ const layoutIds = {
70
+ header: [],
71
+ sections: ['COMB1'],
72
+ rows: []
73
+ };
74
+ const combinations = [
75
+ {
76
+ id: 'COMB1',
77
+ concepts: ['REF_SECTOR', 'MEASURE'],
78
+ },
79
+ {
80
+ id: 'COMB2',
81
+ concepts: ['UNIT_MEASURE', 'CURRENCY'],
82
+ },
83
+ {
84
+ id: 'COMB3',
85
+ concepts: ['ATTR1', 'ATTR2'],
86
+ },
87
+ {
88
+ id: 'COMB4',
89
+ concepts: ['ATTR3', 'ATTR4']
90
+ }
91
+ ];
92
+ const dimensions = [
93
+ { id: 'REF_AREA' },
94
+ { id: 'REF_SECTOR' },
95
+ { id: 'TRANSACTION' },
96
+ { id: 'MEASURE' },
97
+ { id: 'UNIT_MEASURE' },
98
+ { id: 'CURRENCY' }
99
+ ];
100
+ const attributes = [
101
+ { id: 'ATTR1', relationship: ['MEASURE'], series: true },
102
+ { id: 'ATTR2', relationship: ['MEASURE'], series: true },
103
+ { id: 'ATTR3', relationship: [], series: true },
104
+ { id: 'ATTR4', relationship: [], series: true },
105
+ ];
106
+
107
+ expect(getTableLayoutIds(layoutIds, dimensions, attributes, combinations)).to.deep.equal({
108
+ header: ['TRANSACTION'],
109
+ sections: ['COMB1', 'COMB3'],
110
+ rows: ['COMB2', 'REF_AREA']
111
+ });
112
+ });
113
+ });
@@ -100,7 +100,7 @@ const partialObservations3 = {
100
100
  };
101
101
 
102
102
  describe('refineLayoutSize 2 tests', () => {
103
- it('no changes under limit', () => {
103
+ /*it('no changes under limit', () => {
104
104
  const layout = {
105
105
  header: [{ __index: 0 }],
106
106
  sections: [{ __index: 1 }],
@@ -335,6 +335,73 @@ describe('refineLayoutSize 2 tests', () => {
335
335
  limit: 90
336
336
  })(layoutIndexes)
337
337
  ).to.deep.equal(expected);
338
+ });*/
339
+ it('cannot fit the limit', () => {
340
+ const layout = {
341
+ header: [{ __index: 1 }],
342
+ rows: [{ __index: 0 }],
343
+ sections: [],
344
+ };
345
+
346
+ const layoutIndexes = {
347
+ header: [
348
+ { indexes: [0], parentsIndexes: [[]], missingIndexes: [[]] },
349
+ { indexes: [1], parentsIndexes: [[]], missingIndexes: [[]] },
350
+ ],
351
+ sections: [
352
+ [
353
+ { indexes: [] },
354
+ [
355
+ { indexes: [0], parentsIndexes: [[]], missingIndexes: [[]] },
356
+ { indexes: [1], parentsIndexes: [[]], missingIndexes: [[]] },
357
+ { indexes: [2], parentsIndexes: [[]], missingIndexes: [[]] },
358
+ { indexes: [3], parentsIndexes: [[]], missingIndexes: [[]] },
359
+ { indexes: [4], parentsIndexes: [[]], missingIndexes: [[]] },
360
+ { indexes: [5], parentsIndexes: [[]], missingIndexes: [[]] },
361
+ ]
362
+ ]
363
+ ]
364
+ };
365
+
366
+ const observations = {
367
+ '0:0': { orderedDimIndexes: [0, 0] },
368
+ '0:1': { orderedDimIndexes: [0, 1] },
369
+ '1:0': { orderedDimIndexes: [1, 0] },
370
+ '1:1': { orderedDimIndexes: [1, 1] },
371
+ '2:0': { orderedDimIndexes: [2, 0] },
372
+ '2:1': { orderedDimIndexes: [2, 1] },
373
+ '3:0': { orderedDimIndexes: [3, 0] },
374
+ '3:1': { orderedDimIndexes: [3, 1] },
375
+ '4:0': { orderedDimIndexes: [4, 0] },
376
+ '4:1': { orderedDimIndexes: [4, 1] },
377
+ '5:0': { orderedDimIndexes: [5, 0] },
378
+ '5:1': { orderedDimIndexes: [5, 1] },
379
+ };
380
+
381
+ const expected = {
382
+ header: [
383
+ { indexes: [0], parentsIndexes: [[]], missingIndexes: [[]] },
384
+ { indexes: [1], parentsIndexes: [[]], missingIndexes: [[]] },
385
+ ],
386
+ sections: [
387
+ [
388
+ { indexes: [] },
389
+ [
390
+ { indexes: [0], parentsIndexes: [[]], missingIndexes: [[]] },
391
+ ]
392
+ ]
393
+ ],
394
+ truncated: true,
395
+ totalCells: 31
396
+ };
397
+
398
+ expect(
399
+ refineLayoutSize({
400
+ layout,
401
+ observations,
402
+ limit: 2
403
+ })(layoutIndexes)
404
+ ).to.deep.equal(expected);
338
405
  });
339
406
  /*it('no rows', () => {
340
407