@bento-core/facet-filter 1.0.1-icdc.9 → 1.0.1-ins.1

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
@@ -72,17 +72,12 @@ import FacetFilter from 'bento-core';
72
72
  ```
73
73
  import { InputTypes } from 'bento-core';
74
74
 
75
- // fields for labelds and counts
76
- const GROUP = 'group'; // access labels
77
- const COUNT = 'subjects'; // access count value
78
-
79
75
  export const facetsConfig = [{
80
76
  section: CASES,
81
77
  label: 'Program',
82
78
  apiForFiltering: 'filterSubjectCountByProgram',
83
79
  datafield: 'programs',
84
- field: GROUP,
85
- count: COUNT,
80
+ field: GROUP,
86
81
  type: InputTypes.CHECKBOX,
87
82
  sort_type: sortType.ALPHABET,
88
83
  show: true,
@@ -270,29 +265,11 @@ const CustomClearAllFiltersBtn = ({ onClearAllFilters, disable }) => {
270
265
  ```
271
266
  // response
272
267
  // filterCaseCountByProgram: [{group: "COP", subjects: 301}]
273
-
274
- // facet = {
275
- // section: CASES,
276
- // label: 'Program',
277
- // apiForFiltering: 'filterSubjectCountByProgram',
278
- // datafield: 'programs',
279
- // field: GROUP,
280
- // count: COUNT,
281
- // type: InputTypes.CHECKBOX,
282
- // sort_type: sortType.ALPHABET,
283
- // show: true,
284
- // customCount = (text) => `(${text})`,
285
- // }
286
-
287
- const {
288
- field = 'group',
289
- count = 'subjects',
290
- customCount = (text) => `(${text})`,
291
- } = facet;
292
268
  const {
293
- isChecked = false,
294
- index,
295
- section,
269
+ name,
270
+ customName,
271
+ subjects,
272
+ customSubjects,
296
273
  tooltip,
297
274
  } = checkboxItem;
298
275
 
@@ -17,9 +17,7 @@ const BentoFacetFilter = _ref => {
17
17
  let {
18
18
  sideBarSections,
19
19
  CustomFacetSection,
20
- CustomFacetView,
21
- enableClearSection,
22
- enableFacetCollapse
20
+ CustomFacetView
23
21
  } = _ref;
24
22
  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
23
  variant: "middle",
@@ -29,9 +27,7 @@ const BentoFacetFilter = _ref => {
29
27
  CustomSection: CustomFacetSection
30
28
  }, section.items.map(facet => /*#__PURE__*/_react.default.createElement(_ReduxFacetView.default, {
31
29
  facet: facet,
32
- CustomView: CustomFacetView,
33
- enableClearSection: enableClearSection,
34
- enableFacetCollapse: enableFacetCollapse
30
+ CustomView: CustomFacetView
35
31
  }))))));
36
32
  };
37
33
  var _default = (0, _core.withStyles)(_FacetFilterStyle.default)(BentoFacetFilter);
@@ -20,13 +20,6 @@ var _default = () => ({
20
20
  position: 'initial'
21
21
  }
22
22
  },
