@bento-core/facet-filter 1.0.1-ccdihub.26 → 1.0.1-ccdihub.27
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/FacetFilterView.js +4 -1
- package/dist/components/facet/FacetModal.js +15 -2
- package/dist/components/facet/FacetView.js +16 -2
- package/dist/components/facet/SearchFacetView.js +16 -2
- package/dist/components/inputs/FilterItems.js +5 -2
- package/dist/components/inputs/ModalFilterItems.js +5 -2
- package/dist/components/inputs/SearchFilterItems.js +6 -2
- package/dist/components/inputs/checkbox/CheckboxView.js +28 -1
- package/dist/components/inputs/checkbox/ModalCheckboxView.js +28 -1
- package/dist/components/inputs/checkbox/SearchCheckboxView.js +28 -1
- package/dist/components/inputs/slider/SliderView.js +10 -1
- package/dist/index.js +6 -0
- package/dist/store/actions/ActionTypes.js +2 -1
- package/dist/store/actions/Actions.js +7 -2
- package/dist/store/reducers/SideBarReducer.js +4 -0
- package/package.json +4 -2
- package/src/FacetFilterView.js +3 -0
- package/src/components/facet/FacetModal.js +15 -0
- package/src/components/facet/FacetView.js +15 -0
- package/src/components/facet/SearchFacetView.js +15 -0
- package/src/components/inputs/FilterItems.js +3 -1
- package/src/components/inputs/ModalFilterItems.js +3 -0
- package/src/components/inputs/SearchFilterItems.js +4 -0
- package/src/components/inputs/checkbox/CheckboxView.js +30 -0
- package/src/components/inputs/checkbox/ModalCheckboxView.js +30 -0
- package/src/components/inputs/checkbox/SearchCheckboxView.js +30 -0
- package/src/components/inputs/slider/SliderView.js +12 -0
- package/src/index.js +1 -0
- package/src/store/actions/ActionTypes.js +1 -0
- package/src/store/actions/Actions.js +5 -0
- package/src/store/reducers/SideBarReducer.js +5 -0
package/dist/FacetFilterView.js
CHANGED
|
@@ -19,7 +19,8 @@ const BentoFacetFilter = _ref => {
|
|
|
19
19
|
let {
|
|
20
20
|
sideBarSections,
|
|
21
21
|
CustomFacetSection,
|
|
22
|
-
CustomFacetView
|
|
22
|
+
CustomFacetView,
|
|
23
|
+
queryParams
|
|
23
24
|
} = _ref;
|
|
24
25
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, sideBarSections.map((section, index) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Divider, {
|
|
25
26
|
variant: "middle",
|
|
@@ -31,11 +32,13 @@ const BentoFacetFilter = _ref => {
|
|
|
31
32
|
if (facet.search) {
|
|
32
33
|
return /*#__PURE__*/_react.default.createElement(_ReduxSearchFacetView.default, {
|
|
33
34
|
facet: facet,
|
|
35
|
+
queryParams: queryParams,
|
|
34
36
|
CustomView: CustomFacetView
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
return /*#__PURE__*/_react.default.createElement(_ReduxFacetView.default, {
|
|
38
40
|
facet: facet,
|
|
41
|
+
queryParams: queryParams,
|
|
39
42
|
CustomView: CustomFacetView
|
|
40
43
|
}, /*#__PURE__*/_react.default.createElement(_core.List, {
|
|
41
44
|
className: "List_".concat(facet.label)
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactRouterDom = require("react-router-dom");
|
|
9
|
+
var _util = require("@bento-core/util");
|
|
8
10
|
var _core = require("@material-ui/core");
|
|
9
11
|
var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
|
|
10
12
|
var _styles = require("@material-ui/core/styles");
|
|
@@ -26,9 +28,19 @@ const ModalView = _ref => {
|
|
|
26
28
|
onClose,
|
|
27
29
|
onClearFacetSection,
|
|
28
30
|
onSearchTextChange,
|
|
29
|
-
onSortChange
|
|
31
|
+
onSortChange,
|
|
32
|
+
queryParams
|
|
30
33
|
} = _ref;
|
|
34
|
+
const query = new URLSearchParams((0, _reactRouterDom.useLocation)().search);
|
|
35
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
31
36
|
const onClearSection = () => {
|
|
37
|
+
const field = facet.datafield;
|
|
38
|
+
const paramValue = {};
|
|
39
|
+
paramValue[field] = '';
|
|
40
|
+
const queryStr = (0, _util.generateQueryStr)(query, queryParams, paramValue);
|
|
41
|
+
navigate("/explore".concat(queryStr), {
|
|
42
|
+
replace: true
|
|
43
|
+
});
|
|
32
44
|
onSortChange(null);
|
|
33
45
|
onClearFacetSection(facet);
|
|
34
46
|
};
|
|
@@ -81,7 +93,8 @@ const ModalView = _ref => {
|
|
|
81
93
|
facet: facet,
|
|
82
94
|
sortBy: sortBy,
|
|
83
95
|
onClearSection: onClearSection,
|
|
84
|
-
onSortChange: onSortChange
|
|
96
|
+
onSortChange: onSortChange,
|
|
97
|
+
queryParams: queryParams
|
|
85
98
|
}))));
|
|
86
99
|
};
|
|
87
100
|
var _default = (0, _styles.withStyles)(_ModalStyle.default)(ModalView);
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactRouterDom = require("react-router-dom");
|
|
9
|
+
var _util = require("@bento-core/util");
|
|
8
10
|
var _core = require("@material-ui/core");
|
|
9
11
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
10
12
|
var _AccordionSummaryView = _interopRequireDefault(require("../summary/AccordionSummaryView"));
|
|
@@ -27,10 +29,13 @@ const FacetView = _ref => {
|
|
|
27
29
|
facet,
|
|
28
30
|
onClearFacetSection,
|
|
29
31
|
onClearSliderSection,
|
|
30
|
-
CustomView
|
|
32
|
+
CustomView,
|
|
33
|
+
queryParams
|
|
31
34
|
} = _ref;
|
|
32
35
|
const [expand, setExpand] = (0, _react.useState)(false);
|
|
33
36
|
const onExpandFacet = () => setExpand(!expand);
|
|
37
|
+
const query = new URLSearchParams((0, _reactRouterDom.useLocation)().search);
|
|
38
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
34
39
|
|
|
35
40
|
/**
|
|
36
41
|
* expand section incase of active local search
|
|
@@ -47,6 +52,13 @@ const FacetView = _ref => {
|
|
|
47
52
|
setSortBy(type);
|
|
48
53
|
};
|
|
49
54
|
const onClearSection = () => {
|
|
55
|
+
const field = facet.datafield;
|
|
56
|
+
const paramValue = {};
|
|
57
|
+
paramValue[field] = '';
|
|
58
|
+
const queryStr = (0, _util.generateQueryStr)(query, queryParams, paramValue);
|
|
59
|
+
navigate("/explore".concat(queryStr), {
|
|
60
|
+
replace: true
|
|
61
|
+
});
|
|
50
62
|
setSortBy(null);
|
|
51
63
|
if (facet.type === _Types.InputTypes.SLIDER) {
|
|
52
64
|
onClearSliderSection(facet);
|
|
@@ -116,11 +128,13 @@ const FacetView = _ref => {
|
|
|
116
128
|
}
|
|
117
129
|
}, "Sort by count"))), /*#__PURE__*/_react.default.createElement(_FilterItems.default, {
|
|
118
130
|
facet: facet,
|
|
131
|
+
queryParams: queryParams,
|
|
119
132
|
sortBy: sortBy
|
|
120
133
|
})), !expand && type === _Types.InputTypes.CHECKBOX && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.List, {
|
|
121
134
|
id: "filter_Items"
|
|
122
135
|
}, /*#__PURE__*/_react.default.createElement(_FilterItems.default, {
|
|
123
|
-
facet: displayFacet
|
|
136
|
+
facet: displayFacet,
|
|
137
|
+
queryParams: queryParams
|
|
124
138
|
}))), !expand && selectedItems.length > limitCheckBoxCount && /*#__PURE__*/_react.default.createElement("div", {
|
|
125
139
|
className: classes.showMore,
|
|
126
140
|
onClick: onExpandFacet
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactRouterDom = require("react-router-dom");
|
|
9
|
+
var _util = require("@bento-core/util");
|
|
8
10
|
var _core = require("@material-ui/core");
|
|
9
11
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
10
12
|
var _AccordionSummaryView = _interopRequireDefault(require("../summary/AccordionSummaryView"));
|
|
@@ -31,11 +33,21 @@ const SearchFacetView = _ref => {
|
|
|
31
33
|
onClearFacetSection,
|
|
32
34
|
onSearchTextChange,
|
|
33
35
|
onSortChange,
|
|
34
|
-
CustomView
|
|
36
|
+
CustomView,
|
|
37
|
+
queryParams
|
|
35
38
|
} = _ref;
|
|
36
39
|
const [expand, setExpand] = (0, _react.useState)(false);
|
|
37
40
|
const onExpandFacet = () => setExpand(!expand);
|
|
41
|
+
const query = new URLSearchParams((0, _reactRouterDom.useLocation)().search);
|
|
42
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
38
43
|
const onClearSection = () => {
|
|
44
|
+
const field = facet.datafield;
|
|
45
|
+
const paramValue = {};
|
|
46
|
+
paramValue[field] = '';
|
|
47
|
+
const queryStr = (0, _util.generateQueryStr)(query, queryParams, paramValue);
|
|
48
|
+
navigate("/explore".concat(queryStr), {
|
|
49
|
+
replace: true
|
|
50
|
+
});
|
|
39
51
|
onSortChange(facet.datafield, null);
|
|
40
52
|
onClearFacetSection(facet);
|
|
41
53
|
};
|
|
@@ -111,11 +123,13 @@ const SearchFacetView = _ref => {
|
|
|
111
123
|
}, "Sort by count"))), /*#__PURE__*/_react.default.createElement(_SearchFilterItems.default, {
|
|
112
124
|
searchText: searchText,
|
|
113
125
|
facet: facet,
|
|
126
|
+
queryParams: queryParams,
|
|
114
127
|
sortBy: sortBy
|
|
115
128
|
})), !expand && type === _Types.InputTypes.CHECKBOX && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.List, {
|
|
116
129
|
id: "filter_Items"
|
|
117
130
|
}, /*#__PURE__*/_react.default.createElement(_FilterItems.default, {
|
|
118
|
-
facet: displayFacet
|
|
131
|
+
facet: displayFacet,
|
|
132
|
+
queryParams: queryParams
|
|
119
133
|
}))), !expand && selectedItems.length > limitCheckBoxCount && /*#__PURE__*/_react.default.createElement("div", {
|
|
120
134
|
className: classes.showMore,
|
|
121
135
|
onClick: onExpandFacet
|
|
@@ -18,6 +18,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
18
18
|
const FilterItems = _ref => {
|
|
19
19
|
let {
|
|
20
20
|
facet,
|
|
21
|
+
queryParams,
|
|
21
22
|
sortBy
|
|
22
23
|
} = _ref;
|
|
23
24
|
const {
|
|
@@ -37,11 +38,13 @@ const FilterItems = _ref => {
|
|
|
37
38
|
section
|
|
38
39
|
}),
|
|
39
40
|
datafield: datafield,
|
|
40
|
-
facet: facet
|
|
41
|
+
facet: facet,
|
|
42
|
+
queryParams: queryParams
|
|
41
43
|
}));
|
|
42
44
|
case _Types.InputTypes.SLIDER:
|
|
43
45
|
return /*#__PURE__*/_react.default.createElement(_ReduxSlider.default, {
|
|
44
|
-
facet: facet
|
|
46
|
+
facet: facet,
|
|
47
|
+
queryParams: queryParams
|
|
45
48
|
});
|
|
46
49
|
default:
|
|
47
50
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
@@ -23,6 +23,7 @@ const ModalFilterItems = _ref => {
|
|
|
23
23
|
let {
|
|
24
24
|
facet,
|
|
25
25
|
searchText,
|
|
26
|
+
queryParams,
|
|
26
27
|
sortBy,
|
|
27
28
|
onClearSection,
|
|
28
29
|
onSortChange,
|
|
@@ -47,7 +48,8 @@ const ModalFilterItems = _ref => {
|
|
|
47
48
|
section
|
|
48
49
|
}),
|
|
49
50
|
datafield: datafield,
|
|
50
|
-
facet: facet
|
|
51
|
+
facet: facet,
|
|
52
|
+
queryParams: queryParams
|
|
51
53
|
}));
|
|
52
54
|
const makeupItemsLen = 3 - checkedItems.length % 3;
|
|
53
55
|
const makeupItems = [];
|
|
@@ -64,7 +66,8 @@ const ModalFilterItems = _ref => {
|
|
|
64
66
|
section
|
|
65
67
|
}),
|
|
66
68
|
datafield: datafield,
|
|
67
|
-
facet: facet
|
|
69
|
+
facet: facet,
|
|
70
|
+
queryParams: queryParams
|
|
68
71
|
}));
|
|
69
72
|
const makeupUncheckedItemsLen = 3 - uncheckedItems.length % 3;
|
|
70
73
|
const makeupUncheckedItems = [];
|
|
@@ -21,6 +21,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
21
21
|
const SearchFilterItems = _ref => {
|
|
22
22
|
let {
|
|
23
23
|
facet,
|
|
24
|
+
queryParams,
|
|
24
25
|
sortBy,
|
|
25
26
|
searchText,
|
|
26
27
|
classes
|
|
@@ -43,7 +44,8 @@ const SearchFilterItems = _ref => {
|
|
|
43
44
|
section
|
|
44
45
|
}),
|
|
45
46
|
datafield: datafield,
|
|
46
|
-
facet: facet
|
|
47
|
+
facet: facet,
|
|
48
|
+
queryParams: queryParams
|
|
47
49
|
}));
|
|
48
50
|
const uncheckedItems = sortFilters.filter(item => !item.isChecked).filter(item => item.name.toLowerCase().includes(searchText.toLowerCase())).slice(0, displayCount).map((item, index) => /*#__PURE__*/_react.default.createElement(_ReduxSearchCheckbox.default, {
|
|
49
51
|
checkboxItem: _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -51,7 +53,8 @@ const SearchFilterItems = _ref => {
|
|
|
51
53
|
section
|
|
52
54
|
}),
|
|
53
55
|
datafield: datafield,
|
|
54
|
-
facet: facet
|
|
56
|
+
facet: facet,
|
|
57
|
+
queryParams: queryParams
|
|
55
58
|
}));
|
|
56
59
|
(0, _react.useEffect)(() => {
|
|
57
60
|
scrollableRef.current.scrollTo(0, 0);
|
|
@@ -74,6 +77,7 @@ const SearchFilterItems = _ref => {
|
|
|
74
77
|
};
|
|
75
78
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ReduxFacetModal.default, {
|
|
76
79
|
facet: facet,
|
|
80
|
+
queryParams: queryParams,
|
|
77
81
|
open: open,
|
|
78
82
|
onClose: () => setOpen(false)
|
|
79
83
|
}), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", null, checkedItems), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactRouterDom = require("react-router-dom");
|
|
9
|
+
var _util = require("@bento-core/util");
|
|
8
10
|
var _styles = require("@material-ui/core/styles");
|
|
9
11
|
var _core = require("@material-ui/core");
|
|
10
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
@@ -21,7 +23,8 @@ const CheckBoxView = _ref => {
|
|
|
21
23
|
checkboxItem,
|
|
22
24
|
datafield,
|
|
23
25
|
onToggle,
|
|
24
|
-
facet
|
|
26
|
+
facet,
|
|
27
|
+
queryParams
|
|
25
28
|
} = _ref;
|
|
26
29
|
const {
|
|
27
30
|
name,
|
|
@@ -32,6 +35,8 @@ const CheckBoxView = _ref => {
|
|
|
32
35
|
tooltip,
|
|
33
36
|
label
|
|
34
37
|
} = checkboxItem;
|
|
38
|
+
const query = new URLSearchParams((0, _reactRouterDom.useLocation)().search);
|
|
39
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
35
40
|
const indexType = index % 2 === 0 ? 'Even' : 'Odd';
|
|
36
41
|
const checkedSection = "".concat(section).toLowerCase().replace(' ', '_');
|
|
37
42
|
const labelCheckbox = {
|
|
@@ -45,6 +50,28 @@ const CheckBoxView = _ref => {
|
|
|
45
50
|
datafield: datafield,
|
|
46
51
|
isChecked: !isChecked
|
|
47
52
|
};
|
|
53
|
+
const checkedValues = query.get(datafield);
|
|
54
|
+
const paramValue = {};
|
|
55
|
+
if (toggleCheckBoxItem.isChecked) {
|
|
56
|
+
if (checkedValues) {
|
|
57
|
+
const newValues = checkedValues.split('|');
|
|
58
|
+
newValues.push(name);
|
|
59
|
+
paramValue[datafield] = newValues.join('|');
|
|
60
|
+
} else {
|
|
61
|
+
paramValue[datafield] = name;
|
|
62
|
+
}
|
|
63
|
+
} else if (checkedValues) {
|
|
64
|
+
const newValues = checkedValues.split('|');
|
|
65
|
+
const idx = newValues.indexOf(name);
|
|
66
|
+
if (idx > -1) {
|
|
67
|
+
newValues.splice(idx, 1);
|
|
68
|
+
}
|
|
69
|
+
paramValue[datafield] = newValues.length > 0 ? newValues.join('|') : '';
|
|
70
|
+
} else {
|
|
71
|
+
paramValue[datafield] = '';
|
|
72
|
+
}
|
|
73
|
+
const queryStr = (0, _util.generateQueryStr)(query, queryParams, paramValue);
|
|
74
|
+
navigate("/explore".concat(queryStr));
|
|
48
75
|
onToggle(toggleCheckBoxItem);
|
|
49
76
|
};
|
|
50
77
|
const LabelComponent = () => /*#__PURE__*/_react.default.createElement(_core.Box, {
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactRouterDom = require("react-router-dom");
|
|
9
|
+
var _util = require("@bento-core/util");
|
|
8
10
|
var _styles = require("@material-ui/core/styles");
|
|
9
11
|
var _core = require("@material-ui/core");
|
|
10
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
@@ -21,7 +23,8 @@ const CheckBoxView = _ref => {
|
|
|
21
23
|
checkboxItem,
|
|
22
24
|
datafield,
|
|
23
25
|
onToggle,
|
|
24
|
-
facet
|
|
26
|
+
facet,
|
|
27
|
+
queryParams
|
|
25
28
|
} = _ref;
|
|
26
29
|
const {
|
|
27
30
|
name,
|
|
@@ -32,6 +35,8 @@ const CheckBoxView = _ref => {
|
|
|
32
35
|
tooltip,
|
|
33
36
|
label
|
|
34
37
|
} = checkboxItem;
|
|
38
|
+
const query = new URLSearchParams((0, _reactRouterDom.useLocation)().search);
|
|
39
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
35
40
|
const indexType = index % 2 === 0 ? 'Even' : 'Odd';
|
|
36
41
|
const checkedSection = "".concat(section).toLowerCase().replace(' ', '_');
|
|
37
42
|
const labelCheckbox = {
|
|
@@ -45,6 +50,28 @@ const CheckBoxView = _ref => {
|
|
|
45
50
|
datafield: datafield,
|
|
46
51
|
isChecked: !isChecked
|
|
47
52
|
};
|
|
53
|
+
const checkedValues = query.get(datafield);
|
|
54
|
+
const paramValue = {};
|
|
55
|
+
if (toggleCheckBoxItem.isChecked) {
|
|
56
|
+
if (checkedValues) {
|
|
57
|
+
const newValues = checkedValues.split('|');
|
|
58
|
+
newValues.push(name);
|
|
59
|
+
paramValue[datafield] = newValues.join('|');
|
|
60
|
+
} else {
|
|
61
|
+
paramValue[datafield] = name;
|
|
62
|
+
}
|
|
63
|
+
} else if (checkedValues) {
|
|
64
|
+
const newValues = checkedValues.split('|');
|
|
65
|
+
const idx = newValues.indexOf(name);
|
|
66
|
+
if (idx > -1) {
|
|
67
|
+
newValues.splice(idx, 1);
|
|
68
|
+
}
|
|
69
|
+
paramValue[datafield] = newValues.length > 0 ? newValues.join('|') : '';
|
|
70
|
+
} else {
|
|
71
|
+
paramValue[datafield] = '';
|
|
72
|
+
}
|
|
73
|
+
const queryStr = (0, _util.generateQueryStr)(query, queryParams, paramValue);
|
|
74
|
+
navigate("/explore".concat(queryStr));
|
|
48
75
|
onToggle(toggleCheckBoxItem);
|
|
49
76
|
};
|
|
50
77
|
const LabelComponent = () => /*#__PURE__*/_react.default.createElement(_core.Box, {
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactRouterDom = require("react-router-dom");
|
|
9
|
+
var _util = require("@bento-core/util");
|
|
8
10
|
var _styles = require("@material-ui/core/styles");
|
|
9
11
|
var _core = require("@material-ui/core");
|
|
10
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
@@ -21,7 +23,8 @@ const CheckBoxView = _ref => {
|
|
|
21
23
|
checkboxItem,
|
|
22
24
|
datafield,
|
|
23
25
|
onToggle,
|
|
24
|
-
facet
|
|
26
|
+
facet,
|
|
27
|
+
queryParams
|
|
25
28
|
} = _ref;
|
|
26
29
|
const {
|
|
27
30
|
name,
|
|
@@ -32,6 +35,8 @@ const CheckBoxView = _ref => {
|
|
|
32
35
|
tooltip,
|
|
33
36
|
label
|
|
34
37
|
} = checkboxItem;
|
|
38
|
+
const query = new URLSearchParams((0, _reactRouterDom.useLocation)().search);
|
|
39
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
35
40
|
const indexType = index % 2 === 0 ? 'Even' : 'Odd';
|
|
36
41
|
const checkedSection = "".concat(section).toLowerCase().replace(' ', '_');
|
|
37
42
|
const labelCheckbox = {
|
|
@@ -45,6 +50,28 @@ const CheckBoxView = _ref => {
|
|
|
45
50
|
datafield: datafield,
|
|
46
51
|
isChecked: !isChecked
|
|
47
52
|
};
|
|
53
|
+
const checkedValues = query.get(datafield);
|
|
54
|
+
const paramValue = {};
|
|
55
|
+
if (toggleCheckBoxItem.isChecked) {
|
|
56
|
+
if (checkedValues) {
|
|
57
|
+
const newValues = checkedValues.split('|');
|
|
58
|
+
newValues.push(name);
|
|
59
|
+
paramValue[datafield] = newValues.join('|');
|
|
60
|
+
} else {
|
|
61
|
+
paramValue[datafield] = name;
|
|
62
|
+
}
|
|
63
|
+
} else if (checkedValues) {
|
|
64
|
+
const newValues = checkedValues.split('|');
|
|
65
|
+
const idx = newValues.indexOf(name);
|
|
66
|
+
if (idx > -1) {
|
|
67
|
+
newValues.splice(idx, 1);
|
|
68
|
+
}
|
|
69
|
+
paramValue[datafield] = newValues.length > 0 ? newValues.join('|') : '';
|
|
70
|
+
} else {
|
|
71
|
+
paramValue[datafield] = '';
|
|
72
|
+
}
|
|
73
|
+
const queryStr = (0, _util.generateQueryStr)(query, queryParams, paramValue);
|
|
74
|
+
navigate("/explore".concat(queryStr));
|
|
48
75
|
onToggle(toggleCheckBoxItem);
|
|
49
76
|
};
|
|
50
77
|
const LabelComponent = () => /*#__PURE__*/_react.default.createElement(_core.Box, {
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactRouterDom = require("react-router-dom");
|
|
9
|
+
var _util = require("@bento-core/util");
|
|
8
10
|
var _core = require("@material-ui/core");
|
|
9
11
|
var _Types = require("../Types");
|
|
10
12
|
var _InputMinMaxView = _interopRequireDefault(require("./InputMinMaxView"));
|
|
@@ -21,7 +23,8 @@ const SliderView = _ref => {
|
|
|
21
23
|
classes,
|
|
22
24
|
facet,
|
|
23
25
|
onSliderToggle,
|
|
24
|
-
filterState
|
|
26
|
+
filterState,
|
|
27
|
+
queryParams
|
|
25
28
|
} = _ref;
|
|
26
29
|
const {
|
|
27
30
|
minLowerBound,
|
|
@@ -32,6 +35,8 @@ const SliderView = _ref => {
|
|
|
32
35
|
} = facet;
|
|
33
36
|
const lowerBoundValue = facetValues[0];
|
|
34
37
|
const upperBoundValue = facetValues[1];
|
|
38
|
+
const query = new URLSearchParams((0, _reactRouterDom.useLocation)().search);
|
|
39
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
35
40
|
|
|
36
41
|
// Determines whether the lower bound and upper bound values are valid
|
|
37
42
|
const isValid = () => {
|
|
@@ -40,6 +45,10 @@ const SliderView = _ref => {
|
|
|
40
45
|
};
|
|
41
46
|
const handleChangeCommittedSlider = value => {
|
|
42
47
|
if (!value.includes('')) {
|
|
48
|
+
const paramValue = {};
|
|
49
|
+
paramValue[datafield] = value;
|
|
50
|
+
const queryStr = (0, _util.generateQueryStr)(query, queryParams, paramValue);
|
|
51
|
+
navigate("/explore".concat(queryStr));
|
|
43
52
|
onSliderToggle(_objectSpread({
|
|
44
53
|
sliderValue: value
|
|
45
54
|
}, facet));
|
package/dist/index.js
CHANGED
|
@@ -117,6 +117,12 @@ Object.defineProperty(exports, "toggleSilder", {
|
|
|
117
117
|
return _Actions.toggleSilder;
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
|
+
Object.defineProperty(exports, "updateFilterState", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function get() {
|
|
123
|
+
return _Actions.updateFilterState;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
120
126
|
Object.defineProperty(exports, "updateSiderValue", {
|
|
121
127
|
enumerable: true,
|
|
122
128
|
get: function get() {
|
|
@@ -12,7 +12,8 @@ const sideBarActionTypes = {
|
|
|
12
12
|
CLEAR_SLIDER_SECTION: 'CLEAR_SLIDER_SECTION',
|
|
13
13
|
CLEAR_AND_SELECT_FACET_VALUE: 'CLEAR_AND_SELECT_FACET_VALUE',
|
|
14
14
|
SEARCH_TEXT_CHANGED: 'SEARCH_TEXT_CHANGED',
|
|
15
|
-
SORT_CHANGED: 'SORT_CHANGED'
|
|
15
|
+
SORT_CHANGED: 'SORT_CHANGED',
|
|
16
|
+
UPDATE_FILTER_STATE: 'UPDATE_FILTER_STATE'
|
|
16
17
|
};
|
|
17
18
|
exports.sideBarActionTypes = sideBarActionTypes;
|
|
18
19
|
const Actions = '';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.toggleSilder = exports.toggleCheckBox = exports.sortChange = exports.searchTextChange = exports.clearSliderSection = exports.clearFacetSection = exports.clearAllFilters = exports.clearAllAndSelectFacet = void 0;
|
|
6
|
+
exports.updateFilterState = exports.toggleSilder = exports.toggleCheckBox = exports.sortChange = exports.searchTextChange = exports.clearSliderSection = exports.clearFacetSection = exports.clearAllFilters = exports.clearAllAndSelectFacet = void 0;
|
|
7
7
|
var _ActionTypes = require("./ActionTypes");
|
|
8
8
|
const toggleCheckBox = toggleCheckBoxItem => ({
|
|
9
9
|
type: _ActionTypes.sideBarActionTypes.FACET_VALUE_CHANGED,
|
|
@@ -53,4 +53,9 @@ const sortChange = (datafield, sortBy) => ({
|
|
|
53
53
|
sortBy
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
|
-
exports.sortChange = sortChange;
|
|
56
|
+
exports.sortChange = sortChange;
|
|
57
|
+
const updateFilterState = filterState => ({
|
|
58
|
+
type: _ActionTypes.sideBarActionTypes.UPDATE_FILTER_STATE,
|
|
59
|
+
payload: filterState
|
|
60
|
+
});
|
|
61
|
+
exports.updateFilterState = updateFilterState;
|
|
@@ -148,6 +148,10 @@ function sideBarReducerGenerator() {
|
|
|
148
148
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
149
149
|
sortState: _objectSpread({}, updateState)
|
|
150
150
|
});
|
|
151
|
+
case _ActionTypes.sideBarActionTypes.UPDATE_FILTER_STATE:
|
|
152
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
153
|
+
filterState: payload
|
|
154
|
+
});
|
|
151
155
|
default:
|
|
152
156
|
return state;
|
|
153
157
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/facet-filter",
|
|
3
|
-
"version": "1.0.1-ccdihub.
|
|
3
|
+
"version": "1.0.1-ccdihub.27",
|
|
4
4
|
"description": "### Bento core sidebar design:",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@bento-core/util": "1.0.1-ccdihub.1",
|
|
19
20
|
"lodash": "^4.17.20"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
@@ -24,7 +25,8 @@
|
|
|
24
25
|
"clsx": "^1.2.1",
|
|
25
26
|
"react": "^17.0.2",
|
|
26
27
|
"react-dom": "^17.0.0",
|
|
27
|
-
"react-redux": "^7.2.1"
|
|
28
|
+
"react-redux": "^7.2.1",
|
|
29
|
+
"react-router-dom": "^5.1.2"
|
|
28
30
|
},
|
|
29
31
|
"author": "CTOS Bento Team",
|
|
30
32
|
"license": "ISC",
|
package/src/FacetFilterView.js
CHANGED
|
@@ -16,6 +16,7 @@ const BentoFacetFilter = ({
|
|
|
16
16
|
sideBarSections,
|
|
17
17
|
CustomFacetSection,
|
|
18
18
|
CustomFacetView,
|
|
19
|
+
queryParams,
|
|
19
20
|
}) => {
|
|
20
21
|
return (
|
|
21
22
|
<>
|
|
@@ -35,6 +36,7 @@ const BentoFacetFilter = ({
|
|
|
35
36
|
return (
|
|
36
37
|
<SearchFacetView
|
|
37
38
|
facet={facet}
|
|
39
|
+
queryParams={queryParams}
|
|
38
40
|
CustomView={CustomFacetView}
|
|
39
41
|
/>
|
|
40
42
|
);
|
|
@@ -42,6 +44,7 @@ const BentoFacetFilter = ({
|
|
|
42
44
|
return (
|
|
43
45
|
<FacetView
|
|
44
46
|
facet={facet}
|
|
47
|
+
queryParams={queryParams}
|
|
45
48
|
CustomView={CustomFacetView}
|
|
46
49
|
>
|
|
47
50
|
<List className={`List_${facet.label}`}>
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
useLocation,
|
|
4
|
+
useNavigate,
|
|
5
|
+
} from 'react-router-dom';
|
|
6
|
+
import { generateQueryStr } from '@bento-core/util';
|
|
2
7
|
import {
|
|
3
8
|
Modal,
|
|
4
9
|
Box,
|
|
@@ -27,8 +32,17 @@ const ModalView = ({
|
|
|
27
32
|
onClearFacetSection,
|
|
28
33
|
onSearchTextChange,
|
|
29
34
|
onSortChange,
|
|
35
|
+
queryParams,
|
|
30
36
|
}) => {
|
|
37
|
+
const query = new URLSearchParams(useLocation().search);
|
|
38
|
+
const navigate = useNavigate();
|
|
39
|
+
|
|
31
40
|
const onClearSection = () => {
|
|
41
|
+
const field = facet.datafield;
|
|
42
|
+
const paramValue = {};
|
|
43
|
+
paramValue[field] = '';
|
|
44
|
+
const queryStr = generateQueryStr(query, queryParams, paramValue);
|
|
45
|
+
navigate(`/explore${queryStr}`, { replace: true });
|
|
32
46
|
onSortChange(null);
|
|
33
47
|
onClearFacetSection(facet);
|
|
34
48
|
};
|
|
@@ -81,6 +95,7 @@ const ModalView = ({
|
|
|
81
95
|
sortBy={sortBy}
|
|
82
96
|
onClearSection={onClearSection}
|
|
83
97
|
onSortChange={onSortChange}
|
|
98
|
+
queryParams={queryParams}
|
|
84
99
|
/>
|
|
85
100
|
</div>
|
|
86
101
|
</Box>
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
useLocation,
|
|
4
|
+
useNavigate,
|
|
5
|
+
} from 'react-router-dom';
|
|
6
|
+
import { generateQueryStr } from '@bento-core/util';
|
|
2
7
|
import {
|
|
3
8
|
Accordion,
|
|
4
9
|
List,
|
|
@@ -19,9 +24,12 @@ const FacetView = ({
|
|
|
19
24
|
onClearFacetSection,
|
|
20
25
|
onClearSliderSection,
|
|
21
26
|
CustomView,
|
|
27
|
+
queryParams,
|
|
22
28
|
}) => {
|
|
23
29
|
const [expand, setExpand] = useState(false);
|
|
24
30
|
const onExpandFacet = () => setExpand(!expand);
|
|
31
|
+
const query = new URLSearchParams(useLocation().search);
|
|
32
|
+
const navigate = useNavigate();
|
|
25
33
|
|
|
26
34
|
/**
|
|
27
35
|
* expand section incase of active local search
|
|
@@ -39,6 +47,11 @@ const FacetView = ({
|
|
|
39
47
|
};
|
|
40
48
|
|
|
41
49
|
const onClearSection = () => {
|
|
50
|
+
const field = facet.datafield;
|
|
51
|
+
const paramValue = {};
|
|
52
|
+
paramValue[field] = '';
|
|
53
|
+
const queryStr = generateQueryStr(query, queryParams, paramValue);
|
|
54
|
+
navigate(`/explore${queryStr}`, { replace: true });
|
|
42
55
|
setSortBy(null);
|
|
43
56
|
if (facet.type === InputTypes.SLIDER) {
|
|
44
57
|
onClearSliderSection(facet);
|
|
@@ -152,6 +165,7 @@ const FacetView = ({
|
|
|
152
165
|
}
|
|
153
166
|
<FilterItems
|
|
154
167
|
facet={facet}
|
|
168
|
+
queryParams={queryParams}
|
|
155
169
|
sortBy={sortBy}
|
|
156
170
|
/>
|
|
157
171
|
</Accordion>
|
|
@@ -161,6 +175,7 @@ const FacetView = ({
|
|
|
161
175
|
<List id="filter_Items">
|
|
162
176
|
<FilterItems
|
|
163
177
|
facet={displayFacet}
|
|
178
|
+
queryParams={queryParams}
|
|
164
179
|
/>
|
|
165
180
|
</List>
|
|
166
181
|
</>
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
useLocation,
|
|
4
|
+
useNavigate,
|
|
5
|
+
} from 'react-router-dom';
|
|
6
|
+
import { generateQueryStr } from '@bento-core/util';
|
|
2
7
|
import {
|
|
3
8
|
Accordion,
|
|
4
9
|
List,
|
|
@@ -23,11 +28,19 @@ const SearchFacetView = ({
|
|
|
23
28
|
onSearchTextChange,
|
|
24
29
|
onSortChange,
|
|
25
30
|
CustomView,
|
|
31
|
+
queryParams,
|
|
26
32
|
}) => {
|
|
27
33
|
const [expand, setExpand] = useState(false);
|
|
28
34
|
const onExpandFacet = () => setExpand(!expand);
|
|
35
|
+
const query = new URLSearchParams(useLocation().search);
|
|
36
|
+
const navigate = useNavigate();
|
|
29
37
|
|
|
30
38
|
const onClearSection = () => {
|
|
39
|
+
const field = facet.datafield;
|
|
40
|
+
const paramValue = {};
|
|
41
|
+
paramValue[field] = '';
|
|
42
|
+
const queryStr = generateQueryStr(query, queryParams, paramValue);
|
|
43
|
+
navigate(`/explore${queryStr}`, { replace: true });
|
|
31
44
|
onSortChange(facet.datafield, null);
|
|
32
45
|
onClearFacetSection(facet);
|
|
33
46
|
};
|
|
@@ -139,6 +152,7 @@ const SearchFacetView = ({
|
|
|
139
152
|
<SearchFilterItems
|
|
140
153
|
searchText={searchText}
|
|
141
154
|
facet={facet}
|
|
155
|
+
queryParams={queryParams}
|
|
142
156
|
sortBy={sortBy}
|
|
143
157
|
/>
|
|
144
158
|
</Accordion>
|
|
@@ -148,6 +162,7 @@ const SearchFacetView = ({
|
|
|
148
162
|
<List id="filter_Items">
|
|
149
163
|
<FilterItems
|
|
150
164
|
facet={displayFacet}
|
|
165
|
+
queryParams={queryParams}
|
|
151
166
|
/>
|
|
152
167
|
</List>
|
|
153
168
|
</>
|
|
@@ -8,6 +8,7 @@ import { sortBySection } from '../../utils/Sort';
|
|
|
8
8
|
|
|
9
9
|
const FilterItems = ({
|
|
10
10
|
facet,
|
|
11
|
+
queryParams,
|
|
11
12
|
sortBy,
|
|
12
13
|
}) => {
|
|
13
14
|
const {
|
|
@@ -22,10 +23,11 @@ const FilterItems = ({
|
|
|
22
23
|
checkboxItem={{ ...item, index, section }}
|
|
23
24
|
datafield={datafield}
|
|
24
25
|
facet={facet}
|
|
26
|
+
queryParams={queryParams}
|
|
25
27
|
/>
|
|
26
28
|
));
|
|
27
29
|
case InputTypes.SLIDER:
|
|
28
|
-
return (<ReduxSlider facet={facet} />);
|
|
30
|
+
return (<ReduxSlider facet={facet} queryParams={queryParams} />);
|
|
29
31
|
default:
|
|
30
32
|
return (<></>);
|
|
31
33
|
}
|
|
@@ -14,6 +14,7 @@ import clearIcon from '../facet/assets/clearIcon.svg';
|
|
|
14
14
|
const ModalFilterItems = ({
|
|
15
15
|
facet,
|
|
16
16
|
searchText,
|
|
17
|
+
queryParams,
|
|
17
18
|
sortBy,
|
|
18
19
|
onClearSection,
|
|
19
20
|
onSortChange,
|
|
@@ -35,6 +36,7 @@ const ModalFilterItems = ({
|
|
|
35
36
|
checkboxItem={{ ...item, index, section }}
|
|
36
37
|
datafield={datafield}
|
|
37
38
|
facet={facet}
|
|
39
|
+
queryParams={queryParams}
|
|
38
40
|
/>));
|
|
39
41
|
const makeupItemsLen = 3 - (checkedItems.length % 3);
|
|
40
42
|
const makeupItems = [];
|
|
@@ -50,6 +52,7 @@ const ModalFilterItems = ({
|
|
|
50
52
|
checkboxItem={{ ...item, index, section }}
|
|
51
53
|
datafield={datafield}
|
|
52
54
|
facet={facet}
|
|
55
|
+
queryParams={queryParams}
|
|
53
56
|
/>));
|
|
54
57
|
const makeupUncheckedItemsLen = 3 - (uncheckedItems.length % 3);
|
|
55
58
|
const makeupUncheckedItems = [];
|
|
@@ -12,6 +12,7 @@ import ReduxFacetModal from '../facet/ReduxFacetModal';
|
|
|
12
12
|
|
|
13
13
|
const SearchFilterItems = ({
|
|
14
14
|
facet,
|
|
15
|
+
queryParams,
|
|
15
16
|
sortBy,
|
|
16
17
|
searchText,
|
|
17
18
|
classes,
|
|
@@ -31,6 +32,7 @@ const SearchFilterItems = ({
|
|
|
31
32
|
checkboxItem={{ ...item, index, section }}
|
|
32
33
|
datafield={datafield}
|
|
33
34
|
facet={facet}
|
|
35
|
+
queryParams={queryParams}
|
|
34
36
|
/>));
|
|
35
37
|
|
|
36
38
|
const uncheckedItems = sortFilters.filter((item) => !item.isChecked)
|
|
@@ -39,6 +41,7 @@ const SearchFilterItems = ({
|
|
|
39
41
|
checkboxItem={{ ...item, index, section }}
|
|
40
42
|
datafield={datafield}
|
|
41
43
|
facet={facet}
|
|
44
|
+
queryParams={queryParams}
|
|
42
45
|
/>));
|
|
43
46
|
|
|
44
47
|
useEffect(() => {
|
|
@@ -63,6 +66,7 @@ const SearchFilterItems = ({
|
|
|
63
66
|
<>
|
|
64
67
|
<ReduxFacetModal
|
|
65
68
|
facet={facet}
|
|
69
|
+
queryParams={queryParams}
|
|
66
70
|
open={open}
|
|
67
71
|
onClose={() => setOpen(false)}
|
|
68
72
|
/>
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
/* eslint-disable object-shorthand */
|
|
7
7
|
/* eslint-disable react/jsx-one-expression-per-line */
|
|
8
8
|
import React from 'react';
|
|
9
|
+
import {
|
|
10
|
+
useLocation,
|
|
11
|
+
useNavigate,
|
|
12
|
+
} from 'react-router-dom';
|
|
13
|
+
import { generateQueryStr } from '@bento-core/util';
|
|
9
14
|
import { withStyles } from '@material-ui/core/styles';
|
|
10
15
|
import {
|
|
11
16
|
Checkbox,
|
|
@@ -33,6 +38,7 @@ const CheckBoxView = ({
|
|
|
33
38
|
datafield,
|
|
34
39
|
onToggle,
|
|
35
40
|
facet,
|
|
41
|
+
queryParams,
|
|
36
42
|
}) => {
|
|
37
43
|
const {
|
|
38
44
|
name,
|
|
@@ -43,6 +49,8 @@ const CheckBoxView = ({
|
|
|
43
49
|
tooltip,
|
|
44
50
|
label,
|
|
45
51
|
} = checkboxItem;
|
|
52
|
+
const query = new URLSearchParams(useLocation().search);
|
|
53
|
+
const navigate = useNavigate();
|
|
46
54
|
const indexType = index % 2 === 0 ? 'Even' : 'Odd';
|
|
47
55
|
const checkedSection = `${section}`.toLowerCase().replace(' ', '_');
|
|
48
56
|
|
|
@@ -54,6 +62,28 @@ const CheckBoxView = ({
|
|
|
54
62
|
datafield: datafield,
|
|
55
63
|
isChecked: !isChecked,
|
|
56
64
|
};
|
|
65
|
+
const checkedValues = query.get(datafield);
|
|
66
|
+
const paramValue = {};
|
|
67
|
+
if (toggleCheckBoxItem.isChecked) {
|
|
68
|
+
if (checkedValues) {
|
|
69
|
+
const newValues = checkedValues.split('|');
|
|
70
|
+
newValues.push(name);
|
|
71
|
+
paramValue[datafield] = newValues.join('|');
|
|
72
|
+
} else {
|
|
73
|
+
paramValue[datafield] = name;
|
|
74
|
+
}
|
|
75
|
+
} else if (checkedValues) {
|
|
76
|
+
const newValues = checkedValues.split('|');
|
|
77
|
+
const idx = newValues.indexOf(name);
|
|
78
|
+
if (idx > -1) {
|
|
79
|
+
newValues.splice(idx, 1);
|
|
80
|
+
}
|
|
81
|
+
paramValue[datafield] = newValues.length > 0 ? newValues.join('|') : '';
|
|
82
|
+
} else {
|
|
83
|
+
paramValue[datafield] = '';
|
|
84
|
+
}
|
|
85
|
+
const queryStr = generateQueryStr(query, queryParams, paramValue);
|
|
86
|
+
navigate(`/explore${queryStr}`);
|
|
57
87
|
onToggle(toggleCheckBoxItem);
|
|
58
88
|
};
|
|
59
89
|
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
/* eslint-disable object-shorthand */
|
|
7
7
|
/* eslint-disable react/jsx-one-expression-per-line */
|
|
8
8
|
import React from 'react';
|
|
9
|
+
import {
|
|
10
|
+
useLocation,
|
|
11
|
+
useNavigate,
|
|
12
|
+
} from 'react-router-dom';
|
|
13
|
+
import { generateQueryStr } from '@bento-core/util';
|
|
9
14
|
import { withStyles } from '@material-ui/core/styles';
|
|
10
15
|
import {
|
|
11
16
|
Checkbox,
|
|
@@ -33,6 +38,7 @@ const CheckBoxView = ({
|
|
|
33
38
|
datafield,
|
|
34
39
|
onToggle,
|
|
35
40
|
facet,
|
|
41
|
+
queryParams,
|
|
36
42
|
}) => {
|
|
37
43
|
const {
|
|
38
44
|
name,
|
|
@@ -43,6 +49,8 @@ const CheckBoxView = ({
|
|
|
43
49
|
tooltip,
|
|
44
50
|
label,
|
|
45
51
|
} = checkboxItem;
|
|
52
|
+
const query = new URLSearchParams(useLocation().search);
|
|
53
|
+
const navigate = useNavigate();
|
|
46
54
|
const indexType = index % 2 === 0 ? 'Even' : 'Odd';
|
|
47
55
|
const checkedSection = `${section}`.toLowerCase().replace(' ', '_');
|
|
48
56
|
|
|
@@ -54,6 +62,28 @@ const CheckBoxView = ({
|
|
|
54
62
|
datafield: datafield,
|
|
55
63
|
isChecked: !isChecked,
|
|
56
64
|
};
|
|
65
|
+
const checkedValues = query.get(datafield);
|
|
66
|
+
const paramValue = {};
|
|
67
|
+
if (toggleCheckBoxItem.isChecked) {
|
|
68
|
+
if (checkedValues) {
|
|
69
|
+
const newValues = checkedValues.split('|');
|
|
70
|
+
newValues.push(name);
|
|
71
|
+
paramValue[datafield] = newValues.join('|');
|
|
72
|
+
} else {
|
|
73
|
+
paramValue[datafield] = name;
|
|
74
|
+
}
|
|
75
|
+
} else if (checkedValues) {
|
|
76
|
+
const newValues = checkedValues.split('|');
|
|
77
|
+
const idx = newValues.indexOf(name);
|
|
78
|
+
if (idx > -1) {
|
|
79
|
+
newValues.splice(idx, 1);
|
|
80
|
+
}
|
|
81
|
+
paramValue[datafield] = newValues.length > 0 ? newValues.join('|') : '';
|
|
82
|
+
} else {
|
|
83
|
+
paramValue[datafield] = '';
|
|
84
|
+
}
|
|
85
|
+
const queryStr = generateQueryStr(query, queryParams, paramValue);
|
|
86
|
+
navigate(`/explore${queryStr}`);
|
|
57
87
|
onToggle(toggleCheckBoxItem);
|
|
58
88
|
};
|
|
59
89
|
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
/* eslint-disable object-shorthand */
|
|
7
7
|
/* eslint-disable react/jsx-one-expression-per-line */
|
|
8
8
|
import React from 'react';
|
|
9
|
+
import {
|
|
10
|
+
useLocation,
|
|
11
|
+
useNavigate,
|
|
12
|
+
} from 'react-router-dom';
|
|
13
|
+
import { generateQueryStr } from '@bento-core/util';
|
|
9
14
|
import { withStyles } from '@material-ui/core/styles';
|
|
10
15
|
import {
|
|
11
16
|
Checkbox,
|
|
@@ -33,6 +38,7 @@ const CheckBoxView = ({
|
|
|
33
38
|
datafield,
|
|
34
39
|
onToggle,
|
|
35
40
|
facet,
|
|
41
|
+
queryParams,
|
|
36
42
|
}) => {
|
|
37
43
|
const {
|
|
38
44
|
name,
|
|
@@ -43,6 +49,8 @@ const CheckBoxView = ({
|
|
|
43
49
|
tooltip,
|
|
44
50
|
label,
|
|
45
51
|
} = checkboxItem;
|
|
52
|
+
const query = new URLSearchParams(useLocation().search);
|
|
53
|
+
const navigate = useNavigate();
|
|
46
54
|
const indexType = index % 2 === 0 ? 'Even' : 'Odd';
|
|
47
55
|
const checkedSection = `${section}`.toLowerCase().replace(' ', '_');
|
|
48
56
|
|
|
@@ -54,6 +62,28 @@ const CheckBoxView = ({
|
|
|
54
62
|
datafield: datafield,
|
|
55
63
|
isChecked: !isChecked,
|
|
56
64
|
};
|
|
65
|
+
const checkedValues = query.get(datafield);
|
|
66
|
+
const paramValue = {};
|
|
67
|
+
if (toggleCheckBoxItem.isChecked) {
|
|
68
|
+
if (checkedValues) {
|
|
69
|
+
const newValues = checkedValues.split('|');
|
|
70
|
+
newValues.push(name);
|
|
71
|
+
paramValue[datafield] = newValues.join('|');
|
|
72
|
+
} else {
|
|
73
|
+
paramValue[datafield] = name;
|
|
74
|
+
}
|
|
75
|
+
} else if (checkedValues) {
|
|
76
|
+
const newValues = checkedValues.split('|');
|
|
77
|
+
const idx = newValues.indexOf(name);
|
|
78
|
+
if (idx > -1) {
|
|
79
|
+
newValues.splice(idx, 1);
|
|
80
|
+
}
|
|
81
|
+
paramValue[datafield] = newValues.length > 0 ? newValues.join('|') : '';
|
|
82
|
+
} else {
|
|
83
|
+
paramValue[datafield] = '';
|
|
84
|
+
}
|
|
85
|
+
const queryStr = generateQueryStr(query, queryParams, paramValue);
|
|
86
|
+
navigate(`/explore${queryStr}`);
|
|
57
87
|
onToggle(toggleCheckBoxItem);
|
|
58
88
|
};
|
|
59
89
|
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
/* eslint-disable react/jsx-indent */
|
|
4
4
|
/* eslint-disable object-curly-newline */
|
|
5
5
|
import React, { useEffect, useState } from 'react';
|
|
6
|
+
import {
|
|
7
|
+
useLocation,
|
|
8
|
+
useNavigate,
|
|
9
|
+
} from 'react-router-dom';
|
|
10
|
+
import { generateQueryStr } from '@bento-core/util';
|
|
6
11
|
import { withStyles, Slider, Typography, Box } from '@material-ui/core';
|
|
7
12
|
// import styles from './SliderStyle';
|
|
8
13
|
import { silderTypes } from '../Types';
|
|
@@ -13,10 +18,13 @@ const SliderView = ({
|
|
|
13
18
|
facet,
|
|
14
19
|
onSliderToggle,
|
|
15
20
|
filterState,
|
|
21
|
+
queryParams,
|
|
16
22
|
}) => {
|
|
17
23
|
const { minLowerBound, maxUpperBound, quantifier, datafield, facetValues } = facet;
|
|
18
24
|
const lowerBoundValue = facetValues[0];
|
|
19
25
|
const upperBoundValue = facetValues[1];
|
|
26
|
+
const query = new URLSearchParams(useLocation().search);
|
|
27
|
+
const navigate = useNavigate();
|
|
20
28
|
|
|
21
29
|
// Determines whether the lower bound and upper bound values are valid
|
|
22
30
|
const isValid = () => {
|
|
@@ -30,6 +38,10 @@ const SliderView = ({
|
|
|
30
38
|
};
|
|
31
39
|
const handleChangeCommittedSlider = (value) => {
|
|
32
40
|
if (!value.includes('')) {
|
|
41
|
+
const paramValue = {};
|
|
42
|
+
paramValue[datafield] = value;
|
|
43
|
+
const queryStr = generateQueryStr(query, queryParams, paramValue);
|
|
44
|
+
navigate(`/explore${queryStr}`);
|
|
33
45
|
onSliderToggle({ sliderValue: value, ...facet });
|
|
34
46
|
}
|
|
35
47
|
};
|
package/src/index.js
CHANGED
|
@@ -130,6 +130,11 @@ export function sideBarReducerGenerator() {
|
|
|
130
130
|
...state,
|
|
131
131
|
sortState: { ...updateState },
|
|
132
132
|
};
|
|
133
|
+
case sideBarActionTypes.UPDATE_FILTER_STATE:
|
|
134
|
+
return {
|
|
135
|
+
...state,
|
|
136
|
+
filterState: payload,
|
|
137
|
+
};
|
|
133
138
|
default:
|
|
134
139
|
return state;
|
|
135
140
|
}
|