@bento-core/facet-filter 1.0.1-icdc.11 → 1.0.1-icdc.13

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/README.md CHANGED
@@ -54,6 +54,8 @@ import FacetFilter from 'bento-core';
54
54
  facetsConfig={facetsConfig}
55
55
  CustomFacetSection={CustomFacetSection}
56
56
  CustomFacetView={CustomFacetView}
57
+ enableClearSection // add additional clear button on facet Section
58
+ enableFacetCollapse // collapse facet Section when clear
57
59
  />
58
60
  </FacetFilterThemeProvider>
59
61
  ```
@@ -77,7 +79,9 @@ export const facetsConfig = [{
77
79
  label: 'Program',
78
80
  apiForFiltering: 'filterSubjectCountByProgram',
79
81
  datafield: 'programs',
80
- field: GROUP,
82
+ field: 'group', // field for label
83
+ count: 'subject' // field for count
84
+ customCount: (text) => `${text || 0}`, // custom count view add parentheses or change text as required
81
85
  type: InputTypes.CHECKBOX,
82
86
  sort_type: sortType.ALPHABET,
83
87
  show: true,
@@ -144,6 +148,8 @@ const CustomFacetSection = ({ section }) => {
144
148
  facetsConfig={facetsConfig}
145
149
  CustomFacetSection={CustomFacetSection}
146
150
  CustomFacetView={CustomFacetView}
151
+ enableClearSection // add additional clear button on facet Section
152
+ enableFacetCollapse // collapse facet Section when clear
147
153
  />
148
154
  ```
149
155
 
