@sis-cc/dotstatsuite-components 17.13.0 → 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.
@@ -46,7 +46,7 @@ var getName = function getName(_ref) {
46
46
  start = _ref.start,
47
47
  reportYearStart = _ref.reportYearStart;
48
48
  return function (value) {
49
- if (!isTimeDimension) return (0, _dotstatsuiteSdmxjs.getRefinedName)(value);
49
+ if (!isTimeDimension) return R.prop('name')(value);
50
50
  return (0, _date.getReportedTimePeriodLabel)(options.frequency, options.timeFormat, locale)(reportYearStart, {
51
51
  id: value.id,
52
52
  reportedStart: start,
@@ -35,7 +35,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
35
35
  _hiddenIds = options.hiddenIds;
36
36
 
37
37
  var reportYearStart = (0, _getReportingYearStart.getReportingYearStart)(dataNew);
38
-
38
+ var getName = R.prop('name');
39
39
  //---------------------------------------------------------------------------------------Annotations
40
40
  var getStructure = R.pathOr({}, ['data', 'structure']);
41
41
  var structure = getStructure(dataNew);
@@ -56,7 +56,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
56
56
  var sender = getSender(meta);
57
57
 
58
58
  var resHeader = (0, _extends3.default)({}, meta, {
59
- sender: (0, _extends3.default)({}, sender, { name: (0, _dotstatsuiteSdmxjs.getRefinedName)(sender) })
59
+ sender: (0, _extends3.default)({}, sender, { name: getName(sender) })
60
60
  });
61
61
 
62
62
  //----------------------------------------------------------------------------------------Attributes
@@ -71,7 +71,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
71
71
  return (0, _extends3.default)({}, observation, {
72
72
  __index: index,
73
73
  display: !R.has(observation.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(obsAnnotations),
74
- name: (0, _dotstatsuiteSdmxjs.getRefinedName)(observation),
74
+ name: getName(observation),
75
75
  values: (0, _getValuesEnhanced.getValuesEnhanced)({
76
76
  locale: locale,
77
77
  annotations: annotations,
@@ -89,7 +89,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
89
89
  var attrAnnotations = R.props(attr.annotations || [], annotations);
90
90
  return (0, _extends3.default)({}, attr, {
91
91
  display: !R.has(attr.id, hiddenIds) && !(0, _sdmxData.getIsHidden)(attrAnnotations),
92
- name: (0, _dotstatsuiteSdmxjs.getRefinedName)(attr),
92
+ name: getName(attr),
93
93
  values: (0, _getValuesEnhanced.getValuesEnhanced)({
94
94
  locale: locale,
95
95
  annotations: annotations,
@@ -134,7 +134,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
134
134
  observation: R.append((0, _extends3.default)({}, observation, {
135
135
  display: !isHidden,
136
136
  __index: obsIndex,
137
- name: (0, _dotstatsuiteSdmxjs.getRefinedName)(observation),
137
+ name: getName(observation),
138
138
  values: _idHidden ? [] : values,
139
139
  role: isTimeDimension ? TIME_PERIOD_ID : R.head(R.propOr([], 'roles', observation))
140
140
  }))(acc.observation),
@@ -150,7 +150,7 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
150
150
  observation = _getObservations.observation;
151
151
 
152
152
  var resStructure = (0, _extends3.default)({}, structure, {
153
- name: (0, _dotstatsuiteSdmxjs.getRefinedName)((0, _extends3.default)({}, structure, { id: options.dataflowId })),
153
+ name: getName((0, _extends3.default)({}, structure, { id: options.dataflowId })),
154
154
  annotations: annotations,
155
155
  attributes: resAttributes,
156
156
  dimensions: { observation: observation }
@@ -19,15 +19,6 @@ Object.defineProperty(exports, 'SDMX_3_0_CSV_DATA_FORMAT', {
19
19
  }
20
20
  });
21
21
 
22
- var _getSidebarData = require('./getSidebarData');
23
-
24
- Object.defineProperty(exports, 'getSidebarData', {
25
- enumerable: true,
26
- get: function get() {
27
- return _getSidebarData.getSidebarData;
28
- }
29
- });
30
-
31
22
  var _parseMetadataSeries = require('./parseMetadataSeries');
32
23
 
33
24
  Object.defineProperty(exports, 'parseMetadataSeries', {
@@ -13,8 +13,6 @@ var _ramda = require('ramda');
13
13
 
14
14
  var R = _interopRequireWildcard(_ramda);
15
15
 
16
- var _dotstatsuiteSdmxjs = require('@sis-cc/dotstatsuite-sdmxjs');
17
-
18
16
  var _constants = require('./constants');
19
17
 
20
18
  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; } }
@@ -26,7 +24,7 @@ var dimensionValueDisplay = function dimensionValueDisplay(display) {
26
24
  if (display === 'code') {
27
25
  return R.prop('id', data);
28
26
  }
29
- var name = (0, _dotstatsuiteSdmxjs.getRefinedName)(data);
27
+ var name = R.prop('name')(data);
30
28
  if (display === 'both') {
31
29
  return R.prop('id', data) + ': ' + name;
32
30
  }
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.13.0",
4
+ "version": "17.14.0",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  import * as R from 'ramda';
2
2
  import dateFns from 'date-fns';
3
- import { getCodeOrder, getRefinedName } from '@sis-cc/dotstatsuite-sdmxjs';
3
+ import { getCodeOrder } from '@sis-cc/dotstatsuite-sdmxjs';
4
4
  import { getIsHidden } from './sdmx-data';
5
5
  import {
6
6
  getReportedTimePeriodLabel,
@@ -21,18 +21,18 @@ const getId = (value, fallbackId) => {
21
21
 
22
22
  const getName =
23
23
  ({ isTimeDimension, options, locale, start, reportYearStart }) =>
24
- (value) => {
25
- if (!isTimeDimension) return getRefinedName(value);
26
- return getReportedTimePeriodLabel(
27
- options.frequency,
28
- options.timeFormat,
29
- locale,
30
- )(reportYearStart, {
31
- id: value.id,
32
- reportedStart: start,
33
- start: new Date(value.start),
34
- });
35
- };
24
+ (value) => {
25
+ if (!isTimeDimension) return R.prop('name')(value);
26
+ return getReportedTimePeriodLabel(
27
+ options.frequency,
28
+ options.timeFormat,
29
+ locale,
30
+ )(reportYearStart, {
31
+ id: value.id,
32
+ reportedStart: start,
33
+ start: new Date(value.start),
34
+ });
35
+ };
36
36
 
37
37
  export const getValuesEnhanced = ({
38
38
  locale = '',
@@ -115,23 +115,23 @@ const defaultSorts = [byIndexPosition, byOrder];
115
115
 
116
116
  const getTimePeriodAttributes =
117
117
  ({ reportYearStart, options }) =>
118
- (value) => {
119
- const reported = getReportedTimePeriod(
120
- reportYearStart,
121
- value,
122
- options.frequency,
123
- );
124
- const start = reported.start;
125
- const end = reported.end;
126
- const reportTimeNote = getReportedTimePeriodNote(
127
- reportYearStart,
128
- start,
129
- end,
130
- options.frequency,
131
- options.isRtl,
132
- );
133
- const notes = R.isNil(reportTimeNote)
134
- ? []
135
- : R.append(reportTimeNote, []);
136
- return { start, notes };
137
- };
118
+ (value) => {
119
+ const reported = getReportedTimePeriod(
120
+ reportYearStart,
121
+ value,
122
+ options.frequency,
123
+ );
124
+ const start = reported.start;
125
+ const end = reported.end;
126
+ const reportTimeNote = getReportedTimePeriodNote(
127
+ reportYearStart,
128
+ start,
129
+ end,
130
+ options.frequency,
131
+ options.isRtl,
132
+ );
133
+ const notes = R.isNil(reportTimeNote)
134
+ ? []
135
+ : R.append(reportTimeNote, []);
136
+ return { start, notes };
137
+ };
@@ -1,6 +1,5 @@
1
1
  import * as R from 'ramda';
2
2
  import {
3
- getRefinedName,
4
3
  isTimePeriodDimension,
5
4
  } from '@sis-cc/dotstatsuite-sdmxjs';
6
5
  import {
@@ -17,7 +16,7 @@ const TIME_PERIOD_ID = 'TIME_PERIOD';
17
16
  export const dataTransformer = (dataNew, options = {}) => {
18
17
  const { locale, hiddenIds: _hiddenIds } = options;
19
18
  const reportYearStart = getReportingYearStart(dataNew);
20
-
19
+ const getName = R.prop('name')
21
20
  //---------------------------------------------------------------------------------------Annotations
22
21
  const getStructure = R.pathOr({}, ['data', 'structure']);
23
22
  const structure = getStructure(dataNew);
@@ -42,7 +41,7 @@ export const dataTransformer = (dataNew, options = {}) => {
42
41
 
43
42
  const resHeader = {
44
43
  ...meta,
45
- sender: { ...sender, name: getRefinedName(sender) },
44
+ sender: { ...sender, name: getName(sender) },
46
45
  };
47
46
 
48
47
  //----------------------------------------------------------------------------------------Attributes
@@ -59,7 +58,7 @@ export const dataTransformer = (dataNew, options = {}) => {
59
58
  __index: index,
60
59
  display:
61
60
  !R.has(observation.id, hiddenIds) && !getIsHidden(obsAnnotations),
62
- name: getRefinedName(observation),
61
+ name: getName(observation),
63
62
  values: getValuesEnhanced({
64
63
  locale,
65
64
  annotations,
@@ -78,7 +77,7 @@ export const dataTransformer = (dataNew, options = {}) => {
78
77
  return {
79
78
  ...attr,
80
79
  display: !R.has(attr.id, hiddenIds) && !getIsHidden(attrAnnotations),
81
- name: getRefinedName(attr),
80
+ name: getName(attr),
82
81
  values: getValuesEnhanced({
83
82
  locale,
84
83
  annotations,
@@ -131,7 +130,7 @@ export const dataTransformer = (dataNew, options = {}) => {
131
130
  ...observation,
132
131
  display: !isHidden,
133
132
  __index: obsIndex,
134
- name: getRefinedName(observation),
133
+ name: getName(observation),
135
134
  values: _idHidden ? [] : values,
136
135
  role: isTimeDimension
137
136
  ? TIME_PERIOD_ID
@@ -151,7 +150,7 @@ export const dataTransformer = (dataNew, options = {}) => {
151
150
  getObservations(locale)(dimObservations);
152
151
  const resStructure = {
153
152
  ...structure,
154
- name: getRefinedName({ ...structure, id: options.dataflowId }),
153
+ name: getName({ ...structure, id: options.dataflowId }),
155
154
  annotations,
156
155
  attributes: resAttributes,
157
156
  dimensions: { observation },
@@ -3,7 +3,6 @@ export {
3
3
  SDMX_3_0_CSV_DATA_FORMAT
4
4
  } from './constants';
5
5
 
6
- export { getSidebarData } from './getSidebarData';
7
6
  export { parseMetadataSeries } from './parseMetadataSeries';
8
7
  export { sdmx_3_0_DataFormatPatch } from './sdmx3.0DataFormatPatch';
9
8
  export { getDataflowTooltipAttributesIds } from './getDataflowTooltipAttributesIds';
@@ -1,13 +1,12 @@
1
1
  import * as R from 'ramda';
2
- import { getRefinedName } from '@sis-cc/dotstatsuite-sdmxjs';
3
2
  import { EMPTY_ATTACHMENT_LEVEL_CHAR } from './constants';
4
3
 
5
4
  const dimensionValueDisplay = (display) => data => {
6
5
  if (display === 'code') {
7
6
  return R.prop('id', data);
8
7
  }
9
- const name = getRefinedName(data);
10
- if (display === 'both') {
8
+ const name = R.prop('name')(data);
9
+ if (display === 'both') {
11
10
  return `${R.prop('id', data)}: ${name}`;
12
11
  }
13
12
  return name;
@@ -110,9 +109,9 @@ export const parseMetadataSeries = (metadataJson, options) => {
110
109
 
111
110
  return R.assoc(evolvedKey, attributes, acc);
112
111
  },
113
- {},
114
- R.keys(series)
115
- ))(metadataJson);
112
+ {},
113
+ R.keys(series)
114
+ ))(metadataJson);
116
115
 
117
116
  return metadataSeries;
118
117
  };
@@ -1,92 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getSidebarData = 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
- var _src = require('../../rules/src');
17
-
18
- var _constants = require('./constants');
19
-
20
- 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; } }
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
- var sortByCoordinates = function sortByCoordinates(a, b) {
25
- var splitACoord = a.splitCoord;
26
- var splitBCoord = b.splitCoord;
27
-
28
- var aWeight = R.pipe(R.reject(R.isEmpty), R.length)(splitACoord);
29
- var bWeight = R.pipe(R.reject(R.isEmpty), R.length)(splitBCoord);
30
- if (aWeight !== bWeight) {
31
- return bWeight - aWeight;
32
- }
33
-
34
- var ind = 0;
35
- while (splitACoord[ind] === splitBCoord[ind]) {
36
- ind++;
37
- }
38
- var _a = R.isEmpty(splitACoord[ind]) ? 0 : Number(splitACoord[ind]);
39
- var _b = R.isEmpty(splitBCoord[ind]) ? 0 : Number(splitBCoord[ind]);
40
- return _b - _a;
41
- };
42
-
43
- // options = { display, attributesLabel }
44
- var getSidebarData = exports.getSidebarData = function getSidebarData(attributesSeries, metadataSeries, dataflow, dimensions, options) {
45
- var coordinates = R.uniq(R.concat(R.keys(attributesSeries), R.keys(metadataSeries)));
46
- return R.pipe(R.map(function (coordinate) {
47
- var attributes = R.prop(coordinate, attributesSeries);
48
- var metadata = R.prop(coordinate, metadataSeries);
49
- var children = R.concat(R.isNil(attributes) ? [] : [{ id: coordinate + '-attr', label: options.attributesLabel, children: attributes }], R.isNil(metadata) ? [] : metadata);
50
- var splitCoord = R.split(':', coordinate);
51
-
52
- var _R$addIndex = R.addIndex(R.reduce)(function (acc, valIndex, dimIndex) {
53
- if (R.isEmpty(valIndex)) {
54
- return (0, _extends3.default)({}, acc, { split: R.append('', acc.split) });
55
- }
56
- var dim = R.nth(dimIndex, dimensions);
57
- var values = R.propOr([], 'values', dim || {});
58
- var value = R.nth(Number(valIndex), values);
59
- if (!value || !R.propOr(true, 'display', dim) || !R.propOr(true, 'display', value) || R.includes(R.prop('id', value), _constants.REJECTED_VALUE_IDS)) {
60
- return (0, _extends3.default)({}, acc, { split: R.append('', acc.split) });
61
- }
62
- var dimLabel = (0, _src.dimensionValueDisplay)(options.display)(dim);
63
- var valLabel = (0, _src.dimensionValueDisplay)(options.display)(value);
64
- return {
65
- labels: R.append(dimLabel + ': ' + valLabel, acc.labels),
66
- split: R.append(valIndex, acc.split)
67
- };
68
- }, { split: [], labels: [] }, splitCoord),
69
- split = _R$addIndex.split,
70
- labels = _R$addIndex.labels;
71
-
72
- var label = R.isEmpty(labels) ? (0, _src.dimensionValueDisplay)(options.display)(dataflow) : R.join(' - ', labels);
73
-
74
- return {
75
- id: R.join(':', split),
76
- splitCoord: split,
77
- label: label,
78
- children: R.filter(R.identity, children)
79
- };
80
- }), function (series) {
81
- // after removed non displayed dim vals, some series might be duplicated
82
- var grouped = R.groupBy(R.prop('id'), series);
83
- return R.pipe(R.map(function (entries) {
84
- if (R.length(entries) === 1) {
85
- return R.head(entries);
86
- }
87
- var head = R.head(entries);
88
- var children = R.pipe(R.pluck('children'), R.unnest)(entries);
89
- return R.assoc('children', children, head);
90
- }), R.values)(grouped);
91
- }, R.sort(sortByCoordinates))(coordinates);
92
- };
@@ -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,322 +0,0 @@
1
- import { expect } from 'chai';
2
- import { getSidebarData } from '../src/rules2/src/getSidebarData';
3
-
4
- describe('getSidebarData tests', () => {
5
- it('complete case', () => {
6
- const attributes = {
7
- '::': [
8
- { id: 'aa0', label: 'advanced attribute 0', value: 'value' },
9
- { id: 'aa1', label: 'advanced attribute 1', value: 'value' },
10
- ],
11
- '0::': [
12
- { id: 'aa2', label: 'advanced attribute 2', value: 'value' },
13
- { id: 'aa3', label: 'advanced attribute 3', value: 'value' },
14
- ]
15
- };
16
- const metadata = {
17
- '0::': [
18
- { id: 'ma0', label: 'metadata attribute 0', value: 'value' },
19
- { id: 'ma1', label: 'metadata attribute 1', value: 'value' },
20
- ],
21
- '0::0': [
22
- { id: 'ma2', label: 'metadata attribute 2', value: 'value' },
23
- { id: 'ma3', label: 'metadata attribute 3', value: 'value' },
24
- ]
25
- };
26
- const options = {
27
- display: 'code',
28
- attributesLabel: 'Advanced Attributes'
29
- };
30
- const dataflow = {
31
- id: 'DF',
32
- name: 'Dataflow'
33
- };
34
- const dimensions = [
35
- { id: 'd0', name: 'dimension 0', values: [{ id: 'd0v0', name: 'value 0' }] },
36
- { id: 'd1', name: 'dimension 1', values: [{ id: 'd1v0', name: 'value 0' }] },
37
- { id: 'd2', name: 'dimension 2', values: [{ id: 'd2v0', name: 'value 0' }] },
38
- ];
39
-
40
- expect(getSidebarData(attributes, metadata, dataflow, dimensions, options)).to.deep.equal([
41
- {
42
- id: '0::0',
43
- label: 'd0: d0v0 - d2: d2v0',
44
- splitCoord: ['0', '', '0'],
45
- children: [
46
- {
47
- id: 'ma2',
48
- label: 'metadata attribute 2',
49
- value: 'value'
50
- },
51
- {
52
- id: 'ma3',
53
- label: 'metadata attribute 3',
54
- value: 'value'
55
- }
56
- ]
57
- },
58
- {
59
- id: '0::',
60
- label: 'd0: d0v0',
61
- splitCoord: ['0', '', ''],
62
- children: [
63
- {
64
- id: '0::-attr',
65
- label: 'Advanced Attributes',
66
- children: [
67
- {
68
- id: 'aa2',
69
- label: 'advanced attribute 2',
70
- value: 'value'
71
- },
72
- {
73
- id: 'aa3',
74
- label: 'advanced attribute 3',
75
- value: 'value'
76
- }
77
- ]
78
- },
79
- {
80
- id: 'ma0',
81
- label: 'metadata attribute 0',
82
- value: 'value'
83
- },
84
- {
85
- id: 'ma1',
86
- label: 'metadata attribute 1',
87
- value: 'value'
88
- }
89
- ]
90
- },
91
- {
92
- id: '::',
93
- label: 'DF',
94
- splitCoord: ['', '', ''],
95
- children: [
96
- {
97
- id: '::-attr',
98
- label: 'Advanced Attributes',
99
- children: [
100
- {
101
- id: 'aa0',
102
- label: 'advanced attribute 0',
103
- value: 'value'
104
- },
105
- {
106
- id: 'aa1',
107
- label: 'advanced attribute 1',
108
- value: 'value'
109
- }
110
- ]
111
- }
112
- ]
113
- }
114
- ]);
115
- });
116
- it('discordadnce between dimensions and metadata case', () => {
117
- const attributes = {
118
- '::': [
119
- { id: 'aa0', label: 'advanced attribute 0', value: 'value' },
120
- { id: 'aa1', label: 'advanced attribute 1', value: 'value' },
121
- ],
122
- '0::': [
123
- { id: 'aa2', label: 'advanced attribute 2', value: 'value' },
124
- { id: 'aa3', label: 'advanced attribute 3', value: 'value' },
125
- ]
126
- };
127
- const metadata = {
128
- '0::': [
129
- { id: 'ma0', label: 'metadata attribute 0', value: 'value' },
130
- { id: 'ma1', label: 'metadata attribute 1', value: 'value' },
131
- ],
132
- '0::0': [
133
- { id: 'ma2', label: 'metadata attribute 2', value: 'value' },
134
- { id: 'ma3', label: 'metadata attribute 3', value: 'value' },
135
- ]
136
- };
137
- const options = {
138
- display: 'code',
139
- attributesLabel: 'Advanced Attributes'
140
- };
141
- const dataflow = {
142
- id: 'DF',
143
- name: 'Dataflow'
144
- };
145
- const dimensions = [
146
- { id: 'd0', name: 'dimension 0', values: [{ id: 'd0v0', name: 'value 0' }] },
147
- { id: 'd1', name: 'dimension 1', values: [{ id: 'd1v0', name: 'value 0' }] },
148
- ];
149
- expect(getSidebarData(attributes, metadata, dataflow, dimensions, options)).to.deep.equal([
150
- {
151
- id: '0::',
152
- label: 'd0: d0v0',
153
- splitCoord: ['0', '', ''],
154
- children: [
155
- {
156
- id: '0::-attr',
157
- label: 'Advanced Attributes',
158
- children: [
159
- {
160
- id: 'aa2',
161
- label: 'advanced attribute 2',
162
- value: 'value'
163
- },
164
- {
165
- id: 'aa3',
166
- label: 'advanced attribute 3',
167
- value: 'value'
168
- }
169
- ]
170
- },
171
- {
172
- id: 'ma0',
173
- label: 'metadata attribute 0',
174
- value: 'value'
175
- },
176
- {
177
- id: 'ma1',
178
- label: 'metadata attribute 1',
179
- value: 'value'
180
- },
181
- {
182
- id: 'ma2',
183
- label: 'metadata attribute 2',
184
- value: 'value'
185
- },
186
- {
187
- id: 'ma3',
188
- label: 'metadata attribute 3',
189
- value: 'value'
190
- }
191
- ]
192
- },
193
- {
194
- id: '::',
195
- label: 'DF',
196
- splitCoord: ['', '', ''],
197
- children: [
198
- {
199
- id: '::-attr',
200
- label: 'Advanced Attributes',
201
- children: [
202
- {
203
- id: 'aa0',
204
- label: 'advanced attribute 0',
205
- value: 'value'
206
- },
207
- {
208
- id: 'aa1',
209
- label: 'advanced attribute 1',
210
- value: 'value'
211
- }
212
- ]
213
- }
214
- ]
215
- }
216
- ]);
217
- });
218
- it('non displayed dimensions handling', () => {
219
- const attributes = {
220
- '::': [
221
- { id: 'aa0', label: 'advanced attribute 0', value: 'value' },
222
- { id: 'aa1', label: 'advanced attribute 1', value: 'value' },
223
- ],
224
- '0::': [
225
- { id: 'aa2', label: 'advanced attribute 2', value: 'value' },
226
- { id: 'aa3', label: 'advanced attribute 3', value: 'value' },
227
- ]
228
- };
229
- const metadata = {
230
- '0::': [
231
- { id: 'ma0', label: 'metadata attribute 0', value: 'value' },
232
- { id: 'ma1', label: 'metadata attribute 1', value: 'value' },
233
- ],
234
- '0::0': [
235
- { id: 'ma2', label: 'metadata attribute 2', value: 'value' },
236
- { id: 'ma3', label: 'metadata attribute 3', value: 'value' },
237
- ]
238
- };
239
- const options = {
240
- display: 'code',
241
- attributesLabel: 'Advanced Attributes'
242
- };
243
- const dataflow = {
244
- id: 'DF',
245
- name: 'Dataflow'
246
- };
247
- const dimensions = [
248
- { id: 'd0', name: 'dimension 0', values: [{ id: 'd0v0', name: 'value 0' }] },
249
- { id: 'd1', name: 'dimension 1', values: [{ id: 'd1v0', name: 'value 0' }] },
250
- { id: 'd2', name: 'dimension 2', display: false, values: [{ id: 'd2v0', name: 'value 0' }] },
251
- ];
252
-
253
- expect(getSidebarData(attributes, metadata, dataflow, dimensions, options)).to.deep.equal([
254
- {
255
- id: '0::',
256
- label: 'd0: d0v0',
257
- splitCoord: ['0', '', ''],
258
- children: [
259
- {
260
- id: '0::-attr',
261
- label: 'Advanced Attributes',
262
- children: [
263
- {
264
- id: 'aa2',
265
- label: 'advanced attribute 2',
266
- value: 'value'
267
- },
268
- {
269
- id: 'aa3',
270
- label: 'advanced attribute 3',
271
- value: 'value'
272
- }
273
- ]
274
- },
275
- {
276
- id: 'ma0',
277
- label: 'metadata attribute 0',
278
- value: 'value'
279
- },
280
- {
281
- id: 'ma1',
282
- label: 'metadata attribute 1',
283
- value: 'value'
284
- },
285
- {
286
- id: 'ma2',
287
- label: 'metadata attribute 2',
288
- value: 'value'
289
- },
290
- {
291
- id: 'ma3',
292
- label: 'metadata attribute 3',
293
- value: 'value'
294
- }
295
- ]
296
- },
297
- {
298
- id: '::',
299
- label: 'DF',
300
- splitCoord: ['', '', ''],
301
- children: [
302
- {
303
- id: '::-attr',
304
- label: 'Advanced Attributes',
305
- children: [
306
- {
307
- id: 'aa0',
308
- label: 'advanced attribute 0',
309
- value: 'value'
310
- },
311
- {
312
- id: 'aa1',
313
- label: 'advanced attribute 1',
314
- value: 'value'
315
- }
316
- ]
317
- }
318
- ]
319
- }
320
- ]);
321
- });
322
- });