@sis-cc/dotstatsuite-components 13.0.2 → 13.1.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 (44) hide show
  1. package/lib/rules/src/dimension-utils.js +3 -2
  2. package/lib/rules/src/preparators/enhanceObservations.js +5 -11
  3. package/lib/rules/src/sdmx-data/index.js +3 -4
  4. package/lib/rules/src/table/preparators/getOneValueDimensions.js +2 -14
  5. package/lib/rules/src/table/preparators/parseAttributes.js +3 -10
  6. package/lib/rules/src/table/preparators/prepareData.js +5 -24
  7. package/lib/rules/src/table/units/getUnitsArtefacts.js +6 -11
  8. package/lib/rules/src/v8-transformer.js +39 -23
  9. package/lib/rules2/src/getAdvancedAttributes.js +1 -1
  10. package/lib/rules2/src/getNotDisplayedIds.js +42 -0
  11. package/lib/rules2/src/getSidebarData.js +41 -18
  12. package/lib/rules2/src/index.js +9 -0
  13. package/package.json +1 -1
  14. package/src/rules/src/dimension-utils.js +4 -4
  15. package/src/rules/src/preparators/enhanceObservations.js +5 -10
  16. package/src/rules/src/properties/getHeaderProps.js +1 -2
  17. package/src/rules/src/sdmx-data/index.js +4 -4
  18. package/src/rules/src/table/preparators/getOneValueDimensions.js +4 -22
  19. package/src/rules/src/table/preparators/parseAttributes.js +3 -3
  20. package/src/rules/src/table/preparators/prepareData.js +5 -23
  21. package/src/rules/src/table/units/getUnitsArtefacts.js +6 -6
  22. package/src/rules/src/v8-transformer.js +49 -36
  23. package/src/rules2/src/getAdvancedAttributes.js +1 -1
  24. package/src/rules2/src/getNotDisplayedIds.js +40 -0
  25. package/src/rules2/src/getSidebarData.js +41 -23
  26. package/src/rules2/src/index.js +1 -0
  27. package/test/enhanceObservations.test.js +2 -2
  28. package/test/getNotDisplayedIds.test.js +31 -0
  29. package/test/getOneValueDimensions.test.js +12 -17
  30. package/test/getSidebarData.test.js +104 -0
  31. package/test/getUnitsArtefacts.test.js +10 -14
  32. package/test/mocks/table-prep-multi-hierarchies--attributes.json +2 -0
  33. package/test/parseAttributes.test.js +4 -9
  34. package/test/table-prep-perf.test.js +1 -8
  35. package/lib/rules/src/preparators/getDisplay.js +0 -32
  36. package/lib/rules/src/table/preparators/getDisplay.js +0 -32
  37. package/lib/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -16
  38. package/lib/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
  39. package/src/rules/src/preparators/getDisplay.js +0 -20
  40. package/src/rules/src/table/preparators/getDisplay.js +0 -20
  41. package/src/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -9
  42. package/src/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
  43. package/test/getNoDisplayAnnotationsIndexes.test.js +0 -18
  44. package/test/getNoDisplayCodes.test.js +0 -87
@@ -1,5 +1,4 @@
1
1
  import * as R from 'ramda';
2
- import { getDisplay } from './getDisplay';
3
2
  import { formatValue } from './formatValue';
4
3
 
