@sis-cc/dotstatsuite-components 12.0.0 → 12.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/lib/rules/src/table/factories/getLayoutWithFlags.js +16 -7
- package/lib/rules/src/table/factories/getTableData.js +1 -1
- package/lib/rules2/src/refineMetadataCoordinates.js +4 -4
- package/package.json +1 -1
- package/src/rules/src/table/factories/getLayoutWithFlags.js +19 -8
- package/src/rules/src/table/factories/getTableData.js +1 -1
- package/src/rules2/src/refineMetadataCoordinates.js +4 -4
- package/test/getLayoutDataWithFlags.test.js +2 -2
|
@@ -25,7 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
|
|
26
26
|
var getLayoutSerieAttributes = exports.getLayoutSerieAttributes = function getLayoutSerieAttributes(layoutSerie, seriesAttributes) {
|
|
27
27
|
var length = R.length(layoutSerie);
|
|
28
|
-
if (length === 0
|
|
28
|
+
if (length === 0) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -89,18 +89,27 @@ var getCoordinates = function getCoordinates(data, unitsId) {
|
|
|
89
89
|
var getLayoutDataWithFlags = exports.getLayoutDataWithFlags = function getLayoutDataWithFlags(seriesAttributes, display, customAttributes, metadataCoordinates, unitsId) {
|
|
90
90
|
var regularAttrsIds = R.concat(customAttributes.flags || [], customAttributes.footnotes || []);
|
|
91
91
|
var formatSublayout = function formatSublayout(getAttributes) {
|
|
92
|
-
var
|
|
92
|
+
var mCoordinates = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
93
|
+
var supplData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
93
94
|
return function (data) {
|
|
94
95
|
var attributes = getAttributes(data);
|
|
95
96
|
var key = getSerieKey(data);
|
|
96
97
|
var cells = getSublayoutDataCells(display, customAttributes)(data);
|
|
97
98
|
var flags = getFlagsFromSeriesAttributes(display, customAttributes)(attributes);
|
|
98
99
|
var coordinates = getCoordinates(R.concat(supplData, data), unitsId);
|
|
99
|
-
var hasMetadata = (0, _hasCellMetadata.hasCellMetadata)(
|
|
100
|
+
var hasMetadata = (0, _hasCellMetadata.hasCellMetadata)(mCoordinates, coordinates);
|
|
101
|
+
var dataAdvancedAttrs = R.reduce(function (acc, _ref) {
|
|
102
|
+
var dimension = _ref.dimension,
|
|
103
|
+
value = _ref.value;
|
|
104
|
+
|
|
105
|
+
var attrs = (0, _extends3.default)({}, dimension.attributes || {}, value.attributes || {});
|
|
106
|
+
var advAttrs = R.omit(regularAttrsIds, attrs);
|
|
107
|
+
return (0, _extends3.default)({}, acc, advAttrs);
|
|
108
|
+
}, {}, data);
|
|
100
109
|
var advancedAttributesSeries = R.isNil(attributes) ? {} : R.filter(function (serie) {
|
|
101
110
|
return !R.isEmpty(R.omit(regularAttrsIds, R.propOr({}, 'attributes', serie)));
|
|
102
111
|
}, attributes);
|
|
103
|
-
var hasAdvancedAttributes = !R.isEmpty(advancedAttributesSeries);
|
|
112
|
+
var hasAdvancedAttributes = !R.isEmpty(advancedAttributesSeries) || !R.isEmpty(dataAdvancedAttrs);
|
|
104
113
|
var sideProps = hasMetadata || hasAdvancedAttributes ? { hasAdvancedAttributes: hasAdvancedAttributes, hasMetadata: hasMetadata, coordinates: coordinates } : null;
|
|
105
114
|
|
|
106
115
|
return { data: cells, key: key, flags: flags, sideProps: sideProps };
|
|
@@ -110,15 +119,15 @@ var getLayoutDataWithFlags = exports.getLayoutDataWithFlags = function getLayout
|
|
|
110
119
|
return R.evolve({
|
|
111
120
|
headerData: R.map(formatSublayout(function (data) {
|
|
112
121
|
return getLayoutSerieAttributes(data, seriesAttributes);
|
|
113
|
-
})),
|
|
122
|
+
}, metadataCoordinates.header)),
|
|
114
123
|
sectionsData: R.map(function (sectionData) {
|
|
115
124
|
var sectionSerie = R.head(sectionData);
|
|
116
125
|
var sectionAttributes = getLayoutSerieAttributes(sectionSerie, seriesAttributes);
|
|
117
126
|
return [formatSublayout(function () {
|
|
118
127
|
return sectionAttributes;
|
|
119
|
-
})(sectionSerie), R.map(formatSublayout(function (rowData) {
|
|
128
|
+
}, metadataCoordinates.sections)(sectionSerie), R.map(formatSublayout(function (rowData) {
|
|
120
129
|
return getLayoutSerieAttributes(R.concat(sectionSerie, rowData), R.omit(R.keys(sectionAttributes), seriesAttributes));
|
|
121
|
-
}, sectionSerie))(R.last(sectionData))];
|
|
130
|
+
}, metadataCoordinates.rows, sectionSerie))(R.last(sectionData))];
|
|
122
131
|
})
|
|
123
132
|
});
|
|
124
133
|
};
|
|
@@ -96,7 +96,7 @@ var getTableProps = exports.getTableProps = function getTableProps(_ref) {
|
|
|
96
96
|
display: display, unitDimension: unitDimension, unitsDisplay: unitsLevelDisplay, unitsSeries: unitsSeries,
|
|
97
97
|
unitsDefinitionCodes: unitsDefinitionCodes, unitsIndexes: unitsAttachmentIndexesInLayout,
|
|
98
98
|
partialUnitSerieIndexes: partialUnitSerieIndexes, rejectedValueIds: rejectedValueIds, layoutIds: layoutIds
|
|
99
|
-
}), (0, _getLayoutWithFlags.getLayoutDataWithFlags)(seriesAttributesValues, display, customAttributes, refinedMetadataCoordinates
|
|
99
|
+
}), (0, _getLayoutWithFlags.getLayoutDataWithFlags)(seriesAttributesValues, display, customAttributes, refinedMetadataCoordinates, unitDimension.id), (0, _cleanUnitsInLayoutData.cleanUnitsInLayoutData)({ unitsDisplay: unitsLevelDisplay, unitsLayoutIndexes: unitsIndexesInLayout }))(layout, R.propOr({}, 'observations', data));
|
|
100
100
|
|
|
101
101
|
return (0, _extends3.default)({
|
|
102
102
|
cells: (0, _getCuratedCells.getCuratedCells)({ layout: layout, observations: cells, shape: ['header', 'sections', 'rows'] }),
|
|
@@ -19,16 +19,16 @@ var refineMetadataCoordinates = exports.refineMetadataCoordinates = function ref
|
|
|
19
19
|
}
|
|
20
20
|
var removedHeaderCodes = R.omit(layoutIds.header, refinedCoord);
|
|
21
21
|
if (R.isEmpty(removedHeaderCodes)) {
|
|
22
|
-
return R.over(R.lensProp('
|
|
22
|
+
return R.over(R.lensProp('header'), R.append(refinedCoord))(acc);
|
|
23
23
|
}
|
|
24
24
|
var removedSectionCodes = R.omit(layoutIds.sections, refinedCoord);
|
|
25
25
|
if (R.isEmpty(removedSectionCodes)) {
|
|
26
|
-
return R.over(R.lensProp('
|
|
26
|
+
return R.over(R.lensProp('sections'), R.append(refinedCoord))(acc);
|
|
27
27
|
}
|
|
28
28
|
var removedRowsCodes = R.omit(layoutIds.rows, removedSectionCodes);
|
|
29
29
|
if (R.isEmpty(removedRowsCodes)) {
|
|
30
|
-
return R.over(R.lensProp('
|
|
30
|
+
return R.over(R.lensProp('rows'), R.append(refinedCoord))(acc);
|
|
31
31
|
}
|
|
32
32
|
return R.over(R.lensProp('cells'), R.append(refinedCoord))(acc);
|
|
33
|
-
}, { cells: [],
|
|
33
|
+
}, { cells: [], header: [], sections: [], rows: [] }, metadataCoordinates);
|
|
34
34
|
};
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { hasCellMetadata } from '../../../../rules2/src/hasCellMetadata';
|
|
|
5
5
|
|
|
6
6
|
export const getLayoutSerieAttributes = (layoutSerie, seriesAttributes) => {
|
|
7
7
|
const length = R.length(layoutSerie);
|
|
8
|
-
if (length === 0
|
|
8
|
+
if (length === 0) {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -88,36 +88,47 @@ const getCoordinates = (data, unitsId) => R.reduce(
|
|
|
88
88
|
|
|
89
89
|
export const getLayoutDataWithFlags = (seriesAttributes, display, customAttributes, metadataCoordinates, unitsId) => {
|
|
90
90
|
const regularAttrsIds = R.concat(customAttributes.flags || [], customAttributes.footnotes || []);
|
|
91
|
-
const formatSublayout = (getAttributes, supplData = []) => data => {
|
|
91
|
+
const formatSublayout = (getAttributes, mCoordinates = [], supplData = []) => data => {
|
|
92
92
|
const attributes = getAttributes(data);
|
|
93
93
|
const key = getSerieKey(data);
|
|
94
94
|
const cells = getSublayoutDataCells(display, customAttributes)(data);
|
|
95
95
|
const flags = getFlagsFromSeriesAttributes(display, customAttributes)(attributes);
|
|
96
96
|
const coordinates = getCoordinates(R.concat(supplData, data), unitsId);
|
|
97
|
-
const hasMetadata = hasCellMetadata(
|
|
97
|
+
const hasMetadata = hasCellMetadata(mCoordinates, coordinates);
|
|
98
|
+
const dataAdvancedAttrs = R.reduce(
|
|
99
|
+
(acc, { dimension, value }) => {
|
|
100
|
+
const attrs = { ...dimension.attributes || {}, ...value.attributes || {}};
|
|
101
|
+
const advAttrs = R.omit(regularAttrsIds, attrs);
|
|
102
|
+
return ({ ...acc, ...advAttrs })
|
|
103
|
+
},
|
|
104
|
+
{},
|
|
105
|
+
data
|
|
106
|
+
);
|
|
98
107
|
const advancedAttributesSeries = R.isNil(attributes)
|
|
99
108
|
? {}
|
|
100
109
|
: R.filter(
|
|
101
110
|
serie => !R.isEmpty(R.omit(regularAttrsIds, R.propOr({}, 'attributes', serie))),
|
|
102
111
|
attributes
|
|
103
112
|
);
|
|
104
|
-
const hasAdvancedAttributes = !R.isEmpty(advancedAttributesSeries);
|
|
113
|
+
const hasAdvancedAttributes = !R.isEmpty(advancedAttributesSeries) || !R.isEmpty(dataAdvancedAttrs);
|
|
105
114
|
const sideProps = hasMetadata || hasAdvancedAttributes ? { hasAdvancedAttributes, hasMetadata, coordinates } : null;
|
|
106
115
|
|
|
107
116
|
return ({ data: cells, key, flags, sideProps });
|
|
108
117
|
};
|
|
109
118
|
|
|
110
119
|
return R.evolve({
|
|
111
|
-
headerData: R.map(formatSublayout(data => getLayoutSerieAttributes(data, seriesAttributes))),
|
|
120
|
+
headerData: R.map(formatSublayout(data => getLayoutSerieAttributes(data, seriesAttributes), metadataCoordinates.header)),
|
|
112
121
|
sectionsData: R.map(
|
|
113
122
|
sectionData => {
|
|
114
123
|
const sectionSerie = R.head(sectionData);
|
|
115
124
|
const sectionAttributes = getLayoutSerieAttributes(sectionSerie, seriesAttributes);
|
|
116
125
|
return ([
|
|
117
|
-
formatSublayout(() => sectionAttributes)(sectionSerie),
|
|
126
|
+
formatSublayout(() => sectionAttributes, metadataCoordinates.sections)(sectionSerie),
|
|
118
127
|
R.map(
|
|
119
|
-
formatSublayout(
|
|
120
|
-
|
|
128
|
+
formatSublayout(
|
|
129
|
+
rowData => getLayoutSerieAttributes(R.concat(sectionSerie, rowData), R.omit(R.keys(sectionAttributes), seriesAttributes)),
|
|
130
|
+
metadataCoordinates.rows,
|
|
131
|
+
sectionSerie)
|
|
121
132
|
)(R.last(sectionData))
|
|
122
133
|
]);
|
|
123
134
|
}
|
|
@@ -97,7 +97,7 @@ export const getTableProps = ({ data, layoutIds, display, customAttributes, limi
|
|
|
97
97
|
unitsDefinitionCodes, unitsIndexes: unitsAttachmentIndexesInLayout,
|
|
98
98
|
partialUnitSerieIndexes, rejectedValueIds, layoutIds
|
|
99
99
|
}),
|
|
100
|
-
getLayoutDataWithFlags(seriesAttributesValues, display, customAttributes, refinedMetadataCoordinates
|
|
100
|
+
getLayoutDataWithFlags(seriesAttributesValues, display, customAttributes, refinedMetadataCoordinates, unitDimension.id),
|
|
101
101
|
cleanUnitsInLayoutData({ unitsDisplay: unitsLevelDisplay, unitsLayoutIndexes: unitsIndexesInLayout }),
|
|
102
102
|
)(layout, R.propOr({}, 'observations', data));
|
|
103
103
|
|
|
@@ -9,19 +9,19 @@ export const refineMetadataCoordinates = (metadataCoordinates, layoutIds, header
|
|
|
9
9
|
}
|
|
10
10
|
const removedHeaderCodes = R.omit(layoutIds.header, refinedCoord);
|
|
11
11
|
if (R.isEmpty(removedHeaderCodes)) {
|
|
12
|
-
return R.over(R.lensProp('
|
|
12
|
+
return R.over(R.lensProp('header'), R.append(refinedCoord))(acc);
|
|
13
13
|
}
|
|
14
14
|
const removedSectionCodes = R.omit(layoutIds.sections, refinedCoord);
|
|
15
15
|
if (R.isEmpty(removedSectionCodes)) {
|
|
16
|
-
return R.over(R.lensProp('
|
|
16
|
+
return R.over(R.lensProp('sections'), R.append(refinedCoord))(acc);
|
|
17
17
|
}
|
|
18
18
|
const removedRowsCodes = R.omit(layoutIds.rows, removedSectionCodes);
|
|
19
19
|
if (R.isEmpty(removedRowsCodes)) {
|
|
20
|
-
return R.over(R.lensProp('
|
|
20
|
+
return R.over(R.lensProp('rows'), R.append(refinedCoord))(acc);
|
|
21
21
|
}
|
|
22
22
|
return R.over(R.lensProp('cells'), R.append(refinedCoord))(acc);
|
|
23
23
|
},
|
|
24
|
-
{ cells: [],
|
|
24
|
+
{ cells: [], header: [], sections: [], rows: [] },
|
|
25
25
|
metadataCoordinates
|
|
26
26
|
);
|
|
27
27
|
};
|
|
@@ -134,9 +134,9 @@ const expected = {
|
|
|
134
134
|
|
|
135
135
|
describe('getLayoutDataWithFlags test', () => {
|
|
136
136
|
it('empty', () => {
|
|
137
|
-
expect(getLayoutDataWithFlags({}, 'label', {})({ headerData: [], sectionsData: [] })).to.deep.equal({ headerData: [], sectionsData: [] });
|
|
137
|
+
expect(getLayoutDataWithFlags({}, 'label', {}, {}, [])({ headerData: [], sectionsData: [] })).to.deep.equal({ headerData: [], sectionsData: [] });
|
|
138
138
|
});
|
|
139
139
|
it('multi cases', () => {
|
|
140
|
-
expect(getLayoutDataWithFlags(attributesValues, 'code', customAttributes,
|
|
140
|
+
expect(getLayoutDataWithFlags(attributesValues, 'code', customAttributes, {}, [])(layoutData)).to.deep.equal(expected);
|
|
141
141
|
});
|
|
142
142
|
});
|