23
- subSectionSummaryTextWrapper: {
24
- display: 'flex',
25
- alignItems: 'center',
26
- justifyContent: 'space-between',
27
- width: '100%',
28
- paddingRight: '15px'
29
- },
30
23
  subSectionSummaryText: {
31
24
  marginLeft: '10px',
32
25
  lineHeight: 0,
@@ -41,26 +34,21 @@ var _default = () => ({
41
34
  marginBottom: '5px',
42
35
  borderTop: '1px solid #B1B1B1',
43
36
  textAlign: 'left',
44
- // marginLeft: '-5px',
45
- display: 'flex',
46
- alignItems: 'center',
47
- justifyContent: 'space-around'
37
+ marginLeft: '-5px'
48
38
  },
49
39
  sortGroupIcon: {
50
40
  cursor: 'pointer',
51
41
  fontFamily: 'Nunito',
52
- fontSize: '10px'
53
- // marginRight: '12px',
54
- // marginLeft: '16px',
42
+ fontSize: '10px',
43
+ marginRight: '12px',
44
+ marginLeft: '16px'
55
45
  },
56
-
57
46
  sortGroupItem: {
58
47
  cursor: 'pointer',
59
48
  fontFamily: 'Nunito',
60
- fontSize: '10px'
61
- // marginRight: '32px',
49
+ fontSize: '10px',
50
+ marginRight: '32px'
62
51
  },
63
-
64
52
  NonSortGroup: {
65
53
  marginBottom: '5px',
66
54
  borderTop: '1px solid #B1B1B1',
@@ -75,12 +63,11 @@ var _default = () => ({
75
63
  sortGroupItemCounts: {
76
64
  cursor: 'pointer',
77
65
  fontFamily: 'Nunito',
78
- fontSize: '10px'
79
- // float: 'right',
80
- // marginRight: '10px',
81
- // marginTop: '5px',
66
+ fontSize: '10px',
67
+ float: 'right',
68
+ marginRight: '10px',
69
+ marginTop: '5px'
82
70
  },
83
-
84
71
  highlight: {
85
72
  color: '#b2c6d6'
86
73
  },
@@ -7,15 +7,12 @@ 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"));
12
10
  var _AccordionSummaryView = _interopRequireDefault(require("../summary/AccordionSummaryView"));
13
11
  var _Types = require("../inputs/Types");
14
12
  var _FacetStyle = _interopRequireDefault(require("./FacetStyle"));
15
13
  var _FilterItems = _interopRequireDefault(require("../inputs/FilterItems"));
16
14
  var _Sort = require("../../utils/Sort");
17
15
  var _clearIcon = _interopRequireDefault(require("./assets/clearIcon.svg"));
18
- var _ActionTypes = require("../../store/actions/ActionTypes");
19
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
17
  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); }
21
18
  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; }
@@ -28,38 +25,18 @@ const FacetView = _ref => {
28
25
  let {
29
26
  classes,
30
27
  facet,
31
- enableClearSection,
32
28
  onClearFacetSection,
33
29
  onClearSliderSection,
34
30
  CustomView,
35
31
  autoComplete,
36
- upload,
37
- filterState,
38
- currentActionType = {},
39
- enableFacetCollapse
32
+ upload
40
33
  } = _ref;
41
- const [expand, setExpand] = (0, _react.useState)(false);
34
+ const [expand, setExpand] = (0, _react.useState)(true);
42
35
  const onExpandFacet = () => setExpand(!expand);
43
- const {
44
- datafield
45
- } = facet;
46
- /**
47
- * Collapse expanded facet or facets
48
- * 1. on clear facet section
49
- * 2. on clear all
50
- */
51
- (0, _react.useEffect)(() => {
52
- if (enableFacetCollapse) {
53
- const actionType = currentActionType[datafield];
54
- if (actionType && actionType === _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION || currentActionType === _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS) {
55
- setExpand(false);
56
- }
57
- }
58
- }, [filterState]);
59
36
 
60
37
  /**
61
- * expand section incase of active local search
62
- */
38
+ * expand section incase of active local search
39
+ */
63
40
  (0, _react.useEffect)(() => {
64
41
  if (autoComplete && autoComplete.length > 0 || upload && upload.length > 0) {
65
42
  setExpand(true);
@@ -71,13 +48,10 @@ const FacetView = _ref => {
71
48
  };
72
49
  const onClearSection = () => {
73
50
  setSortBy(null);
74
- const activeFilterItems = filterState[datafield];
75
- if (activeFilterItems && Object.keys(activeFilterItems).length > 0) {
76
- if (facet.type === _Types.InputTypes.SLIDER) {
77
- onClearSliderSection(facet);
78
- } else {
79
- onClearFacetSection(facet);
80
- }
51
+ if (facet.type === _Types.InputTypes.SLIDER) {
52
+ onClearSliderSection(facet);
53
+ } else {
54
+ onClearFacetSection(facet);
81
55
  }
82
56
  };
83
57
  /**
@@ -101,25 +75,14 @@ const FacetView = _ref => {
101
75
  },
102
76
  id: facet.section
103
77
  }, CustomView ? /*#__PURE__*/_react.default.createElement(CustomView, {
104
- clearFacetSectionValues: onClearSection,
105
- hasSelections: selectedItems.length,
106
78
  facet: facet,
107
79
  facetClasses: isActiveFacet ? "activeFacet".concat(facet.section) : "inactiveFacet".concat(facet.section)
108
- }) : /*#__PURE__*/_react.default.createElement(_AccordionSummaryView.default, null, !enableClearSection ? /*#__PURE__*/_react.default.createElement("div", {
109
- id: "filterGroup_ ".concat(facet.datafield, "\n ").concat(facet.label),
110
- className: (0, _clsx.default)(classes.subSectionSummaryText, {
111
- ["activeFacet".concat(facet.section)]: isActiveFacet
112
- })
113
- }, facet.label) : /*#__PURE__*/_react.default.createElement("div", {
114
- className: classes.subSectionSummaryTextWrapper
115
- }, /*#__PURE__*/_react.default.createElement("div", {
80
+ }) : /*#__PURE__*/_react.default.createElement(_AccordionSummaryView.default, null, /*#__PURE__*/_react.default.createElement("div", {
116
81
  id: "filterGroup_ ".concat(facet.datafield, "\n ").concat(facet.label),
117
82
  className: (0, _clsx.default)(classes.subSectionSummaryText, {
118
83
  ["activeFacet".concat(facet.section)]: isActiveFacet
119
84
  })
120
- }, facet.label), selectedItems.length ? /*#__PURE__*/_react.default.createElement(_IconButton.default, {
121
- onClick: onClearSection
122
- }, /*#__PURE__*/_react.default.createElement(_Refresh.default, null)) : null)), (facet.type === _Types.InputTypes.SLIDER || facetValues.length === 0) && /*#__PURE__*/_react.default.createElement("div", {
85
+ }, facet.label)), (facet.type === _Types.InputTypes.SLIDER || facetValues.length === 0) && /*#__PURE__*/_react.default.createElement("div", {
123
86
  className: classes.NonSortGroup
124
87
  }, /*#__PURE__*/_react.default.createElement("span", {
125
88
  className: classes.NonSortGroupItem
@@ -14,13 +14,11 @@ const mapStateToProps = state => {
14
14
  var _state$localFind, _state$localFind2;
15
15
  return {
16
16
  filterState: state.statusReducer.filterState,
17
- currentActionType: state.statusReducer.currentActionType,
18
17
  autoComplete: (state === null || state === void 0 ? void 0 : (_state$localFind = state.localFind) === null || _state$localFind === void 0 ? void 0 : _state$localFind.autocomplete) || [],
19
18
  upload: (state === null || state === void 0 ? void 0 : (_state$localFind2 = state.localFind) === null || _state$localFind2 === void 0 ? void 0 : _state$localFind2.upload) || []
20
19
  };
21
20
  };
22
21
  const mapDispatchToProps = dispatch => ({
23
- onToggle: facet => dispatch((0, _Actions.toggleCheckBox)(facet)),
24
22
  onClearFacetSection: facet => {
25
23
  dispatch((0, _Actions.clearFacetSection)(facet));
26
24
  },
@@ -6,7 +6,6 @@ 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"));
10
9
  var _SliderStyle = _interopRequireDefault(require("./SliderStyle"));
11
10
  var _Types = require("../Types");
12
11
  var _InputMinMaxView = _interopRequireDefault(require("./InputMinMaxView"));
@@ -64,9 +63,9 @@ const SliderView = _ref => {
64
63
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
65
64
  className: classes.sliderRoot
66
65
  }, /*#__PURE__*/_react.default.createElement("div", {
67
- className: (0, _clsx.default)(classes.minMaxInputs, 'minMaxInputs')
66
+ className: classes.minMaxInputs
68
67
  }, /*#__PURE__*/_react.default.createElement("div", {
69
- className: (0, _clsx.default)(classes.minValue, 'min_input_box')
68
+ className: classes.minValue
70
69
  }, /*#__PURE__*/_react.default.createElement(_core.Typography, {
71
70
  className: classes.minInputLabel
72
71
  }, "Min:"), /*#__PURE__*/_react.default.createElement(_InputMinMaxView.default, {
@@ -77,7 +76,7 @@ const SliderView = _ref => {
77
76
  type: _Types.silderTypes.INPUT_MIN,
78
77
  onInputChange: handleChangeCommittedSlider
79
78
  })), /*#__PURE__*/_react.default.createElement("div", {
80
- className: (0, _clsx.default)(classes.maxValue, 'max_input_box')
79
+ className: classes.maxValue
81
80
  }, /*#__PURE__*/_react.default.createElement(_core.Typography, {
82
81
  className: classes.maxInputLabel
83
82
  }, "Max:"), /*#__PURE__*/_react.default.createElement(_InputMinMaxView.default, {
@@ -88,7 +87,7 @@ const SliderView = _ref => {
88
87
  type: _Types.silderTypes.INPUT_MAX,
89
88
  onInputChange: handleChangeCommittedSlider
90
89
  }))), /*#__PURE__*/_react.default.createElement("div", {
91
- className: (0, _clsx.default)(classes.slider, 'slider')
90
+ className: classes.slider
92
91
  }, /*#__PURE__*/_react.default.createElement(_core.Slider, {
93
92
  disableSwap: true,
94
93
  getAriaValueText: valuetext,
@@ -11,7 +11,6 @@ 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',
15
14
  marginBottom: -1,
16
15
  minHeight: 48,
17
16
  paddingLeft: 14,
@@ -44,10 +44,7 @@ const onClearFacetSection = _ref2 => {
44
44
  if (updatedState[datafield]) {
45
45
  updatedState[datafield] = {};
46
46
  }
47
- return {
48
- updatedState,
49
- datafield
50
- };
47
+ return updatedState;
51
48
  };
52
49
  exports.onClearFacetSection = onClearFacetSection;
53
50
  const onClearSliderSection = _ref3 => {
@@ -91,43 +88,30 @@ function sideBarReducerGenerator() {
91
88
  case _ActionTypes.sideBarActionTypes.FACET_VALUE_CHANGED:
92
89
  updateState = onToggleStateUpdate(_objectSpread(_objectSpread({}, state), payload));
93
90
  return _objectSpread(_objectSpread({}, state), {}, {
94
- filterState: _objectSpread({}, updateState),
95
- currentActionType: _ActionTypes.sideBarActionTypes.FACET_VALUE_CHANGED
91
+ filterState: _objectSpread({}, updateState)
96
92
  });
97
93
  case _ActionTypes.sideBarActionTypes.ON_TOGGLE_SLIDER:
98
94
  updateState = updateSiderValue(_objectSpread(_objectSpread({}, state), payload));
99
95
  return _objectSpread(_objectSpread({}, state), {}, {
100
- filterState: _objectSpread({}, updateState),
101
- currentActionType: _ActionTypes.sideBarActionTypes.ON_TOGGLE_SLIDER
96
+ filterState: _objectSpread({}, updateState)
102
97
  });
103
98
  case _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS:
104
99
  return _objectSpread(_objectSpread({}, state), {}, {
105
- filterState: {},
106
- currentActionType: _ActionTypes.sideBarActionTypes.CLEAR_ALL_FILTERS
100
+ filterState: {}
107
101
  });
108
102
  case _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION:
109
- const {
110
- updatedState: updtState,
111
- datafield
112
- } = onClearFacetSection(_objectSpread(_objectSpread({}, payload), state));
113
- updateState = updtState;
114
- const currentActionType = {
115
- [datafield]: _ActionTypes.sideBarActionTypes.CLEAR_FACET_SECTION
116
- };
103
+ updateState = onClearFacetSection(_objectSpread(_objectSpread({}, payload), state));
117
104
  return _objectSpread(_objectSpread({}, state), {}, {
118
- filterState: _objectSpread({}, updateState),
119
- currentActionType
105
+ filterState: _objectSpread({}, updateState)
120
106
  });
121
107
  case _ActionTypes.sideBarActionTypes.CLEAR_SLIDER_SECTION:
122
108
  updateState = onClearSliderSection(_objectSpread(_objectSpread({}, payload), state));
123
109
  return _objectSpread(_objectSpread({}, state), {}, {
124
- filterState: _objectSpread({}, updateState),
125
- currentActionType: _ActionTypes.sideBarActionTypes.CLEAR_SLIDER_SECTION
110
+ filterState: _objectSpread({}, updateState)
126
111
  });
127
112
  case _ActionTypes.sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE:
128
113
  return {
129
- filterState: payload,
130
- currentActionType: _ActionTypes.sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE
114
+ filterState: payload
131
115
  };
132
116
  default:
133
117
  return state;
@@ -74,7 +74,7 @@ const sortBySection = _ref => {
74
74
  /**
75
75
  * Display checked item always on top
76
76
  */
77
- const sortedValues = sortByCheckedItem([...sortfacetValues]);
78
- return sortedValues;
77
+ // const sortedValues = sortByCheckedItem([...sortfacetValues]);
78
+ return sortfacetValues;
79
79
  };
80
80
  exports.sortBySection = sortBySection;
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "@bento-core/facet-filter",
3
- "version": "1.0.1-icdc.9",
4
- "description": "",
3
+ "version": "1.0.1-ins.1",
4
+ "description": "### Bento core sidebar design:",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
9
  "lint": "eslint src"
10
10
  },
11
- "repository": "https://github.com/CBIIT/bento-frontend",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/CBIIT/bento-frontend.git"
14
+ },
12
15
  "publishConfig": {
13
16
  "access": "public"
14
17
  },
@@ -24,5 +27,9 @@
24
27
  "react-redux": "^7.2.1"
25
28
  },
26
29
  "author": "CTOS Bento Team",
27
- "license": "ISC"
30
+ "license": "ISC",
31
+ "bugs": {
32
+ "url": "https://github.com/CBIIT/bento-frontend/issues"
33
+ },
34
+ "homepage": "https://github.com/CBIIT/bento-frontend#readme"
28
35
  }
@@ -1,7 +1,10 @@
1
1
  /* eslint-disable arrow-body-style */
2
2
  /* eslint-disable padded-blocks */
3
3
  import React from 'react';
4
- import { Divider, withStyles } from '@material-ui/core';
4
+ import {
5
+ Divider,
6
+ withStyles,
7
+ } from '@material-ui/core';
5
8
  import styles from './FacetFilterStyle';
6
9
  import FacetSectionView from './components/section/FacetSectionView';
7
10
  import FacetView from './components/facet/ReduxFacetView';
@@ -10,29 +13,30 @@ const BentoFacetFilter = ({
10
13
  sideBarSections,
11
14
  CustomFacetSection,
12
15
  CustomFacetView,
13
- enableClearSection,
14
- enableFacetCollapse,
15
16
  }) => {
16
17
  return (
17
18
  <>
18
- {sideBarSections.map((section, index) => (
19
- <>
20
- <Divider variant="middle" className={`divider${index}`} />
21
- <FacetSectionView
22
- section={section}
23
- CustomSection={CustomFacetSection}
24
- >
25
- {section.items.map((facet) => (
26
- <FacetView
27
- facet={facet}
28
- CustomView={CustomFacetView}
29
- enableClearSection={enableClearSection}
30
- enableFacetCollapse={enableFacetCollapse}
31
- />
32
- ))}
33
- </FacetSectionView>
34
- </>
35
- ))}
19
+ {
20
+ sideBarSections.map((section, index) => (
21
+ <>
22
+ <Divider
23
+ variant="middle"
24
+ className={`divider${index}`}
25
+ />
26
+ <FacetSectionView
27
+ section={section}
28
+ CustomSection={CustomFacetSection}
29
+ >
30
+ {section.items.map((facet) => (
31
+ <FacetView
32
+ facet={facet}
33
+ CustomView={CustomFacetView}
34
+ />
35
+ ))}
36
+ </FacetSectionView>
37
+ </>
38
+ ))
39
+ }
36
40
  </>
37
41
  );
38
42
  };
@@ -14,13 +14,6 @@ export default () => ({
14
14
  position: 'initial',
15
15
  },
16
16
  },
17
- subSectionSummaryTextWrapper: {
18
- display: 'flex',
19
- alignItems: 'center',
20
- justifyContent: 'space-between',
21
- width: '100%',
22
- paddingRight: '15px',
23
- },
24
17
  subSectionSummaryText: {
25
18
  marginLeft: '10px',
26
19
  lineHeight: 0,
@@ -35,23 +28,20 @@ export default () => ({
35
28
  marginBottom: '5px',
36
29
  borderTop: '1px solid #B1B1B1',
37
30
  textAlign: 'left',
38
- // marginLeft: '-5px',
39
- display: 'flex',
40
- alignItems: 'center',
41
- justifyContent: 'space-around',
31
+ marginLeft: '-5px',
42
32
  },
43
33
  sortGroupIcon: {
44
34
  cursor: 'pointer',
45
35
  fontFamily: 'Nunito',
46
36
  fontSize: '10px',
47
- // marginRight: '12px',
48
- // marginLeft: '16px',
37
+ marginRight: '12px',
38
+ marginLeft: '16px',
49
39
  },
50
40
  sortGroupItem: {
51
41
  cursor: 'pointer',
52
42
  fontFamily: 'Nunito',
53
43
  fontSize: '10px',
54
- // marginRight: '32px',
44
+ marginRight: '32px',
55
45
  },
56
46
  NonSortGroup: {
57
47
  marginBottom: '5px',
@@ -68,9 +58,9 @@ export default () => ({
68
58
  cursor: 'pointer',
69
59
  fontFamily: 'Nunito',
70
60
  fontSize: '10px',
71
- // float: 'right',
72
- // marginRight: '10px',
73
- // marginTop: '5px',
61
+ float: 'right',
62
+ marginRight: '10px',
63
+ marginTop: '5px',
74
64
  },
75
65
  highlight: {
76
66
  color: '#b2c6d6',
@@ -1,58 +1,36 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import {
3
- Accordion, List, withStyles, Icon,
3
+ Accordion,
4
+ List,
5
+ withStyles,
6
+ Icon,
4
7
  } from '@material-ui/core';
5
8
  import clsx from 'clsx';
6
- import RefreshIcon from '@material-ui/icons/Refresh';
7
- import IconButton from '@material-ui/core/IconButton';
8
9
  import CustomAccordionSummary from '../summary/AccordionSummaryView';
9
10
  import { InputTypes } from '../inputs/Types';
10
11
  import styles from './FacetStyle';
11
12
  import FilterItems from '../inputs/FilterItems';
12
13
  import { sortType } from '../../utils/Sort';
13
14
  import clearIcon 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,
20
19
  onClearFacetSection,
21
20
  onClearSliderSection,
22
21
  CustomView,
23
22
  autoComplete,
24
23
  upload,
25
- filterState,
26
- currentActionType = {},
27
- enableFacetCollapse,
28
24
  }) => {
29
- const [expand, setExpand] = useState(false);
25
+ const [expand, setExpand] = useState(true);
30
26
  const onExpandFacet = () => setExpand(!expand);
31
27
 
32
- const { datafield } = facet;
33
28
  /**
34
- * Collapse expanded facet or facets
35
- * 1. on clear facet section
36
- * 2. on clear all
37
- */
38
- useEffect(() => {
39
- if (enableFacetCollapse) {
40
- const actionType = currentActionType[datafield];
41
- if ((actionType && actionType === sideBarActionTypes.CLEAR_FACET_SECTION)
42
- || currentActionType === sideBarActionTypes.CLEAR_ALL_FILTERS) {
43
- setExpand(false);
44
- }
45
- }
46
- }, [filterState]);
47
-
48
- /**
49
- * expand section incase of active local search
50
- */
29
+ * expand section incase of active local search
30
+ */
51
31
  useEffect(() => {
52
- if (
53
- (autoComplete && autoComplete.length > 0)
54
- || (upload && upload.length > 0)
55
- ) {
32
+ if ((autoComplete && autoComplete.length > 0)
33
+ || (upload && upload.length > 0)) {
56
34
  setExpand(true);
57
35
  }
58
36
  }, [autoComplete, upload]);
@@ -64,13 +42,10 @@ const FacetView = ({
64
42
 
65
43
  const onClearSection = () => {
66
44
  setSortBy(null);
67
- const activeFilterItems = filterState[datafield];
68
- if (activeFilterItems && Object.keys(activeFilterItems).length > 0) {
69
- if (facet.type === InputTypes.SLIDER) {
70
- onClearSliderSection(facet);
71
- } else {
72
- onClearFacetSection(facet);
73
- }
45
+ if (facet.type === InputTypes.SLIDER) {
46
+ onClearSliderSection(facet);
47
+ } else {
48
+ onClearFacetSection(facet);
74
49
  }
75
50
  };
76
51
  /**
@@ -82,7 +57,6 @@ const FacetView = ({
82
57
  displayFacet.facetValues = selectedItems;
83
58
  const isActiveFacet = [...selectedItems].length > 0;
84
59
  const limitCheckBoxCount = facet?.showCheckboxCount || 5;
85
-
86
60
  return (
87
61
  <>
88
62
  <Accordion
@@ -94,103 +68,119 @@ const FacetView = ({
94
68
  }}
95
69
  id={facet.section}
96
70
  >
97
- {CustomView ? (
71
+ { CustomView ? (
98
72
  <CustomView
99
- clearFacetSectionValues={onClearSection}
100
- hasSelections={selectedItems.length}
101
73
  facet={facet}
102
74
  facetClasses={
103
- isActiveFacet
104
- ? `activeFacet${facet.section}`
105
- : `inactiveFacet${facet.section}`
75
+ isActiveFacet ? `activeFacet${facet.section}`
76
+ : `inactiveFacet${facet.section}`
106
77
  }
107
78
  />
108
79
  ) : (
109
80
  <CustomAccordionSummary>
110
- {!enableClearSection ? (
111
- <div
112
- id={`filterGroup_ ${facet.datafield}
113
- ${facet.label}`}
114
- className={clsx(classes.subSectionSummaryText, {
115
- [`activeFacet${facet.section}`]: isActiveFacet,
116
- })}
117
- >
118
- {facet.label}
119
- </div>
120
- ) : (
121
- <div className={classes.subSectionSummaryTextWrapper}>
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
- {selectedItems.length ? (
132
- <IconButton onClick={onClearSection}>
133
- <RefreshIcon />
134
- </IconButton>
135
- ) : null}
136
- </div>
137
- )}
81
+ <div
82
+ id={
83
+ `filterGroup_ ${facet.datafield}
84
+ ${facet.label}`
85
+ }
86
+ className={clsx(classes.subSectionSummaryText, {
87
+ [`activeFacet${facet.section}`]: isActiveFacet,
88
+ })}
89
+ >
90
+ {facet.label}
91
+ </div>
138
92
  </CustomAccordionSummary>
139
93
  )}
140
- {(facet.type === InputTypes.SLIDER || facetValues.length === 0) && (
94
+ {
95
+ (facet.type === InputTypes.SLIDER || facetValues.length === 0)
96
+ && (
141
97
  <div className={classes.NonSortGroup}>
142
- <span className={classes.NonSortGroupItem}>
98
+ <span
99
+ className={classes.NonSortGroupItem}
100
+ >
143
101
  No data for this field
144
102
  </span>
145
103
  </div>
146
- )}
147
- {(facet.type === InputTypes.SLIDER || facetValues.length > 0) && (
104
+ )
105
+ }
106
+ {
107
+ (facet.type === InputTypes.SLIDER || facetValues.length > 0)
108
+ && (
148
109
  <div className={classes.sortGroup}>
149
110
  <span className={classes.sortGroupIcon}>
150
- <Icon style={{ fontSize: 10 }} onClick={onClearSection}>
151
- <img src={clearIcon} height={12} width={12} alt="clear-icon" />
111
+ <Icon
112
+ style={{ fontSize: 10 }}
113
+ onClick={onClearSection}
114
+ >
115
+ <img
116
+ src={clearIcon}
117
+ height={12}
118
+ width={12}
119
+ alt="clear-icon"
120
+ />
152
121
  </Icon>
153
122
  </span>
154
- {facet.type === InputTypes.CHECKBOX && facetValues.length > 0 && (
155
- <>
156
- <span
157
- className={clsx(classes.sortGroupItem, {
158
- [classes.highlight]: sortBy === sortType.ALPHABET,
159
- })}
160
- onClick={() => {
161
- onSortFacet(sortType.ALPHABET);
162
- }}
163
- >
164
- Sort alphabetically
165
- </span>
166
- <span
167
- className={clsx(classes.sortGroupItemCounts, {
168
- [classes.highlight]: sortBy === sortType.NUMERIC,
169
- })}
170
- onClick={() => {
171
- onSortFacet(sortType.NUMERIC);
172
- }}
173
- >
174
- Sort by count
175
- </span>
176
- </>
177
- )}
123
+ { (facet.type === InputTypes.CHECKBOX && facetValues.length > 0)
124
+ && (
125
+ <>
126
+ <span
127
+ className={
128
+ clsx(classes.sortGroupItem, {
129
+ [classes.highlight]: sortBy === sortType.ALPHABET,
130
+ })
131
+ }
132
+ onClick={() => {
133
+ onSortFacet(sortType.ALPHABET);
134
+ }}
135
+ >
136
+ Sort alphabetically
137
+ </span>
138
+ <span
139
+ className={
140
+ clsx(classes.sortGroupItemCounts, {
141
+ [classes.highlight]: sortBy === sortType.NUMERIC,
142
+ })
143
+ }
144
+ onClick={() => {
145
+ onSortFacet(sortType.NUMERIC);
146
+ }}
147
+ >
148
+ Sort by count
149
+ </span>
150
+ </>
151
+ )}
178
152
  </div>
179
- )}
180
- {expand && <FilterItems facet={facet} sortBy={sortBy} />}
153
+ )
154
+ }
155
+ {(expand)
156
+ && (
157
+ <FilterItems
158
+ facet={facet}
159
+ sortBy={sortBy}
160
+ />
161
+ )}
181
162
  </Accordion>
182
- {!expand && type === InputTypes.CHECKBOX && selectedItems.length > 0 && (
183
- <>
184
- <List id="filter_Items">
185
- <FilterItems facet={displayFacet} />
186
- </List>
187
- </>
188
- )}
189
- {!expand && selectedItems.length > limitCheckBoxCount && (
190
- <div className={classes.showMore} onClick={onExpandFacet}>
191
- ...expand to see all selections
192
- </div>
193
- )}
163
+ {
164
+ (!expand && type === InputTypes.CHECKBOX && selectedItems.length > 0) && (
165
+ <>
166
+ <List id="filter_Items">
167
+ <FilterItems
168
+ facet={displayFacet}
169
+ />
170
+ </List>
171
+ </>
172
+ )
173
+ }
174
+ {
175
+ (!expand && selectedItems.length > limitCheckBoxCount) && (
176
+ <div
177
+ className={classes.showMore}
178
+ onClick={onExpandFacet}
179
+ >
180
+ ...expand to see all selections
181
+ </div>
182
+ )
183
+ }
194
184
  </>
195
185
  );
196
186
  };
@@ -1,29 +1,19 @@
1
1
  import React from 'react';
2
2
  import { connect } from 'react-redux';
3
- import {
4
- clearFacetSection,
5
- clearSliderSection,
6
- toggleCheckBox,
7
- } from '../../store/actions/Actions';
3
+ import { clearFacetSection, clearSliderSection } from '../../store/actions/Actions';
8
4
  import FacetView from './FacetView';
9
5
 
10
- const ReduxFacetView = (props) => <FacetView {...props} />;
6
+ const ReduxFacetView = ((props) => <FacetView {...props} />);
11
7
 
12
8
  const mapStateToProps = (state) => ({
13
9
  filterState: state.statusReducer.filterState,
14
- currentActionType: state.statusReducer.currentActionType,
15
10
  autoComplete: state?.localFind?.autocomplete || [],
16
11
  upload: state?.localFind?.upload || [],
17
12
  });
18
13
 
19
14
  const mapDispatchToProps = (dispatch) => ({
20
- onToggle: (facet) => dispatch(toggleCheckBox(facet)),
21
- onClearFacetSection: (facet) => {
22
- dispatch(clearFacetSection(facet));
23
- },
24
- onClearSliderSection: (facet) => {
25
- dispatch(clearSliderSection(facet));
26
- },
15
+ onClearFacetSection: (facet) => { dispatch(clearFacetSection(facet)); },
16
+ onClearSliderSection: (facet) => { dispatch(clearSliderSection(facet)); },
27
17
  });
28
18
 
29
19
  export default connect(mapStateToProps, mapDispatchToProps)(ReduxFacetView);
@@ -20,8 +20,7 @@ import {
20
20
  } from '@material-ui/core';
21
21
  import clsx from 'clsx';
22
22
  import {
23
- CheckBox as CheckBoxIcon,
24
- CheckBoxOutlineBlank as CheckBoxBlankIcon,
23
+ CheckBox as CheckBoxIcon, CheckBoxOutlineBlank as CheckBoxBlankIcon,
25
24
  } from '@material-ui/icons';
26
25
  import styles from './CheckboxStyle';
27
26
 
@@ -32,7 +31,12 @@ const CheckBoxView = ({
32
31
  onToggle,
33
32
  facet,
34
33
  }) => {
35
- const { isChecked = false, index, section, tooltip } = checkboxItem;
34
+ const {
35
+ isChecked = false,
36
+ index,
37
+ section,
38
+ tooltip,
39
+ } = checkboxItem;
36
40
  const {
37
41
  field = 'group',
38
42
  count = 'subjects',
@@ -61,7 +65,9 @@ const CheckBoxView = ({
61
65
  [`${checkedSection}NameChecked`]: isChecked,
62
66
  })}
63
67
  >
64
- <Typography className={classes.checkboxName}>{name}</Typography>
68
+ <Typography className={classes.checkboxName}>
69
+ {name}
70
+ </Typography>
65
71
  </Box>
66
72
  );
67
73
 
@@ -73,9 +79,7 @@ const CheckBoxView = ({
73
79
  alignItems="flex-start"
74
80
  onClick={handleToggle}
75
81
  classes={{ gutters: classes.listItemGutters }}
76
- className={clsx({
77
- [`${checkedSection}Checked${indexType}`]: isChecked,
78
- })}
82
+ className={clsx({ [`${checkedSection}Checked${indexType}`]: isChecked })}
79
83
  >
80
84
  <Checkbox
81
85
  id={`checkbox_${facet.label}_${name}`}
@@ -87,21 +91,23 @@ const CheckBoxView = ({
87
91
  }
88
92
  onClick={handleToggle}
89
93
  checked={isChecked}
90
- checkedIcon={
94
+ checkedIcon={(
91
95
  <CheckBoxIcon
92
96
  style={{
93
97
  fontSize: 18,
94
98
  }}
95
99
  className={`${checkedSection}CheckedIcon`}
96
100
  />
97
- }
101
+ )}
98
102
  disableRipple
99
103
  color="secondary"
100
104
  classes={{ root: classes.checkboxRoot }}
101
105
  />
102
- {tooltip ? (
106
+ { tooltip ? (
103
107
  <Tooltip id={datafield} title={tooltip}>
104
- <div className={datafield}>{name}</div>
108
+ <div className={datafield}>
109
+ {name}
110
+ </div>
105
111
  </Tooltip>
106
112
  ) : (
107
113
  <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,7 +4,6 @@
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';
8
7
  import styles from './SliderStyle';
9
8
  import { silderTypes } from '../Types';
10
9
  import InputMinMaxView from './InputMinMaxView';
@@ -54,8 +53,8 @@ const SliderView = ({
54
53
  return (
55
54
  <>
56
55
  <div className={classes.sliderRoot}>
57
- <div className={clsx(classes.minMaxInputs, 'minMaxInputs')}>
58
- <div className={clsx(classes.minValue, 'min_input_box')}>
56
+ <div className={classes.minMaxInputs}>
57
+ <div className={classes.minValue}>
59
58
  <Typography className={classes.minInputLabel}>
60
59
  Min:
61
60
  </Typography>
@@ -68,7 +67,7 @@ const SliderView = ({
68
67
  onInputChange={handleChangeCommittedSlider}
69
68
  />
70
69
  </div>
71
- <div className={clsx(classes.maxValue, 'max_input_box')}>
70
+ <div className={classes.maxValue}>
72
71
  <Typography className={classes.maxInputLabel}>
73
72
  Max:
74
73
  </Typography>
@@ -82,7 +81,7 @@ const SliderView = ({
82
81
  />
83
82
  </div>
84
83
  </div>
85
- <div className={clsx(classes.slider, 'slider')}>
84
+ <div className={classes.slider}>
86
85
  {/* Change to red if invalid range */}
87
86
  <Slider
88
87
  disableSwap
@@ -1,11 +1,15 @@
1
1
  import React from 'react';
2
- import { AccordionSummary, withStyles } from '@material-ui/core';
3
- import { ExpandMore as ExpandMoreIcon } from '@material-ui/icons';
2
+ import {
3
+ AccordionSummary,
4
+ withStyles,
5
+ } from '@material-ui/core';
6
+ import {
7
+ ExpandMore as ExpandMoreIcon,
8
+ } from '@material-ui/icons';
4
9
  import style from './AccordionSummaryStyle';
5
10
 
6
11
  const Summary = withStyles({
7
12
  root: {
8
- width: '307px',
9
13
  marginBottom: -1,
10
14
  minHeight: 48,
11
15
  paddingLeft: 14,
@@ -23,7 +27,10 @@ const Summary = withStyles({
23
27
  expanded: {},
24
28
  })(AccordionSummary);
25
29
 
26
- const CustomAccordionSummary = ({ children, classes }) => (
30
+ const CustomAccordionSummary = ({
31
+ children,
32
+ classes,
33
+ }) => (
27
34
  <Summary
28
35
  expandIcon={(
29
36
  <ExpandMoreIcon
@@ -30,7 +30,7 @@ export const onClearFacetSection = ({
30
30
  if (updatedState[datafield]) {
31
31
  updatedState[datafield] = {};
32
32
  }
33
- return { updatedState, datafield };
33
+ return updatedState;
34
34
  };
35
35
 
36
36
  export const onClearSliderSection = ({
@@ -67,44 +67,33 @@ export function sideBarReducerGenerator() {
67
67
  return {
68
68
  ...state,
69
69
  filterState: { ...updateState },
70
- currentActionType: sideBarActionTypes.FACET_VALUE_CHANGED,
71
70
  };
72
71
  case sideBarActionTypes.ON_TOGGLE_SLIDER:
73
72
  updateState = updateSiderValue({ ...state, ...payload });
74
73
  return {
75
74
  ...state,
76
75
  filterState: { ...updateState },
77
- currentActionType: sideBarActionTypes.ON_TOGGLE_SLIDER,
78
76
  };
79
77
  case sideBarActionTypes.CLEAR_ALL_FILTERS:
80
78
  return {
81
79
  ...state,
82
80
  filterState: {},
83
- currentActionType: sideBarActionTypes.CLEAR_ALL_FILTERS,
84
81
  };
85
82
  case sideBarActionTypes.CLEAR_FACET_SECTION:
86
- const {
87
- updatedState: updtState,
88
- datafield,
89
- } = onClearFacetSection({ ...payload, ...state });
90
- updateState = updtState;
91
- const currentActionType = { [datafield]: sideBarActionTypes.CLEAR_FACET_SECTION };
83
+ updateState = onClearFacetSection({ ...payload, ...state });
92
84
  return {
93
85
  ...state,
94
86
  filterState: { ...updateState },
95
- currentActionType,
96
87
  };
97
88
  case sideBarActionTypes.CLEAR_SLIDER_SECTION:
98
89
  updateState = onClearSliderSection({ ...payload, ...state });
99
90
  return {
100
91
  ...state,
101
92
  filterState: { ...updateState },
102
- currentActionType: sideBarActionTypes.CLEAR_SLIDER_SECTION,
103
93
  };
104
94
  case sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE:
105
95
  return {
106
96
  filterState: payload,
107
- currentActionType: sideBarActionTypes.CLEAR_AND_SELECT_FACET_VALUE,
108
97
  };
109
98
  default:
110
99
  return state;
package/src/utils/Sort.js CHANGED
@@ -72,6 +72,6 @@ export const sortBySection = ({
72
72
  /**
73
73
  * Display checked item always on top
74
74
  */
75
- const sortedValues = sortByCheckedItem([...sortfacetValues]);
76
- return sortedValues;
75
+ // const sortedValues = sortByCheckedItem([...sortfacetValues]);
76
+ return sortfacetValues;
77
77
  };