@bento-core/facet-filter 1.0.1-popsci.1 → 1.0.1-popsci.2
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 +3 -59
- package/dist/FacetFilterController.js +16 -23
- package/dist/FacetFilterView.js +6 -1
- package/dist/components/facet/FacetView.js +4 -4
- package/dist/components/inputs/checkbox/CheckboxView.js +13 -21
- package/dist/components/inputs/slider/SliderView.js +3 -16
- package/dist/utils/Sort.js +6 -8
- package/package.json +3 -2
- package/src/FacetFilterController.js +13 -18
- package/src/FacetFilterView.js +9 -1
- package/src/components/facet/FacetView.js +57 -95
- package/src/components/inputs/checkbox/CheckboxView.js +14 -26
- package/src/components/inputs/slider/SliderView.js +18 -28
- package/src/utils/Sort.js +8 -14
package/README.md
CHANGED
|
@@ -95,8 +95,6 @@ export const facetsConfig = [{
|
|
|
95
95
|
minLowerBound: 0,
|
|
96
96
|
maxUpperBound: 100,
|
|
97
97
|
quantifier: 'Years',
|
|
98
|
-
CustomLowerUpperBound: CustomLowerUpperBound, // Custom component for displaying lower and upper bounds
|
|
99
|
-
CustomSliderValue: CustomSliderValue, // Custom component for displaying slider value
|
|
100
98
|
].
|
|
101
99
|
```
|
|
102
100
|
1. **apiForFiltering** refers to object key for retrieving name and subjects count from query response (DASHBOARD_QUERY)
|
|
@@ -246,66 +244,12 @@ className={clsx(classes.sectionSummaryText, classes[facetClasses])}
|
|
|
246
244
|
## 10 CLearAllFilterButton Component
|
|
247
245
|
Bento Core provides 1. function to clear all active filters, 2. disable flag (true incase of no active filters). Client is responsible for defining view (custom html).
|
|
248
246
|
```
|
|
249
|
-
import {
|
|
250
|
-
import { getFilters } from '@bento-core/facet-filter';
|
|
247
|
+
import { generateClearAllFilterBtn } from 'bento-core';
|
|
251
248
|
|
|
252
249
|
const CustomClearAllFiltersBtn = ({ onClearAllFilters, disable }) => {
|
|
253
250
|
//...custom component 1. bind onClearFilters fn
|
|
254
251
|
// 2. disable flag to disable button
|
|
255
|
-
}
|
|
256
|
-
// get filter data
|
|
257
|
-
// filterState: state.statusReducer.filterState, (from reducer)
|
|
258
|
-
// const activeFilters = getFilters(filterState) // formating
|
|
259
|
-
|
|
260
|
-
<ClearAllFiltersBtn
|
|
261
|
-
Component={CustomClearAllFiltersBtn}
|
|
262
|
-
activeFilters={activeFilters}
|
|
263
|
-
/>
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
## 11 Facet Value Component
|
|
267
|
-
```
|
|
268
|
-
// response
|
|
269
|
-
// filterCaseCountByProgram: [{group: "COP", subjects: 301}]
|
|
270
|
-
const {
|
|
271
|
-
name,
|
|
272
|
-
customName,
|
|
273
|
-
subjects,
|
|
274
|
-
customSubjects,
|
|
275
|
-
tooltip,
|
|
276
|
-
} = checkboxItem;
|
|
277
|
-
|
|
278
|
-
// 1. by default facet value component display group ("COP")
|
|
279
|
-
// 2. set customName to display customize value
|
|
280
|
-
// 3. by default facet value component display subjects (301)
|
|
281
|
-
// 4. set customSubjects to display customize value or adjust correct field for subject count
|
|
282
|
-
// 5. tooltip - provide text value to tooltip text
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Add Bento frontend filter count/subjects
|
|
286
|
-
* Add tootip text
|
|
287
|
-
*/
|
|
288
|
-
const filterData = facetsConfig.reduce((acc, item) => {
|
|
289
|
-
const facetValues = searchData[item.apiPath];
|
|
290
|
-
if (!facetValues) {
|
|
291
|
-
return acc;
|
|
292
|
-
}
|
|
293
|
-
const subjectCounts = [...facetValues].map((checkbox) => {
|
|
294
|
-
const text = tooltipText[item.tooltipKey];
|
|
295
|
-
return {
|
|
296
|
-
...checkbox,
|
|
297
|
-
customSubjects: checkbox.count,
|
|
298
|
-
tooltip: text ? text[checkbox.group] : undefined,
|
|
299
|
-
};
|
|
300
|
-
});
|
|
301
|
-
return { ...acc, [item.apiPath]: [...subjectCounts] };
|
|
302
|
-
}, {});
|
|
252
|
+
}
|
|
303
253
|
|
|
304
|
-
|
|
305
|
-
data={filterData}
|
|
306
|
-
facetSectionConfig={facetSectionVariables}
|
|
307
|
-
facetsConfig={facetsConfig}
|
|
308
|
-
CustomFacetSection={CustomFacetSection}
|
|
309
|
-
CustomFacetView={CustomFacetView}
|
|
310
|
-
/>
|
|
254
|
+
const ClearAllFiltersButton = () => generateClearAllFilterBtn(CustomClearAllFiltersBtn);
|
|
311
255
|
```
|
|
@@ -12,13 +12,13 @@ var _FacetFilterView = _interopRequireDefault(require("./FacetFilterView"));
|
|
|
12
12
|
const _excluded = ["section"];
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
17
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
18
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
21
19
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
22
22
|
const FacetFilterController = props => {
|
|
23
23
|
/**
|
|
24
24
|
* update checkbox state
|
|
@@ -29,8 +29,7 @@ const FacetFilterController = props => {
|
|
|
29
29
|
filterState,
|
|
30
30
|
data,
|
|
31
31
|
facetsConfig,
|
|
32
|
-
facetSectionConfig
|
|
33
|
-
tooltipText = {}
|
|
32
|
+
facetSectionConfig
|
|
34
33
|
} = props;
|
|
35
34
|
const updateFacetState = filterSections => {
|
|
36
35
|
const updateSections = [...filterSections];
|
|
@@ -38,16 +37,9 @@ const FacetFilterController = props => {
|
|
|
38
37
|
for (const [key, value] of Object.entries(filterState)) {
|
|
39
38
|
updateSections.forEach(sideBar => {
|
|
40
39
|
if (sideBar.type === _Types.InputTypes.CHECKBOX && sideBar.datafield === key) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} = sideBar;
|
|
44
|
-
const updateFacetVals = facetValues.map(item => {
|
|
45
|
-
const facetVal = item[sideBar.field];
|
|
46
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
47
|
-
isChecked: value[facetVal] ? value[facetVal] : false
|
|
48
|
-
});
|
|
40
|
+
sideBar.facetValues.forEach(item => {
|
|
41
|
+
item.isChecked = value[item.name] ? value[item.name] : false;
|
|
49
42
|
});
|
|
50
|
-
sideBar.facetValues = updateFacetVals;
|
|
51
43
|
}
|
|
52
44
|
if (sideBar.type === _Types.InputTypes.SLIDER && sideBar.datafield === key) {
|
|
53
45
|
sideBar.facetValues = value;
|
|
@@ -57,13 +49,9 @@ const FacetFilterController = props => {
|
|
|
57
49
|
} else {
|
|
58
50
|
updateSections.forEach(sideBar => {
|
|
59
51
|
if (sideBar.type === _Types.InputTypes.CHECKBOX) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
const updateFacetVals = facetValues.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
64
|
-
isChecked: false
|
|
65
|
-
}));
|
|
66
|
-
sideBar.facetValues = updateFacetVals;
|
|
52
|
+
sideBar.facetValues.forEach(item => {
|
|
53
|
+
item.isChecked = false;
|
|
54
|
+
});
|
|
67
55
|
}
|
|
68
56
|
/**
|
|
69
57
|
* set default value for slider - on clear all filter
|
|
@@ -108,7 +96,6 @@ const FacetFilterController = props => {
|
|
|
108
96
|
* Construct filter object
|
|
109
97
|
* 1. add facet values to facets
|
|
110
98
|
* 2. add 'name' key to each facet value
|
|
111
|
-
* 3. add '
|
|
112
99
|
*/
|
|
113
100
|
const addFacetValues = facets => {
|
|
114
101
|
const updateFacets = [];
|
|
@@ -118,13 +105,19 @@ const FacetFilterController = props => {
|
|
|
118
105
|
facetValues: []
|
|
119
106
|
});
|
|
120
107
|
const {
|
|
108
|
+
field,
|
|
121
109
|
ApiLowerBoundName,
|
|
122
110
|
ApiUpperBoundName,
|
|
123
111
|
apiForFiltering
|
|
124
112
|
} = updateFacet;
|
|
125
113
|
if (data[apiForFiltering]) {
|
|
126
114
|
if (Array.isArray(data[apiForFiltering])) {
|
|
127
|
-
|
|
115
|
+
const updateField = data[apiForFiltering].map(item => {
|
|
116
|
+
const addField = _objectSpread({}, item);
|
|
117
|
+
addField.name = item[field];
|
|
118
|
+
return addField;
|
|
119
|
+
});
|
|
120
|
+
updateFacet.facetValues = updateField;
|
|
128
121
|
}
|
|
129
122
|
/**
|
|
130
123
|
* add object to facet values
|
|
@@ -147,7 +140,7 @@ const FacetFilterController = props => {
|
|
|
147
140
|
* Generate facet sections state
|
|
148
141
|
*
|
|
149
142
|
*/
|
|
150
|
-
const displayFacets = facetsConfig.filter(facet => facet.show);
|
|
143
|
+
const displayFacets = facetsConfig.filter(facet => facet.show).slice(0, 16);
|
|
151
144
|
const facetStates = addFacetValues(displayFacets);
|
|
152
145
|
const updateState = updateFacetState(facetStates);
|
|
153
146
|
const facetSections = arrangeBySections(updateState);
|
package/dist/FacetFilterView.js
CHANGED
|
@@ -9,6 +9,7 @@ var _core = require("@material-ui/core");
|
|
|
9
9
|
var _FacetFilterStyle = _interopRequireDefault(require("./FacetFilterStyle"));
|
|
10
10
|
var _FacetSectionView = _interopRequireDefault(require("./components/section/FacetSectionView"));
|
|
11
11
|
var _ReduxFacetView = _interopRequireDefault(require("./components/facet/ReduxFacetView"));
|
|
12
|
+
var _FilterItems = _interopRequireDefault(require("./components/inputs/FilterItems"));
|
|
12
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
14
|
/* eslint-disable arrow-body-style */
|
|
14
15
|
/* eslint-disable padded-blocks */
|
|
@@ -28,7 +29,11 @@ const BentoFacetFilter = _ref => {
|
|
|
28
29
|
}, section.items.map(facet => /*#__PURE__*/_react.default.createElement(_ReduxFacetView.default, {
|
|
29
30
|
facet: facet,
|
|
30
31
|
CustomView: CustomFacetView
|
|
31
|
-
}
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(_core.List, {
|
|
33
|
+
className: "List_".concat(facet.label)
|
|
34
|
+
}, /*#__PURE__*/_react.default.createElement(_FilterItems.default, {
|
|
35
|
+
facet: facet
|
|
36
|
+
}))))))));
|
|
32
37
|
};
|
|
33
38
|
var _default = (0, _core.withStyles)(_FacetFilterStyle.default)(BentoFacetFilter);
|
|
34
39
|
exports.default = _default;
|
|
@@ -35,8 +35,8 @@ const FacetView = _ref => {
|
|
|
35
35
|
const onExpandFacet = () => setExpand(!expand);
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
* expand section incase of active local search
|
|
39
|
+
*/
|
|
40
40
|
(0, _react.useEffect)(() => {
|
|
41
41
|
if (autoComplete && autoComplete.length > 0 || upload && upload.length > 0) {
|
|
42
42
|
setExpand(true);
|
|
@@ -82,11 +82,11 @@ const FacetView = _ref => {
|
|
|
82
82
|
className: (0, _clsx.default)(classes.subSectionSummaryText, {
|
|
83
83
|
["activeFacet".concat(facet.section)]: isActiveFacet
|
|
84
84
|
})
|
|
85
|
-
}, facet.label)),
|
|
85
|
+
}, facet.label)), facetValues.length === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
86
86
|
className: classes.NonSortGroup
|
|
87
87
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
88
88
|
className: classes.NonSortGroupItem
|
|
89
|
-
}, "No data for this field")),
|
|
89
|
+
}, "No data for this field")), facetValues.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
90
90
|
className: classes.sortGroup
|
|
91
91
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
92
92
|
className: classes.sortGroupIcon
|
|
@@ -18,8 +18,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
/* eslint-disable object-curly-newline */
|
|
19
19
|
/* eslint-disable object-shorthand */
|
|
20
20
|
/* eslint-disable react/jsx-one-expression-per-line */
|
|
21
|
-
/* eslint-disable no-useless-escape */
|
|
22
21
|
|
|
22
|
+
const alignment = 'flex-start';
|
|
23
23
|
const CheckBoxView = _ref => {
|
|
24
24
|
let {
|
|
25
25
|
classes,
|
|
@@ -29,23 +29,19 @@ const CheckBoxView = _ref => {
|
|
|
29
29
|
facet
|
|
30
30
|
} = _ref;
|
|
31
31
|
const {
|
|
32
|
+
name,
|
|
33
|
+
subjects,
|
|
32
34
|
isChecked = false,
|
|
33
35
|
index,
|
|
34
36
|
section,
|
|
35
|
-
tooltip
|
|
37
|
+
tooltip,
|
|
38
|
+
label
|
|
36
39
|
} = checkboxItem;
|
|
37
|
-
const {
|
|
38
|
-
field = 'group',
|
|
39
|
-
count = 'subjects',
|
|
40
|
-
customCount = text => "(".concat(text, ")"),
|
|
41
|
-
defaultValue = ''
|
|
42
|
-
} = facet;
|
|
43
40
|
const indexType = index % 2 === 0 ? 'Even' : 'Odd';
|
|
44
|
-
const checkedSection = "".concat(section).toLowerCase().replace(
|
|
45
|
-
const name = checkboxItem[field] || defaultValue || 'N/A';
|
|
41
|
+
const checkedSection = "".concat(section).toLowerCase().replace(' ', '_');
|
|
46
42
|
const handleToggle = () => {
|
|
47
43
|
const toggleCheckBoxItem = {
|
|
48
|
-
name:
|
|
44
|
+
name: name,
|
|
49
45
|
datafield: datafield,
|
|
50
46
|
isChecked: !isChecked
|
|
51
47
|
};
|
|
@@ -57,7 +53,9 @@ const CheckBoxView = _ref => {
|
|
|
57
53
|
["".concat(checkedSection, "NameUnChecked")]: !isChecked,
|
|
58
54
|
["".concat(checkedSection, "NameChecked")]: isChecked
|
|
59
55
|
})
|
|
60
|
-
}, /*#__PURE__*/_react.default.createElement(_core.Typography, {
|
|
56
|
+
}, label ? /*#__PURE__*/_react.default.createElement(_core.Typography, {
|
|
57
|
+
className: classes.checkboxLabel
|
|
58
|
+
}, label) : /*#__PURE__*/_react.default.createElement(_core.Typography, {
|
|
61
59
|
className: classes.checkboxName
|
|
62
60
|
}, name));
|
|
63
61
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.ListItem, {
|
|
@@ -76,8 +74,7 @@ const CheckBoxView = _ref => {
|
|
|
76
74
|
icon: /*#__PURE__*/_react.default.createElement(_icons.CheckBoxOutlineBlank, {
|
|
77
75
|
style: {
|
|
78
76
|
fontSize: 18
|
|
79
|
-
}
|
|
80
|
-
className: checkedSection
|
|
77
|
+
}
|
|
81
78
|
}),
|
|
82
79
|
onClick: handleToggle,
|
|
83
80
|
checked: isChecked,
|
|
@@ -91,23 +88,18 @@ const CheckBoxView = _ref => {
|
|
|
91
88
|
color: "secondary",
|
|
92
89
|
classes: {
|
|
93
90
|
root: classes.checkboxRoot
|
|
94
|
-
},
|
|
95
|
-
inputProps: {
|
|
96
|
-
'aria-label': 'Select'
|
|
97
91
|
}
|
|
98
92
|
}), tooltip ? /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
99
93
|
id: datafield,
|
|
100
94
|
title: tooltip
|
|
101
95
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
102
96
|
className: datafield
|
|
103
|
-
},
|
|
104
|
-
className: "".concat(checkedSection, "_md_space")
|
|
105
|
-
}), /*#__PURE__*/_react.default.createElement(_core.Typography, {
|
|
97
|
+
}, /*#__PURE__*/_react.default.createElement(LabelComponent, null))) : /*#__PURE__*/_react.default.createElement(LabelComponent, null), /*#__PURE__*/_react.default.createElement(_core.ListItemText, null), /*#__PURE__*/_react.default.createElement(_core.Typography, {
|
|
106
98
|
className: (0, _clsx.default)("".concat(checkedSection, "Subjects"), {
|
|
107
99
|
["".concat(checkedSection, "SubjectUnChecked")]: !isChecked,
|
|
108
100
|
["".concat(checkedSection, "SubjectChecked")]: isChecked
|
|
109
101
|
})
|
|
110
|
-
},
|
|
102
|
+
}, "(".concat(subjects, ")"))), /*#__PURE__*/_react.default.createElement(_core.Divider, {
|
|
111
103
|
style: {
|
|
112
104
|
backgroundColor: isChecked ? '#FFFFFF' : '#b1b1b1',
|
|
113
105
|
margin: '0px',
|
|
@@ -29,9 +29,7 @@ const SliderView = _ref => {
|
|
|
29
29
|
maxUpperBound,
|
|
30
30
|
quantifier,
|
|
31
31
|
datafield,
|
|
32
|
-
facetValues
|
|
33
|
-
CustomLowerUpperBound,
|
|
34
|
-
CustomSliderValue
|
|
32
|
+
facetValues
|
|
35
33
|
} = facet;
|
|
36
34
|
const lowerBoundValue = facetValues[0];
|
|
37
35
|
const upperBoundValue = facetValues[1];
|
|
@@ -104,24 +102,13 @@ const SliderView = _ref => {
|
|
|
104
102
|
thumb: isValid() ? classes.thumb : classes.invalidThumb,
|
|
105
103
|
track: isValid() ? classes.track : classes.invalidTrack
|
|
106
104
|
}
|
|
107
|
-
})),
|
|
108
|
-
minLowerBound,
|
|
109
|
-
maxUpperBound,
|
|
110
|
-
classes
|
|
111
|
-
}) : /*#__PURE__*/_react.default.createElement(_core.Box, {
|
|
105
|
+
})), /*#__PURE__*/_react.default.createElement(_core.Box, {
|
|
112
106
|
className: classes.lowerUpperBound
|
|
113
107
|
}, /*#__PURE__*/_react.default.createElement(_core.Typography, {
|
|
114
108
|
className: classes.lowerBound
|
|
115
109
|
}, minLowerBound), /*#__PURE__*/_react.default.createElement(_core.Typography, {
|
|
116
110
|
className: classes.upperBound
|
|
117
|
-
}, maxUpperBound))),
|
|
118
|
-
sliderValue,
|
|
119
|
-
minLowerBound,
|
|
120
|
-
maxUpperBound,
|
|
121
|
-
isValid,
|
|
122
|
-
quantifier,
|
|
123
|
-
classes
|
|
124
|
-
}) : (sliderValue[0] > minLowerBound || sliderValue[1] < maxUpperBound) && /*#__PURE__*/_react.default.createElement(_core.Typography, {
|
|
111
|
+
}, maxUpperBound))), (sliderValue[0] > minLowerBound || sliderValue[1] < maxUpperBound) && /*#__PURE__*/_react.default.createElement(_core.Typography, {
|
|
125
112
|
className: isValid() ? classes.sliderText : classes.invalidSliderText
|
|
126
113
|
}, sliderValue[0], ' - ', sliderValue[1], "\xA0", quantifier));
|
|
127
114
|
};
|
package/dist/utils/Sort.js
CHANGED
|
@@ -46,30 +46,28 @@ const sortBySection = _ref => {
|
|
|
46
46
|
let {
|
|
47
47
|
facetValues,
|
|
48
48
|
sort_type,
|
|
49
|
-
sortBy
|
|
50
|
-
field,
|
|
51
|
-
count = 'subjects'
|
|
49
|
+
sortBy
|
|
52
50
|
} = _ref;
|
|
53
51
|
const sortfacetValues = [...facetValues];
|
|
54
52
|
if (!sortfacetValues) {
|
|
55
53
|
return facetValues;
|
|
56
54
|
}
|
|
57
55
|
if (sortBy === sortType.NUMERIC) {
|
|
58
|
-
sortfacetValues.sort((a, b) => b
|
|
56
|
+
sortfacetValues.sort((a, b) => b.subjects - a.subjects);
|
|
59
57
|
} else {
|
|
60
|
-
sortfacetValues.sort((a, b) => lowerCaseString(a
|
|
58
|
+
sortfacetValues.sort((a, b) => lowerCaseString(a.name) > lowerCaseString(b.name) || -(lowerCaseString(a.name) < lowerCaseString(b.name)));
|
|
61
59
|
}
|
|
62
60
|
if (sort_type === sortType.CUSTOM_NUMBER && sortBy !== sortType.NUMERIC) {
|
|
63
61
|
sortfacetValues.sort((a, b) => {
|
|
64
|
-
const aNumbs = getNumberArray(a
|
|
65
|
-
const bNumbs = getNumberArray(b
|
|
62
|
+
const aNumbs = getNumberArray(a.name);
|
|
63
|
+
const bNumbs = getNumberArray(b.name);
|
|
66
64
|
const aNumb = Number(aNumbs[0]);
|
|
67
65
|
const bNumb = Number(bNumbs[0]);
|
|
68
66
|
return aNumbs.length === bNumbs.length ? aNumb > bNumb : -(aNumb <= bNumb);
|
|
69
67
|
});
|
|
70
68
|
}
|
|
71
69
|
if (sort_type === sortType.RANGE && sortBy !== sortType.NUMERIC) {
|
|
72
|
-
sortfacetValues.sort((a, b) => startIndex(a
|
|
70
|
+
sortfacetValues.sort((a, b) => startIndex(a.name) > startIndex(b.name) || -(startIndex(a.name) < startIndex(b.name)));
|
|
73
71
|
}
|
|
74
72
|
/**
|
|
75
73
|
* Display checked item always on top
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/facet-filter",
|
|
3
|
-
"version": "1.0.1-popsci.
|
|
3
|
+
"version": "1.0.1-popsci.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,5 +24,6 @@
|
|
|
24
24
|
"react-redux": "^7.2.1"
|
|
25
25
|
},
|
|
26
26
|
"author": "CTOS Bento Team",
|
|
27
|
-
"license": "ISC"
|
|
27
|
+
"license": "ISC",
|
|
28
|
+
"gitHead": "5c65b1486cf1962dce93f6e71019e6079d82a4ba"
|
|
28
29
|
}
|
|
@@ -25,7 +25,6 @@ const FacetFilterController = (props) => {
|
|
|
25
25
|
data,
|
|
26
26
|
facetsConfig,
|
|
27
27
|
facetSectionConfig,
|
|
28
|
-
tooltipText = {},
|
|
29
28
|
} = props;
|
|
30
29
|
|
|
31
30
|
const updateFacetState = (filterSections) => {
|
|
@@ -34,15 +33,9 @@ const FacetFilterController = (props) => {
|
|
|
34
33
|
for (const [key, value] of Object.entries(filterState)) {
|
|
35
34
|
updateSections.forEach((sideBar) => {
|
|
36
35
|
if (sideBar.type === InputTypes.CHECKBOX && sideBar.datafield === key) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const facetVal = item[sideBar.field];
|
|
40
|
-
return {
|
|
41
|
-
...item,
|
|
42
|
-
isChecked: value[facetVal] ? value[facetVal] : false,
|
|
43
|
-
};
|
|
36
|
+
sideBar.facetValues.forEach((item) => {
|
|
37
|
+
item.isChecked = value[item.name] ? value[item.name] : false;
|
|
44
38
|
});
|
|
45
|
-
sideBar.facetValues = updateFacetVals;
|
|
46
39
|
}
|
|
47
40
|
if (sideBar.type === InputTypes.SLIDER && sideBar.datafield === key) {
|
|
48
41
|
sideBar.facetValues = value;
|
|
@@ -52,12 +45,9 @@ const FacetFilterController = (props) => {
|
|
|
52
45
|
} else {
|
|
53
46
|
updateSections.forEach((sideBar) => {
|
|
54
47
|
if (sideBar.type === InputTypes.CHECKBOX) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
isChecked: false,
|
|
59
|
-
}));
|
|
60
|
-
sideBar.facetValues = updateFacetVals;
|
|
48
|
+
sideBar.facetValues.forEach((item) => {
|
|
49
|
+
item.isChecked = false;
|
|
50
|
+
});
|
|
61
51
|
}
|
|
62
52
|
/**
|
|
63
53
|
* set default value for slider - on clear all filter
|
|
@@ -93,7 +83,6 @@ const FacetFilterController = (props) => {
|
|
|
93
83
|
* Construct filter object
|
|
94
84
|
* 1. add facet values to facets
|
|
95
85
|
* 2. add 'name' key to each facet value
|
|
96
|
-
* 3. add '
|
|
97
86
|
*/
|
|
98
87
|
const addFacetValues = (facets) => {
|
|
99
88
|
const updateFacets = [];
|
|
@@ -101,13 +90,19 @@ const FacetFilterController = (props) => {
|
|
|
101
90
|
facets.forEach((facet) => {
|
|
102
91
|
const updateFacet = { ...facet, facetValues: [] };
|
|
103
92
|
const {
|
|
93
|
+
field,
|
|
104
94
|
ApiLowerBoundName,
|
|
105
95
|
ApiUpperBoundName,
|
|
106
96
|
apiForFiltering,
|
|
107
97
|
} = updateFacet;
|
|
108
98
|
if (data[apiForFiltering]) {
|
|
109
99
|
if (Array.isArray(data[apiForFiltering])) {
|
|
110
|
-
|
|
100
|
+
const updateField = data[apiForFiltering].map((item) => {
|
|
101
|
+
const addField = { ...item };
|
|
102
|
+
addField.name = item[field];
|
|
103
|
+
return addField;
|
|
104
|
+
});
|
|
105
|
+
updateFacet.facetValues = updateField;
|
|
111
106
|
}
|
|
112
107
|
/**
|
|
113
108
|
* add object to facet values
|
|
@@ -130,7 +125,7 @@ const FacetFilterController = (props) => {
|
|
|
130
125
|
* Generate facet sections state
|
|
131
126
|
*
|
|
132
127
|
*/
|
|
133
|
-
const displayFacets = facetsConfig.filter((facet) => facet.show);
|
|
128
|
+
const displayFacets = facetsConfig.filter((facet) => facet.show).slice(0, 16);
|
|
134
129
|
const facetStates = addFacetValues(displayFacets);
|
|
135
130
|
const updateState = updateFacetState(facetStates);
|
|
136
131
|
const facetSections = arrangeBySections(updateState);
|
package/src/FacetFilterView.js
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import {
|
|
5
5
|
Divider,
|
|
6
|
+
List,
|
|
6
7
|
withStyles,
|
|
7
8
|
} from '@material-ui/core';
|
|
8
9
|
import styles from './FacetFilterStyle';
|
|
9
10
|
import FacetSectionView from './components/section/FacetSectionView';
|
|
10
11
|
import FacetView from './components/facet/ReduxFacetView';
|
|
12
|
+
import FilterItems from './components/inputs/FilterItems';
|
|
11
13
|
|
|
12
14
|
const BentoFacetFilter = ({
|
|
13
15
|
sideBarSections,
|
|
@@ -31,7 +33,13 @@ const BentoFacetFilter = ({
|
|
|
31
33
|
<FacetView
|
|
32
34
|
facet={facet}
|
|
33
35
|
CustomView={CustomFacetView}
|
|
34
|
-
|
|
36
|
+
>
|
|
37
|
+
<List className={`List_${facet.label}`}>
|
|
38
|
+
<FilterItems
|
|
39
|
+
facet={facet}
|
|
40
|
+
/>
|
|
41
|
+
</List>
|
|
42
|
+
</FacetView>
|
|
35
43
|
))}
|
|
36
44
|
</FacetSectionView>
|
|
37
45
|
</>
|
|
@@ -1,9 +1,6 @@
|
|
|
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';
|
|
9
6
|
import CustomAccordionSummary from '../summary/AccordionSummaryView';
|
|
@@ -26,11 +23,13 @@ const FacetView = ({
|
|
|
26
23
|
const onExpandFacet = () => setExpand(!expand);
|
|
27
24
|
|
|
28
25
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
* Expand section incase of active local search
|
|
27
|
+
*/
|
|
31
28
|
useEffect(() => {
|
|
32
|
-
if (
|
|
33
|
-
|
|
29
|
+
if (
|
|
30
|
+
(autoComplete && autoComplete.length > 0)
|
|
31
|
+
|| (upload && upload.length > 0)
|
|
32
|
+
) {
|
|
34
33
|
setExpand(true);
|
|
35
34
|
}
|
|
36
35
|
}, [autoComplete, upload]);
|
|
@@ -68,21 +67,20 @@ const FacetView = ({
|
|
|
68
67
|
}}
|
|
69
68
|
id={facet.section}
|
|
70
69
|
>
|
|
71
|
-
{
|
|
70
|
+
{CustomView ? (
|
|
72
71
|
<CustomView
|
|
73
72
|
facet={facet}
|
|
74
73
|
facetClasses={
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
isActiveFacet
|
|
75
|
+
? `activeFacet${facet.section}`
|
|
76
|
+
: `inactiveFacet${facet.section}`
|
|
77
77
|
}
|
|
78
78
|
/>
|
|
79
79
|
) : (
|
|
80
80
|
<CustomAccordionSummary>
|
|
81
81
|
<div
|
|
82
|
-
id={
|
|
83
|
-
|
|
84
|
-
${facet.label}`
|
|
85
|
-
}
|
|
82
|
+
id={`filterGroup_ ${facet.datafield}
|
|
83
|
+
${facet.label}`}
|
|
86
84
|
className={clsx(classes.subSectionSummaryText, {
|
|
87
85
|
[`activeFacet${facet.section}`]: isActiveFacet,
|
|
88
86
|
})}
|
|
@@ -91,96 +89,60 @@ const FacetView = ({
|
|
|
91
89
|
</div>
|
|
92
90
|
</CustomAccordionSummary>
|
|
93
91
|
)}
|
|
94
|
-
{
|
|
95
|
-
(facet.type === InputTypes.SLIDER || facetValues.length === 0)
|
|
96
|
-
&& (
|
|
92
|
+
{facetValues.length === 0 && (
|
|
97
93
|
<div className={classes.NonSortGroup}>
|
|
98
|
-
<span
|
|
99
|
-
className={classes.NonSortGroupItem}
|
|
100
|
-
>
|
|
94
|
+
<span className={classes.NonSortGroupItem}>
|
|
101
95
|
No data for this field
|
|
102
96
|
</span>
|
|
103
97
|
</div>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
{
|
|
107
|
-
(facet.type === InputTypes.SLIDER || facetValues.length > 0)
|
|
108
|
-
&& (
|
|
98
|
+
)}
|
|
99
|
+
{facetValues.length > 0 && (
|
|
109
100
|
<div className={classes.sortGroup}>
|
|
110
101
|
<span className={classes.sortGroupIcon}>
|
|
111
|
-
<Icon
|
|
112
|
-
|
|
113
|
-
onClick={onClearSection}
|
|
114
|
-
>
|
|
115
|
-
<img
|
|
116
|
-
src={clearIcon}
|
|
117
|
-
height={12}
|
|
118
|
-
width={12}
|
|
119
|
-
alt="clear-icon"
|
|
120
|
-
/>
|
|
102
|
+
<Icon style={{ fontSize: 10 }} onClick={onClearSection}>
|
|
103
|
+
<img src={clearIcon} height={12} width={12} alt="clear-icon" />
|
|
121
104
|
</Icon>
|
|
122
105
|
</span>
|
|
123
|
-
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
>
|
|
148
|
-
Sort by count
|
|
149
|
-
</span>
|
|
150
|
-
</>
|
|
151
|
-
)}
|
|
106
|
+
{facet.type === InputTypes.CHECKBOX && facetValues.length > 0 && (
|
|
107
|
+
<>
|
|
108
|
+
<span
|
|
109
|
+
className={clsx(classes.sortGroupItem, {
|
|
110
|
+
[classes.highlight]: sortBy === sortType.ALPHABET,
|
|
111
|
+
})}
|
|
112
|
+
onClick={() => {
|
|
113
|
+
onSortFacet(sortType.ALPHABET);
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
Sort alphabetically
|
|
117
|
+
</span>
|
|
118
|
+
<span
|
|
119
|
+
className={clsx(classes.sortGroupItemCounts, {
|
|
120
|
+
[classes.highlight]: sortBy === sortType.NUMERIC,
|
|
121
|
+
})}
|
|
122
|
+
onClick={() => {
|
|
123
|
+
onSortFacet(sortType.NUMERIC);
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
Sort by count
|
|
127
|
+
</span>
|
|
128
|
+
</>
|
|
129
|
+
)}
|
|
152
130
|
</div>
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
{(expand)
|
|
156
|
-
&& (
|
|
157
|
-
<FilterItems
|
|
158
|
-
facet={facet}
|
|
159
|
-
sortBy={sortBy}
|
|
160
|
-
/>
|
|
161
|
-
)}
|
|
131
|
+
)}
|
|
132
|
+
{expand && <FilterItems facet={facet} sortBy={sortBy} />}
|
|
162
133
|
</Accordion>
|
|
163
|
-
{
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
}
|
|
134
|
+
{!expand && type === InputTypes.CHECKBOX && selectedItems.length > 0 && (
|
|
135
|
+
<>
|
|
136
|
+
<List id="filter_Items">
|
|
137
|
+
<FilterItems facet={displayFacet} />
|
|
138
|
+
</List>
|
|
139
|
+
</>
|
|
140
|
+
)}
|
|
141
|
+
{!expand && selectedItems.length > limitCheckBoxCount && (
|
|
142
|
+
<div className={classes.showMore} onClick={onExpandFacet}>
|
|
143
|
+
...expand to see all selections
|
|
144
|
+
</div>
|
|
145
|
+
)}
|
|
184
146
|
</>
|
|
185
147
|
);
|
|
186
148
|
};
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
/* eslint-disable object-curly-newline */
|
|
6
6
|
/* eslint-disable object-shorthand */
|
|
7
7
|
/* eslint-disable react/jsx-one-expression-per-line */
|
|
8
|
-
/* eslint-disable no-useless-escape */
|
|
9
|
-
|
|
10
8
|
import React from 'react';
|
|
11
9
|
import { withStyles } from '@material-ui/core/styles';
|
|
12
10
|
import {
|
|
@@ -24,6 +22,8 @@ import {
|
|
|
24
22
|
} from '@material-ui/icons';
|
|
25
23
|
import styles from './CheckboxStyle';
|
|
26
24
|
|
|
25
|
+
const alignment = 'flex-start';
|
|
26
|
+
|
|
27
27
|
const CheckBoxView = ({
|
|
28
28
|
classes,
|
|
29
29
|
checkboxItem,
|
|
@@ -32,26 +32,20 @@ const CheckBoxView = ({
|
|
|
32
32
|
facet,
|
|
33
33
|
}) => {
|
|
34
34
|
const {
|
|
35
|
+
name,
|
|
36
|
+
subjects,
|
|
35
37
|
isChecked = false,
|
|
36
38
|
index,
|
|
37
39
|
section,
|
|
38
40
|
tooltip,
|
|
41
|
+
label,
|
|
39
42
|
} = checkboxItem;
|
|
40
|
-
const {
|
|
41
|
-
field = 'group',
|
|
42
|
-
count = 'subjects',
|
|
43
|
-
customCount = (text) => `(${text})`,
|
|
44
|
-
defaultValue = '',
|
|
45
|
-
} = facet;
|
|
46
|
-
|
|
47
43
|
const indexType = index % 2 === 0 ? 'Even' : 'Odd';
|
|
48
|
-
const checkedSection = `${section}`.toLowerCase().replace(
|
|
49
|
-
|
|
50
|
-
const name = checkboxItem[field] || defaultValue || 'N/A';
|
|
44
|
+
const checkedSection = `${section}`.toLowerCase().replace(' ', '_');
|
|
51
45
|
|
|
52
46
|
const handleToggle = () => {
|
|
53
47
|
const toggleCheckBoxItem = {
|
|
54
|
-
name:
|
|
48
|
+
name: name,
|
|
55
49
|
datafield: datafield,
|
|
56
50
|
isChecked: !isChecked,
|
|
57
51
|
};
|
|
@@ -66,9 +60,9 @@ const CheckBoxView = ({
|
|
|
66
60
|
[`${checkedSection}NameChecked`]: isChecked,
|
|
67
61
|
})}
|
|
68
62
|
>
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
</Typography>
|
|
63
|
+
{label ? (
|
|
64
|
+
<Typography className={classes.checkboxLabel}>{label}</Typography>
|
|
65
|
+
) : (<Typography className={classes.checkboxName}>{name}</Typography>)}
|
|
72
66
|
</Box>
|
|
73
67
|
);
|
|
74
68
|
|
|
@@ -84,12 +78,7 @@ const CheckBoxView = ({
|
|
|
84
78
|
>
|
|
85
79
|
<Checkbox
|
|
86
80
|
id={`checkbox_${facet.label}_${name}`}
|
|
87
|
-
icon={
|
|
88
|
-
<CheckBoxBlankIcon
|
|
89
|
-
style={{ fontSize: 18 }}
|
|
90
|
-
className={checkedSection}
|
|
91
|
-
/>
|
|
92
|
-
}
|
|
81
|
+
icon={<CheckBoxBlankIcon style={{ fontSize: 18 }} />}
|
|
93
82
|
onClick={handleToggle}
|
|
94
83
|
checked={isChecked}
|
|
95
84
|
checkedIcon={(
|
|
@@ -103,25 +92,24 @@ const CheckBoxView = ({
|
|
|
103
92
|
disableRipple
|
|
104
93
|
color="secondary"
|
|
105
94
|
classes={{ root: classes.checkboxRoot }}
|
|
106
|
-
inputProps={{ 'aria-label': 'Select' }}
|
|
107
95
|
/>
|
|
108
96
|
{ tooltip ? (
|
|
109
97
|
<Tooltip id={datafield} title={tooltip}>
|
|
110
98
|
<div className={datafield}>
|
|
111
|
-
|
|
99
|
+
<LabelComponent />
|
|
112
100
|
</div>
|
|
113
101
|
</Tooltip>
|
|
114
102
|
) : (
|
|
115
103
|
<LabelComponent />
|
|
116
104
|
)}
|
|
117
|
-
<ListItemText
|
|
105
|
+
<ListItemText />
|
|
118
106
|
<Typography
|
|
119
107
|
className={clsx(`${checkedSection}Subjects`, {
|
|
120
108
|
[`${checkedSection}SubjectUnChecked`]: !isChecked,
|
|
121
109
|
[`${checkedSection}SubjectChecked`]: isChecked,
|
|
122
110
|
})}
|
|
123
111
|
>
|
|
124
|
-
{
|
|
112
|
+
{`(${subjects})`}
|
|
125
113
|
</Typography>
|
|
126
114
|
</ListItem>
|
|
127
115
|
<Divider
|
|
@@ -14,15 +14,7 @@ const SliderView = ({
|
|
|
14
14
|
onSliderToggle,
|
|
15
15
|
filterState,
|
|
16
16
|
}) => {
|
|
17
|
-
const {
|
|
18
|
-
minLowerBound,
|
|
19
|
-
maxUpperBound,
|
|
20
|
-
quantifier,
|
|
21
|
-
datafield,
|
|
22
|
-
facetValues,
|
|
23
|
-
CustomLowerUpperBound,
|
|
24
|
-
CustomSliderValue,
|
|
25
|
-
} = facet;
|
|
17
|
+
const { minLowerBound, maxUpperBound, quantifier, datafield, facetValues } = facet;
|
|
26
18
|
const lowerBoundValue = facetValues[0];
|
|
27
19
|
const upperBoundValue = facetValues[1];
|
|
28
20
|
|
|
@@ -107,26 +99,24 @@ const SliderView = ({
|
|
|
107
99
|
}}
|
|
108
100
|
/>
|
|
109
101
|
</div>
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
{maxUpperBound}
|
|
119
|
-
</Typography>
|
|
120
|
-
</Box>
|
|
121
|
-
)}
|
|
102
|
+
<Box className={classes.lowerUpperBound}>
|
|
103
|
+
<Typography className={classes.lowerBound}>
|
|
104
|
+
{minLowerBound}
|
|
105
|
+
</Typography>
|
|
106
|
+
<Typography className={classes.upperBound}>
|
|
107
|
+
{maxUpperBound}
|
|
108
|
+
</Typography>
|
|
109
|
+
</Box>
|
|
122
110
|
</div>
|
|
123
111
|
{/* Change to red if invalid range */}
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
112
|
+
{
|
|
113
|
+
(sliderValue[0] > minLowerBound || sliderValue[1] < maxUpperBound)
|
|
114
|
+
&& (
|
|
115
|
+
<Typography
|
|
116
|
+
className={isValid()
|
|
117
|
+
? classes.sliderText
|
|
118
|
+
: classes.invalidSliderText}
|
|
119
|
+
>
|
|
130
120
|
{sliderValue[0]}
|
|
131
121
|
{' - '}
|
|
132
122
|
{sliderValue[1]}
|
|
@@ -134,7 +124,7 @@ const SliderView = ({
|
|
|
134
124
|
{quantifier}
|
|
135
125
|
</Typography>
|
|
136
126
|
)
|
|
137
|
-
|
|
127
|
+
}
|
|
138
128
|
</>
|
|
139
129
|
);
|
|
140
130
|
};
|
package/src/utils/Sort.js
CHANGED
|
@@ -37,28 +37,22 @@ export const getNumberArray = (range) => {
|
|
|
37
37
|
* @param {array} checkboxData
|
|
38
38
|
* @return {array}
|
|
39
39
|
*/
|
|
40
|
-
export const sortBySection = ({
|
|
41
|
-
facetValues,
|
|
42
|
-
sort_type,
|
|
43
|
-
sortBy,
|
|
44
|
-
field,
|
|
45
|
-
count = 'subjects',
|
|
46
|
-
}) => {
|
|
40
|
+
export const sortBySection = ({ facetValues, sort_type, sortBy }) => {
|
|
47
41
|
const sortfacetValues = [...facetValues];
|
|
48
42
|
if (!sortfacetValues) {
|
|
49
43
|
return facetValues;
|
|
50
44
|
}
|
|
51
45
|
if (sortBy === sortType.NUMERIC) {
|
|
52
|
-
sortfacetValues.sort((a, b) => b
|
|
46
|
+
sortfacetValues.sort((a, b) => b.subjects - a.subjects);
|
|
53
47
|
} else {
|
|
54
|
-
sortfacetValues.sort(((a, b) => (lowerCaseString(a
|
|
55
|
-
|| -(lowerCaseString(a
|
|
48
|
+
sortfacetValues.sort(((a, b) => (lowerCaseString(a.name) > lowerCaseString(b.name)
|
|
49
|
+
|| -(lowerCaseString(a.name) < lowerCaseString(b.name)))));
|
|
56
50
|
}
|
|
57
51
|
|
|
58
52
|
if (sort_type === sortType.CUSTOM_NUMBER && sortBy !== sortType.NUMERIC) {
|
|
59
53
|
sortfacetValues.sort((a, b) => {
|
|
60
|
-
const aNumbs = getNumberArray(a
|
|
61
|
-
const bNumbs = getNumberArray(b
|
|
54
|
+
const aNumbs = getNumberArray(a.name);
|
|
55
|
+
const bNumbs = getNumberArray(b.name);
|
|
62
56
|
const aNumb = Number(aNumbs[0]);
|
|
63
57
|
const bNumb = Number(bNumbs[0]);
|
|
64
58
|
return (aNumbs.length === bNumbs.length) ? aNumb > bNumb : -(aNumb <= bNumb);
|
|
@@ -66,8 +60,8 @@ export const sortBySection = ({
|
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
if (sort_type === sortType.RANGE && sortBy !== sortType.NUMERIC) {
|
|
69
|
-
sortfacetValues.sort(((a, b) => (startIndex(a
|
|
70
|
-
|| -(startIndex(a
|
|
63
|
+
sortfacetValues.sort(((a, b) => (startIndex(a.name) > startIndex(b.name)
|
|
64
|
+
|| -(startIndex(a.name) < startIndex(b.name)))));
|
|
71
65
|
}
|
|
72
66
|
/**
|
|
73
67
|
* Display checked item always on top
|