@@ -169,6 +175,8 @@ const CustomFacetView = ({ facet, facetClasses }) => {
169
175
  facetsConfig={facetsConfig}
170
176
  CustomFacetSection={CustomFacetSection}
171
177
  CustomFacetView={CustomFacetView}
178
+ enableClearSection // add additional clear button on facet Section
179
+ enableFacetCollapse // collapse facet Section when clear
172
180
  />
173
181
  ```
174
182
 
@@ -18,7 +18,9 @@ const BentoFacetFilter = _ref => {
18
18
  sideBarSections,
19
19
  CustomFacetSection,
20
20
  CustomFacetView,
21
- clearIcon
21
+ clearIcon,
22
+ enableClearSection,
23
+ enableFacetCollapse
22
24
  } = _ref;
23
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, {
24
26
  variant: "middle",
@@ -29,6 +31,8 @@ const BentoFacetFilter = _ref => {
29
31
  }, section.items.map(facet => /*#__PURE__*/_react.default.createElement(_ReduxFacetView.default, {
30
32
  facet: facet,
31
33
  CustomView: CustomFacetView,
34
+ enableClearSection: enableClearSection,
35
+ enableFacetCollapse: enableFacetCollapse,
32
36
  clearIcon: clearIcon
33
37
  }))))));
34
38
  };
@@ -7,12 +7,15 @@ exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _core = require("@material-ui/core");
9
9
  var _clsx = _interopRequireDefault(require("clsx"));
10
+ var _Refresh = _interopRequireDefault(require("@material-ui/icons/Refresh"));
11
+ var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
10
12
  var _AccordionSummaryView = _interopRequireDefault(require("../summary/AccordionSummaryView"));
11
13
  var _Types = require("../inputs/Types");
12
14
  var _FacetStyle = _interopRequireDefault(require("./FacetStyle"));
13
15
  var _FilterItems = _interopRequireDefault(require("../inputs/FilterItems"));
14
16
  var _Sort = require("../../utils/Sort");
15
17
  var _clearIcon = _interopRequireDefault(require("./assets/clearIcon.svg"));
18
+ var _ActionTypes = require("../../store/actions/ActionTypes");
16
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
21
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -25,19 +28,51 @@ const FacetView = _ref => {
25
28
  let {
26
29
  classes,
27
30
  facet,
31
+ enableClearSection,
28
32
  onClearFacetSection,
29
33
  onClearSliderSection,
30
34
  CustomView,
31
35
  autoComplete,
32
36
  upload,
33
- clearIcon
37
+ clearIcon,
38
+ filterState,
39
+ currentActionType = {},
40
+ enableFacetCollapse
34
41
  } = _ref;
35
42
  const [expand, setExpand] = (0, _react.useState)(false);
36
43
  const onExpandFacet = () => setExpand(!expand);
44
+ const {
45
+ datafield
46
+ } = facet;
47
+ /**
48
+ * Collapse expanded facet or facets
49
+ * 1. on clear facet section
50
+ * 2. on clear all
51
+ * 3. on uncheck facet from DQB
52
+ */
53
+ (0, _react.useEffect)(() => {
54
+ if (enableFacetCollapse) {
55
+ const actionType = currentActionType[datafield];
56
+ // collapse facet if uncheck from DQB
57
+ if (actionType && actionType === _ActionTypes.sideBarActionTypes.FACET_VALUE_CHANGED) {
58
+ const {
59
+ isFacetOrigin
60
+ } = currentActionType;
61
+ if (!isFacetOrigin) {
62
+ if (Object.keys(filterState[datafield] || {}).length === 0) {
63
+ setExpand(false);
64
+ }
65
+ }
66
+ }
67
+ if (actionType && actionType === _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION || currentActionType === _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS) {
68
+ setExpand(false);
69
+ }
70
+ }
71
+ }, [filterState]);
37
72
 
38
73
  /**
39
- * expand section incase of active local search
40
- */
74
+ * expand section incase of active local search
75
+ */
41
76
  (0, _react.useEffect)(() => {
42
77
  if (autoComplete && autoComplete.length > 0 || upload && upload.length > 0) {
43
78
  setExpand(true);
@@ -49,10 +84,13 @@ const FacetView = _ref => {
49
84
  };
50
85
  const onClearSection = () => {
51
86
  setSortBy(null);
52
- if (facet.type === _Types.InputTypes.SLIDER) {
53
- onClearSliderSection(facet);
54
- } else {
55
- onClearFacetSection(facet);
87
+ const activeFilterItems = filterState[datafield];
88
+ if (activeFilterItems && Object.keys(activeFilterItems).length > 0) {
89
+ if (facet.type === _Types.InputTypes.SLIDER) {
90
+ onClearSliderSection(facet);
91
+ } else {
92
+ onClearFacetSection(facet);
93
+ }
56
94
  }
57
95
  };
58
96
  /**
@@ -76,14 +114,25 @@ const FacetView = _ref => {
76
114
  },
77
115
  id: facet.section
78
116
  }, CustomView ? /*#__PURE__*/_react.default.createElement(CustomView, {
117
+ clearFacetSectionValues: onClearSection,
118
+ hasSelections: selectedItems.length > 0,
79
119
  facet: facet,
80
120
  facetClasses: isActiveFacet ? "activeFacet".concat(facet.section) : "inactiveFacet".concat(facet.section)
81
- }) : /*#__PURE__*/_react.default.createElement(_AccordionSummaryView.default, null, /*#__PURE__*/_react.default.createElement("div", {
121
+ }) : /*#__PURE__*/_react.default.createElement(_AccordionSummaryView.default, null, !enableClearSection ? /*#__PURE__*/_react.default.createElement("div", {
122
+ id: "filterGroup_ ".concat(facet.datafield, "\n ").concat(facet.label),
123
+ className: (0, _clsx.default)(classes.subSectionSummaryText, {
124
+ ["activeFacet".concat(facet.section)]: isActiveFacet
125
+ })
126
+ }, facet.label) : /*#__PURE__*/_react.default.createElement("div", {
127
+ className: classes.subSectionSummaryTextWrapper
128
+ }, /*#__PURE__*/_react.default.createElement("div", {
82
129
  id: "filterGroup_ ".concat(facet.datafield, "\n ").concat(facet.label),
83
130
  className: (0, _clsx.default)(classes.subSectionSummaryText, {
84
131
  ["activeFacet".concat(facet.section)]: isActiveFacet
85
132
  })
86
- }, facet.label)), (facet.type === _Types.InputTypes.SLIDER || facetValues.length === 0) && /*#__PURE__*/_react.default.createElement("div", {
133
+ }, facet.label), selectedItems.length ? /*#__PURE__*/_react.default.createElement(_IconButton.default, {
134
+ onClick: onClearSection
135
+ }, /*#__PURE__*/_react.default.createElement(_Refresh.default, null)) : null)), (facet.type === _Types.InputTypes.SLIDER || facetValues.length === 0) && /*#__PURE__*/_react.default.createElement("div", {
87
136
  className: classes.NonSortGroup
88
137
  }, /*#__PURE__*/_react.default.createElement("span", {
89
138
  className: classes.NonSortGroupItem
@@ -14,11 +14,13 @@ const mapStateToProps = state => {
14
14
  var _state$localFind, _state$localFind2;
15
15
  return {
16
16
  filterState: state.statusReducer.filterState,
17
+ currentActionType: state.statusReducer.currentActionType,
17
18
  autoComplete: (state === null || state === void 0 ? void 0 : (_state$localFind = state.localFind) === null || _state$localFind === void 0 ? void 0 : _state$localFind.autocomplete) || [],
18
19
  upload: (state === null || state === void 0 ? void 0 : (_state$localFind2 = state.localFind) === null || _state$localFind2 === void 0 ? void 0 : _state$localFind2.upload) || []
19
20
  };
20
21
  };
21
22
  const mapDispatchToProps = dispatch => ({
23
+ onToggle: facet => dispatch((0, _Actions.toggleCheckBox)(facet)),
22
24
  onClearFacetSection: facet => {
23
25
  dispatch((0, _Actions.clearFacetSection)(facet));
24
26
  },
@@ -10,14 +10,8 @@ var _core = require("@material-ui/core");
10
10
  var _clsx = _interopRequireDefault(require("clsx"));
11
11
  var _icons = require("@material-ui/icons");
12
12
  var _CheckboxStyle = _interopRequireDefault(require("./CheckboxStyle"));
13
+ var _ActionTypes = require("../../../store/actions/ActionTypes");
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- /* eslint-disable no-unused-vars */
15
- /* eslint-disable no-unused-vars */
16
- /* eslint-disable react/jsx-wrap-multilines */
17
- /* eslint-disable react/jsx-indent */
18
- /* eslint-disable object-curly-newline */
19
- /* eslint-disable object-shorthand */
20
- /* eslint-disable react/jsx-one-expression-per-line */
21
15
  /* eslint-disable no-useless-escape */
22
16
 
23
17
  const CheckBoxView = _ref => {
@@ -44,9 +38,13 @@ const CheckBoxView = _ref => {
44
38
  const name = checkboxItem[field] || 'N/A';
45
39
  const handleToggle = () => {
46
40
  const toggleCheckBoxItem = {
47
- name: name,
48
- datafield: datafield,
49
- isChecked: !isChecked
41
+ name,
42
+ datafield,
43
+ isChecked: !isChecked,
44
+ actionType: {
45
+ [datafield]: _ActionTypes.sideBarActionTypes.FACET_VALUE_CHANGED,
46
+ isFacetOrigin: true
47
+ }
50
48
  };
51
49
  onToggle(toggleCheckBoxItem);
52
50
  };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _core = require("@material-ui/core");
9
+ var _clsx = _interopRequireDefault(require("clsx"));
9
10
  var _SliderStyle = _interopRequireDefault(require("./SliderStyle"));
10
11
  var _Types = require("../Types");
11
12
  var _InputMinMaxView = _interopRequireDefault(require("./InputMinMaxView"));
@@ -63,9 +64,9 @@ const SliderView = _ref => {
63
64
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
64
65
  className: classes.sliderRoot
65
66
  }, /*#__PURE__*/_react.default.createElement("div", {
66
- className: classes.minMaxInputs
67
+ className: (0, _clsx.default)(classes.minMaxInputs, 'minMaxInputs')
67
68
  }, /*#__PURE__*/_react.default.createElement("div", {
68
- className: classes.minValue
69
+ className: (0, _clsx.default)(classes.minValue, 'min_input_box')
69
70
  }, /*#__PURE__*/_react.default.createElement(_core.Typography, {
70
71
  className: classes.minInputLabel
71
72
  }, "Min:"), /*#__PURE__*/_react.default.createElement(_InputMinMaxView.default, {
@@ -76,7 +77,7 @@ const SliderView = _ref => {
76
77
  type: _Types.silderTypes.INPUT_MIN,
77
78
  onInputChange: handleChangeCommittedSlider
78
79
  })), /*#__PURE__*/_react.default.createElement("div", {
79
- className: classes.maxValue
80
+ className: (0, _clsx.default)(classes.maxValue, 'max_input_box')
80
81
  }, /*#__PURE__*/_react.default.createElement(_core.Typography, {
81
82
  className: classes.maxInputLabel
82
83
  }, "Max:"), /*#__PURE__*/_react.default.createElement(_InputMinMaxView.default, {
@@ -87,7 +88,7 @@ const SliderView = _ref => {
87
88
  type: _Types.silderTypes.INPUT_MAX,
88
89
  onInputChange: handleChangeCommittedSlider
89
90
  }))), /*#__PURE__*/_react.default.createElement("div", {
90
- className: classes.slider
91
+ className: (0, _clsx.default)(classes.slider, 'slider')
91
92
  }, /*#__PURE__*/_react.default.createElement(_core.Slider, {
92
93
  disableSwap: true,
93
94
  getAriaValueText: valuetext,
@@ -11,6 +11,7 @@ var _AccordionSummaryStyle = _interopRequireDefault(require("./AccordionSummaryS
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
  const Summary = (0, _core.withStyles)({
13
13
  root: {
14
+ width: '307px',
14
15
  marginBottom: -1,
15
16
  minHeight: 48,
16
17
  paddingLeft: 14,
package/dist/index.js CHANGED
@@ -81,6 +81,12 @@ Object.defineProperty(exports, "onToggleStateUpdate", {
81
81
  return _SideBarReducer.onToggleStateUpdate;
82
82
  }
83
83
  });
84
+ Object.defineProperty(exports, "sideBarActionTypes", {
85
+ enumerable: true,
86
+ get: function get() {
87
+ return _ActionTypes.sideBarActionTypes;
88
+ }
89
+ });
84
90
  Object.defineProperty(exports, "sideBarReducerGenerator", {
85
91
  enumerable: true,
86
92
  get: function get() {
@@ -129,6 +135,7 @@ var _filter = require("./utils/filter");
129
135
  var _Types = require("./components/inputs/Types");
130
136
  var _SideBarReducer = require("./store/reducers/SideBarReducer");
131
137
  var _Actions = require("./store/actions/Actions");
138
+ var _ActionTypes = require("./store/actions/ActionTypes");
132
139
  var _component = require("./generator/component");
133
140
  var _ReduxClearAllBtn = _interopRequireDefault(require("./components/reset/ReduxClearAllBtn"));
134
141
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -44,7 +44,10 @@ const onClearFacetSection = _ref2 => {
44
44
  if (updatedState[datafield]) {
45
45
  updatedState[datafield] = {};
46
46
  }
47
- return updatedState;
47
+ return {
48
+ updatedState,
49
+ datafield
50
+ };
48
51
  };
49
52
  exports.onClearFacetSection = onClearFacetSection;
50
53
  const onClearSliderSection = _ref3 => {
@@ -87,31 +90,47 @@ function sideBarReducerGenerator() {
87
90
  switch (type) {
88
91
  case _ActionTypes.sideBarActionTypes.FACET_VALUE_CHANGED:
89
92
  updateState = onToggleStateUpdate(_objectSpread(_objectSpread({}, state), payload));
93
+ const {
94
+ actionType = _ActionTypes.sideBarActionTypes.FACET_VALUE_CHANGED
95
+ } = payload;
90
96
  return _objectSpread(_objectSpread({}, state), {}, {
91
- filterState: _objectSpread({}, updateState)
97
+ filterState: _objectSpread({}, updateState),
98
+ currentActionType: actionType
92
99
  });
93
100
  case _ActionTypes.sideBarActionTypes.ON_TOGGLE_SLIDER:
94
101
  updateState = updateSiderValue(_objectSpread(_objectSpread({}, state), payload));
95
102
  return _objectSpread(_objectSpread({}, state), {}, {
96
- filterState: _objectSpread({}, updateState)
103
+ filterState: _objectSpread({}, updateState),
104
+ currentActionType: _ActionTypes.sideBarActionTypes.ON_TOGGLE_SLIDER
97
105
  });
98
106
  case _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS:
99
107
  return _objectSpread(_objectSpread({}, state), {}, {
100
- filterState: {}
108
+ filterState: {},
109
+ currentActionType: _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS
101
110
  });
102
111
  case _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION:
103
- updateState = onClearFacetSection(_objectSpread(_objectSpread({}, payload), state));
112
+ const {
113
+ updatedState: updtState,
114
+ datafield
115
+ } = onClearFacetSection(_objectSpread(_objectSpread({}, payload), state));
116
+ updateState = updtState;
117
+ const currentActionType = {
118
+ [datafield]: _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION
119
+ };
104
120
  return _objectSpread(_objectSpread({}, state), {}, {
105
- filterState: _objectSpread({}, updateState)
121
+ filterState: _objectSpread({}, updateState),
122
+ currentActionType
106
123
  });
107
124
  case _ActionTypes.sideBarActionTypes.CLEAR_SLIDER_SECTION:
108
125
  updateState = onClearSliderSection(_objectSpread(_objectSpread({}, payload), state));
109
126
  return _objectSpread(_objectSpread({}, state), {}, {
110
- filterState: _objectSpread({}, updateState)
127
+ filterState: _objectSpread({}, updateState),
128
+ currentActionType: _ActionTypes.sideBarActionTypes.CLEAR_SLIDER_SECTION
111
129
  });
112
130
  case _ActionTypes.sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE:
113
131
  return {
114
- filterState: payload
132
+ filterState: payload,
133
+ currentActionType: _ActionTypes.sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE
115
134
  };
116
135
  default:
117
136
  return state;
@@ -47,7 +47,7 @@ const sortBySection = _ref => {
47
47
  facetValues,
48
48
  sort_type,
49
49
  sortBy,
50
- field,
50
+ field = 'group',
51
51
  count = 'subjects'
52
52
  } = _ref;
53
53
  const sortfacetValues = [...facetValues];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/facet-filter",
3
- "version": "1.0.1-icdc.11",
3
+ "version": "1.0.1-icdc.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -14,31 +14,30 @@ const BentoFacetFilter = ({
14
14
  CustomFacetSection,
15
15
  CustomFacetView,
16
16
  clearIcon,
17
+ enableClearSection,
18
+ enableFacetCollapse,
17
19
  }) => {
18
20
  return (
19
21
  <>
20
- {
21
- sideBarSections.map((section, index) => (
22
- <>
23
- <Divider
24
- variant="middle"
25
- className={`divider${index}`}
26
- />
27
- <FacetSectionView
28
- section={section}
29
- CustomSection={CustomFacetSection}
30
- >
31
- {section.items.map((facet) => (
32
- <FacetView
33
- facet={facet}
34
- CustomView={CustomFacetView}
35
- clearIcon={clearIcon}
36
- />
37
- ))}
38
- </FacetSectionView>
39
- </>
40
- ))
41
- }
22
+ {sideBarSections.map((section, index) => (
23
+ <>
24
+ <Divider variant="middle" className={`divider${index}`} />
25
+ <FacetSectionView
26
+ section={section}
27
+ CustomSection={CustomFacetSection}
28
+ >
29
+ {section.items.map((facet) => (
30
+ <FacetView
31
+ facet={facet}
32
+ CustomView={CustomFacetView}
33
+ enableClearSection={enableClearSection}
34
+ enableFacetCollapse={enableFacetCollapse}
35
+ clearIcon={clearIcon}
36
+ />
37
+ ))}
38
+ </FacetSectionView>
39
+ </>
40
+ ))}
42
41
  </>
43
42
  );
44
43
  };
@@ -1,37 +1,69 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import {
3
- Accordion,
4
- List,
5
- withStyles,
6
- Icon,
3
+ Accordion, List, withStyles, Icon,
7
4
  } from '@material-ui/core';
8
5
  import clsx from 'clsx';
6
+ import RefreshIcon from '@material-ui/icons/Refresh';
7
+ import IconButton from '@material-ui/core/IconButton';
9
8
  import CustomAccordionSummary from '../summary/AccordionSummaryView';
10
9
  import { InputTypes } from '../inputs/Types';
11
10
  import styles from './FacetStyle';
12
11
  import FilterItems from '../inputs/FilterItems';
13
12
  import { sortType } from '../../utils/Sort';
14
13
  import clearIconLocal from './assets/clearIcon.svg';
14
+ import { sideBarActionTypes } from '../../store/actions/ActionTypes';
15
15
 
16
16
  const FacetView = ({
17
17
  classes,
18
18
  facet,
19
+ enableClearSection,
19
20
  onClearFacetSection,
20
21
  onClearSliderSection,
21
22
  CustomView,
22
23
  autoComplete,
23
24
  upload,
24
25
  clearIcon,
26
+ filterState,
27
+ currentActionType = {},
28
+ enableFacetCollapse,
25
29
  }) => {
26
30
  const [expand, setExpand] = useState(false);
27
31
  const onExpandFacet = () => setExpand(!expand);
28
32
 
33
+ const { datafield } = facet;
29
34
  /**
30
- * expand section incase of active local search
31
- */
35
+ * Collapse expanded facet or facets
36
+ * 1. on clear facet section
37
+ * 2. on clear all
38
+ * 3. on uncheck facet from DQB
39
+ */
40
+ useEffect(() => {
41
+ if (enableFacetCollapse) {
42
+ const actionType = currentActionType[datafield];
43
+ // collapse facet if uncheck from DQB
44
+ if (actionType && actionType === sideBarActionTypes.FACET_VALUE_CHANGED) {
45
+ const { isFacetOrigin } = currentActionType;
46
+ if (!isFacetOrigin) {
47
+ if (Object.keys(filterState[datafield] || {}).length === 0) {
48
+ setExpand(false);
49
+ }
50
+ }
51
+ }
52
+ if ((actionType && actionType === sideBarActionTypes.CLEAR_FACET_SECTION)
53
+ || currentActionType === sideBarActionTypes.CLEAR_ALL_FILTERS) {
54
+ setExpand(false);
55
+ }
56
+ }
57
+ }, [filterState]);
58
+
59
+ /**
60
+ * expand section incase of active local search
61
+ */
32
62
  useEffect(() => {
33
- if ((autoComplete && autoComplete.length > 0)
34
- || (upload && upload.length > 0)) {
63
+ if (
64
+ (autoComplete && autoComplete.length > 0)
65
+ || (upload && upload.length > 0)
66
+ ) {
35
67
  setExpand(true);
36
68
  }
37
69
  }, [autoComplete, upload]);
@@ -43,10 +75,13 @@ const FacetView = ({
43
75
 
44
76
  const onClearSection = () => {
45
77
  setSortBy(null);
46
- if (facet.type === InputTypes.SLIDER) {
47
- onClearSliderSection(facet);
48
- } else {
49
- onClearFacetSection(facet);
78
+ const activeFilterItems = filterState[datafield];
79
+ if (activeFilterItems && Object.keys(activeFilterItems).length > 0) {
80
+ if (facet.type === InputTypes.SLIDER) {
81
+ onClearSliderSection(facet);
82
+ } else {
83
+ onClearFacetSection(facet);
84
+ }
50
85
  }
51
86
  };
52
87
  /**
@@ -58,6 +93,7 @@ const FacetView = ({
58
93
  displayFacet.facetValues = selectedItems;
59
94
  const isActiveFacet = [...selectedItems].length > 0;
60
95
  const limitCheckBoxCount = facet?.showCheckboxCount || 5;
96
+
61
97
  return (
62
98
  <>
63
99
  <Accordion
@@ -69,41 +105,56 @@ const FacetView = ({
69
105
  }}
70
106
  id={facet.section}
71
107
  >
72
- { CustomView ? (
108
+ {CustomView ? (
73
109
  <CustomView
110
+ clearFacetSectionValues={onClearSection}
111
+ hasSelections={selectedItems.length > 0}
74
112
  facet={facet}
75
113
  facetClasses={
76
- isActiveFacet ? `activeFacet${facet.section}`
77
- : `inactiveFacet${facet.section}`
114
+ isActiveFacet
115
+ ? `activeFacet${facet.section}`
116
+ : `inactiveFacet${facet.section}`
78
117
  }
79
118
  />
80
119
  ) : (
81
120
  <CustomAccordionSummary>
82
- <div
83
- id={
84
- `filterGroup_ ${facet.datafield}
85
- ${facet.label}`
86
- }
87
- className={clsx(classes.subSectionSummaryText, {
88
- [`activeFacet${facet.section}`]: isActiveFacet,
89
- })}
90
- >
91
- {facet.label}
92
- </div>
121
+ {!enableClearSection ? (
122
+ <div
123
+ id={`filterGroup_ ${facet.datafield}
124
+ ${facet.label}`}
125
+ className={clsx(classes.subSectionSummaryText, {
126
+ [`activeFacet${facet.section}`]: isActiveFacet,
127
+ })}
128
+ >
129
+ {facet.label}
130
+ </div>
131
+ ) : (
132
+ <div className={classes.subSectionSummaryTextWrapper}>
133
+ <div
134
+ id={`filterGroup_ ${facet.datafield}
135
+ ${facet.label}`}
136
+ className={clsx(classes.subSectionSummaryText, {
137
+ [`activeFacet${facet.section}`]: isActiveFacet,
138
+ })}
139
+ >
140
+ {facet.label}
141
+ </div>
142
+ {selectedItems.length ? (
143
+ <IconButton onClick={onClearSection}>
144
+ <RefreshIcon />
145
+ </IconButton>
146
+ ) : null}
147
+ </div>
148
+ )}
93
149
  </CustomAccordionSummary>
94
150
  )}
95
- {
96
- (facet.type === InputTypes.SLIDER || facetValues.length === 0)
97
- && (
151
+ {(facet.type === InputTypes.SLIDER || facetValues.length === 0) && (
98
152
  <div className={classes.NonSortGroup}>
99
- <span
100
- className={classes.NonSortGroupItem}
101
- >
153
+ <span className={classes.NonSortGroupItem}>
102
154
  No data for this field
103
155
  </span>
104
156
  </div>
105
- )
106
- }
157
+ )}
107
158
  {
108
159
  (facet.type === InputTypes.SLIDER || facetValues.length > 0)
109
160
  && (
@@ -1,19 +1,29 @@
1
1
  import React from 'react';
2
2
  import { connect } from 'react-redux';
3
- import { clearFacetSection, clearSliderSection } from '../../store/actions/Actions';
3
+ import {
4
+ clearFacetSection,
5
+ clearSliderSection,
6
+ toggleCheckBox,
7
+ } from '../../store/actions/Actions';
4
8
  import FacetView from './FacetView';
5
9
 
6
- const ReduxFacetView = ((props) => <FacetView {...props} />);
10
+ const ReduxFacetView = (props) => <FacetView {...props} />;
7
11
 
8
12
  const mapStateToProps = (state) => ({
9
13
  filterState: state.statusReducer.filterState,
14
+ currentActionType: state.statusReducer.currentActionType,
10
15
  autoComplete: state?.localFind?.autocomplete || [],
11
16
  upload: state?.localFind?.upload || [],
12
17
  });
13
18
 
14
19
  const mapDispatchToProps = (dispatch) => ({
15
- onClearFacetSection: (facet) => { dispatch(clearFacetSection(facet)); },
16
- onClearSliderSection: (facet) => { dispatch(clearSliderSection(facet)); },
20
+ onToggle: (facet) => dispatch(toggleCheckBox(facet)),
21
+ onClearFacetSection: (facet) => {
22
+ dispatch(clearFacetSection(facet));
23
+ },
24
+ onClearSliderSection: (facet) => {
25
+ dispatch(clearSliderSection(facet));
26
+ },
17
27
  });
18
28
 
19
29
  export default connect(mapStateToProps, mapDispatchToProps)(ReduxFacetView);
@@ -1,10 +1,3 @@
1
- /* eslint-disable no-unused-vars */
2
- /* eslint-disable no-unused-vars */
3
- /* eslint-disable react/jsx-wrap-multilines */
4
- /* eslint-disable react/jsx-indent */
5
- /* eslint-disable object-curly-newline */
6
- /* eslint-disable object-shorthand */
7
- /* eslint-disable react/jsx-one-expression-per-line */
8
1
  /* eslint-disable no-useless-escape */
9
2
 
10
3
  import React from 'react';
@@ -20,9 +13,11 @@ import {
20
13
  } from '@material-ui/core';
21
14
  import clsx from 'clsx';
22
15
  import {
23
- CheckBox as CheckBoxIcon, CheckBoxOutlineBlank as CheckBoxBlankIcon,
16
+ CheckBox as CheckBoxIcon,
17
+ CheckBoxOutlineBlank as CheckBoxBlankIcon,
24
18
  } from '@material-ui/icons';
25
19
  import styles from './CheckboxStyle';
20
+ import { sideBarActionTypes } from '../../../store/actions/ActionTypes';
26
21
 
27
22
  const CheckBoxView = ({
28
23
  classes,
@@ -50,9 +45,13 @@ const CheckBoxView = ({
50
45
 
51
46
  const handleToggle = () => {
52
47
  const toggleCheckBoxItem = {
53
- name: name,
54
- datafield: datafield,
48
+ name,
49
+ datafield,
55
50
  isChecked: !isChecked,
51
+ actionType: {
52
+ [datafield]: sideBarActionTypes.FACET_VALUE_CHANGED,
53
+ isFacetOrigin: true,
54
+ },
56
55
  };
57
56
  onToggle(toggleCheckBoxItem);
58
57
  };
@@ -65,9 +64,7 @@ const CheckBoxView = ({
65
64
  [`${checkedSection}NameChecked`]: isChecked,
66
65
  })}
67
66
  >
68
- <Typography className={classes.checkboxName}>
69
- {name}
70
- </Typography>
67
+ <Typography className={classes.checkboxName}>{name}</Typography>
71
68
  </Box>
72
69
  );
73
70
 
@@ -79,16 +76,18 @@ const CheckBoxView = ({
79
76
  alignItems="flex-start"
80
77
  onClick={handleToggle}
81
78
  classes={{ gutters: classes.listItemGutters }}
82
- className={clsx({ [`${checkedSection}Checked${indexType}`]: isChecked })}
79
+ className={clsx({
80
+ [`${checkedSection}Checked${indexType}`]: isChecked,
81
+ })}
83
82
  >
84
83
  <Checkbox
85
84
  id={`checkbox_${facet.label}_${name}`}
86
- icon={
85
+ icon={(
87
86
  <CheckBoxBlankIcon
88
87
  style={{ fontSize: 18 }}
89
88
  className={checkedSection}
90
89
  />
91
- }
90
+ )}
92
91
  onClick={handleToggle}
93
92
  checked={isChecked}
94
93
  checkedIcon={(
@@ -103,11 +102,9 @@ const CheckBoxView = ({
103
102
  color="secondary"
104
103
  classes={{ root: classes.checkboxRoot }}
105
104
  />
106
- { tooltip ? (
105
+ {tooltip ? (
107
106
  <Tooltip id={datafield} title={tooltip}>
108
- <div className={datafield}>
109
- {name}
110
- </div>
107
+ <div className={datafield}>{name}</div>
111
108
  </Tooltip>
112
109
  ) : (
113
110
  <LabelComponent />
@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
3
3
  import { toggleCheckBox } from '../../../store/actions/Actions';
4
4
  import CheckboxView from './CheckboxView';
5
5
 
6
- const ReduxCheckbox = ((props) => <CheckboxView {...props} />);
6
+ const ReduxCheckbox = (props) => <CheckboxView {...props} />;
7
7
 
8
8
  const mapStateToProps = (state) => ({
9
9
  filterState: state.statusReducer.filterState,
@@ -4,6 +4,7 @@
4
4
  /* eslint-disable object-curly-newline */
5
5
  import React, { useEffect, useState } from 'react';
6
6
  import { withStyles, Slider, Typography, Box } from '@material-ui/core';
7
+ import clsx from 'clsx';
7
8
  import styles from './SliderStyle';
8
9
  import { silderTypes } from '../Types';
9
10
  import InputMinMaxView from './InputMinMaxView';
@@ -53,8 +54,8 @@ const SliderView = ({
53
54
  return (
54
55
  <>
55
56
  <div className={classes.sliderRoot}>
56
- <div className={classes.minMaxInputs}>
57
- <div className={classes.minValue}>
57
+ <div className={clsx(classes.minMaxInputs, 'minMaxInputs')}>
58
+ <div className={clsx(classes.minValue, 'min_input_box')}>
58
59
  <Typography className={classes.minInputLabel}>
59
60
  Min:
60
61
  </Typography>
@@ -67,7 +68,7 @@ const SliderView = ({
67
68
  onInputChange={handleChangeCommittedSlider}
68
69
  />
69
70
  </div>
70
- <div className={classes.maxValue}>
71
+ <div className={clsx(classes.maxValue, 'max_input_box')}>
71
72
  <Typography className={classes.maxInputLabel}>
72
73
  Max:
73
74
  </Typography>
@@ -81,7 +82,7 @@ const SliderView = ({
81
82
  />
82
83
  </div>
83
84
  </div>
84
- <div className={classes.slider}>
85
+ <div className={clsx(classes.slider, 'slider')}>
85
86
  {/* Change to red if invalid range */}
86
87
  <Slider
87
88
  disableSwap
@@ -1,15 +1,11 @@
1
1
  import React from 'react';
2
- import {
3
- AccordionSummary,
4
- withStyles,
5
- } from '@material-ui/core';
6
- import {
7
- ExpandMore as ExpandMoreIcon,
8
- } from '@material-ui/icons';
2
+ import { AccordionSummary, withStyles } from '@material-ui/core';
3
+ import { ExpandMore as ExpandMoreIcon } from '@material-ui/icons';
9
4
  import style from './AccordionSummaryStyle';
10
5
 
11
6
  const Summary = withStyles({
12
7
  root: {
8
+ width: '307px',
13
9
  marginBottom: -1,
14
10
  minHeight: 48,
15
11
  paddingLeft: 14,
@@ -27,10 +23,7 @@ const Summary = withStyles({
27
23
  expanded: {},
28
24
  })(AccordionSummary);
29
25
 
30
- const CustomAccordionSummary = ({
31
- children,
32
- classes,
33
- }) => (
26
+ const CustomAccordionSummary = ({ children, classes }) => (
34
27
  <Summary
35
28
  expandIcon={(
36
29
  <ExpandMoreIcon
package/src/index.js CHANGED
@@ -23,6 +23,9 @@ export {
23
23
  clearSliderSection,
24
24
  clearAllAndSelectFacet,
25
25
  } from './store/actions/Actions';
26
+ export {
27
+ sideBarActionTypes,
28
+ } from './store/actions/ActionTypes';
26
29
  export {
27
30
  generateFacetSectionView,
28
31
  } from './generator/component';
@@ -30,7 +30,7 @@ export const onClearFacetSection = ({
30
30
  if (updatedState[datafield]) {
31
31
  updatedState[datafield] = {};
32
32
  }
33
- return updatedState;
33
+ return { updatedState, datafield };
34
34
  };
35
35
 
36
36
  export const onClearSliderSection = ({
@@ -64,36 +64,48 @@ export function sideBarReducerGenerator() {
64
64
  switch (type) {
65
65
  case sideBarActionTypes.FACET_VALUE_CHANGED:
66
66
  updateState = onToggleStateUpdate({ ...state, ...payload });
67
+ const { actionType = sideBarActionTypes.FACET_VALUE_CHANGED } = payload;
67
68
  return {
68
69
  ...state,
69
70
  filterState: { ...updateState },
71
+ currentActionType: actionType,
70
72
  };
71
73
  case sideBarActionTypes.ON_TOGGLE_SLIDER:
72
74
  updateState = updateSiderValue({ ...state, ...payload });
73
75
  return {
74
76
  ...state,
75
77
  filterState: { ...updateState },
78
+ currentActionType: sideBarActionTypes.ON_TOGGLE_SLIDER,
76
79
  };
77
80
  case sideBarActionTypes.CLEAR_ALL_FILTERS:
78
81
  return {
79
82
  ...state,
80
83
  filterState: {},
84
+ currentActionType: sideBarActionTypes.CLEAR_ALL_FILTERS,
81
85
  };
82
86
  case sideBarActionTypes.CLEAR_FACET_SECTION:
83
- updateState = onClearFacetSection({ ...payload, ...state });
87
+ const {
88
+ updatedState: updtState,
89
+ datafield,
90
+ } = onClearFacetSection({ ...payload, ...state });
91
+ updateState = updtState;
92
+ const currentActionType = { [datafield]: sideBarActionTypes.CLEAR_FACET_SECTION };
84
93
  return {
85
94
  ...state,
86
95
  filterState: { ...updateState },
96
+ currentActionType,
87
97
  };
88
98
  case sideBarActionTypes.CLEAR_SLIDER_SECTION:
89
99
  updateState = onClearSliderSection({ ...payload, ...state });
90
100
  return {
91
101
  ...state,
92
102
  filterState: { ...updateState },
103
+ currentActionType: sideBarActionTypes.CLEAR_SLIDER_SECTION,
93
104
  };
94
105
  case sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE:
95
106
  return {
96
107
  filterState: payload,
108
+ currentActionType: sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE,
97
109
  };
98
110
  default:
99
111
  return state;
package/src/utils/Sort.js CHANGED
@@ -41,7 +41,7 @@ export const sortBySection = ({
41
41
  facetValues,
42
42
  sort_type,
43
43
  sortBy,
44
- field,
44
+ field = 'group',
45
45
  count = 'subjects',
46
46
  }) => {
47
47
  const sortfacetValues = [...facetValues];