@bento-core/query-bar 1.0.1-icdc.3 → 1.0.1-ins.0
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 +0 -10
- package/dist/generators/QueryBarGenerator.js +23 -14
- package/dist/generators/config.js +6 -1
- package/dist/generators/styles.js +2 -2
- package/package.json +11 -4
- package/src/generators/QueryBarGenerator.js +28 -13
- package/src/generators/config.js +5 -0
- package/src/generators/styles.js +2 -2
package/README.md
CHANGED
|
@@ -58,16 +58,6 @@ const CONFIG = {
|
|
|
58
58
|
* @var {number}
|
|
59
59
|
*/
|
|
60
60
|
maxItems: 2,
|
|
61
|
-
/**
|
|
62
|
-
* overirdes maxItems to display all the active filter items
|
|
63
|
-
* @var {boolean}
|
|
64
|
-
*/
|
|
65
|
-
displayAllActiveFilters: false,
|
|
66
|
-
/**
|
|
67
|
-
* key to access label text
|
|
68
|
-
* @var {boolean}
|
|
69
|
-
*/
|
|
70
|
-
group: 'group',
|
|
71
61
|
},
|
|
72
62
|
|
|
73
63
|
/* Component Helper Functions */
|
|
@@ -38,10 +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
|
-
|
|
42
|
-
|
|
43
|
-
// ? config.group : DEFAULT_CONFIG.config.group;
|
|
44
|
-
|
|
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;
|
|
45
43
|
const clearAll = functions && typeof functions.clearAll === 'function' ? functions.clearAll : _config.default.functions.clearAll;
|
|
46
44
|
const clearUpload = functions && typeof functions.clearUpload === 'function' ? functions.clearUpload : _config.default.functions.clearUpload;
|
|
47
45
|
const clearAutocomplete = functions && typeof functions.clearAutocomplete === 'function' ? functions.clearAutocomplete : _config.default.functions.clearAutocomplete;
|
|
@@ -80,6 +78,7 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
80
78
|
return facet;
|
|
81
79
|
}
|
|
82
80
|
const {
|
|
81
|
+
data,
|
|
83
82
|
items
|
|
84
83
|
} = facet;
|
|
85
84
|
const itemKeys = Object.keys(items);
|
|
@@ -87,19 +86,29 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
87
86
|
|
|
88
87
|
/* Find any SELECTED CHECKBOXES that do NOT have any data
|
|
89
88
|
* and remove them from the list of selected checkboxes artificially */
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
itemKeys.forEach(item => {
|
|
90
|
+
if (data.findIndex(d => d.group === item) < 0) {
|
|
91
|
+
itemKeys.splice(itemKeys.indexOf(item), 1);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
// return { ...facet, items: itemKeys };
|
|
96
95
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
96
|
+
* Maintain consistant behavior with facet filter component
|
|
97
|
+
* Display the active filter items based on the count value
|
|
98
|
+
* Display active filter items in query bar only if count is greater than 0
|
|
99
|
+
* behavior similar to filter component
|
|
100
100
|
*/
|
|
101
|
+
// const { group, count } = config;
|
|
102
|
+
const displayItems = itemKeys.reduce((accumulator, item) => {
|
|
103
|
+
const itemList = data.filter(d => d[group] === item && d[count] > 0) || [];
|
|
104
|
+
if (itemList.length > 0) {
|
|
105
|
+
const labels = itemList.map(filter => filter[group]);
|
|
106
|
+
accumulator.push(labels);
|
|
107
|
+
}
|
|
108
|
+
return accumulator;
|
|
109
|
+
}, []);
|
|
101
110
|
return _objectSpread(_objectSpread({}, facet), {}, {
|
|
102
|
-
items:
|
|
111
|
+
items: displayItems
|
|
103
112
|
});
|
|
104
113
|
}).filter(facet => facet.items.length > 0);
|
|
105
114
|
if ((mappedInputs.length || autocomplete.length || upload.length) <= 0) {
|
|
@@ -22,7 +22,12 @@ var _default = {
|
|
|
22
22
|
* key to access label text
|
|
23
23
|
* @var {boolean}
|
|
24
24
|
*/
|
|
25
|
-
group: 'group'
|
|
25
|
+
group: 'group',
|
|
26
|
+
/**
|
|
27
|
+
* key to access count value
|
|
28
|
+
* @var {boolean}
|
|
29
|
+
*/
|
|
30
|
+
count: 'subjects'
|
|
26
31
|
},
|
|
27
32
|
/* Component Helper Functions */
|
|
28
33
|
functions: {
|
|
@@ -92,10 +92,10 @@ var _default = () => ({
|
|
|
92
92
|
localFindBackground: {
|
|
93
93
|
backgroundColor: '#C0E9D7'
|
|
94
94
|
},
|
|
95
|
-
|
|
95
|
+
facetSectionProjects: {
|
|
96
96
|
color: '#10A075'
|
|
97
97
|
},
|
|
98
|
-
|
|
98
|
+
facetSectionProjectsBackground: {
|
|
99
99
|
backgroundColor: '#C0E9D7'
|
|
100
100
|
},
|
|
101
101
|
facetSectionFiles: {
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/query-bar",
|
|
3
|
-
"version": "1.0.1-
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.1-ins.0",
|
|
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": {
|
|
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":
|
|
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
|
"lodash": "^4.17.20"
|
|
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,5 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import { withStyles, Button } from '@material-ui/core';
|
|
3
|
+
// eslint-disable-next-line import/no-unresolved
|
|
3
4
|
import { InputTypes } from '@bento-core/facet-filter';
|
|
4
5
|
import clsx from 'clsx';
|
|
5
6
|
import { Filter } from '../components/FilterMap';
|
|
@@ -27,8 +28,11 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
|
|
|
27
28
|
? config.displayAllActiveFilters
|
|
28
29
|
: DEFAULT_CONFIG.config.displayAllActiveFilters;
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const group = config && typeof config.group === 'string'
|
|
32
|
+
? config.group : DEFAULT_CONFIG.config.group;
|
|
33
|
+
|
|
34
|
+
const count = config && typeof config.count === 'string'
|
|
35
|
+
? config.count : DEFAULT_CONFIG.config.count;
|
|
32
36
|
|
|
33
37
|
const clearAll = functions && typeof functions.clearAll === 'function'
|
|
34
38
|
? functions.clearAll
|
|
@@ -80,24 +84,35 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
|
|
|
80
84
|
.map((facet) => {
|
|
81
85
|
if (facet.type !== CHECKBOX) { return facet; }
|
|
82
86
|
|
|
83
|
-
const { items } = facet;
|
|
87
|
+
const { data, items } = facet;
|
|
84
88
|
const itemKeys = Object.keys(items);
|
|
85
89
|
itemKeys.sort((a, b) => a.localeCompare(b));
|
|
86
90
|
|
|
87
91
|
/* Find any SELECTED CHECKBOXES that do NOT have any data
|
|
88
92
|
* and remove them from the list of selected checkboxes artificially */
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
itemKeys.forEach((item) => {
|
|
94
|
+
if (data.findIndex((d) => d.group === item) < 0) {
|
|
95
|
+
itemKeys.splice(itemKeys.indexOf(item), 1);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
// return { ...facet, items: itemKeys };
|
|
95
99
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
100
|
+
* Maintain consistant behavior with facet filter component
|
|
101
|
+
* Display the active filter items based on the count value
|
|
102
|
+
* Display active filter items in query bar only if count is greater than 0
|
|
103
|
+
* behavior similar to filter component
|
|
99
104
|
*/
|
|
100
|
-
|
|
105
|
+
// const { group, count } = config;
|
|
106
|
+
const displayItems = itemKeys.reduce((accumulator, item) => {
|
|
107
|
+
const itemList = data.filter((d) => (d[group] === item && d[count] > 0)) || [];
|
|
108
|
+
if (itemList.length > 0) {
|
|
109
|
+
const labels = itemList.map((filter) => filter[group]);
|
|
110
|
+
accumulator.push(labels);
|
|
111
|
+
}
|
|
112
|
+
return accumulator;
|
|
113
|
+
}, []);
|
|
114
|
+
|
|
115
|
+
return { ...facet, items: displayItems };
|
|
101
116
|
})
|
|
102
117
|
.filter((facet) => facet.items.length > 0);
|
|
103
118
|
|
package/src/generators/config.js
CHANGED
package/src/generators/styles.js
CHANGED
|
@@ -86,10 +86,10 @@ export default () => ({
|
|
|
86
86
|
localFindBackground: {
|
|
87
87
|
backgroundColor: '#C0E9D7',
|
|
88
88
|
},
|
|
89
|
-
|
|
89
|
+
facetSectionProjects: {
|
|
90
90
|
color: '#10A075',
|
|
91
91
|
},
|
|
92
|
-
|
|
92
|
+
facetSectionProjectsBackground: {
|
|
93
93
|
backgroundColor: '#C0E9D7',
|
|
94
94
|
},
|
|
95
95
|
facetSectionFiles: {
|