@bento-core/facet-filter 1.0.1-ccdihub.22 → 1.0.1-ccdihub.24
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/FacetFilterController.js +30 -5
- package/dist/components/facet/FacetView.js +8 -8
- package/dist/components/facet/ReduxFacetView.js +7 -9
- package/dist/components/inputs/checkbox/ReduxCheckbox.js +1 -4
- package/package.json +1 -1
- package/src/FacetFilterController.js +31 -6
- package/src/components/facet/FacetView.js +7 -9
- package/src/components/facet/ReduxFacetView.js +5 -6
- package/src/components/inputs/checkbox/ReduxCheckbox.js +1 -5
|
@@ -26,11 +26,20 @@ const FacetFilterController = props => {
|
|
|
26
26
|
* 2. subject state
|
|
27
27
|
*/
|
|
28
28
|
const {
|
|
29
|
-
|
|
29
|
+
activeFilters,
|
|
30
30
|
data,
|
|
31
31
|
facetsConfig,
|
|
32
32
|
facetSectionConfig
|
|
33
33
|
} = props;
|
|
34
|
+
const filterState = {};
|
|
35
|
+
for (const [key, value] of Object.entries(activeFilters)) {
|
|
36
|
+
if (key !== 'participant_ids') {
|
|
37
|
+
filterState[key] = {};
|
|
38
|
+
value.forEach(item => {
|
|
39
|
+
filterState[key][item] = true;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
34
43
|
const updateFacetState = filterSections => {
|
|
35
44
|
const updateSections = [...filterSections];
|
|
36
45
|
if (!_lodash.default.isEmpty(filterState)) {
|
|
@@ -112,11 +121,30 @@ const FacetFilterController = props => {
|
|
|
112
121
|
} = updateFacet;
|
|
113
122
|
if (data[apiForFiltering]) {
|
|
114
123
|
if (Array.isArray(data[apiForFiltering])) {
|
|
124
|
+
const validValues = [];
|
|
115
125
|
const updateField = data[apiForFiltering].map(item => {
|
|
116
126
|
const addField = _objectSpread({}, item);
|
|
117
127
|
addField.name = item[field];
|
|
128
|
+
validValues.push(addField.name);
|
|
118
129
|
return addField;
|
|
119
130
|
});
|
|
131
|
+
/**
|
|
132
|
+
* Check if there are orphen filter values and add them to the facet values
|
|
133
|
+
*/
|
|
134
|
+
if (filterState !== undefined) {
|
|
135
|
+
const facetFilter = filterState[facet.datafield];
|
|
136
|
+
if (facetFilter) {
|
|
137
|
+
for (const [key, value] of Object.entries(facetFilter)) {
|
|
138
|
+
if (validValues.indexOf(key) === -1) {
|
|
139
|
+
const tmp = {};
|
|
140
|
+
tmp.group = key;
|
|
141
|
+
tmp.name = key;
|
|
142
|
+
tmp.subjects = 0;
|
|
143
|
+
updateField.push(tmp);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
120
148
|
updateFacet.facetValues = updateField;
|
|
121
149
|
}
|
|
122
150
|
/**
|
|
@@ -150,8 +178,5 @@ const FacetFilterController = props => {
|
|
|
150
178
|
sideBarSections: facetSections
|
|
151
179
|
})));
|
|
152
180
|
};
|
|
153
|
-
|
|
154
|
-
filterState: state.statusReducer.filterState
|
|
155
|
-
});
|
|
156
|
-
var _default = (0, _reactRedux.connect)(mapStateToProps, null)(FacetFilterController);
|
|
181
|
+
var _default = (0, _reactRedux.connect)(null, null)(FacetFilterController);
|
|
157
182
|
exports.default = _default;
|
|
@@ -27,9 +27,7 @@ const FacetView = _ref => {
|
|
|
27
27
|
facet,
|
|
28
28
|
onClearFacetSection,
|
|
29
29
|
onClearSliderSection,
|
|
30
|
-
CustomView
|
|
31
|
-
autoComplete,
|
|
32
|
-
upload
|
|
30
|
+
CustomView
|
|
33
31
|
} = _ref;
|
|
34
32
|
const [expand, setExpand] = (0, _react.useState)(false);
|
|
35
33
|
const onExpandFacet = () => setExpand(!expand);
|
|
@@ -37,11 +35,13 @@ const FacetView = _ref => {
|
|
|
37
35
|
/**
|
|
38
36
|
* expand section incase of active local search
|
|
39
37
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
38
|
+
// useEffect(() => {
|
|
39
|
+
// if ((autoComplete && autoComplete.length > 0)
|
|
40
|
+
// || (upload && upload.length > 0)) {
|
|
41
|
+
// setExpand(true);
|
|
42
|
+
// }
|
|
43
|
+
// }, [autoComplete, upload]);
|
|
44
|
+
|
|
45
45
|
const [sortBy, setSortBy] = (0, _react.useState)(null);
|
|
46
46
|
const onSortFacet = type => {
|
|
47
47
|
setSortBy(type);
|
|
@@ -10,14 +10,12 @@ var _Actions = require("../../store/actions/Actions");
|
|
|
10
10
|
var _FacetView = _interopRequireDefault(require("./FacetView"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
const ReduxFacetView = props => /*#__PURE__*/_react.default.createElement(_FacetView.default, props);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
};
|
|
13
|
+
|
|
14
|
+
// const mapStateToProps = (state) => ({
|
|
15
|
+
// autoComplete: state?.localFind?.autocomplete || [],
|
|
16
|
+
// upload: state?.localFind?.upload || [],
|
|
17
|
+
// });
|
|
18
|
+
|
|
21
19
|
const mapDispatchToProps = dispatch => ({
|
|
22
20
|
onClearFacetSection: facet => {
|
|
23
21
|
dispatch((0, _Actions.clearFacetSection)(facet));
|
|
@@ -26,5 +24,5 @@ const mapDispatchToProps = dispatch => ({
|
|
|
26
24
|
dispatch((0, _Actions.clearSliderSection)(facet));
|
|
27
25
|
}
|
|
28
26
|
});
|
|
29
|
-
var _default = (0, _reactRedux.connect)(
|
|
27
|
+
var _default = (0, _reactRedux.connect)(null, mapDispatchToProps)(ReduxFacetView);
|
|
30
28
|
exports.default = _default;
|
|
@@ -10,11 +10,8 @@ var _Actions = require("../../../store/actions/Actions");
|
|
|
10
10
|
var _CheckboxView = _interopRequireDefault(require("./CheckboxView"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
const ReduxCheckbox = props => /*#__PURE__*/_react.default.createElement(_CheckboxView.default, props);
|
|
13
|
-
const mapStateToProps = state => ({
|
|
14
|
-
filterState: state.statusReducer.filterState
|
|
15
|
-
});
|
|
16
13
|
const mapDispatchToProps = dispatch => ({
|
|
17
14
|
onToggle: view => dispatch((0, _Actions.toggleCheckBox)(view))
|
|
18
15
|
});
|
|
19
|
-
var _default = (0, _reactRedux.connect)(
|
|
16
|
+
var _default = (0, _reactRedux.connect)(null, mapDispatchToProps)(ReduxCheckbox);
|
|
20
17
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -21,12 +21,22 @@ const FacetFilterController = (props) => {
|
|
|
21
21
|
* 2. subject state
|
|
22
22
|
*/
|
|
23
23
|
const {
|
|
24
|
-
|
|
24
|
+
activeFilters,
|
|
25
25
|
data,
|
|
26
26
|
facetsConfig,
|
|
27
27
|
facetSectionConfig,
|
|
28
28
|
} = props;
|
|
29
29
|
|
|
30
|
+
const filterState = {};
|
|
31
|
+
for (const [key, value] of Object.entries(activeFilters)) {
|
|
32
|
+
if (key !== 'participant_ids') {
|
|
33
|
+
filterState[key] = {};
|
|
34
|
+
value.forEach((item) => {
|
|
35
|
+
filterState[key][item] = true;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
const updateFacetState = (filterSections) => {
|
|
31
41
|
const updateSections = [...filterSections];
|
|
32
42
|
if (!_.isEmpty(filterState)) {
|
|
@@ -97,11 +107,30 @@ const FacetFilterController = (props) => {
|
|
|
97
107
|
} = updateFacet;
|
|
98
108
|
if (data[apiForFiltering]) {
|
|
99
109
|
if (Array.isArray(data[apiForFiltering])) {
|
|
110
|
+
const validValues = [];
|
|
100
111
|
const updateField = data[apiForFiltering].map((item) => {
|
|
101
112
|
const addField = { ...item };
|
|
102
113
|
addField.name = item[field];
|
|
114
|
+
validValues.push(addField.name);
|
|
103
115
|
return addField;
|
|
104
116
|
});
|
|
117
|
+
/**
|
|
118
|
+
* Check if there are orphen filter values and add them to the facet values
|
|
119
|
+
*/
|
|
120
|
+
if (filterState !== undefined) {
|
|
121
|
+
const facetFilter = filterState[facet.datafield];
|
|
122
|
+
if (facetFilter) {
|
|
123
|
+
for (const [key, value] of Object.entries(facetFilter)) {
|
|
124
|
+
if (validValues.indexOf(key) === -1) {
|
|
125
|
+
const tmp = {};
|
|
126
|
+
tmp.group = key;
|
|
127
|
+
tmp.name = key;
|
|
128
|
+
tmp.subjects = 0;
|
|
129
|
+
updateField.push(tmp);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
105
134
|
updateFacet.facetValues = updateField;
|
|
106
135
|
}
|
|
107
136
|
/**
|
|
@@ -142,8 +171,4 @@ const FacetFilterController = (props) => {
|
|
|
142
171
|
);
|
|
143
172
|
};
|
|
144
173
|
|
|
145
|
-
|
|
146
|
-
filterState: state.statusReducer.filterState,
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
export default connect(mapStateToProps, null)(FacetFilterController);
|
|
174
|
+
export default connect(null, null)(FacetFilterController);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Accordion,
|
|
4
4
|
List,
|
|
@@ -19,8 +19,6 @@ const FacetView = ({
|
|
|
19
19
|
onClearFacetSection,
|
|
20
20
|
onClearSliderSection,
|
|
21
21
|
CustomView,
|
|
22
|
-
autoComplete,
|
|
23
|
-
upload,
|
|
24
22
|
}) => {
|
|
25
23
|
const [expand, setExpand] = useState(false);
|
|
26
24
|
const onExpandFacet = () => setExpand(!expand);
|
|
@@ -28,12 +26,12 @@ const FacetView = ({
|
|
|
28
26
|
/**
|
|
29
27
|
* expand section incase of active local search
|
|
30
28
|
*/
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, [autoComplete, upload]);
|
|
29
|
+
// useEffect(() => {
|
|
30
|
+
// if ((autoComplete && autoComplete.length > 0)
|
|
31
|
+
// || (upload && upload.length > 0)) {
|
|
32
|
+
// setExpand(true);
|
|
33
|
+
// }
|
|
34
|
+
// }, [autoComplete, upload]);
|
|
37
35
|
|
|
38
36
|
const [sortBy, setSortBy] = useState(null);
|
|
39
37
|
const onSortFacet = (type) => {
|
|
@@ -5,15 +5,14 @@ import FacetView from './FacetView';
|
|
|
5
5
|
|
|
6
6
|
const ReduxFacetView = ((props) => <FacetView {...props} />);
|
|
7
7
|
|
|
8
|
-
const mapStateToProps = (state) => ({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
8
|
+
// const mapStateToProps = (state) => ({
|
|
9
|
+
// autoComplete: state?.localFind?.autocomplete || [],
|
|
10
|
+
// upload: state?.localFind?.upload || [],
|
|
11
|
+
// });
|
|
13
12
|
|
|
14
13
|
const mapDispatchToProps = (dispatch) => ({
|
|
15
14
|
onClearFacetSection: (facet) => { dispatch(clearFacetSection(facet)); },
|
|
16
15
|
onClearSliderSection: (facet) => { dispatch(clearSliderSection(facet)); },
|
|
17
16
|
});
|
|
18
17
|
|
|
19
|
-
export default connect(
|
|
18
|
+
export default connect(null, mapDispatchToProps)(ReduxFacetView);
|
|
@@ -5,12 +5,8 @@ import CheckboxView from './CheckboxView';
|
|
|
5
5
|
|
|
6
6
|
const ReduxCheckbox = ((props) => <CheckboxView {...props} />);
|
|
7
7
|
|
|
8
|
-
const mapStateToProps = (state) => ({
|
|
9
|
-
filterState: state.statusReducer.filterState,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
8
|
const mapDispatchToProps = (dispatch) => ({
|
|
13
9
|
onToggle: (view) => dispatch(toggleCheckBox(view)),
|
|
14
10
|
});
|
|
15
11
|
|
|
16
|
-
export default connect(
|
|
12
|
+
export default connect(null, mapDispatchToProps)(ReduxCheckbox);
|