@bento-core/facet-filter 1.0.1-ccdihub.23 → 1.0.1-ccdihub.25
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 +16 -11
- 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 +17 -12
- 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,18 @@ 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
|
+
// console.log(activeFilters);
|
|
36
|
+
for (const [key, value] of Object.entries(activeFilters)) {
|
|
37
|
+
if (key !== 'participant_ids') {
|
|
38
|
+
filterState[key] = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
34
41
|
const updateFacetState = filterSections => {
|
|
35
42
|
const updateSections = [...filterSections];
|
|
36
43
|
if (!_lodash.default.isEmpty(filterState)) {
|
|
@@ -38,7 +45,8 @@ const FacetFilterController = props => {
|
|
|
38
45
|
updateSections.forEach(sideBar => {
|
|
39
46
|
if (sideBar.type === _Types.InputTypes.CHECKBOX && sideBar.datafield === key) {
|
|
40
47
|
sideBar.facetValues.forEach(item => {
|
|
41
|
-
item.isChecked = value[item.name] ? value[item.name] : false;
|
|
48
|
+
// item.isChecked = value[item.name] ? value[item.name] : false;
|
|
49
|
+
item.isChecked = value.indexOf(item.name) > -1;
|
|
42
50
|
});
|
|
43
51
|
}
|
|
44
52
|
if (sideBar.type === _Types.InputTypes.SLIDER && sideBar.datafield === key) {
|
|
@@ -125,15 +133,15 @@ const FacetFilterController = props => {
|
|
|
125
133
|
if (filterState !== undefined) {
|
|
126
134
|
const facetFilter = filterState[facet.datafield];
|
|
127
135
|
if (facetFilter) {
|
|
128
|
-
|
|
129
|
-
if (validValues.indexOf(
|
|
136
|
+
facetFilter.forEach(item => {
|
|
137
|
+
if (validValues.indexOf(item) === -1) {
|
|
130
138
|
const tmp = {};
|
|
131
|
-
tmp.group =
|
|
132
|
-
tmp.name =
|
|
139
|
+
tmp.group = item;
|
|
140
|
+
tmp.name = item;
|
|
133
141
|
tmp.subjects = 0;
|
|
134
142
|
updateField.push(tmp);
|
|
135
143
|
}
|
|
136
|
-
}
|
|
144
|
+
});
|
|
137
145
|
}
|
|
138
146
|
}
|
|
139
147
|
updateFacet.facetValues = updateField;
|
|
@@ -169,8 +177,5 @@ const FacetFilterController = props => {
|
|
|
169
177
|
sideBarSections: facetSections
|
|
170
178
|
})));
|
|
171
179
|
};
|
|
172
|
-
|
|
173
|
-
filterState: state.statusReducer.filterState
|
|
174
|
-
});
|
|
175
|
-
var _default = (0, _reactRedux.connect)(mapStateToProps, null)(FacetFilterController);
|
|
180
|
+
var _default = (0, _reactRedux.connect)(null, null)(FacetFilterController);
|
|
176
181
|
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,20 @@ 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
|
+
// console.log(activeFilters);
|
|
32
|
+
for (const [key, value] of Object.entries(activeFilters)) {
|
|
33
|
+
if (key !== 'participant_ids') {
|
|
34
|
+
filterState[key] = value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
const updateFacetState = (filterSections) => {
|
|
31
39
|
const updateSections = [...filterSections];
|
|
32
40
|
if (!_.isEmpty(filterState)) {
|
|
@@ -34,7 +42,8 @@ const FacetFilterController = (props) => {
|
|
|
34
42
|
updateSections.forEach((sideBar) => {
|
|
35
43
|
if (sideBar.type === InputTypes.CHECKBOX && sideBar.datafield === key) {
|
|
36
44
|
sideBar.facetValues.forEach((item) => {
|
|
37
|
-
item.isChecked = value[item.name] ? value[item.name] : false;
|
|
45
|
+
// item.isChecked = value[item.name] ? value[item.name] : false;
|
|
46
|
+
item.isChecked = value.indexOf(item.name) > -1;
|
|
38
47
|
});
|
|
39
48
|
}
|
|
40
49
|
if (sideBar.type === InputTypes.SLIDER && sideBar.datafield === key) {
|
|
@@ -110,15 +119,15 @@ const FacetFilterController = (props) => {
|
|
|
110
119
|
if (filterState !== undefined) {
|
|
111
120
|
const facetFilter = filterState[facet.datafield];
|
|
112
121
|
if (facetFilter) {
|
|
113
|
-
|
|
114
|
-
if (validValues.indexOf(
|
|
122
|
+
facetFilter.forEach((item) => {
|
|
123
|
+
if (validValues.indexOf(item) === -1) {
|
|
115
124
|
const tmp = {};
|
|
116
|
-
tmp.group =
|
|
117
|
-
tmp.name =
|
|
125
|
+
tmp.group = item;
|
|
126
|
+
tmp.name = item;
|
|
118
127
|
tmp.subjects = 0;
|
|
119
128
|
updateField.push(tmp);
|
|
120
129
|
}
|
|
121
|
-
}
|
|
130
|
+
});
|
|
122
131
|
}
|
|
123
132
|
}
|
|
124
133
|
updateFacet.facetValues = updateField;
|
|
@@ -161,8 +170,4 @@ const FacetFilterController = (props) => {
|
|
|
161
170
|
);
|
|
162
171
|
};
|
|
163
172
|
|
|
164
|
-
|
|
165
|
-
filterState: state.statusReducer.filterState,
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
export default connect(mapStateToProps, null)(FacetFilterController);
|
|
173
|
+
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);
|