@sis-cc/dotstatsuite-components 21.0.1 → 21.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.
- package/dist/dotstatsuite-components.js +38112 -0
- package/package.json +4 -1
- package/.editorconfig +0 -19
- package/.gitlab-ci.yml +0 -48
- package/prettier.config.js +0 -13
- package/src/app.js +0 -13
- package/src/bridge-d3-react/README.md +0 -42
- package/src/bridge-d3-react/src/app.js +0 -64
- package/src/bridge-d3-react/src/index.js +0 -17
- package/src/bridge-d3-react/src/mock-choro.js +0 -394
- package/src/bridge-d3-react/src/react-chart-factory.js +0 -65
- package/src/index.js +0 -12
- package/src/rules/README.md +0 -23
- package/src/rules/src/chart/getAxisOptions.js +0 -258
- package/src/rules/src/chart/getBaseOptions.js +0 -84
- package/src/rules/src/chart/getChartOptions.js +0 -118
- package/src/rules/src/chart/getGridOptions.js +0 -52
- package/src/rules/src/chart/getTooltipOptions.js +0 -230
- package/src/rules/src/constants.js +0 -64
- package/src/rules/src/date.js +0 -118
- package/src/rules/src/dimension-utils.js +0 -54
- package/src/rules/src/factories/choro-series.js +0 -65
- package/src/rules/src/factories/sample-focus.js +0 -22
- package/src/rules/src/factories/sample-series.js +0 -51
- package/src/rules/src/factories/scatter-dimension.js +0 -31
- package/src/rules/src/factories/scatter-focus.js +0 -39
- package/src/rules/src/factories/scatter-series.js +0 -94
- package/src/rules/src/factories/stacked-dimension.js +0 -29
- package/src/rules/src/factories/stacked-series.js +0 -185
- package/src/rules/src/factories/symbol-dimension.js +0 -29
- package/src/rules/src/factories/symbol-series.js +0 -62
- package/src/rules/src/factories/timeline-focus.js +0 -18
- package/src/rules/src/factories/timeline-series.js +0 -91
- package/src/rules/src/get-values-enhanced.js +0 -134
- package/src/rules/src/header/getDefaultSubtitle.js +0 -40
- package/src/rules/src/header/getHeaderUnits.js +0 -17
- package/src/rules/src/header/getSubtitleFlags.js +0 -43
- package/src/rules/src/header/getTitleFlags.js +0 -8
- package/src/rules/src/header/index.js +0 -4
- package/src/rules/src/index.js +0 -398
- package/src/rules/src/layout.js +0 -113
- package/src/rules/src/observation-formater.js +0 -83
- package/src/rules/src/preparators/enhanceObservations.js +0 -152
- package/src/rules/src/preparators/formatValue.js +0 -84
- package/src/rules/src/preparators/getObservations.js +0 -19
- package/src/rules/src/preparators/getReportingYearStart.js +0 -16
- package/src/rules/src/properties/errors.js +0 -19
- package/src/rules/src/properties/focus.js +0 -69
- package/src/rules/src/properties/getAvailableChartTypes.js +0 -34
- package/src/rules/src/properties/getHeaderProps.js +0 -74
- package/src/rules/src/properties/getInformationsStateFromNewProps.js +0 -47
- package/src/rules/src/properties/getObservationsType.js +0 -29
- package/src/rules/src/properties/getStringifiedSubtitle.js +0 -6
- package/src/rules/src/properties/index.js +0 -424
- package/src/rules/src/properties/information.js +0 -84
- package/src/rules/src/properties/linear.js +0 -129
- package/src/rules/src/properties/scatter.js +0 -158
- package/src/rules/src/properties/stacked.js +0 -98
- package/src/rules/src/properties/symbol.js +0 -79
- package/src/rules/src/properties/utils.js +0 -110
- package/src/rules/src/sdmx-data/index.js +0 -39
- package/src/rules/src/table/factories/getCellValue.js +0 -50
- package/src/rules/src/table/index.js +0 -1
- package/src/rules/src/v8-transformer.js +0 -176
- package/src/rules/test/extractSdmxArtefacts.js +0 -26
- package/src/rules/test/get-values-enhanced.test.js +0 -127
- package/src/rules/test/oecd-HEALTH_PROT-no-freq.json +0 -2903
- package/src/rules/test/oecd-HEALTH_PROT-parsed.js +0 -398
- package/src/rules/test/oecd-HEALTH_PROT-wrong-freq.json +0 -2913
- package/src/rules/test/oecd-HEALTH_PROT.json +0 -2913
- package/src/rules/test/oecd-KEI.json +0 -372
- package/src/rules/test/scatter-property.js +0 -455
- package/src/rules/test/stacked-property.js +0 -273
- package/src/rules/test/symbol-property.js +0 -262
- package/src/rules/test/v8-transformer.test.js +0 -90
- package/src/rules2/src/applyHierarchicalCodesToDim.js +0 -149
- package/src/rules2/src/combinedValuesDisplay.js +0 -74
- package/src/rules2/src/constants.js +0 -6
- package/src/rules2/src/duplicateObservations.js +0 -35
- package/src/rules2/src/enhanceObservations.js +0 -95
- package/src/rules2/src/getAdvAttrSeriesAtCoordinates.js +0 -29
- package/src/rules2/src/getAttributesSeries.js +0 -36
- package/src/rules2/src/getCombinationDefinitions.js +0 -47
- package/src/rules2/src/getDataflowAttributes.js +0 -23
- package/src/rules2/src/getDataflowTooltipAttributesIds.js +0 -31
- package/src/rules2/src/getDimensionValuesIndexes.js +0 -13
- package/src/rules2/src/getHCodelistsRefsInData.js +0 -32
- package/src/rules2/src/getHeaderCombinations.js +0 -48
- package/src/rules2/src/getHeaderCoordinates.js +0 -7
- package/src/rules2/src/getHeaderSubtitle.js +0 -34
- package/src/rules2/src/getHeaderTitle.js +0 -15
- package/src/rules2/src/getMSDInformations.js +0 -23
- package/src/rules2/src/getManyValuesDimensions.js +0 -34
- package/src/rules2/src/getMetadataCoordinates.js +0 -37
- package/src/rules2/src/getMetadataStructureFromData.js +0 -17
- package/src/rules2/src/getNotDisplayedIds.js +0 -53
- package/src/rules2/src/getOneValueDimensions.js +0 -34
- package/src/rules2/src/getSeriesCombinations.js +0 -24
- package/src/rules2/src/hasCellMetadata.js +0 -14
- package/src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy2.js +0 -57
- package/src/rules2/src/hierarchiseDimensionWithNativeHierarchy2.js +0 -35
- package/src/rules2/src/index.js +0 -50
- package/src/rules2/src/parseAttributes.js +0 -41
- package/src/rules2/src/parseCombinations.js +0 -102
- package/src/rules2/src/parseHierarchicalCodelist.js +0 -48
- package/src/rules2/src/parseMetadataSeries.js +0 -117
- package/src/rules2/src/prepareData.js +0 -73
- package/src/rules2/src/refineAttributes.js +0 -16
- package/src/rules2/src/refineDimensions.js +0 -18
- package/src/rules2/src/refineMetadataCoordinates.js +0 -28
- package/src/rules2/src/refineTimePeriod.js +0 -127
- package/src/rules2/src/sdmx3.0DataFormatPatch.js +0 -9
- package/src/rules2/src/table/declineObservationsOverAttributes.js +0 -32
- package/src/rules2/src/table/getCells.js +0 -93
- package/src/rules2/src/table/getCellsAttributesIds.js +0 -38
- package/src/rules2/src/table/getCellsMetadataCoordinates.js +0 -13
- package/src/rules2/src/table/getCombinationDimensionsData.js +0 -39
- package/src/rules2/src/table/getCuratedCells.js +0 -33
- package/src/rules2/src/table/getFlagsAndNotes.js +0 -23
- package/src/rules2/src/table/getIndexedCombinationsByDisplay.js +0 -16
- package/src/rules2/src/table/getLayout.js +0 -84
- package/src/rules2/src/table/getLayoutData2.js +0 -198
- package/src/rules2/src/table/getSortedLayoutIndexes.js +0 -124
- package/src/rules2/src/table/getTableLabelAccessor.js +0 -9
- package/src/rules2/src/table/getTableLayoutIds.js +0 -314
- package/src/rules2/src/table/getTableProps.js +0 -75
- package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +0 -79
- package/src/rules2/src/table/parseValueHierarchy.js +0 -33
- package/src/rules2/src/table/refineLayoutSize2.js +0 -321
- package/src/rules2/src/utils.js +0 -37
- package/src/viewer/mocks/bar.js +0 -33
- package/src/viewer/mocks/gpp-symbol.js +0 -93
- package/src/viewer/mocks/gpp-time.js +0 -1103
- package/src/viewer/mocks/row.js +0 -39
- package/src/viewer/mocks/scatter.js +0 -93
- package/src/viewer/mocks/stack.js +0 -161
- package/src/viewer/src/app/leg.js +0 -36
- package/src/viewer/src/app/nodata-res.js +0 -22
- package/src/viewer/src/app/nodata-sized.js +0 -23
- package/src/viewer/src/app/one-table-cell.js +0 -70
- package/src/viewer/src/app/table.js +0 -423
- package/src/viewer/src/app/use-case-1.js +0 -33
- package/src/viewer/src/app/use-case-2.js +0 -38
- package/src/viewer/src/app/use-case-3.js +0 -18
- package/src/viewer/src/app.js +0 -116
- package/src/viewer/src/chart.js +0 -52
- package/src/viewer/src/chartUtils/options.js +0 -30
- package/src/viewer/src/chartUtils/series.js +0 -51
- package/src/viewer/src/footer.js +0 -24
- package/src/viewer/src/header.js +0 -10
- package/src/viewer/src/index.js +0 -158
- package/src/viewer/src/legends/AxisLegend.js +0 -41
- package/src/viewer/src/legends/ChartLegends.js +0 -66
- package/src/viewer/src/legends/FocusLegend.js +0 -63
- package/src/viewer/src/legends/Legend.js +0 -46
- package/src/viewer/src/legends/SeriesLegend.js +0 -78
- package/src/viewer/src/utils.js +0 -21
- package/test/applyHierarchicalCodesToDim.test.js +0 -160
- package/test/combinedValuesDisplay.test.js +0 -66
- package/test/duplicateObs.test.js +0 -118
- package/test/enhanceObservations2.test.js +0 -257
- package/test/getAttributesSeries.test.js +0 -66
- package/test/getAxisOptions.test.js +0 -309
- package/test/getBaseOptions.test.js +0 -77
- package/test/getCellValue.test.js +0 -32
- package/test/getCells.test.js +0 -178
- package/test/getCellsMetadataCoordinates.test.js +0 -40
- package/test/getCombinationDefinitions.test.js +0 -104
- package/test/getCombinationDimensionsData.test.js +0 -99
- package/test/getDataflowAttributes.test.js +0 -23
- package/test/getDataflowTooltipAttributesIds.test.js +0 -146
- package/test/getDimensionValuesIndexes.test.js +0 -33
- package/test/getGridOptions.test.js +0 -65
- package/test/getHCodelistsRefs.test.js +0 -23
- package/test/getHeaderCombinations.test.js +0 -62
- package/test/getHeaderTitle.test.js +0 -25
- package/test/getLayout.test.js +0 -54
- package/test/getLayoutData2.test.js +0 -535
- package/test/getMSDInformations.test.js +0 -35
- package/test/getMetadataCoordinates.test.js +0 -0
- package/test/getNotDisplayedIds.test.js +0 -47
- package/test/getObservationsType.test.js +0 -55
- package/test/getOneValueDimensions.test.js +0 -35
- package/test/getReportingYearStart.test.js +0 -59
- package/test/getSeriesCombinations.test.js +0 -29
- package/test/getSortedLayoutIndexes.test.js +0 -1138
- package/test/getTableLabelAccessor.test.js +0 -50
- package/test/getTableLayoutIds.test.js +0 -356
- package/test/hierarchiseDimensionWithNativeHierarchy2.test.js +0 -109
- package/test/isTableLayoutCompatible.test.js +0 -102
- package/test/metadata-parsing-perf.test.js +0 -509
- package/test/mocks/MSD_TEST.json +0 -490
- package/test/mocks/OECD_SNA_TABLE1_1.0_-_AUS_V_metadata.json +0 -152
- package/test/mocks/h-codelist.json +0 -2095
- package/test/mocks/large_metadata_series.json +0 -701
- package/test/mocks/observations-advanced-attributes.json +0 -55382
- package/test/mocks/table-invert-time--data.json +0 -80211
- package/test/mocks/table-invert-time--inverted.json +0 -80076
- package/test/mocks/table-layout-multi-hierarchies--layout.json +0 -621
- package/test/mocks/table-layout-multi-hierarchies--layoutData.json +0 -32411
- package/test/mocks/table-layout-multi-hierarchies--layoutIndexes.json +0 -2760
- package/test/mocks/table-layout-multi-hierarchies--observations.json +0 -30688
- package/test/mocks/table-layout-multi-hierarchies--sizedIndexes.json +0 -2762
- package/test/mocks/table-layout-truncation1--layout.json +0 -27469
- package/test/mocks/table-layout-truncation1--layoutData.json +0 -20358
- package/test/mocks/table-layout-truncation1--layoutIndexes.json +0 -7512
- package/test/mocks/table-layout-truncation1--observations.json +0 -70002
- package/test/mocks/table-layout-truncation1--sizedIndexes.json +0 -3011
- package/test/mocks/table-prep-multi-hierarchies--attributes.json +0 -46
- package/test/mocks/table-prep-multi-hierarchies--dimensions.json +0 -688
- package/test/mocks/table-prep-multi-hierarchies--enhancedObservations.json +0 -19696
- package/test/mocks/table-prep-multi-hierarchies--observations.json +0 -8246
- package/test/mocks/table-prep-multi-hierarchies--sdmxJson.json +0 -2985
- package/test/mocks/table-prep-simple-duplicate--dimensions2.json +0 -858
- package/test/mocks/table-prep-simple-duplicate--duplicated2.json +0 -77502
- package/test/mocks/table-prep-simple-duplicate--observations2.json +0 -60002
- package/test/mocks/table-prep-truncation1--dimensions.json +0 -35057
- package/test/mocks/table-prep-truncation1--enhancedObservations.json +0 -70002
- package/test/mocks/table-prep-truncation1--observations.json +0 -27502
- package/test/mocks/table-prep-truncation1--sdmxJson.json +0 -55103
- package/test/mocks/table-prep-units--observations.json +0 -284286
- package/test/mocks/table-prep-units--unitsSeries.json +0 -41042
- package/test/parseAttributes.test.js +0 -36
- package/test/parseCombinations.test.js +0 -172
- package/test/parseHierarchicalCodelist.test.js +0 -140
- package/test/parseMetadataSeries.test.js +0 -128
- package/test/parseSeriesIndexesHierarchies.test.js +0 -345
- package/test/parseValueHierarchy.test.js +0 -138
- package/test/refineAttributes.test.js +0 -29
- package/test/refineLayoutSize2.test.js +0 -3410
- package/test/refineMetadataCoordinates.test.js +0 -86
- package/test/refineTimePeriod.test.js +0 -580
- package/test/refinedDimensions.test.js +0 -35
- package/vite.config.mjs +0 -51
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
const addParentId = (id, ids) => {
|
|
4
|
-
const last = R.last(ids);
|
|
5
|
-
return R.append(R.isNil(last) ? id : `${last}.${id}`, ids);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const refineUnconfirmedPaths = (paths) => {
|
|
9
|
-
let confirmedPaths = R.filter(p => p.length === 1, paths);
|
|
10
|
-
if (!R.isEmpty(confirmedPaths)) {
|
|
11
|
-
confirmedPaths = R.reduce((acc, k) => {
|
|
12
|
-
if (R.has(k, acc)) {
|
|
13
|
-
return acc;
|
|
14
|
-
}
|
|
15
|
-
const ps = R.prop(k, paths);
|
|
16
|
-
const flatConfirmed = R.unnest(R.values(acc));
|
|
17
|
-
const filtered = R.filter(p => !!R.find(cP => R.includes(p, cP) || R.includes(cP, p), flatConfirmed), ps);
|
|
18
|
-
if (!R.isEmpty(filtered)) {
|
|
19
|
-
return R.assoc(k, [R.head(filtered)], acc);
|
|
20
|
-
}
|
|
21
|
-
return acc;
|
|
22
|
-
}, confirmedPaths, R.keys(paths));
|
|
23
|
-
}
|
|
24
|
-
const remainingIds = R.reject(id => R.has(id, confirmedPaths), R.keys(paths));
|
|
25
|
-
const getCommonPaths = ids => {
|
|
26
|
-
const { commonPaths, rejectedIds } = R.reduce(
|
|
27
|
-
(acc, id) => {
|
|
28
|
-
const ps = R.prop(id, paths);
|
|
29
|
-
if (R.isEmpty(acc.commonPaths)) {
|
|
30
|
-
return R.assoc('commonPaths', ps, acc);
|
|
31
|
-
}
|
|
32
|
-
const common = R.intersection(acc.commonPaths, ps);
|
|
33
|
-
return R.isEmpty(common)
|
|
34
|
-
? R.assoc('rejectedChildrenIds', id, acc)
|
|
35
|
-
: R.assoc('commonPaths', common, acc);
|
|
36
|
-
},
|
|
37
|
-
{ commonPaths: [], rejectedIds: [] }
|
|
38
|
-
)(ids);
|
|
39
|
-
if (!R.isEmpty(rejectedIds)) {
|
|
40
|
-
return R.append(R.head(commonPaths), getCommonPaths(rejectedIds));
|
|
41
|
-
}
|
|
42
|
-
return [R.head(commonPaths)];
|
|
43
|
-
};
|
|
44
|
-
const commons = getCommonPaths(remainingIds);
|
|
45
|
-
return R.reduce(
|
|
46
|
-
(acc, id) => R.assoc(id, R.intersection(commons, R.prop(id, paths)), acc),
|
|
47
|
-
confirmedPaths,
|
|
48
|
-
remainingIds
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const applyHierarchicalCodesToDim = (hCodes, dim) => {
|
|
53
|
-
const confirmedHierarchisedChilds = new Set([]);
|
|
54
|
-
let unconfirmedPaths = {};
|
|
55
|
-
|
|
56
|
-
const indexedValues = R.reduce((acc, val) => {
|
|
57
|
-
if (!val.isSelected) {
|
|
58
|
-
return acc;
|
|
59
|
-
}
|
|
60
|
-
return R.assoc(val.id, val, acc);
|
|
61
|
-
}, {}, dim.values || []);
|
|
62
|
-
|
|
63
|
-
const parseHCodes = (parentsDef, parentsInDim) => R.reduce((acc, hC) => {
|
|
64
|
-
const { codeID, hierarchicalCodes = [] } = hC;
|
|
65
|
-
const hasInDim = R.has(codeID, indexedValues);
|
|
66
|
-
const isUnconfirmed = R.length(parentsInDim) !== R.length(parentsDef);
|
|
67
|
-
const children = parseHCodes(
|
|
68
|
-
R.append(codeID, parentsDef),
|
|
69
|
-
hasInDim ? addParentId(codeID, parentsInDim) : parentsInDim
|
|
70
|
-
)(hierarchicalCodes);
|
|
71
|
-
if (!hasInDim) {
|
|
72
|
-
return R.concat(acc, children);
|
|
73
|
-
}
|
|
74
|
-
const path = R.join('.', parentsDef);
|
|
75
|
-
let val = {
|
|
76
|
-
...R.prop(codeID, indexedValues),
|
|
77
|
-
path,
|
|
78
|
-
parents: parentsInDim,
|
|
79
|
-
parent: R.last(parentsInDim),
|
|
80
|
-
children
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
if (isUnconfirmed) {
|
|
84
|
-
unconfirmedPaths = R.over(R.lensProp(val.id), paths => R.append(path, paths || []), unconfirmedPaths);
|
|
85
|
-
val = R.assoc('unconfirmed', true, val);
|
|
86
|
-
return R.append(val, acc);
|
|
87
|
-
}
|
|
88
|
-
confirmedHierarchisedChilds.add(codeID);
|
|
89
|
-
return R.append(val, acc);
|
|
90
|
-
}, []);
|
|
91
|
-
|
|
92
|
-
const parsed = parseHCodes([], [])(hCodes);
|
|
93
|
-
|
|
94
|
-
const _unconfirmedPaths = R.pipe(
|
|
95
|
-
R.reject(id => confirmedHierarchisedChilds.has(id)),
|
|
96
|
-
ids => R.pick(ids, unconfirmedPaths)
|
|
97
|
-
)(R.keys(unconfirmedPaths));
|
|
98
|
-
|
|
99
|
-
const refinedUnconfirmedPaths = refineUnconfirmedPaths(_unconfirmedPaths);
|
|
100
|
-
|
|
101
|
-
const flattenDescendants = R.reduce((acc, val ) => {
|
|
102
|
-
const children = flattenDescendants(val.children || []);
|
|
103
|
-
return R.concat(acc, R.prepend(val, children));
|
|
104
|
-
}, []);
|
|
105
|
-
|
|
106
|
-
const isValid = val => !val.unconfirmed || R.includes(val.path, R.propOr([], val.id, refinedUnconfirmedPaths));
|
|
107
|
-
|
|
108
|
-
const refineCodes = R.reduce((acc, hC) => {
|
|
109
|
-
const _flatDescendants = flattenDescendants(hC.children);
|
|
110
|
-
const flatDescendants = R.prepend(hC, _flatDescendants);
|
|
111
|
-
const validDescendant = R.find(isValid, flatDescendants);
|
|
112
|
-
if (!validDescendant) {
|
|
113
|
-
return acc;
|
|
114
|
-
}
|
|
115
|
-
const refined = R.pipe(
|
|
116
|
-
R.map(v => {
|
|
117
|
-
confirmedHierarchisedChilds.add(v.id);
|
|
118
|
-
return R.omit(['unconfirmed', 'children', 'path'], v);
|
|
119
|
-
})
|
|
120
|
-
)(flatDescendants);
|
|
121
|
-
return R.concat(acc, refined);
|
|
122
|
-
}, []);
|
|
123
|
-
|
|
124
|
-
const refined = refineCodes(parsed);
|
|
125
|
-
|
|
126
|
-
const missingValues = R.pipe(
|
|
127
|
-
R.keys,
|
|
128
|
-
R.filter(id => !confirmedHierarchisedChilds.has(id)),
|
|
129
|
-
ids => R.props(ids, indexedValues),
|
|
130
|
-
R.map(v => ({ ...v, parents: [], parent: undefined })),
|
|
131
|
-
R.sortBy(R.propOr(-1, '__indexPosition')),
|
|
132
|
-
)(indexedValues);
|
|
133
|
-
|
|
134
|
-
let hierarchicalIndexes = {};
|
|
135
|
-
return R.pipe(
|
|
136
|
-
R.concat,
|
|
137
|
-
R.addIndex(R.map)((v, ind) => {
|
|
138
|
-
const parents = R.props(v.parents, hierarchicalIndexes);
|
|
139
|
-
const hierId = R.last(v.parents) ? `${R.last(v.parents)}.${v.id}` : v.id;
|
|
140
|
-
hierarchicalIndexes[hierId] = ind;
|
|
141
|
-
return {
|
|
142
|
-
...v,
|
|
143
|
-
parents,
|
|
144
|
-
__indexPosition: ind
|
|
145
|
-
};
|
|
146
|
-
}),
|
|
147
|
-
values => ({ ...dim, values })
|
|
148
|
-
)(missingValues, refined);
|
|
149
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { dimensionValueDisplay } from '../../rules/src';
|
|
3
|
-
import { REJECTED_VALUE_IDS } from './constants';
|
|
4
|
-
|
|
5
|
-
const getRefinedMissinParentsLabels = R.pipe(
|
|
6
|
-
R.propOr([], 'missingParents'),
|
|
7
|
-
R.reduce((acc, par) => {
|
|
8
|
-
if (
|
|
9
|
-
!R.propOr(true, 'display', par) ||
|
|
10
|
-
R.includes(par.id, REJECTED_VALUE_IDS)
|
|
11
|
-
) {
|
|
12
|
-
return acc;
|
|
13
|
-
}
|
|
14
|
-
return R.append(dimensionValueDisplay('label')(par), acc);
|
|
15
|
-
}, []),
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
export const singleValueDisplay = (display, value) => {
|
|
19
|
-
if (display === 'label') {
|
|
20
|
-
return R.converge(
|
|
21
|
-
(missingParents, label) =>
|
|
22
|
-
R.isEmpty(missingParents)
|
|
23
|
-
? label
|
|
24
|
-
: R.join(' > ', R.append(label, missingParents)),
|
|
25
|
-
[getRefinedMissinParentsLabels, dimensionValueDisplay(display)],
|
|
26
|
-
)(value);
|
|
27
|
-
} else if (display === 'both') {
|
|
28
|
-
return `(${singleValueDisplay('code', value)}) ${singleValueDisplay(
|
|
29
|
-
'label',
|
|
30
|
-
value,
|
|
31
|
-
)}`;
|
|
32
|
-
}
|
|
33
|
-
return dimensionValueDisplay(display)(value);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const _combinedValuesDisplay = (_display) => (values) =>
|
|
37
|
-
R.pipe(
|
|
38
|
-
R.reduce((acc, val) => {
|
|
39
|
-
if (R.isNil(val)) return acc;
|
|
40
|
-
const isDisplayed = R.propOr(true, 'display', val);
|
|
41
|
-
const isRejected = R.includes(val.id, REJECTED_VALUE_IDS);
|
|
42
|
-
if ((!isDisplayed || isRejected) && _display === 'label') return acc;
|
|
43
|
-
return R.append(singleValueDisplay(_display, val), acc);
|
|
44
|
-
}, []),
|
|
45
|
-
(labels) => {
|
|
46
|
-
if (!R.isEmpty(labels) || _display !== 'label') {
|
|
47
|
-
return R.join(', ', labels);
|
|
48
|
-
}
|
|
49
|
-
const totalValue = R.find(R.propEq('id', '_T'), values);
|
|
50
|
-
if (!R.isNil(totalValue)) {
|
|
51
|
-
return dimensionValueDisplay('label')(totalValue);
|
|
52
|
-
}
|
|
53
|
-
if (R.isEmpty(values)) {
|
|
54
|
-
return '';
|
|
55
|
-
}
|
|
56
|
-
const firstValue = R.head(values);
|
|
57
|
-
return dimensionValueDisplay('label')(firstValue);
|
|
58
|
-
},
|
|
59
|
-
)(values);
|
|
60
|
-
|
|
61
|
-
export const combinedValuesDisplay = (display, values) => {
|
|
62
|
-
if (display === 'both') {
|
|
63
|
-
return R.converge(
|
|
64
|
-
(_ids, labels) => {
|
|
65
|
-
return dimensionValueDisplay('both')({
|
|
66
|
-
id: _ids,
|
|
67
|
-
name: labels,
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
[_combinedValuesDisplay('code'), _combinedValuesDisplay('label')],
|
|
71
|
-
)(values);
|
|
72
|
-
}
|
|
73
|
-
return _combinedValuesDisplay(display)(values);
|
|
74
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export const SDMX_3_0_JSON_DATA_FORMAT = 'application/vnd.sdmx.data+json;version=2.0';
|
|
2
|
-
export const SDMX_3_0_CSV_DATA_FORMAT = 'application/vnd.sdmx.data+csv;version=2.0';
|
|
3
|
-
export const EMPTY_ATTACHMENT_LEVEL_CHAR = '~';
|
|
4
|
-
export const REPORTING_YEAR_START_DAY = 'REPORTING_YEAR_START_DAY';
|
|
5
|
-
export const REPYEARSTART = 'REPYEARSTART';
|
|
6
|
-
export const REJECTED_VALUE_IDS = ['_L', '_T', '_Z'];
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
export const duplicateObs = (dims, observations) => {
|
|
4
|
-
const obsValues = R.values(observations);
|
|
5
|
-
if (R.length(dims) === 0) {
|
|
6
|
-
return observations;
|
|
7
|
-
}
|
|
8
|
-
const duplicated = R.reduce(
|
|
9
|
-
(obs, dim) => {
|
|
10
|
-
const groupedObs = R.groupBy(o => R.prop(dim.id, o.indexedDimValIds), obs);
|
|
11
|
-
const enhancedObs = R.addIndex(R.map)(
|
|
12
|
-
(value, index) => {
|
|
13
|
-
const matchingObs = R.propOr([], value.id, groupedObs);
|
|
14
|
-
|
|
15
|
-
return R.map(
|
|
16
|
-
obs => R.over(
|
|
17
|
-
R.lensProp('orderedDimIndexes'),
|
|
18
|
-
_indexes => {
|
|
19
|
-
const indexes = R.isNil(_indexes) ? R.map(i => Number(i), obs.dimValuesIndexes) : _indexes;
|
|
20
|
-
return R.set(R.lensIndex(dim.__index), index)(indexes);
|
|
21
|
-
}
|
|
22
|
-
)(obs),
|
|
23
|
-
matchingObs
|
|
24
|
-
);
|
|
25
|
-
},
|
|
26
|
-
dim.values
|
|
27
|
-
);
|
|
28
|
-
return R.unnest(enhancedObs);
|
|
29
|
-
},
|
|
30
|
-
obsValues,
|
|
31
|
-
dims
|
|
32
|
-
);
|
|
33
|
-
const res = R.indexBy(R.pipe(R.prop('orderedDimIndexes'), R.join(':')), duplicated);
|
|
34
|
-
return res;
|
|
35
|
-
};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { formatValue } from '../../rules/src/preparators/formatValue';
|
|
3
|
-
import { REJECTED_VALUE_IDS } from './constants';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
options = {
|
|
7
|
-
customAttributes: {
|
|
8
|
-
decimals: id,
|
|
9
|
-
prefscale: id,
|
|
10
|
-
},
|
|
11
|
-
}
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const parseAttributesValues = (obs, attributes, indexedDimensions) => {
|
|
15
|
-
const { attrValuesIndexes, dimValuesIndexes } = obs;
|
|
16
|
-
return R.addIndex(R.reduce)(
|
|
17
|
-
(acc, valueIndex, attrIndex) => {
|
|
18
|
-
const attribute = R.nth(attrIndex, attributes);
|
|
19
|
-
if (R.isNil(attribute) || !R.prop('series', attribute)) {
|
|
20
|
-
return acc;
|
|
21
|
-
}
|
|
22
|
-
const _value = R.nth(valueIndex, attribute.values || []);
|
|
23
|
-
let value = R.isNil(_value)
|
|
24
|
-
? _value
|
|
25
|
-
: R.over(R.lensProp('display'), (display=true) => display && !R.includes(_value.id, REJECTED_VALUE_IDS))(_value);
|
|
26
|
-
if ((!R.propOr(true, 'display', attribute) || !R.propOr(true, 'display', value))) {
|
|
27
|
-
value = null;
|
|
28
|
-
}
|
|
29
|
-
const relationship = R.propOr([], 'relationship', attribute);
|
|
30
|
-
let coordinates = {};
|
|
31
|
-
const serieKey = R.pipe(
|
|
32
|
-
dims => R.isEmpty(relationship) ? R.values(dims) : R.props(relationship, dims),
|
|
33
|
-
R.map(dim => {
|
|
34
|
-
const valueIndex = R.nth(dim.__index, dimValuesIndexes);
|
|
35
|
-
const valueId = R.path(['values', valueIndex, 'id'], dim);
|
|
36
|
-
coordinates = R.assoc(dim.id, valueId, coordinates);
|
|
37
|
-
return `${dim.id}=${valueId}`;
|
|
38
|
-
}),
|
|
39
|
-
R.ifElse(R.isEmpty, R.always(null), R.join(':'))
|
|
40
|
-
)(indexedDimensions);
|
|
41
|
-
|
|
42
|
-
return R.assoc(
|
|
43
|
-
attribute.id,
|
|
44
|
-
{ ...R.pick(['id', 'name', 'relationship', 'display', 'combined'], attribute), value, serieKey, coordinates, isObs: R.isEmpty(relationship) },
|
|
45
|
-
acc
|
|
46
|
-
);
|
|
47
|
-
},
|
|
48
|
-
{},
|
|
49
|
-
attrValuesIndexes
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const getFormatAttributesIndexes = (attributes, customAttributes) => R.addIndex(R.reduce)(
|
|
54
|
-
(acc, attribute, index) => {
|
|
55
|
-
if (R.equals(attribute.id, customAttributes.decimals)) {
|
|
56
|
-
return ({ ...acc, decimals: index });
|
|
57
|
-
}
|
|
58
|
-
if (R.equals(attribute.id, customAttributes.prefscale)) {
|
|
59
|
-
return ({ ...acc, prefscale: index });
|
|
60
|
-
}
|
|
61
|
-
return acc;
|
|
62
|
-
},
|
|
63
|
-
{ prefscale: null, decimals: null },
|
|
64
|
-
attributes
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
export const enhanceObservations = (dimensions = [], observations = {}, attributes = [], options = {}) => {
|
|
68
|
-
const formatAttributesIndexes = getFormatAttributesIndexes(attributes, R.propOr({}, 'customAttributes', options));
|
|
69
|
-
const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
|
|
70
|
-
|
|
71
|
-
return R.map(
|
|
72
|
-
(observation) => {
|
|
73
|
-
const { dimValuesIndexes } = observation;
|
|
74
|
-
|
|
75
|
-
const indexedDimValIds = R.addIndex(R.reduce)(
|
|
76
|
-
(acc, dimension, dimensionIndex) => {
|
|
77
|
-
const id = dimension.id;
|
|
78
|
-
const valueIndex = R.nth(dimensionIndex, dimValuesIndexes);
|
|
79
|
-
const valueId = R.path(['values', Number(valueIndex), 'id'], dimension);
|
|
80
|
-
return R.assoc(id, valueId, acc);
|
|
81
|
-
},
|
|
82
|
-
{},
|
|
83
|
-
dimensions
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
return ({
|
|
87
|
-
...observation,
|
|
88
|
-
attributes: parseAttributesValues(observation, attributes, indexedDimensions),
|
|
89
|
-
formattedValue: formatValue(observation, formatAttributesIndexes, attributes),
|
|
90
|
-
indexedDimValIds,
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
observations
|
|
94
|
-
);
|
|
95
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
const attribueValueDisplay = (display) => data => {
|
|
4
|
-
if (display === 'code') {
|
|
5
|
-
return R.prop('id', data);
|
|
6
|
-
}
|
|
7
|
-
if (display === 'both') {
|
|
8
|
-
return `${R.prop('id', data)}: ${R.prop('name', data)}`;
|
|
9
|
-
}
|
|
10
|
-
return R.prop('name', data);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const getAdvAttrSeriesAtCoordinates = (coordinates, advancedAttributes, display) => R.pipe(
|
|
14
|
-
R.filter(serie => {
|
|
15
|
-
const mergedCoord = R.mergeLeft(serie.coordinates, coordinates);
|
|
16
|
-
return R.equals(mergedCoord, coordinates);
|
|
17
|
-
}),
|
|
18
|
-
R.map(serie => {
|
|
19
|
-
return R.pipe(
|
|
20
|
-
R.propOr({}, 'attributes'),
|
|
21
|
-
R.values,
|
|
22
|
-
R.map(attribute => ({
|
|
23
|
-
id: attribute.id,
|
|
24
|
-
label: attribueValueDisplay(display)(attribute),
|
|
25
|
-
value: attribueValueDisplay(display)(attribute.value)
|
|
26
|
-
}))
|
|
27
|
-
)(serie);
|
|
28
|
-
}),
|
|
29
|
-
)(advancedAttributes);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
export const getAttributesSeries = observations => R.pipe(
|
|
4
|
-
R.values,
|
|
5
|
-
R.reduce(
|
|
6
|
-
(acc, { attributes }) => {
|
|
7
|
-
let res = acc.res;
|
|
8
|
-
let rejected = acc.rejected;
|
|
9
|
-
R.forEachObjIndexed(
|
|
10
|
-
(attribute) => {
|
|
11
|
-
if (!R.isNil(attribute.serieKey) && !attribute.isObs) {
|
|
12
|
-
if (R.isNil(attribute.value)) {
|
|
13
|
-
res = R.dissocPath([attribute.serieKey, attribute.id], res);
|
|
14
|
-
rejected = R.assocPath([attribute.serieKey, attribute.id], true, rejected);
|
|
15
|
-
}
|
|
16
|
-
if (R.path([attribute.serieKey, attribute.id], rejected)) {
|
|
17
|
-
return ;
|
|
18
|
-
}
|
|
19
|
-
const valueInRes = R.path([attribute.serieKey, attribute.id, 'value', 'id'], res);
|
|
20
|
-
if (!R.isNil(valueInRes) && valueInRes !== R.path(['value', 'id'], attribute)) {
|
|
21
|
-
res = R.dissocPath([attribute.serieKey, attribute.id], res);
|
|
22
|
-
rejected = R.assocPath([attribute.serieKey, attribute.id], true, rejected);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
res = R.assocPath([attribute.serieKey, attribute.id], attribute, res);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
attributes
|
|
30
|
-
);
|
|
31
|
-
return ({ res, rejected });
|
|
32
|
-
},
|
|
33
|
-
{ res: {}, rejected: {}, }
|
|
34
|
-
),
|
|
35
|
-
R.prop('res')
|
|
36
|
-
)(observations);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
const parseTexts = texts => R.reduce(
|
|
4
|
-
(acc, text) => {
|
|
5
|
-
const splitted = R.split(':', text);
|
|
6
|
-
if (R.length(splitted) !== 2) {
|
|
7
|
-
return acc;
|
|
8
|
-
}
|
|
9
|
-
const [id, name] = splitted;
|
|
10
|
-
return R.assoc(id, name, acc);
|
|
11
|
-
},
|
|
12
|
-
{},
|
|
13
|
-
texts
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
export const parseCombinationDefinition = (locale) => (title, texts) => R.useWith(
|
|
17
|
-
(titles, texts) =>
|
|
18
|
-
R.reduce((acc, title) => {
|
|
19
|
-
const split = R.split(':', title);
|
|
20
|
-
if (R.length(split) !== 2) {
|
|
21
|
-
return acc;
|
|
22
|
-
}
|
|
23
|
-
const [id, codes] = split;
|
|
24
|
-
if (R.isEmpty(codes)) {
|
|
25
|
-
return acc;
|
|
26
|
-
}
|
|
27
|
-
return R.append({
|
|
28
|
-
id,
|
|
29
|
-
concepts: R.split(',', codes),
|
|
30
|
-
name: R.hasPath([locale, id], texts)
|
|
31
|
-
? R.path([locale, id], texts)
|
|
32
|
-
: `[${id}]`,
|
|
33
|
-
}, acc);
|
|
34
|
-
}, [], titles),
|
|
35
|
-
[R.split(';'), R.map(R.pipe(R.split(';'), parseTexts))],
|
|
36
|
-
)(title, texts);
|
|
37
|
-
|
|
38
|
-
export const getCombinationDefinitions = (annotations, locale) => {
|
|
39
|
-
const annotation = R.find(annot => annot.type === 'COMBINED_CONCEPTS', annotations);
|
|
40
|
-
if (R.isNil(annotation)) {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
const title = R.propOr('', 'title', annotation);
|
|
44
|
-
const texts = R.propOr({}, 'texts', annotation);
|
|
45
|
-
|
|
46
|
-
return parseCombinationDefinition(locale)(title, texts);
|
|
47
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { REJECTED_VALUE_IDS } from './constants';
|
|
3
|
-
|
|
4
|
-
export const getDataflowAttributes = (attributes, combinations) => {
|
|
5
|
-
const combinationsConceptsIds = R.pipe(R.pluck('concepts'), R.unnest)(combinations);
|
|
6
|
-
return R.reduce(
|
|
7
|
-
(acc, attribute) => {
|
|
8
|
-
if (!R.prop('header', attribute) || !R.isEmpty(attribute.relationship)
|
|
9
|
-
|| R.includes(attribute.id, combinationsConceptsIds)) {
|
|
10
|
-
return acc;
|
|
11
|
-
}
|
|
12
|
-
const value = R.head(attribute.values);
|
|
13
|
-
if (!R.propOr(true, 'display', attribute) || R.isNil(value)
|
|
14
|
-
|| !R.propOr(true, 'display', value) || R.includes(R.prop('id', value), REJECTED_VALUE_IDS)) {
|
|
15
|
-
return acc;
|
|
16
|
-
}
|
|
17
|
-
return R.assoc(attribute.id, { ...R.pick(['id', 'name'], attribute), value }, acc);
|
|
18
|
-
},
|
|
19
|
-
{},
|
|
20
|
-
attributes,
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
export const getDataflowTooltipAttributesIds = (sdmxJson, defaults = {}) => {
|
|
4
|
-
const dataflowAnnotationsIndexes = R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson);
|
|
5
|
-
const dataflowAnnotations = R.props(dataflowAnnotationsIndexes, R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson));
|
|
6
|
-
|
|
7
|
-
const flagsAttrAnnotation = R.find(R.propEq('type', 'LAYOUT_FLAG'), dataflowAnnotations);
|
|
8
|
-
const footnotesAttrAnnotation = R.find(R.propEq('type', 'LAYOUT_NOTE'), dataflowAnnotations);
|
|
9
|
-
|
|
10
|
-
const customFlags = R.pipe(
|
|
11
|
-
R.propOr('', 'title'),
|
|
12
|
-
title => R.isNil(title) || R.isEmpty(title) ? [] : R.split(',', title)
|
|
13
|
-
)(flagsAttrAnnotation || {});
|
|
14
|
-
|
|
15
|
-
const customNotes = R.pipe(
|
|
16
|
-
R.propOr('', 'title'),
|
|
17
|
-
title => R.isNil(title) || R.isEmpty(title) ? [] : R.split(',', title),
|
|
18
|
-
notes => R.difference(notes, customFlags)
|
|
19
|
-
)(footnotesAttrAnnotation || {});
|
|
20
|
-
|
|
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 });
|
|
30
|
-
};
|
|
31
|
-
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
export const getDimensionValuesIndexes = (values) => R.addIndex(R.reduce)(
|
|
4
|
-
(acc, value, position) => {
|
|
5
|
-
const sdmxIndex = value.__index;
|
|
6
|
-
return R.over(
|
|
7
|
-
R.lensProp(String(sdmxIndex)),
|
|
8
|
-
R.ifElse(R.isNil, R.always([position]), R.append(position))
|
|
9
|
-
)(acc);
|
|
10
|
-
},
|
|
11
|
-
{},
|
|
12
|
-
values
|
|
13
|
-
);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
|
|
3
|
-
export const getHCodelistsRefs = annotations => R.reduce(
|
|
4
|
-
(acc, annotation) => {
|
|
5
|
-
if (annotation.type !== 'HIER_CONTEXT') {
|
|
6
|
-
return acc;
|
|
7
|
-
}
|
|
8
|
-
const references = annotation.text || annotation.title || '';
|
|
9
|
-
const refs = R.pipe(
|
|
10
|
-
R.split(','),
|
|
11
|
-
R.reduce(
|
|
12
|
-
(acc2, ref) => {
|
|
13
|
-
const match = ref.match(/([\w@_.]+):([\w@_.]+):([\w@_.]+)\(([\d.]+)\).([\w@_.]+)$/);
|
|
14
|
-
if (R.isNil(match)) {
|
|
15
|
-
return acc2;
|
|
16
|
-
}
|
|
17
|
-
const [codelistId, agencyId, code, version, hierarchy] = R.tail(match);
|
|
18
|
-
return R.assoc(codelistId, { agencyId, code, version, hierarchy, codelistId }, acc2);
|
|
19
|
-
},
|
|
20
|
-
{}
|
|
21
|
-
)
|
|
22
|
-
)(references);
|
|
23
|
-
return R.mergeRight(acc, refs);
|
|
24
|
-
},
|
|
25
|
-
{},
|
|
26
|
-
annotations,
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
export const getHCodelistsRefsInData = sdmxJson => {
|
|
30
|
-
const annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
|
|
31
|
-
return getHCodelistsRefs(annotations);
|
|
32
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { dimensionValueDisplay } from '../../rules/src';
|
|
3
|
-
import { combinedValuesDisplay } from './combinedValuesDisplay';
|
|
4
|
-
import { REJECTED_VALUE_IDS } from './constants';
|
|
5
|
-
|
|
6
|
-
export const getHeaderCombinations = (combinations, dimensions, attributes, display) => {
|
|
7
|
-
const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
|
|
8
|
-
const indexedAttributes = R.indexBy(R.prop('id'), attributes);
|
|
9
|
-
return R.reduce(
|
|
10
|
-
(acc, comb) => {
|
|
11
|
-
if (!R.prop('header', comb) || !R.propOr(true, 'display', comb)) {
|
|
12
|
-
return acc;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const header = `${dimensionValueDisplay(display)(comb)}:`;
|
|
16
|
-
|
|
17
|
-
const label = R.pipe(
|
|
18
|
-
R.reduce(
|
|
19
|
-
(_acc, concept) => {
|
|
20
|
-
const artefact = R.has(concept, indexedDimensions)
|
|
21
|
-
? R.prop(concept, indexedDimensions)
|
|
22
|
-
: R.prop(concept, indexedAttributes);
|
|
23
|
-
if (R.isNil(artefact)) {
|
|
24
|
-
return _acc;
|
|
25
|
-
}
|
|
26
|
-
const value = R.path(['values', 0], artefact);
|
|
27
|
-
if (R.isNil(value)) {
|
|
28
|
-
return _acc;
|
|
29
|
-
}
|
|
30
|
-
if (R.has(concept, indexedAttributes) && (!R.propOr(true, 'display', value)
|
|
31
|
-
|| !R.propOr(true, 'artefact', value) || R.includes(value.id, REJECTED_VALUE_IDS))) {
|
|
32
|
-
return _acc;
|
|
33
|
-
}
|
|
34
|
-
return R.append(value, _acc);
|
|
35
|
-
},
|
|
36
|
-
[]
|
|
37
|
-
),
|
|
38
|
-
values => combinedValuesDisplay(display, values)
|
|
39
|
-
)(comb.concepts || []);
|
|
40
|
-
if (R.isEmpty(label)) {
|
|
41
|
-
return acc;
|
|
42
|
-
}
|
|
43
|
-
return R.append({ header, label }, acc);
|
|
44
|
-
},
|
|
45
|
-
[],
|
|
46
|
-
combinations,
|
|
47
|
-
);
|
|
48
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as R from 'ramda';
|
|
2
|
-
import { getFlagsAndNotes } from './table/getFlagsAndNotes';
|
|
3
|
-
import { dimensionValueDisplay } from '../../rules/src/';
|
|
4
|
-
|
|
5
|
-
export const getHeaderSubtitle = (dimensions, combinations, customAttributes, display, microdataDimension) => {
|
|
6
|
-
const combinationsConepts = R.pipe(R.pluck('concepts'), R.unnest)(combinations);
|
|
7
|
-
const DEFAULT_REJECTED_SUBTITLE_IDS = ['_L', '_T', '_Z'];
|
|
8
|
-
|
|
9
|
-
return R.reduce(
|
|
10
|
-
(acc, dim) => {
|
|
11
|
-
if (!R.propOr(true, 'display', dim) || R.propEq('id', microdataDimension, dim)
|
|
12
|
-
|| R.includes(dim.id, combinationsConepts)) {
|
|
13
|
-
return acc;
|
|
14
|
-
}
|
|
15
|
-
const value = R.path(['values', 0], dim);
|
|
16
|
-
if (!R.propOr(true, 'display', value) || R.includes(value.id, DEFAULT_REJECTED_SUBTITLE_IDS)) {
|
|
17
|
-
return acc;
|
|
18
|
-
}
|
|
19
|
-
const header = `${dimensionValueDisplay(display)(dim)}:`;
|
|
20
|
-
const label = dimensionValueDisplay(display)(value);
|
|
21
|
-
const flags = R.pipe(
|
|
22
|
-
getFlagsAndNotes,
|
|
23
|
-
R.map(entry => ({
|
|
24
|
-
code: entry.code,
|
|
25
|
-
header: `${dimensionValueDisplay(display)(entry)}:`,
|
|
26
|
-
label: dimensionValueDisplay(display)(entry.value),
|
|
27
|
-
})),
|
|
28
|
-
)(dim.attrValues, customAttributes);
|
|
29
|
-
return R.append({ header, label, flags }, acc);
|
|
30
|
-
},
|
|
31
|
-
[],
|
|
32
|
-
dimensions,
|
|
33
|
-
);
|
|
34
|
-
};
|