@sis-cc/dotstatsuite-components 15.0.9 → 15.0.10

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,7 +11,9 @@ var R = _interopRequireWildcard(_ramda);
11
11
 
12
12
  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
13
 
14
- var getDataflowTooltipAttributesIds = exports.getDataflowTooltipAttributesIds = function getDataflowTooltipAttributesIds(sdmxJson, defaults) {
14
+ var getDataflowTooltipAttributesIds = exports.getDataflowTooltipAttributesIds = function getDataflowTooltipAttributesIds(sdmxJson) {
15
+ var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
16
+
15
17
  var dataflowAnnotationsIndexes = R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson);
16
18
  var dataflowAnnotations = R.props(dataflowAnnotationsIndexes, R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson));
17
19
 
@@ -24,10 +26,13 @@ var getDataflowTooltipAttributesIds = exports.getDataflowTooltipAttributesIds =
24
26
 
25
27
  var customNotes = R.pipe(R.propOr('', 'title'), function (title) {
26
28
  return R.isNil(title) || R.isEmpty(title) ? [] : R.split(',', title);
29
+ }, function (notes) {
30
+ return R.difference(notes, customFlags);
27
31
  })(footnotesAttrAnnotation || {});
28
32
 
29
- return {
30
- flags: R.isNil(flagsAttrAnnotation) ? defaults.flags : customFlags,
31
- notes: R.isNil(footnotesAttrAnnotation) ? defaults.notes : customNotes
32
- };
33
+ var flags = R.isNil(flagsAttrAnnotation) ? R.difference(defaults.flags || [], customNotes) : customFlags;
34
+
35
+ var notes = R.isNil(footnotesAttrAnnotation) ? R.difference(defaults.notes, flags) : customNotes;
36
+
37
+ return { flags: flags, notes: notes };
33
38
  };
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": "15.0.9",
4
+ "version": "15.0.10",
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
 
3
- export const getDataflowTooltipAttributesIds = (sdmxJson, defaults) => {
3
+ export const getDataflowTooltipAttributesIds = (sdmxJson, defaults = {}) => {
4
4
  const dataflowAnnotationsIndexes = R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson);
5
5
  const dataflowAnnotations = R.props(dataflowAnnotationsIndexes, R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson));
6
6
 
@@ -14,12 +14,18 @@ export const getDataflowTooltipAttributesIds = (sdmxJson, defaults) => {
14
14
 
15
15
  const customNotes = R.pipe(
16
16
  R.propOr('', 'title'),
17
- title => R.isNil(title) || R.isEmpty(title) ? [] : R.split(',', title)
17
+ title => R.isNil(title) || R.isEmpty(title) ? [] : R.split(',', title),
18
+ notes => R.difference(notes, customFlags)
18
19
  )(footnotesAttrAnnotation || {});
19
20
 
20
- return ({
21
- flags: R.isNil(flagsAttrAnnotation) ? defaults.flags : customFlags,
22
- notes: R.isNil(footnotesAttrAnnotation) ? defaults.notes : customNotes,
23
- });
21
+ const flags = R.isNil(flagsAttrAnnotation)
22
+ ? R.difference(defaults.flags || [], customNotes)
23
+ : customFlags;
24
+
25
+ const notes = R.isNil(footnotesAttrAnnotation)
26
+ ? R.difference(defaults.notes, flags)
27
+ : customNotes;
28
+
29
+ return ({ flags, notes });
24
30
  };
25
31
 
@@ -87,4 +87,56 @@ describe('getDataflowTooltipAttributesIds tests', () => {
87
87
 
88
88
  expect(getDataflowTooltipAttributesIds({ data }, def)).to.deep.equal({ flags: ['f2', 'f3'], notes: [] });
89
89
  });
90
+ it('custom flags overrides default notes', () => {
91
+ const defaultIds = {
92
+ flags: [],
93
+ notes: ['ATTR0', 'ATTR1']
94
+ };
95
+ const data = {
96
+ dataSets: [{
97
+ annotations: [0]
98
+ }],
99
+ structure: {
100
+ annotations: [
101
+ { id: 'annot0', type: 'LAYOUT_FLAG', title: 'ATTR0,ATTR1' },
102
+ ]
103
+ }
104
+ };
105
+ expect(getDataflowTooltipAttributesIds({ data }, defaultIds)).to.deep.equal({ flags: ['ATTR0', 'ATTR1'], notes: [] });
106
+ });
107
+ it('custom notes overrides default flags', () => {
108
+ const defaultIds = {
109
+ flags: ['ATTR0', 'ATTR1'],
110
+ notes: ['ATTR2', 'ATTR3']
111
+ };
112
+ const data = {
113
+ dataSets: [{
114
+ annotations: [0]
115
+ }],
116
+ structure: {
117
+ annotations: [
118
+ { id: 'annot0', type: 'LAYOUT_NOTE', title: 'ATTR1,ATTR2' },
119
+ ]
120
+ }
121
+ };
122
+ expect(getDataflowTooltipAttributesIds({ data }, defaultIds)).to.deep.equal({ flags: ['ATTR0'], notes: ['ATTR1', 'ATTR2'] });
123
+ });
124
+ it('custom flags overrides custom notes', () => {
125
+ const defaultIds = {
126
+ flags: [],
127
+ notes: []
128
+ };
129
+ const data = {
130
+ dataSets: [{
131
+ annotations: [0, 1]
132
+ }],
133
+ structure: {
134
+ annotations: [
135
+ { id: 'annot0', type: 'LAYOUT_FLAG', title: 'ATTR0,ATTR1' },
136
+ { id: 'annot1', type: 'LAYOUT_NOTE', title: 'ATTR1,ATTR2' },
137
+ ]
138
+ }
139
+ };
140
+ expect(getDataflowTooltipAttributesIds({ data }, defaultIds)).to.deep.equal({ flags: ['ATTR0', 'ATTR1'], notes: ['ATTR2'] });
141
+ });
90
142
  });