5
4
  /*
@@ -9,8 +8,6 @@ import { formatValue } from './formatValue';
9
8
  decimals: id,
10
9
  prefscale: id,
11
10
  },
12
- noDisplayIndexes,
13
- notDisplayedCodes,
14
11
  unitsArtefacts,
15
12
  obsAttributes,
16
13
  rejectedValueIds,
@@ -38,12 +35,12 @@ const getUnitsValues = (indexes, options) => R.reduce(
38
35
  return acc;
39
36
  }
40
37
  const valueIndex = R.prop(codelist.__index, indexes);
41
- if (R.isNil(valueIndex) || !getDisplay(options)(codelist)) {
38
+ if (R.isNil(valueIndex) || !R.propOr(true, 'display', codelist)) {
42
39
  return acc;
43
40
  }
44
41
  const value = R.path(['values', Number(valueIndex)], codelist);
45
42
  if (R.isNil(value) || R.includes(value.id, R.propOr([], 'rejectedValueIds', options))
46
- || !getDisplay(options)({ ...value, parent: codelist.id })) {
43
+ || !R.propOr(true, 'display', value)) {
47
44
  return acc;
48
45
  }
49
46
  return R.assoc(
@@ -94,7 +91,7 @@ const getFormatAttributesIndexes = (attributes, customAttributes) => R.addIndex(
94
91
  );
95
92
 
96
93
  const getAttributeValue = (attribute, valueIndex, options) => {
97
- if (!getDisplay(options)(attribute)) {
94
+ if (!R.propOr(true, 'display', attribute)) {
98
95
  return null;
99
96
  }
100
97
  const value = R.pipe(
@@ -102,7 +99,7 @@ const getAttributeValue = (attribute, valueIndex, options) => {
102
99
  R.nth(valueIndex)
103
100
  )(attribute);
104
101
 
105
- if (R.isNil(value) || !getDisplay(options)({ ...value, parent: attribute.id })) {
102
+ if (R.isNil(value) || !R.propOr(true, 'display', value)) {
106
103
  return null;
107
104
  }
108
105
 
@@ -121,8 +118,6 @@ export const enhanceObservations = (dimensions = [], observations = {}, attribut
121
118
  R.props(options.attributesIds || [])
122
119
  )(_attributes);
123
120
 
124
- const seriesDimensions = R.filter(R.pipe(R.propOr([], 'values'), R.length, R.lt(1)), dimensions);
125
-
126
121
  return R.mapObjIndexed(
127
122
  (observation) => {
128
123
  const { attrValuesIndexes, dimValuesIndexes } = observation;
@@ -154,7 +149,7 @@ export const enhanceObservations = (dimensions = [], observations = {}, attribut
154
149
  attributes: obsAttributes,
155
150
  formattedValue: formatValue(observation, formatAttributesIndexes, attributes),
156
151
  orderedDimIndexes: getOrderedDimensionsIndexes(dimensions, dimValuesIndexes),
157
- units: getObservationUnits(observation, seriesDimensions, _attributes, options),
152
+ units: getObservationUnits(observation, dimensions, _attributes, options),
158
153
  indexedDimValIds,
159
154
  });
160
155
  },
@@ -1,12 +1,11 @@
1
1
  import * as R from 'ramda';
2
2
  import {
3
3
  getDefaultSubtitle,
4
- getDefaultTitle,
5
4
  getHeaderUnits,
6
5
  getSubtitleFlags,
7
6
  getTitleFlags
8
7
  } from '../header';
9
- import { dimensionValueDisplay, extractSdmxArtefacts, parseDisplay } from '../';
8
+ import { dimensionValueDisplay, parseDisplay } from '../';
10
9
  import { isChart } from './utils';
11
10
 
12
11
  const isCustomInvalid = ({ type }) => (value) => R.isNil(value) || !isChart(type);
@@ -31,7 +31,7 @@ export const getRelationnalAnnotations = annotationIndexes => annotations => R.m
31
31
 
32
32
  export const hiddenFormat = { isHidden: true }
33
33
 
34
- export const getIsHidden = R.reduce((acc, annotation) => {
35
- if (R.equals(getType(annotation), NOT_DISPLAYED)) return hiddenFormat;
36
- return acc;
37
- }, {});
34
+ export const getIsHidden = annotations => R.pipe(
35
+ R.find(R.propEq('type', NOT_DISPLAYED)),
36
+ R.complement(R.isNil)
37
+ )(annotations);
@@ -1,34 +1,16 @@
1
1
  import * as R from 'ramda';
2
2
  import { getAttributeValue } from './getAttributeValue';
3
3
 
4
- export const getOneValueDimensions = (dimensions, attributesIds, attributes, getDisplay) => R.map(
4
+ export const getOneValueDimensions = (dimensions, attributesIds, attributes) => R.map(
5
5
  (dimension) => {
6
6
  const dimensionAttributes = R.pipe(
7
7
  R.mapObjIndexed(attr => getAttributeValue(attr, 0)),
8
8
  R.filter(R.complement(R.isNil))
9
9
  )(R.pick(R.propOr([], dimension.id, attributesIds), attributes));
10
10
 
11
- const display = getDisplay(dimension);
12
-
13
- const value = R.pipe(
14
- R.path(['values', 0]),
15
- R.assoc('attributes', dimensionAttributes),
16
- (val) => R.assoc(
17
- 'display',
18
- getDisplay({ ...val, parent: dimension.id }),
19
- val
20
- )
21
- )(dimension);
22
-
23
- return R.pipe(
24
- R.assoc(
25
- 'display',
26
- display
27
- ),
28
- R.assocPath(
29
- ['values', 0],
30
- value
31
- )
11
+ return R.over(
12
+ R.lensPath(['values', 0]),
13
+ R.assoc('attributes', dimensionAttributes)
32
14
  )(dimension);
33
15
  },
34
16
  dimensions
@@ -78,11 +78,11 @@ const getAttributeRegisters = (attribute, parsedDimensionsIds, customAttributes)
78
78
  ]
79
79
  };
80
80
 
81
- export const parseAttributes = ({ attributes, parsedDimensionsIds, customAttributes, getDisplay }) => R.addIndex(R.reduce)(
81
+ export const parseAttributes = ({ attributes, parsedDimensionsIds, customAttributes }) => R.addIndex(R.reduce)(
82
82
  (acc, attribute, attributeIndex) => {
83
83
  const values = R.propOr([], 'values', attribute);
84
84
 
85
- if (R.isEmpty(values) || !getDisplay(attribute) || R.includes(attribute.id, R.propOr([], 'units', customAttributes))) {
85
+ if (R.isEmpty(values) || !R.propOr(true, 'display', attribute) || R.includes(attribute.id, R.propOr([], 'units', customAttributes))) {
86
86
  return acc;
87
87
  }
88
88
 
@@ -92,7 +92,7 @@ export const parseAttributes = ({ attributes, parsedDimensionsIds, customAttribu
92
92
  R.over(
93
93
  R.lensProp('values'),
94
94
  R.map((value) => {
95
- if (!getDisplay({ ...value, parent: attribute.id })) {
95
+ if (!R.propOr(true, 'display', value)) {
96
96
  return null;
97
97
  }
98
98
  return value;
@@ -1,8 +1,6 @@
1
1
  import * as R from 'ramda';
2
2
  import { getObservationsType } from '../../properties/getObservationsType';
3
3
  import { parseDimensionsIds } from './parseDimensionsIds';
4
- import { getNoDisplayAnnotationsIndexes } from './getNoDisplayAnnotationsIndexes';
5
- import { getNoDisplayCodes } from './getNoDisplayCodes';
6
4
  import { parseAttributes } from './parseAttributes';
7
5
  import { getDimensionsAttributesRegisters } from './getDimensionsAttributesRegisters';
8
6
  import { parseAttributesValuesFromObservations } from './parseAttributesValuesFromObservations';
@@ -17,7 +15,6 @@ import { getHeaderUnits } from '../units/getHeaderUnits';
17
15
  import { getAttachmentSeriesIndexes } from '../units/getAttachmentSeriesIndexes';
18
16
  import { getUnitsSeries } from '../units/getUnitsSeries';
19
17
 
20
- import { getDisplay } from '../../preparators/getDisplay';
21
18
  import { getObservations } from '../../preparators/getObservations';
22
19
  import { enhanceObservations } from '../../preparators/enhanceObservations';
23
20
 
@@ -44,18 +41,8 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
44
41
 
45
42
  const parsedDimensionsIds = parseDimensionsIds(dimensions);
46
43
 
47
- const annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
48
-
49
- const noDisplayIndexes = getNoDisplayAnnotationsIndexes(annotations);
50
- const notDisplayedCodes = getNoDisplayCodes({
51
- noDisplayIndexes,
52
- annotations,
53
- datasetIndexes: R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson)
54
- });
55
- const _getDisplay = getDisplay({ noDisplayIndexes, notDisplayedCodes });
56
-
57
- //------------------------------------------------------------------
58
- const unitsArtefacts = getUnitsArtefacts({ unitsDefinitionCodes, data: sdmxJson, getDisplay: _getDisplay });
44
+ //------------------------------------------------------------------
45
+ const unitsArtefacts = getUnitsArtefacts({ unitsDefinitionCodes, data: sdmxJson });
59
46
  const headerUnits = getHeaderUnits({ unitsArtefacts, unitsDefinitionCodes, rejectedValueIds });
60
47
  const _dimensions = R.pipe(
61
48
  R.pathOr([], ['data', 'structure', 'dimensions', 'observation']),
@@ -73,7 +60,6 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
73
60
  R.pathOr([], ['data', 'structure', 'attributes', 'dataSet'], sdmxJson),
74
61
  ),
75
62
  parsedDimensionsIds,
76
- getDisplay: _getDisplay,
77
63
  customAttributes: _customAttributes,
78
64
  });
79
65
 
@@ -81,14 +67,11 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
81
67
  const observationsAttributesIds = R.propOr([], 'observations', attributesIdsIndexedByTargets);
82
68
  const obsUnitsIds = R.pipe(
83
69
  ({ attributes, dimensions }) => R.merge(attributes.series || {}, dimensions.series || {}),
84
- R.values,
85
- R.pluck('id')
70
+ R.keys
86
71
  )(unitsArtefacts);
87
72
  const options = {
88
73
  attachmentSeriesIndexes,
89
74
  customAttributes,
90
- noDisplayIndexes,
91
- notDisplayedCodes,
92
75
  attributesIds: R.concat(seriesAttributesIds, observationsAttributesIds),
93
76
  unitsIds: obsUnitsIds
94
77
  };
@@ -107,7 +90,7 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
107
90
  attributesIndexedByIds
108
91
  );
109
92
 
110
- const dimensionsAttributesValues = parseAttributesValuesFromObservations( // => { series: { key: { attrId: [...indexes] } }, dimensions: {} }
93
+ const dimensionsAttributesValues = parseAttributesValuesFromObservations( // => { series: { key: { attrId: [...indexes] } }, dimensions: {} }
111
94
  observations,
112
95
  attributesRegisters
113
96
  );
@@ -129,7 +112,6 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
129
112
  )(dimensionsIndexedByIds),
130
113
  attributesIdsIndexedByTargets.oneValueDimensions,
131
114
  attributesIndexedByIds,
132
- _getDisplay
133
115
  );
134
116
 
135
117
  const manyValuesDimensions = getManyValuesDimensions(
@@ -156,7 +138,7 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
156
138
 
157
139
  const dataflowAdvancedAttributes = getDataflowAdvancedAttributes(
158
140
  headerAttributes,
159
- oneValueDimensions,
141
+ R.pick(R.keys(parsedDimensionsIds.oneValue), dimensionsIndexedByIds),
160
142
  headerAdvancedAttrIds,
161
143
  R.length(dimensions)
162
144
  );
@@ -1,12 +1,12 @@
1
1
  import * as R from 'ramda';
2
2
 
3
- export const getRelevantLength = (getDisplay) => (attr) => R.pipe(
3
+ export const getRelevantLength = (attr) => R.pipe(
4
4
  R.propOr([], 'values'),
5
- R.filter(val => getDisplay(R.assoc('parent', attr.id, val))),
5
+ R.filter(R.propOr(true, 'display')),
6
6
  R.length
7
7
  )(attr);
8
8
 
9
- export const getUnitsArtefacts = ({ unitsDefinitionCodes=[], data, getDisplay }) => {
9
+ export const getUnitsArtefacts = ({ unitsDefinitionCodes=[], data }) => {
10
10
  const dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], data);
11
11
  const parsedUnitsDimensions = R.addIndex(R.reduce)(
12
12
  (acc, dimension, index) => {
@@ -39,7 +39,7 @@ export const getUnitsArtefacts = ({ unitsDefinitionCodes=[], data, getDisplay })
39
39
  R.filter(R.pipe(R.propOr([], 'values'), R.length, R.equals(1))),
40
40
  R.indexBy(R.prop('id')),
41
41
  R.pick(unitsDefinitionCodes),
42
- R.filter(getDisplay),
42
+ R.filter(R.propOr(true, 'display')),
43
43
  R.mapObjIndexed(R.assoc('datasetLevel', true))
44
44
  ),
45
45
  R.pipe(
@@ -47,10 +47,10 @@ export const getUnitsArtefacts = ({ unitsDefinitionCodes=[], data, getDisplay })
47
47
  R.addIndex(R.reduce)(
48
48
  (acc, attr, index) => {
49
49
  if(!R.includes(attr.id, unitsDefinitionCodes) || R.length(R.propOr([], 'values', attr)) === 0
50
- || !getDisplay(attr)) {
50
+ || !R.propOr(true, 'display', attr)) {
51
51
  return acc;
52
52
  }
53
- const length = getRelevantLength(getDisplay)(attr);
53
+ const length = getRelevantLength(attr);
54
54
  if (length === 0) {
55
55
  return acc;
56
56
  }
@@ -5,6 +5,7 @@ import {
5
5
  getRelationnalAnnotations, setAnnotationsLayout, getIsHidden, hiddenFormat } from './sdmx-data';
6
6
  import { getReportedTimePeriodLabel } from './date';
7
7
  import { getReportingYearStart } from './preparators/getReportingYearStart';
8
+ import { getNotDisplayedIds } from '../../rules2/src';
8
9
 
9
10
  export const dataTransformer = (dataNew, options = {}) => {
10
11
  const getLanguage = R.pipe(R.pathOr('', ['meta', 'contentLanguages']), R.head());
@@ -12,14 +13,37 @@ export const dataTransformer = (dataNew, options = {}) => {
12
13
  const reportYearStart = getReportingYearStart(dataNew);
13
14
  const getProp = (prop, locale) => R.pathOr(null,[prop, locale]);
14
15
  const getLocalisedProp = R.curry((prop, collection) => getProp(prop, locale)(collection));
15
- const getValues = R.map((value) => ({ ...value, name: getLocalisedProp('names', value) }));
16
- const getValuesEnhanced = (locale, annotations, isTimeDimension) =>
16
+
17
+ //---------------------------------------------------------------------------------------Annotations
18
+ const getStructure = R.pathOr({},['data', 'structure']);
19
+ const structure = getStructure(dataNew);
20
+ const getAnnotations = R.propOr([], 'annotations');
21
+ const annotations = getAnnotations(structure);
22
+ const getDataSets = R.pathOr({},['data', 'dataSets']);
23
+ const dataSets = getDataSets(dataNew);
24
+
25
+ const dataSetsAnnotations = R.props(R.pathOr([],[0, 'annotations'], dataSets), annotations);
26
+
27
+ const hiddenIds = getNotDisplayedIds(dataSetsAnnotations);
28
+
29
+ //--------------------------------------------------------------------------------------------------
30
+ const getValues = (values, parent) => R.map((value) => {
31
+ const valAnnotations = R.props(value.annotations || [], annotations);
32
+ return ({
33
+ ...value,
34
+ display: !R.has(`${parent}.${value.id}`, hiddenIds) && !getIsHidden(valAnnotations),
35
+ name: getLocalisedProp('names', value)
36
+ });
37
+ }, values);
38
+
39
+ const getValuesEnhanced = (locale, annotations, isTimeDimension, parent) =>
17
40
  R.pipe(
18
41
  R.addIndex(R.map)((value, __index) => {
19
42
  const valueAnnotations = R.pipe(
20
43
  R.propOr([], 'annotations'),
21
44
  R.flip(R.props)(annotations)
22
45
  )(value);
46
+ const isHidden = R.has(`${parent}.${value.id}`, hiddenIds) || getIsHidden(valueAnnotations);
23
47
  const name = getLocalisedProp('names')(value);
24
48
  let __indexPosition = NaN;
25
49
  let start = null;
@@ -40,6 +64,7 @@ export const dataTransformer = (dataNew, options = {}) => {
40
64
  R.always(isTimeDimension),
41
65
  R.replace(/M/g, '')
42
66
  )(value.id),
67
+ display: !isHidden,
43
68
  name: R.when(
44
69
  R.always(isTimeDimension),
45
70
  R.always(getReportedTimePeriodLabel(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start:value.start }))
@@ -56,12 +81,6 @@ export const dataTransformer = (dataNew, options = {}) => {
56
81
  R.addIndex(R.map)((val, index) => R.assoc('__indexPosition', index, val))
57
82
  );
58
83
 
59
- const getDataSets = R.pathOr({},['data', 'dataSets']);
60
- const dataSets = getDataSets(dataNew);
61
-
62
- const getStructure = R.pathOr({},['data', 'structure']);
63
- const structure = getStructure(dataNew);
64
-
65
84
  //--------------------------------------------------------------------------------------------Header
66
85
  const getMeta = R.propOr({}, 'meta');
67
86
  const meta = getMeta(dataNew);
@@ -74,20 +93,6 @@ export const dataTransformer = (dataNew, options = {}) => {
74
93
  sender: {...sender, name: getLocalisedProp('names', sender)},
75
94
  };
76
95
 
77
- //---------------------------------------------------------------------------------------Annotations
78
- const getAnnotations = R.propOr([], 'annotations');
79
- const annotations = getAnnotations(structure);
80
-
81
- const dataSetsAnnotations = getRelationnalAnnotations(
82
- R.pathOr([],[0, 'annotations'])(dataSets)
83
- )(annotations);
84
-
85
- const hiddenIds = R.pipe(
86
- R.find(R.propEq('type', 'NOT_DISPLAYED')),
87
- R.propOr('', 'title'),
88
- R.ifElse(R.isEmpty, R.always([]), R.split(','))
89
- )(annotations);
90
-
91
96
  //----------------------------------------------------------------------------------------Attributes
92
97
  const getAttributes = R.propOr({}, 'attributes');
93
98
  const attributes = getAttributes(structure);
@@ -95,19 +100,27 @@ export const dataTransformer = (dataNew, options = {}) => {
95
100
  const getAttrObservations = R.propOr([], 'observation');
96
101
  const attrObservations = getAttrObservations(attributes);
97
102
 
98
- const resAttrObservations = R.map((observation) => ({
99
- ...observation,
100
- name: getLocalisedProp('names', observation),
101
- values: getValues(observation.values || []),
102
- roles: !R.isNil(observation.role) ? R.head(observation.role) : null,
103
- }), attrObservations);
103
+ const resAttrObservations = R.map((observation) => {
104
+ const obsAnnotations = R.props(observation.annotations || [], annotations);
105
+ return ({
106
+ ...observation,
107
+ display: !R.has(observation.id, hiddenIds) && !getIsHidden(obsAnnotations),
108
+ name: getLocalisedProp('names', observation),
109
+ values: getValues(observation.values || [], observation.id),
110
+ roles: !R.isNil(observation.role) ? R.head(observation.role) : null,
111
+ });
112
+ }, attrObservations);
104
113
 
105
114
  const datasetAttributes = R.map(
106
- (attr) => ({
107
- ...attr,
108
- name: getLocalisedProp('names', observation),
109
- values: getValues(attr.values || [])
110
- }),
115
+ (attr) => {
116
+ const attrAnnotations = R.props(attr.annotations || [], annotations);
117
+ return ({
118
+ ...attr,
119
+ display: !R.has(attr.id, hiddenIds) && !getIsHidden(attrAnnotations),
120
+ name: getLocalisedProp('names', observation),
121
+ values: getValues(attr.values || [], attr.id)
122
+ });
123
+ },
111
124
  R.propOr([], 'dataSet', attributes)
112
125
  )
113
126
 
@@ -126,10 +139,10 @@ export const dataTransformer = (dataNew, options = {}) => {
126
139
  const getObservations = locale => R.addIndex(R.reduce)((acc, observation, obsIndex) => {
127
140
  const id = R.prop('id')(observation);
128
141
  const dimAnnotations = getRelationnalAnnotations(R.propOr([],'annotations')(observation))(annotations)
129
- const isHidden = R.includes(id)(hiddenIds) ? hiddenFormat : getIsHidden(dimAnnotations);
142
+ const isHidden = R.has(id, hiddenIds) || getIsHidden(dimAnnotations);
130
143
  const isTime = isTimePeriodDimension(observation);
131
144
 
132
- const values = getValuesEnhanced(locale, annotations, isTime)(R.propOr([],'values', observation));
145
+ const values = getValuesEnhanced(locale, annotations, isTime, id)(R.propOr([],'values', observation));
133
146
  const ids = R.pipe(R.pluck('id'), R.indexBy(R.identity))(values);
134
147
  const groupedByParentsValues = R.groupBy(val => {
135
148
  const parentId = R.propOr('##ROOT', 'parent', val);
@@ -158,11 +171,11 @@ export const dataTransformer = (dataNew, options = {}) => {
158
171
  return ({
159
172
  observation: R.append({
160
173
  ...observation,
174
+ display: !isHidden,
161
175
  __index: obsIndex,
162
176
  name: getLocalisedProp('names', observation),
163
177
  values: sortedValues,
164
178
  role: R.isNil(observation.roles) ? null : R.head(observation.roles),
165
- ...isHidden,
166
179
  })(acc.observation),
167
180
  dimensionsLayout: setAnnotationsLayout(id, acc.dimensionsLayout)(dimAnnotations),
168
181
  });
@@ -26,7 +26,7 @@ export const getDataflowAdvancedAttributes = (attributes, dimensions, advancedAt
26
26
  coordinates = { ...coordinates, [dId]: vId };
27
27
  key = R.set(R.lensIndex(dIndex), 0)(key);
28
28
  },
29
- attrDimensions
29
+ R.reject(R.isNil, attrDimensions)
30
30
  );
31
31
  }
32
32
 
@@ -0,0 +1,40 @@
1
+ import * as R from 'ramda';
2
+
3
+ export const getNotDisplayedIds = (annotations) => R.pipe(
4
+ 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
+ if (R.isEmpty(val)) {
27
+ return _acc;
28
+ }
29
+ const key = `${dimensionId}.${val}`;
30
+ return R.assoc(key, key, _acc);
31
+ },
32
+ acc,
33
+ values
34
+ );
35
+ },
36
+ {},
37
+ ids
38
+ );
39
+ }
40
+ )(annotations);
@@ -42,33 +42,51 @@ export const getSidebarData = (attributesSeries, metadataSeries, dataflow, dimen
42
42
  R.isNil(metadata) ? [] : metadata,
43
43
  );
44
44
  const splitCoord = R.split(':', coordinate);
45
- let label = null;
46
- if (R.all(R.isEmpty, splitCoord)) {
47
- label = dimensionValueDisplay(options.display)(dataflow);
48
- }
49
- else {
50
- label = R.pipe(
51
- R.addIndex(R.reduce)((acc, valIndex, dimIndex) => {
52
- if (R.isEmpty(valIndex)) {
53
- return acc;
54
- }
55
- const dim = R.nth(dimIndex, dimensions);
56
- const dimLabel = dimensionValueDisplay(options.display)(dim);
57
- const value = R.nth(Number(valIndex), dim.values);
58
- const valLabel = dimensionValueDisplay(options.display)(value);
59
- return R.append(`${dimLabel}: ${valLabel}`, acc);
60
- }, []),
61
- R.join(' - ')
62
- )(splitCoord);
63
- }
64
-
45
+ const { split, labels } = R.addIndex(R.reduce)(
46
+ (acc, valIndex, dimIndex) => {
47
+ if (R.isEmpty(valIndex)) {
48
+ return ({ ...acc, split: R.append('', acc.split) });
49
+ }
50
+ const dim = R.nth(dimIndex, dimensions);
51
+ const value = R.nth(Number(valIndex), dim.values);
52
+ if (!R.propOr(true, 'display', dim) || !R.propOr(true, 'display', value)) {
53
+ return ({ ...acc, split: R.append('', acc.split) });
54
+ }
55
+ const dimLabel = dimensionValueDisplay(options.display)(dim);
56
+ const valLabel = dimensionValueDisplay(options.display)(value);
57
+ return ({
58
+ labels: R.append(`${dimLabel}: ${valLabel}`, acc.labels),
59
+ split: R.append(valIndex, acc.split)
60
+ });
61
+ },
62
+ { split: [], labels: [] },
63
+ splitCoord
64
+ );
65
+ const label = R.isEmpty(labels)
66
+ ? dimensionValueDisplay(options.display)(dataflow)
67
+ : R.join(' - ', labels);
68
+
65
69
  return ({
66
- id: coordinate,
67
- splitCoord,
70
+ id: R.join(':', split),
71
+ splitCoord: split,
68
72
  label,
69
73
  children: R.filter(R.identity, children),
70
74
  });
71
75
  }),
72
- R.sort(sortByCoordinates)
76
+ series => { // after removed non displayed dim vals, some series might be duplicated
77
+ const grouped = R.groupBy(R.prop('id'), series);
78
+ return R.pipe(
79
+ R.map(entries => {
80
+ if (R.length(entries) === 1) {
81
+ return R.head(entries);
82
+ }
83
+ const head = R.head(entries);
84
+ const children = R.pipe(R.pluck('children'), R.unnest)(entries);
85
+ return R.assoc('children', children, head);
86
+ }),
87
+ R.values
88
+ )(grouped);
89
+ },
90
+ R.sort(sortByCoordinates),
73
91
  )(coordinates);
74
92
  };
@@ -8,3 +8,4 @@ export { parseMetadataSeries } from './parseMetadataSeries';
8
8
  export { sdmx_3_0_DataFormatPatch } from './sdmx3.0DataFormatPatch';
9
9
  export { getDataflowTooltipAttributesIds } from './getDataflowTooltipAttributesIds';
10
10
  export { getMSDInformations } from './getMSDInformations';
11
+ export { getNotDisplayedIds } from './getNotDisplayedIds';
@@ -100,7 +100,7 @@ describe('enhanceObservations tests', () => {
100
100
  },
101
101
  {
102
102
  id: 'a4',
103
- values: [{ id: 'v0' }, { id: 'v1' }],
103
+ values: [{ id: 'v0' }, { id: 'v1', display: false }],
104
104
  },
105
105
  ];
106
106
 
@@ -112,7 +112,7 @@ describe('enhanceObservations tests', () => {
112
112
  { id: 'v0', __index: 0, __indexPosition: 0 },
113
113
  { id: 'v1', __index: 1, __indexPosition: 1 },
114
114
  { id: 'v2', __index: 2, __indexPosition: 2 },
115
- { id: 'v3', __index: 3, __indexPosition: 3 }
115
+ { id: 'v3', __index: 3, __indexPosition: 3, display: false }
116
116
  ]
117
117
  },
118
118
  {
@@ -0,0 +1,31 @@
1
+ import { expect } from 'chai';
2
+ import { getNotDisplayedIds } from '../src/rules2/src/getNotDisplayedIds';
3
+
4
+ describe('getNotDisplayedIds tests', () => {
5
+ it('not provided case', () => {
6
+ const annotations = [
7
+ { type: 'test0' },
8
+ { type: 'test1' },
9
+ { type: 'NOT_DISPLAYED', title: '' },
10
+ { type: 'test2' },
11
+ ];
12
+ expect(getNotDisplayedIds(annotations)).to.deep.equal({});
13
+ });
14
+ it('complete case', () => {
15
+ const annotations = [
16
+ { type: 'test0' },
17
+ { type: 'test1' },
18
+ { type: 'NOT_DISPLAYED', title: 'd0,d1=,d2=v0,d3=v0+,d4=v0+v1' },
19
+ { type: 'test2' },
20
+ ];
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
+ };
29
+ expect(getNotDisplayedIds(annotations)).to.deep.equal(expected);
30
+ });
31
+ })
@@ -1,29 +1,24 @@
1
1
  import { expect } from 'chai';
2
2
  import { getOneValueDimensions } from '../src/rules/src/table/preparators/getOneValueDimensions';
3
- import { getDisplay } from '../src/rules/src/preparators/getDisplay';
4
-
5
- const noDisplayIndexes = [0, 2, 4];
6
-
7
- const notDisplayedCodes = { '5': { id: '5' }, '6': { id: '6', values: { '6.1': '6.1' } } }
8
3
 
9
4
  describe('getOneValueDimensions tests', () => {
10
5
  it('no display indexes test', () => {
11
6
  const dimensions = [
12
- { id: '0', values: [{ id: '0.1' }] },
13
- { id: '1', annotations: [1, 3, 5], values: [{ id: '1.1' }] },
14
- { id: '2', annotations: [0, 3, 5], values: [{ id: '2.1' }] },
15
- { id: '3', values: [{ id: '3.1', annotations: [7, 8] }] },
16
- { id: '4', values: [{ id: '4.1', annotations: [2, 7] }] },
17
- { id: '5', values: [{ id: '5.1' }] },
18
- { id: '6', values: [{ id: '6.1' }] },
7
+ { id: '0', display: true, values: [{ id: '0.1', display: true }] },
8
+ { id: '1', display: true, values: [{ id: '1.1', display: true }] },
9
+ { id: '2', display: false, values: [{ id: '2.1', display: true }] },
10
+ { id: '3', display: true, values: [{ id: '3.1', display: true }] },
11
+ { id: '4', display: true, values: [{ id: '4.1', display: false }] },
12
+ { id: '5', display: false, values: [{ id: '5.1', display: true }] },
13
+ { id: '6', display: true, values: [{ display: false, id: '6.1' }] },
19
14
  ];
20
15
 
21
- expect(getOneValueDimensions(dimensions, {}, [], getDisplay({ noDisplayIndexes, notDisplayedCodes }))).to.deep.equal([
16
+ expect(getOneValueDimensions(dimensions, {}, [])).to.deep.equal([
22
17
  { id: '0', display: true, values: [{ id: '0.1', attributes: {}, display: true }] },
23
- { id: '1', annotations: [1, 3, 5], display: true, values: [{ id: '1.1', attributes: {}, display: true }] },
24
- { id: '2', annotations: [0, 3, 5], display: false, values: [{ id: '2.1', attributes: {}, display: true }] },
25
- { id: '3', display: true, values: [{ id: '3.1', annotations: [7, 8], attributes: {}, display: true }] },
26
- { id: '4', display: true, values: [{ id: '4.1', annotations: [2, 7], attributes: {}, display: false }] },
18
+ { id: '1', display: true, values: [{ id: '1.1', attributes: {}, display: true }] },
19
+ { id: '2', display: false, values: [{ id: '2.1', attributes: {}, display: true }] },
20
+ { id: '3', display: true, values: [{ id: '3.1', attributes: {}, display: true }] },
21
+ { id: '4', display: true, values: [{ id: '4.1', attributes: {}, display: false }] },
27
22
  { id: '5', display: false, values: [{ id: '5.1', attributes: {}, display: true }] },
28
23
  { id: '6', display: true, values: [{ id: '6.1', attributes: {}, display: false }] },
29
24
  ]);