@sis-cc/dotstatsuite-components 17.1.0 → 17.2.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.
@@ -11,10 +11,16 @@ var R = _interopRequireWildcard(_ramda);
11
11
 
12
12
  var _constants = require('./constants');
13
13
 
14
+ var _src = require('../../rules2/src');
15
+
14
16
  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; } }
15
17
 
16
18
  var isTableLayoutCompatible = function isTableLayoutCompatible(data, layout) {
17
- var multiValuesDimensions = R.pipe(R.pathOr([], ['structure', 'dimensions', 'observation']), R.reject(R.pipe(R.propOr([], 'values'), R.length, R.gte(1))), R.pluck('id'))(data);
19
+ var dataquery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
20
+
21
+ var multiValuesDimensions = R.pipe(R.pathOr([], ['structure', 'dimensions', 'observation']), function (dimensions) {
22
+ return (0, _src.refineDimensions)(dimensions, dataquery);
23
+ }, R.reject(R.prop('header')), R.pluck('id'))(data);
18
24
  var dimensionsInLayout = R.pipe(R.values, R.unnest)(layout);
19
25
 
20
26
  var dimensionsLength = R.length(multiValuesDimensions);
@@ -63,7 +69,8 @@ var isSharedLayoutCompatible = exports.isSharedLayoutCompatible = function isSha
63
69
  var type = R.prop('type', sharedData);
64
70
  if (type === 'table') {
65
71
  var layoutIds = R.pathOr({}, ['config', 'table', 'layoutIds'], sharedData);
66
- return isTableLayoutCompatible(sdmxData, layoutIds);
72
+ var dataquery = R.path(['config', 'sdmxSource', 'dataquery'], sharedData);
73
+ return isTableLayoutCompatible(sdmxData, layoutIds, dataquery);
67
74
  }
68
75
  var chartDimension = R.pathOr({}, ['config', 'chart', 'chartDimension'], sharedData);
69
76
  return isChartLayoutCompatible(sdmxData, type, chartDimension);
@@ -22,7 +22,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
22
  var getManyValuesDimensions = exports.getManyValuesDimensions = function getManyValuesDimensions(dimensions, attributesSeries, customAttributes, combinations) {
23
23
  var combConceptsIds = R.pipe(R.pluck('concepts'), R.unnest)(combinations);
24
24
  return R.reduce(function (acc, dim) {
25
- if (R.length(dim.values || []) < 2) {
25
+ if (dim.header) {
26
26
  return acc;
27
27
  }
28
28
  var enhancedValues = R.map(function (val) {
@@ -39,7 +39,7 @@ var getOneValueDimensions = exports.getOneValueDimensions = function getOneValue
39
39
  })(acc);
40
40
  }, {}, attributes);
41
41
  return R.reduce(function (acc, dim) {
42
- if (R.length(dim.values || []) !== 1) {
42
+ if (!dim.header) {
43
43
  return acc;
44
44
  }
45
45
  var attrValues = R.propOr({}, dim.id, indexedRelevantAttributes);
@@ -157,6 +157,15 @@ Object.defineProperty(exports, 'getCombinationDefinitions', {
157
157
  }
158
158
  });
159
159
 
160
+ var _refineDimensions = require('./refineDimensions');
161
+
162
+ Object.defineProperty(exports, 'refineDimensions', {
163
+ enumerable: true,
164
+ get: function get() {
165
+ return _refineDimensions.refineDimensions;
166
+ }
167
+ });
168
+
160
169
  var _parseAttributes = require('./parseAttributes');
161
170
 
162
171
  Object.defineProperty(exports, 'parseAttributes', {
@@ -39,8 +39,8 @@ var parseAttributes = exports.parseAttributes = function parseAttributes(attribu
39
39
  return (0, _extends3.default)({}, res, { series: true, relationship: [] });
40
40
  }
41
41
  var seriesDimensions = R.pipe(R.pathOr([], ['relationship', 'dimensions']), R.filter(function (id) {
42
- var values = R.path([id, 'values'], indexedDimensions);
43
- return R.length(values) > 1;
42
+ var dimension = R.prop(id, indexedDimensions);
43
+ return !dimension.header;
44
44
  }))(attr);
45
45
  if (R.length(seriesDimensions) > 0) {
46
46
  return (0, _extends3.default)({}, res, { series: true, relationship: seriesDimensions });
@@ -42,11 +42,11 @@ var parseCombinations = exports.parseCombinations = function parseCombinations(c
42
42
  return false;
43
43
  }
44
44
  if (R.has(concept, indexedDimensions)) {
45
- var values = R.path([concept, 'values'], indexedDimensions);
46
- relationship = R.length(values) > 1 ? R.append(concept, relationship) : relationship;
45
+ var dimension = R.prop(concept, indexedDimensions);
46
+ relationship = !dimension.header ? R.append(concept, relationship) : relationship;
47
47
  ids = (0, _extends4.default)({}, ids, (0, _defineProperty3.default)({}, concept, concept));
48
- displayable_values_count += R.length(values);
49
- return R.length(values) > 1;
48
+ displayable_values_count += R.length(dimension.values || []);
49
+ return !dimension.header;
50
50
  } else if (!R.has(concept, indexedAttributes)) {
51
51
  return false;
52
52
  }
@@ -11,6 +11,8 @@ var R = _interopRequireWildcard(_ramda);
11
11
 
12
12
  var _src = require('../../rules/src');
13
13
 
14
+ var _refineDimensions = require('./refineDimensions');
15
+
14
16
  var _enhanceObservations = require('./enhanceObservations');
15
17
 
16
18
  var _parseAttributes = require('./parseAttributes');
@@ -53,9 +55,11 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, _ref) {
53
55
  hierarchies = _ref.hierarchies,
54
56
  dataflow = _ref.dataflow,
55
57
  display = _ref.display,
56
- defaultCombinations = _ref.defaultCombinations;
58
+ defaultCombinations = _ref.defaultCombinations,
59
+ dataquery = _ref.dataquery;
57
60
 
58
61
  var dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], sdmxJson);
62
+ var refinedDimensions = (0, _refineDimensions.refineDimensions)(dimensions, dataquery);
59
63
  var attributes = R.pathOr([], ['data', 'structure', 'attributes', 'observation'], sdmxJson);
60
64
  var annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
61
65
  var observations = (0, _src.getObservations)(sdmxJson);
@@ -68,15 +72,15 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, _ref) {
68
72
  }
69
73
  var metadataCoordinates = (0, _getMetadataCoordinates.getMetadataCoordinates)(sdmxJson);
70
74
 
71
- var parsedAttributes = (0, _parseAttributes.parseAttributes)(attributes, dimensions, customAttributes);
72
- var parsedCombinations = (0, _parseCombinations.parseCombinations)(combinations, parsedAttributes, dimensions);
75
+ var parsedAttributes = (0, _parseAttributes.parseAttributes)(attributes, refinedDimensions, customAttributes);
76
+ var parsedCombinations = (0, _parseCombinations.parseCombinations)(combinations, parsedAttributes, refinedDimensions);
73
77
  var seriesCombinations = R.filter(R.prop('series'), parsedCombinations);
74
78
  var refinedAttributes = (0, _refineAttributes.refineAttributes)(parsedAttributes, seriesCombinations);
75
79
 
76
- var enhancedObservations = (0, _enhanceObservations.enhanceObservations)(dimensions, observations, refinedAttributes, { customAttributes: customAttributes });
80
+ var enhancedObservations = (0, _enhanceObservations.enhanceObservations)(refinedDimensions, observations, refinedAttributes, { customAttributes: customAttributes });
77
81
  var attributesSeries = (0, _getAttributesSeries.getAttributesSeries)(enhancedObservations);
78
- var manyValuesDimensions = (0, _getManyValuesDimensions.getManyValuesDimensions)(dimensions, attributesSeries, customAttributes, seriesCombinations);
79
- var oneValueDimensions = (0, _getOneValueDimensions.getOneValueDimensions)(dimensions, parsedAttributes);
82
+ var manyValuesDimensions = (0, _getManyValuesDimensions.getManyValuesDimensions)(refinedDimensions, attributesSeries, customAttributes, seriesCombinations);
83
+ var oneValueDimensions = (0, _getOneValueDimensions.getOneValueDimensions)(refinedDimensions, parsedAttributes);
80
84
  var headerCoordinates = (0, _getHeaderCoordinates.getHeaderCoordinates)(oneValueDimensions);
81
85
  var hierarchisedDimensions = R.map(function (dim) {
82
86
  if (R.isEmpty(R.propOr({}, dim.id, hierarchies))) {
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.refineDimensions = undefined;
7
+
8
+ var _extends2 = require('babel-runtime/helpers/extends');
9
+
10
+ var _extends3 = _interopRequireDefault(_extends2);
11
+
12
+ var _ramda = require('ramda');
13
+
14
+ var R = _interopRequireWildcard(_ramda);
15
+
16
+ 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; } }
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ var refineDimensions = exports.refineDimensions = function refineDimensions() {
21
+ var dimensions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
22
+ var dataquery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
23
+
24
+ var selectionIds = R.pipe(R.split('.'), R.map(R.split('+')))(dataquery);
25
+
26
+ return R.addIndex(R.map)(function (dim, index) {
27
+ var selection = R.nth(index, selectionIds);
28
+ if (R.isNil(selection) || R.length(selection) === 0 || R.isEmpty(R.head(selection))) {
29
+ return (0, _extends3.default)({}, dim, { header: R.length(dim.values || []) <= 1 });
30
+ }
31
+ var values = R.map(function (val) {
32
+ if (R.includes(val.id, selection)) {
33
+ return val;
34
+ }
35
+ return R.assoc('empty', true, val);
36
+ }, dim.values || []);
37
+ return (0, _extends3.default)({}, dim, { values: values, header: R.length(values) <= 1 || R.length(selection) === 1 });
38
+ }, dimensions);
39
+ };
@@ -79,6 +79,9 @@ var getLayout = exports.getLayout = function getLayout(layoutIds, dimensions, co
79
79
  if (R.has(id, conceptIds)) {
80
80
  return acc;
81
81
  }
82
+ if (!R.has(id, indexedDimensions)) {
83
+ return acc;
84
+ }
82
85
  return R.append(R.prop(id, indexedDimensions), acc);
83
86
  }, [], layoutIds[key]);
84
87
  return R.concat(rest, combs);
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.1.0",
4
+ "version": "17.2.0",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -6,11 +6,13 @@ import {
6
6
  STACKED_ROW,
7
7
  V_SYMBOL
8
8
  } from './constants';
9
+ import { refineDimensions } from '../../rules2/src';
9
10
 
10
- const isTableLayoutCompatible = (data, layout) => {
11
+ const isTableLayoutCompatible = (data, layout, dataquery='') => {
11
12
  const multiValuesDimensions = R.pipe(
12
13
  R.pathOr([], ['structure', 'dimensions', 'observation']),
13
- R.reject(R.pipe(R.propOr([], 'values'), R.length, R.gte(1))),
14
+ dimensions => refineDimensions(dimensions, dataquery),
15
+ R.reject(R.prop('header')),
14
16
  R.pluck('id')
15
17
  )(data);
16
18
  const dimensionsInLayout = R.pipe(R.values, R.unnest)(layout);
@@ -82,7 +84,8 @@ export const isSharedLayoutCompatible = (sdmxData, sharedData) => {
82
84
  const type = R.prop('type', sharedData);
83
85
  if (type === 'table') {
84
86
  const layoutIds = R.pathOr({}, ['config', 'table', 'layoutIds'], sharedData);
85
- return isTableLayoutCompatible(sdmxData, layoutIds);
87
+ const dataquery = R.path(['config', 'sdmxSource', 'dataquery'], sharedData);
88
+ return isTableLayoutCompatible(sdmxData, layoutIds, dataquery);
86
89
  }
87
90
  const chartDimension = R.pathOr({}, ['config', 'chart', 'chartDimension'], sharedData);
88
91
  return isChartLayoutCompatible(sdmxData, type, chartDimension);
@@ -5,7 +5,7 @@ export const getManyValuesDimensions = (dimensions, attributesSeries, customAttr
5
5
  const combConceptsIds = R.pipe(R.pluck('concepts'), R.unnest)(combinations);
6
6
  return R.reduce(
7
7
  (acc, dim) => {
8
- if (R.length(dim.values || []) < 2) {
8
+ if (dim.header) {
9
9
  return acc;
10
10
  }
11
11
  const enhancedValues = R.map(val => {
@@ -22,7 +22,7 @@ export const getOneValueDimensions = (dimensions, attributes) => {
22
22
  );
23
23
  return R.reduce(
24
24
  (acc, dim) => {
25
- if (R.length(dim.values || []) !== 1) {
25
+ if (!dim.header) {
26
26
  return acc;
27
27
  }
28
28
  const attrValues = R.propOr({}, dim.id, indexedRelevantAttributes);
@@ -18,6 +18,7 @@ export { hierarchiseDimensionWithAdvancedHierarchy } from './hierarchiseDimensio
18
18
  export { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy';
19
19
  export { getDimensionValuesIndexes } from './getDimensionValuesIndexes';
20
20
  export { getCombinationDefinitions } from './getCombinationDefinitions';
21
+ export { refineDimensions } from './refineDimensions';
21
22
  export { parseAttributes } from './parseAttributes';
22
23
  export { parseCombinations } from './parseCombinations';
23
24
  export { refineAttributes } from './refineAttributes';
@@ -24,8 +24,8 @@ export const parseAttributes = (attributes, dimensions, customAttributes) => {
24
24
  const seriesDimensions = R.pipe(
25
25
  R.pathOr([], ['relationship', 'dimensions']),
26
26
  R.filter(id => {
27
- const values = R.path([id, 'values'], indexedDimensions);
28
- return R.length(values) > 1;
27
+ const dimension = R.prop(id, indexedDimensions);
28
+ return !dimension.header;
29
29
  }),
30
30
  )(attr);
31
31
  if (R.length(seriesDimensions) > 0) {
@@ -21,11 +21,11 @@ export const parseCombinations = (combinations, parsedAttributes, dimensions) =>
21
21
  return false;
22
22
  }
23
23
  if (R.has(concept, indexedDimensions)) {
24
- const values = R.path([concept, 'values'], indexedDimensions);
25
- relationship = R.length(values) > 1 ? R.append(concept, relationship) : relationship;
24
+ const dimension = R.prop(concept, indexedDimensions);
25
+ relationship = !dimension.header ? R.append(concept, relationship) : relationship;
26
26
  ids = { ...ids, [concept]: concept };
27
- displayable_values_count += R.length(values);
28
- return R.length(values) > 1;
27
+ displayable_values_count += R.length(dimension.values || []);
28
+ return !dimension.header;
29
29
  }
30
30
  else if (!R.has(concept, indexedAttributes)) {
31
31
  return false;
@@ -1,5 +1,6 @@
1
1
  import * as R from 'ramda';
2
2
  import { getObservations } from '../../rules/src';
3
+ import { refineDimensions } from './refineDimensions';
3
4
  import { enhanceObservations } from './enhanceObservations';
4
5
  import { parseAttributes } from './parseAttributes';
5
6
  import { getCombinationDefinitions, parseCombinationDefinition } from './getCombinationDefinitions';
@@ -18,8 +19,9 @@ import { getHeaderSubtitle } from './getHeaderSubtitle';
18
19
  import { getHeaderCombinations } from './getHeaderCombinations';
19
20
  import { getHeaderCoordinates } from './getHeaderCoordinates';
20
21
 
21
- export const prepareData = (sdmxJson, { customAttributes, locale, hierarchies, dataflow, display, defaultCombinations }) => {
22
+ export const prepareData = (sdmxJson, { customAttributes, locale, hierarchies, dataflow, display, defaultCombinations, dataquery }) => {
22
23
  const dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], sdmxJson);
24
+ const refinedDimensions = refineDimensions(dimensions, dataquery);
23
25
  const attributes = R.pathOr([], ['data', 'structure', 'attributes', 'observation'], sdmxJson);
24
26
  const annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
25
27
  const observations = getObservations(sdmxJson);
@@ -30,15 +32,15 @@ export const prepareData = (sdmxJson, { customAttributes, locale, hierarchies, d
30
32
  }
31
33
  const metadataCoordinates = getMetadataCoordinates(sdmxJson);
32
34
 
33
- const parsedAttributes = parseAttributes(attributes, dimensions, customAttributes);
34
- const parsedCombinations = parseCombinations(combinations, parsedAttributes, dimensions);
35
+ const parsedAttributes = parseAttributes(attributes, refinedDimensions, customAttributes);
36
+ const parsedCombinations = parseCombinations(combinations, parsedAttributes, refinedDimensions);
35
37
  const seriesCombinations = R.filter(R.prop('series'), parsedCombinations);
36
38
  const refinedAttributes = refineAttributes(parsedAttributes, seriesCombinations);
37
39
 
38
- const enhancedObservations = enhanceObservations(dimensions, observations, refinedAttributes, { customAttributes });
40
+ const enhancedObservations = enhanceObservations(refinedDimensions, observations, refinedAttributes, { customAttributes });
39
41
  const attributesSeries = getAttributesSeries(enhancedObservations);
40
- const manyValuesDimensions = getManyValuesDimensions(dimensions, attributesSeries, customAttributes, seriesCombinations);
41
- const oneValueDimensions = getOneValueDimensions(dimensions, parsedAttributes);
42
+ const manyValuesDimensions = getManyValuesDimensions(refinedDimensions, attributesSeries, customAttributes, seriesCombinations);
43
+ const oneValueDimensions = getOneValueDimensions(refinedDimensions, parsedAttributes);
42
44
  const headerCoordinates = getHeaderCoordinates(oneValueDimensions);
43
45
  const hierarchisedDimensions = R.map(dim => {
44
46
  if (R.isEmpty(R.propOr({}, dim.id, hierarchies))) {
@@ -0,0 +1,19 @@
1
+ import * as R from 'ramda';
2
+
3
+ export const refineDimensions = (dimensions=[], dataquery='') => {
4
+ const selectionIds = R.pipe(R.split('.'), R.map(R.split('+')))(dataquery);
5
+
6
+ return R.addIndex(R.map)((dim, index) => {
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
+ const values = R.map(val => {
12
+ if (R.includes(val.id, selection)) {
13
+ return val;
14
+ }
15
+ return R.assoc('empty', true, val);
16
+ }, dim.values || []);
17
+ return { ...dim, values, header: R.length(values) <= 1 || R.length(selection) === 1 };
18
+ }, dimensions);
19
+ };
@@ -59,6 +59,9 @@ export const getLayout = (layoutIds, dimensions, combinations, isTimeInverted) =
59
59
  if (R.has(id, conceptIds)) {
60
60
  return acc;
61
61
  }
62
+ if (!R.has(id, indexedDimensions)) {
63
+ return acc;
64
+ }
62
65
  return R.append(R.prop(id, indexedDimensions), acc);
63
66
  },
64
67
  [],
@@ -13,20 +13,23 @@ describe('getOneValueDimensions tests', () => {
13
13
  ];
14
14
 
15
15
  const dimensions = [
16
- { id: 'd0', values: [{ id: 'v' }] },
17
- { id: 'd1', values: [{ id: 'v' }] },
18
- { id: 'd2', display: false, values: [{ id: 'v' }] },
19
- { id: 'd3', values: [{ id: 'v', display: false }] },
20
- { id: 'd4', values: [{ id: '_T' }] },
21
- { id: 'd5', values: [{ id: 'v0' }, { id: 'v1' }] },
16
+ { id: 'd0', header: true, values: [{ id: 'v' }] },
17
+ { id: 'd1', header: true, values: [{ id: 'v' }] },
18
+ { id: 'd2', header: true, display: false, values: [{ id: 'v' }] },
19
+ { id: 'd3', header: true, values: [{ id: 'v', display: false }] },
20
+ { id: 'd4', header: true, values: [{ id: '_T' }] },
21
+ { id: 'd5', header: true, values: [{ id: 'v0' }, { id: 'v1' }] },
22
+ { id: 'd6', header: false, values: [{ id: 'v0' }] },
23
+ { id: 'd7', header: false, values: [{ id: 'v0' }, { id: 'v1' }] },
22
24
  ];
23
25
 
24
26
  expect(getOneValueDimensions(dimensions, attributes)).to.deep.equal([
25
- { id: 'd0', values: [{ id: 'v' }], attrValues: { a1: { id: 'a1', header: true, values: [{ id: 'v' }], relationship: ['d0'], value: { id: 'v' } } } },
26
- { id: 'd1', values: [{ id: 'v' }], attrValues: {} },
27
- { id: 'd2', values: [{ id: 'v' }], display: false, attrValues: {} },
28
- { id: 'd3', values: [{ id: 'v', display: false }], attrValues: {} },
29
- { id: 'd4', values: [{ id: '_T' }], attrValues: {} },
27
+ { id: 'd0', header: true, values: [{ id: 'v' }], attrValues: { a1: { id: 'a1', header: true, values: [{ id: 'v' }], relationship: ['d0'], value: { id: 'v' } } } },
28
+ { id: 'd1', header: true, values: [{ id: 'v' }], attrValues: {} },
29
+ { id: 'd2', header: true, values: [{ id: 'v' }], display: false, attrValues: {} },
30
+ { id: 'd3', header: true, values: [{ id: 'v', display: false }], attrValues: {} },
31
+ { id: 'd4', header: true, values: [{ id: '_T' }], attrValues: {} },
32
+ { id: 'd5', header: true, values: [{ id: 'v0' }, { id: 'v1' }], attrValues: {} },
30
33
  ])
31
34
  });
32
35
  });
@@ -12,19 +12,19 @@ const attributes = [
12
12
  const customAttributes = {};
13
13
 
14
14
  const dimensions = [
15
- { id: 'd1', values: [{ id: 'v0' }] },
16
- { id: 'd2', values: [{ id: 'v0' }] },
17
- { id: 'd3', values: [{ id: 'v0' }] },
18
- { id: 'd4', values: [{ id: 'v0' }, { id: 'v1' }] },
19
- { id: 'd5', values: [{ id: 'v0' }, { id: 'v1' }] },
20
- { id: 'd6', values: [{ id: 'v0' }, { id: 'v1' }] },
15
+ { id: 'd1', header: true, values: [{ id: 'v0' }] },
16
+ { id: 'd2', header: true, values: [{ id: 'v0' }] },
17
+ { id: 'd3', header: true, values: [{ id: 'v0' }] },
18
+ { id: 'd4', header: false, values: [{ id: 'v0' }, { id: 'v1' }] },
19
+ { id: 'd5', header: false, values: [{ id: 'v0' }, { id: 'v1' }] },
20
+ { id: 'd6', header: false, values: [{ id: 'v0' }, { id: 'v1' }] },
21
21
  ];
22
22
 
23
23
  describe('parseAttributes test', () => {
24
24
  it('complete case', () => {
25
25
  expect(parseAttributes(attributes, dimensions, customAttributes)).to.deep.equal([
26
26
  { id: 'a6', index: 0, relationship: [], series: true, values: [{ id: 'a6v1' }] },
27
- { id: 'a8', index: 1, relationship: ['d1'], header: true,values: [{ id: 'a8v1' }] },
27
+ { id: 'a8', index: 1, relationship: ['d1'], header: true, values: [{ id: 'a8v1' }] },
28
28
  { id: 'a9', index: 2, relationship: ['d4'], series: true, values: [{ id: 'a9v1' }] },
29
29
  { id: 'a10', index: 3, relationship: ['d1', 'd2'], header: true, values: [{ id: 'a10v1' }] },
30
30
  { id: 'a11', index: 4, relationship: ['d4'], series: true, values: [{ id: 'a11v1' }] },
@@ -17,12 +17,12 @@ describe('parseCombinations tests', () => {
17
17
  ];
18
18
 
19
19
  const dimensions = [
20
- { id: 'DIM1', values: [{ id: 'v1' }] },
21
- { id: 'DIM2', values: [{ id: 'v1' }] },
22
- { id: 'DIM3', values: [{ id: 'v1' }, { id: 'v2' }] },
23
- { id: 'DIM4', values: [{ id: 'v1' }, { id: 'v2' }] },
24
- { id: 'DIM5', values: [{ id: '_Z' }, { id: 'v2', display: false }] },
25
- { id: 'DIM6', values: [{ id: 'v1', display: false }, { id: 'v2', display: false }] }
20
+ { id: 'DIM1', header: true, values: [{ id: 'v1' }] },
21
+ { id: 'DIM2', header: true, values: [{ id: 'v1' }] },
22
+ { id: 'DIM3', header: false, values: [{ id: 'v1' }, { id: 'v2' }] },
23
+ { id: 'DIM4', header: false, values: [{ id: 'v1' }, { id: 'v2' }] },
24
+ { id: 'DIM5', header: false, values: [{ id: '_Z' }, { id: 'v2', display: false }] },
25
+ { id: 'DIM6', header: false, values: [{ id: 'v1', display: false }, { id: 'v2', display: false }] }
26
26
  ];
27
27
 
28
28
  const attributes = [
@@ -0,0 +1,35 @@
1
+ import { expect } from 'chai';
2
+ import { refineDimensions } from '../src/rules2/src';
3
+
4
+ describe('refine dimensions tests', () => {
5
+ it('blank case', () => {
6
+ expect(refineDimensions([], '')).to.deep.equal([]);
7
+ });
8
+ it('complete case', () => {
9
+ const dimensions = [
10
+ { id: 'd0', values: [] },
11
+ { id: 'd1', values: [{ id: 'v0' }] },
12
+ { id: 'd2', values: [{ id: 'v0' }, { id: 'v1' }, { id: 'v2' }] },
13
+ { id: 'd3', values: [{ id: 'v0' }, { id: 'v1' }, { id: 'v2' }] },
14
+ { id: 'd4', values: [{ id: 'v0' }, { id: 'v1' }, { id: 'v2' }] },
15
+ { id: 'd5', values: [{ id: 'v0' }] },
16
+ { id: 'd6', values: [{ id: 'v0' }, { id: 'v1' }] },
17
+ { id: 'd7', values: [{ id: 'v0' }] },
18
+ { id: 'd8', values: [{ id: 'v0' }, { id: 'v1' }] }
19
+ ];
20
+
21
+ const dataquery = '.v0+v1.v0.v0+v1...';
22
+
23
+ expect(refineDimensions(dimensions, dataquery)).to.deep.equal([
24
+ { id: 'd0', values: [], header: true },
25
+ { id: 'd1', values: [{ id: 'v0' }], header: true },
26
+ { id: 'd2', values: [{ id: 'v0' }, { id: 'v1', empty: true }, { id: 'v2', empty: true }], header: true },
27
+ { id: 'd3', values: [{ id: 'v0' }, { id: 'v1' }, { id: 'v2', empty: true }], header: false },
28
+ { id: 'd4', values: [{ id: 'v0' }, { id: 'v1' }, { id: 'v2' }], header: false },
29
+ { id: 'd5', values: [{ id: 'v0' }], header: true },
30
+ { id: 'd6', values: [{ id: 'v0' }, { id: 'v1' }], header: false },
31
+ { id: 'd7', values: [{ id: 'v0' }], header: true },
32
+ { id: 'd8', values: [{ id: 'v0' }, { id: 'v1' }], header: false }
33
+ ]);
34
+ })
35
+ });