@bento-core/query-bar 1.0.0-c3dc.8 → 1.0.0-c3dc.9
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.
|
@@ -17,18 +17,49 @@ var _default = _ref => {
|
|
|
17
17
|
} = _ref;
|
|
18
18
|
const {
|
|
19
19
|
items,
|
|
20
|
-
section
|
|
20
|
+
section,
|
|
21
|
+
unknownAges
|
|
21
22
|
} = data;
|
|
23
|
+
const getDisplayContent = () => {
|
|
24
|
+
const baseLabel = data.label;
|
|
25
|
+
const hasRange = items && items.length >= 2;
|
|
26
|
+
|
|
27
|
+
// If unknownAges is 'only', we're showing only unknown ages
|
|
28
|
+
if (unknownAges === 'only') {
|
|
29
|
+
return {
|
|
30
|
+
label: "".concat(baseLabel, " (Unknown Ages Only)"),
|
|
31
|
+
showRange: false,
|
|
32
|
+
rangeText: ''
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// If unknownAges is 'exclude', we're excluding unknown ages from the range
|
|
37
|
+
if (unknownAges === 'exclude') {
|
|
38
|
+
return {
|
|
39
|
+
label: "".concat(baseLabel, " (Unknown Ages Excluded)"),
|
|
40
|
+
showRange: hasRange,
|
|
41
|
+
rangeText: hasRange ? "".concat(items[0], " \u2013 ").concat(items[1]) : ''
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Default: unknownAges is 'include' or not set
|
|
46
|
+
return {
|
|
47
|
+
label: baseLabel,
|
|
48
|
+
showRange: hasRange,
|
|
49
|
+
rangeText: hasRange ? "".concat(items[0], " \u2013 ").concat(items[1]) : ''
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const displayContent = getDisplayContent();
|
|
22
53
|
return /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement("span", null, ' ', index !== 0 ? /*#__PURE__*/_react.default.createElement("span", {
|
|
23
54
|
className: classes.operators
|
|
24
55
|
}, " AND ") : '', /*#__PURE__*/_react.default.createElement("span", {
|
|
25
56
|
className: (0, _clsx.default)(classes.filterName, classes["facetSection".concat(section, "Background")]),
|
|
26
57
|
onClick: () => onSectionClick(data)
|
|
27
|
-
},
|
|
58
|
+
}, displayContent.label), ' '), displayContent.showRange && /*#__PURE__*/_react.default.createElement("span", null, ' ', /*#__PURE__*/_react.default.createElement("span", {
|
|
28
59
|
className: classes.operators
|
|
29
60
|
}, "IS BETWEEN", ' '), /*#__PURE__*/_react.default.createElement("span", {
|
|
30
61
|
className: (0, _clsx.default)(classes.filterCheckboxes, classes["facetSection".concat(section)]),
|
|
31
62
|
onClick: () => onItemClick(data, items[0])
|
|
32
|
-
},
|
|
63
|
+
}, displayContent.rangeText)));
|
|
33
64
|
};
|
|
34
65
|
exports.default = _default;
|
|
@@ -82,7 +82,7 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
82
82
|
return _objectSpread(_objectSpread({}, facet), {}, {
|
|
83
83
|
items: itemKeys
|
|
84
84
|
});
|
|
85
|
-
}).filter(facet => facet.items.length > 0);
|
|
85
|
+
}).filter(facet => facet.items.length > 0 || facet.unknownAges && facet.unknownAges !== 'include');
|
|
86
86
|
if ((mappedInputs.length || autocomplete.length || upload.length) <= 0) {
|
|
87
87
|
return null;
|
|
88
88
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/query-bar",
|
|
3
|
-
"version": "1.0.0-c3dc.
|
|
3
|
+
"version": "1.0.0-c3dc.9",
|
|
4
4
|
"description": "This package provides the Query Bar component that displays the current Facet Search and Local Find filters on the Dashboard/Explore page. It also provides the direct ability to reset all or some of the filters with the click of a button. It is designed to be implemented directly with the:",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"react-redux": "^7.2.1"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@bento-core/facet-filter": "^1.0.1-c3dc.
|
|
26
|
+
"@bento-core/facet-filter": "^1.0.1-c3dc.9",
|
|
27
27
|
"lodash": "^4.17.20"
|
|
28
28
|
},
|
|
29
29
|
"author": "CTOS Bento Team",
|
|
@@ -5,7 +5,39 @@ export default ({
|
|
|
5
5
|
index, data, classes,
|
|
6
6
|
onSectionClick, onItemClick,
|
|
7
7
|
}) => {
|
|
8
|
-
const { items, section } = data;
|
|
8
|
+
const { items, section, unknownAges } = data;
|
|
9
|
+
|
|
10
|
+
const getDisplayContent = () => {
|
|
11
|
+
const baseLabel = data.label;
|
|
12
|
+
const hasRange = items && items.length >= 2;
|
|
13
|
+
|
|
14
|
+
// If unknownAges is 'only', we're showing only unknown ages
|
|
15
|
+
if (unknownAges === 'only') {
|
|
16
|
+
return {
|
|
17
|
+
label: `${baseLabel} (Unknown Ages Only)`,
|
|
18
|
+
showRange: false,
|
|
19
|
+
rangeText: '',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// If unknownAges is 'exclude', we're excluding unknown ages from the range
|
|
24
|
+
if (unknownAges === 'exclude') {
|
|
25
|
+
return {
|
|
26
|
+
label: `${baseLabel} (Unknown Ages Excluded)`,
|
|
27
|
+
showRange: hasRange,
|
|
28
|
+
rangeText: hasRange ? `${items[0]} – ${items[1]}` : '',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Default: unknownAges is 'include' or not set
|
|
33
|
+
return {
|
|
34
|
+
label: baseLabel,
|
|
35
|
+
showRange: hasRange,
|
|
36
|
+
rangeText: hasRange ? `${items[0]} – ${items[1]}` : '',
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const displayContent = getDisplayContent();
|
|
9
41
|
|
|
10
42
|
return (
|
|
11
43
|
<span>
|
|
@@ -16,23 +48,25 @@ export default ({
|
|
|
16
48
|
className={clsx(classes.filterName, classes[`facetSection${section}Background`])}
|
|
17
49
|
onClick={() => onSectionClick(data)}
|
|
18
50
|
>
|
|
19
|
-
{
|
|
51
|
+
{displayContent.label}
|
|
20
52
|
</span>
|
|
21
53
|
{' '}
|
|
22
54
|
</span>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<span className={classes.operators}>
|
|
26
|
-
IS BETWEEN
|
|
55
|
+
{displayContent.showRange && (
|
|
56
|
+
<span>
|
|
27
57
|
{' '}
|
|
58
|
+
<span className={classes.operators}>
|
|
59
|
+
IS BETWEEN
|
|
60
|
+
{' '}
|
|
61
|
+
</span>
|
|
62
|
+
<span
|
|
63
|
+
className={clsx(classes.filterCheckboxes, classes[`facetSection${section}`])}
|
|
64
|
+
onClick={() => onItemClick(data, items[0])}
|
|
65
|
+
>
|
|
66
|
+
{displayContent.rangeText}
|
|
67
|
+
</span>
|
|
28
68
|
</span>
|
|
29
|
-
|
|
30
|
-
className={clsx(classes.filterCheckboxes, classes[`facetSection${section}`])}
|
|
31
|
-
onClick={() => onItemClick(data, items[0])}
|
|
32
|
-
>
|
|
33
|
-
{`${items[0]} – ${items[1]}`}
|
|
34
|
-
</span>
|
|
35
|
-
</span>
|
|
69
|
+
)}
|
|
36
70
|
</span>
|
|
37
71
|
);
|
|
38
72
|
};
|
|
@@ -91,7 +91,7 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
|
|
|
91
91
|
|
|
92
92
|
return { ...facet, items: itemKeys };
|
|
93
93
|
})
|
|
94
|
-
.filter((facet) => facet.items.length > 0);
|
|
94
|
+
.filter((facet) => facet.items.length > 0 || (facet.unknownAges && facet.unknownAges !== 'include'));
|
|
95
95
|
|
|
96
96
|
if ((mappedInputs.length || autocomplete.length || upload.length) <= 0) {
|
|
97
97
|
return null;
|