@bento-core/query-bar 1.0.1-icdc.1 → 1.0.1-icdc.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.
|
@@ -38,6 +38,8 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
38
38
|
const styles = () => _objectSpread(_objectSpread({}, (0, _styles.default)()), customStyles);
|
|
39
39
|
const maxItems = config && typeof config.maxItems === 'number' ? config.maxItems : _config.default.config.maxItems;
|
|
40
40
|
const displayAllActiveFilters = config && typeof config.displayAllActiveFilters === 'boolean' ? config.displayAllActiveFilters : _config.default.config.displayAllActiveFilters;
|
|
41
|
+
const group = config && typeof config.group === 'string' ? config.group : _config.default.config.group;
|
|
42
|
+
const count = config && typeof config.count === 'string' ? config.count : _config.default.config.count;
|
|
41
43
|
const clearAll = functions && typeof functions.clearAll === 'function' ? functions.clearAll : _config.default.functions.clearAll;
|
|
42
44
|
const clearUpload = functions && typeof functions.clearUpload === 'function' ? functions.clearUpload : _config.default.functions.clearUpload;
|
|
43
45
|
const clearAutocomplete = functions && typeof functions.clearAutocomplete === 'function' ? functions.clearAutocomplete : _config.default.functions.clearAutocomplete;
|
|
@@ -96,10 +98,11 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
96
98
|
* Display active filter items in query bar only if count is greater than 0
|
|
97
99
|
* behavior similar to filter component
|
|
98
100
|
*/
|
|
101
|
+
// const { group, count } = config;
|
|
99
102
|
const displayItems = itemKeys.reduce((accumulator, item) => {
|
|
100
|
-
const itemList = data.filter(d => d
|
|
103
|
+
const itemList = data.filter(d => d[group] === item && d[count] > 0) || [];
|
|
101
104
|
if (itemList.length > 0) {
|
|
102
|
-
const labels = itemList.map(filter => filter
|
|
105
|
+
const labels = itemList.map(filter => filter[group]);
|
|
103
106
|
accumulator.push(labels);
|
|
104
107
|
}
|
|
105
108
|
return accumulator;
|
|
@@ -17,7 +17,17 @@ var _default = {
|
|
|
17
17
|
* overirdes maxItems to display all the active filter items
|
|
18
18
|
* @var {boolean}
|
|
19
19
|
*/
|
|
20
|
-
displayAllActiveFilters: false
|
|
20
|
+
displayAllActiveFilters: false,
|
|
21
|
+
/**
|
|
22
|
+
* key to access label text
|
|
23
|
+
* @var {boolean}
|
|
24
|
+
*/
|
|
25
|
+
group: 'group',
|
|
26
|
+
/**
|
|
27
|
+
* key to access count value
|
|
28
|
+
* @var {boolean}
|
|
29
|
+
*/
|
|
30
|
+
count: 'subjects'
|
|
21
31
|
},
|
|
22
32
|
/* Component Helper Functions */
|
|
23
33
|
functions: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/query-bar",
|
|
3
|
-
"version": "1.0.1-icdc.
|
|
3
|
+
"version": "1.0.1-icdc.2",
|
|
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": {
|
|
@@ -27,6 +27,12 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
|
|
|
27
27
|
? config.displayAllActiveFilters
|
|
28
28
|
: DEFAULT_CONFIG.config.displayAllActiveFilters;
|
|
29
29
|
|
|
30
|
+
const group = config && typeof config.group === 'string'
|
|
31
|
+
? config.group : DEFAULT_CONFIG.config.group;
|
|
32
|
+
|
|
33
|
+
const count = config && typeof config.count === 'string'
|
|
34
|
+
? config.count : DEFAULT_CONFIG.config.count;
|
|
35
|
+
|
|
30
36
|
const clearAll = functions && typeof functions.clearAll === 'function'
|
|
31
37
|
? functions.clearAll
|
|
32
38
|
: DEFAULT_CONFIG.functions.clearAll;
|
|
@@ -95,10 +101,11 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
|
|
|
95
101
|
* Display active filter items in query bar only if count is greater than 0
|
|
96
102
|
* behavior similar to filter component
|
|
97
103
|
*/
|
|
104
|
+
// const { group, count } = config;
|
|
98
105
|
const displayItems = itemKeys.reduce((accumulator, item) => {
|
|
99
|
-
const itemList = data.filter((d) => (d
|
|
106
|
+
const itemList = data.filter((d) => (d[group] === item && d[count] > 0)) || [];
|
|
100
107
|
if (itemList.length > 0) {
|
|
101
|
-
const labels = itemList.map((filter) => filter
|
|
108
|
+
const labels = itemList.map((filter) => filter[group]);
|
|
102
109
|
accumulator.push(labels);
|
|
103
110
|
}
|
|
104
111
|
return accumulator;
|
package/src/generators/config.js
CHANGED
|
@@ -12,6 +12,16 @@ export default {
|
|
|
12
12
|
* @var {boolean}
|
|
13
13
|
*/
|
|
14
14
|
displayAllActiveFilters: false,
|
|
15
|
+
/**
|
|
16
|
+
* key to access label text
|
|
17
|
+
* @var {boolean}
|
|
18
|
+
*/
|
|
19
|
+
group: 'group',
|
|
20
|
+
/**
|
|
21
|
+
* key to access count value
|
|
22
|
+
* @var {boolean}
|
|
23
|
+
*/
|
|
24
|
+
count: 'subjects',
|
|
15
25
|
},
|
|
16
26
|
|
|
17
27
|
/* Component Helper Functions */
|