@bento-core/query-bar 1.0.1-icdc.2 → 1.0.1-icdc.4
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 +10 -0
- package/dist/assets/CopyIcon.svg +3 -0
- package/dist/components/QueryUrl.js +68 -0
- package/dist/generators/QueryBarGenerator.js +24 -25
- package/dist/generators/config.js +7 -2
- package/dist/generators/styles.js +36 -0
- package/package.json +6 -13
- package/src/assets/CopyIcon.svg +3 -0
- package/src/components/QueryUrl.js +73 -0
- package/src/generators/QueryBarGenerator.js +147 -140
- package/src/generators/config.js +7 -2
- package/src/generators/styles.js +36 -0
package/README.md
CHANGED
|
@@ -58,6 +58,16 @@ 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',
|
|
61
71
|
},
|
|
62
72
|
|
|
63
73
|
/* Component Helper Functions */
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="16" height="19" viewBox="0 0 16 19" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M13 9.75715C13 10.0452 12.78 10.2714 12.5 10.2714H7.5C7.22 10.2714 7 10.0452 7 9.75715C7 9.46915 7.22 9.24287 7.5 9.24287H12.5C12.78 9.24287 13 9.46915 13 9.75715ZM12.5 11.3H7.5C7.22 11.3 7 11.5263 7 11.8143C7 12.1023 7.22 12.3286 7.5 12.3286H12.5C12.78 12.3286 13 12.1023 13 11.8143C13 11.5263 12.78 11.3 12.5 11.3ZM12.5 13.3572H7.5C7.22 13.3572 7 13.5834 7 13.8714C7 14.1594 7.22 14.3857 7.5 14.3857H12.5C12.78 14.3857 13 14.1594 13 13.8714C13 13.5834 12.78 13.3572 12.5 13.3572ZM16 8.21429V16.4429C16 17.5743 15.1 18.5 14 18.5H6C4.9 18.5 4 17.5743 4 16.4429V15.4143H2C0.9 15.4143 0 14.4886 0 13.3572V4.10001C0 2.96858 0.9 2.04286 2 2.04286H4.5C4.5 1.18915 5.17 0.500008 6 0.500008C6.83 0.500008 7.5 1.18915 7.5 2.04286H10C11.1 2.04286 12 2.96858 12 4.10001V6.15715H14C15.1 6.15715 16 7.08287 16 8.21429ZM6 6.15715H11V4.10001C11 3.53429 10.55 3.07144 10 3.07144H9V4.10001H3V3.07144H2C1.45 3.07144 1 3.53429 1 4.10001V13.3572C1 13.9229 1.45 14.3857 2 14.3857H4V8.21429C4 7.08287 4.9 6.15715 6 6.15715ZM15 8.21429C15 7.64858 14.55 7.18572 14 7.18572H6C5.45 7.18572 5 7.64858 5 8.21429V16.4429C5 17.0086 5.45 17.4714 6 17.4714H14C14.55 17.4714 15 17.0086 15 16.4429V8.21429Z" fill="#142D64"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _core = require("@material-ui/core");
|
|
9
|
+
var _CopyIcon = _interopRequireDefault(require("../assets/CopyIcon.svg"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
17
|
+
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); }
|
|
18
|
+
const QueryUrl = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
classes,
|
|
21
|
+
filterItems,
|
|
22
|
+
localFind,
|
|
23
|
+
rootPath
|
|
24
|
+
} = _ref;
|
|
25
|
+
const [expand, setExpand] = (0, _react.useState)(false);
|
|
26
|
+
const toggleExpand = () => setExpand(!expand);
|
|
27
|
+
const {
|
|
28
|
+
autocomplete = [],
|
|
29
|
+
upload
|
|
30
|
+
} = localFind;
|
|
31
|
+
const pathFilterParams = filterItems.reduce((acc, item) => {
|
|
32
|
+
const {
|
|
33
|
+
datafield,
|
|
34
|
+
items = []
|
|
35
|
+
} = item;
|
|
36
|
+
acc[datafield] = items;
|
|
37
|
+
return acc;
|
|
38
|
+
}, {});
|
|
39
|
+
const query = JSON.stringify(_objectSpread(_objectSpread({}, pathFilterParams), {}, {
|
|
40
|
+
autocomplete,
|
|
41
|
+
upload
|
|
42
|
+
}));
|
|
43
|
+
const url = encodeURI(rootPath.concat(query));
|
|
44
|
+
const copyUrl = async () => {
|
|
45
|
+
await navigator.clipboard.writeText(url);
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
48
|
+
className: classes.urlContainer
|
|
49
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
50
|
+
onClick: toggleExpand,
|
|
51
|
+
className: classes.viewLinkToggleBtn
|
|
52
|
+
}, expand ? 'Hide Query URL' : 'Show Query URL'), expand && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Link, {
|
|
53
|
+
target: "_blank",
|
|
54
|
+
href: url,
|
|
55
|
+
className: classes.link
|
|
56
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, url)), /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
57
|
+
title: "Copy to Clipboard",
|
|
58
|
+
className: classes.Tooltip
|
|
59
|
+
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
60
|
+
onClick: copyUrl,
|
|
61
|
+
className: classes.copyIconBtn
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
63
|
+
src: _CopyIcon.default,
|
|
64
|
+
alt: "copy icon"
|
|
65
|
+
})))));
|
|
66
|
+
};
|
|
67
|
+
var _default = QueryUrl;
|
|
68
|
+
exports.default = _default;
|
|
@@ -11,6 +11,7 @@ var _clsx = _interopRequireDefault(require("clsx"));
|
|
|
11
11
|
var _FilterMap = require("../components/FilterMap");
|
|
12
12
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
13
13
|
var _config = _interopRequireDefault(require("./config"));
|
|
14
|
+
var _QueryUrl = _interopRequireDefault(require("../components/QueryUrl"));
|
|
14
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
16
|
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); }
|
|
16
17
|
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; }
|
|
@@ -37,9 +38,13 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
37
38
|
} = _facetFilter.InputTypes;
|
|
38
39
|
const styles = () => _objectSpread(_objectSpread({}, (0, _styles.default)()), customStyles);
|
|
39
40
|
const maxItems = config && typeof config.maxItems === 'number' ? config.maxItems : _config.default.config.maxItems;
|
|
41
|
+
const queryURLRootPath = config && typeof config.rootPath === 'string' ? config.rootPath : _config.default.config.rootPath;
|
|
42
|
+
const viewQueryURL = config && typeof config.viewQueryURL === 'boolean' ? config.viewQueryURL : _config.default.config.viewQueryURL;
|
|
40
43
|
const displayAllActiveFilters = config && typeof config.displayAllActiveFilters === 'boolean' ? config.displayAllActiveFilters : _config.default.config.displayAllActiveFilters;
|
|
41
|
-
|
|
42
|
-
const
|
|
44
|
+
|
|
45
|
+
// const group = config && typeof config.group === 'string'
|
|
46
|
+
// ? config.group : DEFAULT_CONFIG.config.group;
|
|
47
|
+
|
|
43
48
|
const clearAll = functions && typeof functions.clearAll === 'function' ? functions.clearAll : _config.default.functions.clearAll;
|
|
44
49
|
const clearUpload = functions && typeof functions.clearUpload === 'function' ? functions.clearUpload : _config.default.functions.clearUpload;
|
|
45
50
|
const clearAutocomplete = functions && typeof functions.clearAutocomplete === 'function' ? functions.clearAutocomplete : _config.default.functions.clearAutocomplete;
|
|
@@ -78,7 +83,6 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
78
83
|
return facet;
|
|
79
84
|
}
|
|
80
85
|
const {
|
|
81
|
-
data,
|
|
82
86
|
items
|
|
83
87
|
} = facet;
|
|
84
88
|
const itemKeys = Object.keys(items);
|
|
@@ -86,35 +90,25 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
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
|
-
itemKeys.forEach(item => {
|
|
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
|
+
|
|
95
99
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* behavior similar to filter component
|
|
100
|
+
* commenting out line 89-93
|
|
101
|
+
* to display all the active filters in the query bar
|
|
102
|
+
* ICDC-3287
|
|
100
103
|
*/
|
|
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
|
-
}, []);
|
|
110
104
|
return _objectSpread(_objectSpread({}, facet), {}, {
|
|
111
|
-
items:
|
|
105
|
+
items: itemKeys
|
|
112
106
|
});
|
|
113
107
|
}).filter(facet => facet.items.length > 0);
|
|
114
108
|
if ((mappedInputs.length || autocomplete.length || upload.length) <= 0) {
|
|
115
109
|
return null;
|
|
116
110
|
}
|
|
117
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
111
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
118
112
|
className: classes.queryWrapper
|
|
119
113
|
}, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
120
114
|
className: classes.clearQueryButton,
|
|
@@ -163,7 +157,12 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
163
157
|
classes: classes,
|
|
164
158
|
onSectionClick: filter.type === CHECKBOX ? resetFacetSection : resetFacetSlider,
|
|
165
159
|
onItemClick: filter.type === CHECKBOX ? resetFacetCheckbox : resetFacetSlider
|
|
166
|
-
}))))
|
|
160
|
+
})))), viewQueryURL && queryURLRootPath && /*#__PURE__*/_react.default.createElement(_QueryUrl.default, {
|
|
161
|
+
classes: classes,
|
|
162
|
+
localFind: localFind,
|
|
163
|
+
filterItems: mappedInputs,
|
|
164
|
+
rootPath: queryURLRootPath
|
|
165
|
+
})));
|
|
167
166
|
})
|
|
168
167
|
};
|
|
169
168
|
};
|
|
@@ -24,10 +24,15 @@ var _default = {
|
|
|
24
24
|
*/
|
|
25
25
|
group: 'group',
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* root path of bento app
|
|
28
28
|
* @var {boolean}
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
rootPath: null,
|
|
31
|
+
/**
|
|
32
|
+
* display query URL
|
|
33
|
+
* @var {boolean}
|
|
34
|
+
*/
|
|
35
|
+
viewQueryURL: false
|
|
31
36
|
},
|
|
32
37
|
/* Component Helper Functions */
|
|
33
38
|
functions: {
|
|
@@ -119,6 +119,42 @@ var _default = () => ({
|
|
|
119
119
|
'&:hover': {
|
|
120
120
|
cursor: 'pointer'
|
|
121
121
|
}
|
|
122
|
+
},
|
|
123
|
+
urlContainer: {
|
|
124
|
+
marginTop: '10px'
|
|
125
|
+
},
|
|
126
|
+
link: {
|
|
127
|
+
lineBreak: 'anywhere',
|
|
128
|
+
fontFamily: 'Nunito',
|
|
129
|
+
fontSize: '12px',
|
|
130
|
+
fontWeight: '500',
|
|
131
|
+
lineHeight: '16px',
|
|
132
|
+
letterSpacing: '0em',
|
|
133
|
+
color: '#1D79A8',
|
|
134
|
+
backgroundColor: '#fff',
|
|
135
|
+
padding: '5px',
|
|
136
|
+
borderRadius: '5px',
|
|
137
|
+
marginLeft: '10px'
|
|
138
|
+
},
|
|
139
|
+
viewLinkToggleBtn: {
|
|
140
|
+
height: '20px',
|
|
141
|
+
fontFamily: 'Nunito',
|
|
142
|
+
fontSize: '12px',
|
|
143
|
+
fontWeight: '500',
|
|
144
|
+
lineHeight: '16px',
|
|
145
|
+
letterSpacing: '0em',
|
|
146
|
+
textAlign: 'left',
|
|
147
|
+
backgroundColor: '#1D79A8',
|
|
148
|
+
textTransform: 'none',
|
|
149
|
+
color: '#fff',
|
|
150
|
+
'&:hover': {
|
|
151
|
+
backgroundColor: '#1D79A8',
|
|
152
|
+
color: '#fff'
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
copyIconBtn: {
|
|
156
|
+
padding: '0px',
|
|
157
|
+
marginLeft: '10px'
|
|
122
158
|
}
|
|
123
159
|
});
|
|
124
160
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/query-bar",
|
|
3
|
-
"version": "1.0.1-icdc.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1-icdc.4",
|
|
4
|
+
"description": "",
|
|
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":
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/CBIIT/bento-frontend.git"
|
|
14
|
-
},
|
|
11
|
+
"repository": "https://github.com/CBIIT/bento-frontend",
|
|
15
12
|
"publishConfig": {
|
|
16
13
|
"access": "public"
|
|
17
14
|
},
|
|
@@ -20,17 +17,13 @@
|
|
|
20
17
|
"clsx": "^1.2.1",
|
|
21
18
|
"react": "^17.0.2",
|
|
22
19
|
"react-dom": "^17.0.0",
|
|
23
|
-
"react-redux": "^7.2.1"
|
|
20
|
+
"react-redux": "^7.2.1",
|
|
21
|
+
"@material-ui/icons": "^4.11.3"
|
|
24
22
|
},
|
|
25
23
|
"dependencies": {
|
|
26
24
|
"@bento-core/facet-filter": "^1.0.0",
|
|
27
25
|
"lodash": "^4.17.20"
|
|
28
26
|
},
|
|
29
27
|
"author": "CTOS Bento Team",
|
|
30
|
-
"license": "ISC"
|
|
31
|
-
"bugs": {
|
|
32
|
-
"url": "https://github.com/CBIIT/bento-frontend/issues"
|
|
33
|
-
},
|
|
34
|
-
"homepage": "https://github.com/CBIIT/bento-frontend#readme",
|
|
35
|
-
"devDependencies": {}
|
|
28
|
+
"license": "ISC"
|
|
36
29
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="16" height="19" viewBox="0 0 16 19" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M13 9.75715C13 10.0452 12.78 10.2714 12.5 10.2714H7.5C7.22 10.2714 7 10.0452 7 9.75715C7 9.46915 7.22 9.24287 7.5 9.24287H12.5C12.78 9.24287 13 9.46915 13 9.75715ZM12.5 11.3H7.5C7.22 11.3 7 11.5263 7 11.8143C7 12.1023 7.22 12.3286 7.5 12.3286H12.5C12.78 12.3286 13 12.1023 13 11.8143C13 11.5263 12.78 11.3 12.5 11.3ZM12.5 13.3572H7.5C7.22 13.3572 7 13.5834 7 13.8714C7 14.1594 7.22 14.3857 7.5 14.3857H12.5C12.78 14.3857 13 14.1594 13 13.8714C13 13.5834 12.78 13.3572 12.5 13.3572ZM16 8.21429V16.4429C16 17.5743 15.1 18.5 14 18.5H6C4.9 18.5 4 17.5743 4 16.4429V15.4143H2C0.9 15.4143 0 14.4886 0 13.3572V4.10001C0 2.96858 0.9 2.04286 2 2.04286H4.5C4.5 1.18915 5.17 0.500008 6 0.500008C6.83 0.500008 7.5 1.18915 7.5 2.04286H10C11.1 2.04286 12 2.96858 12 4.10001V6.15715H14C15.1 6.15715 16 7.08287 16 8.21429ZM6 6.15715H11V4.10001C11 3.53429 10.55 3.07144 10 3.07144H9V4.10001H3V3.07144H2C1.45 3.07144 1 3.53429 1 4.10001V13.3572C1 13.9229 1.45 14.3857 2 14.3857H4V8.21429C4 7.08287 4.9 6.15715 6 6.15715ZM15 8.21429C15 7.64858 14.55 7.18572 14 7.18572H6C5.45 7.18572 5 7.64858 5 8.21429V16.4429C5 17.0086 5.45 17.4714 6 17.4714H14C14.55 17.4714 15 17.0086 15 16.4429V8.21429Z" fill="#142D64"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
IconButton,
|
|
5
|
+
Link,
|
|
6
|
+
Tooltip,
|
|
7
|
+
} from '@material-ui/core';
|
|
8
|
+
import CopyIcon from '../assets/CopyIcon.svg';
|
|
9
|
+
|
|
10
|
+
const QueryUrl = ({
|
|
11
|
+
classes,
|
|
12
|
+
filterItems,
|
|
13
|
+
localFind,
|
|
14
|
+
rootPath,
|
|
15
|
+
}) => {
|
|
16
|
+
const [expand, setExpand] = useState(false);
|
|
17
|
+
const toggleExpand = () => setExpand(!expand);
|
|
18
|
+
|
|
19
|
+
const { autocomplete = [], upload } = localFind;
|
|
20
|
+
|
|
21
|
+
const pathFilterParams = filterItems.reduce((acc, item) => {
|
|
22
|
+
const { datafield, items = [] } = item;
|
|
23
|
+
acc[datafield] = items;
|
|
24
|
+
return acc;
|
|
25
|
+
}, {});
|
|
26
|
+
|
|
27
|
+
const query = JSON.stringify({
|
|
28
|
+
...pathFilterParams,
|
|
29
|
+
autocomplete,
|
|
30
|
+
upload,
|
|
31
|
+
});
|
|
32
|
+
const url = encodeURI(rootPath.concat(query));
|
|
33
|
+
|
|
34
|
+
const copyUrl = async () => {
|
|
35
|
+
await navigator.clipboard.writeText(url);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div className={classes.urlContainer}>
|
|
40
|
+
<Button
|
|
41
|
+
onClick={toggleExpand}
|
|
42
|
+
className={classes.viewLinkToggleBtn}
|
|
43
|
+
>
|
|
44
|
+
{ (expand) ? 'Hide Query URL' : 'Show Query URL'}
|
|
45
|
+
</Button>
|
|
46
|
+
{
|
|
47
|
+
(expand) && (
|
|
48
|
+
<>
|
|
49
|
+
<Link
|
|
50
|
+
target="_blank"
|
|
51
|
+
href={url}
|
|
52
|
+
className={classes.link}
|
|
53
|
+
>
|
|
54
|
+
<span>
|
|
55
|
+
{url}
|
|
56
|
+
</span>
|
|
57
|
+
</Link>
|
|
58
|
+
<Tooltip
|
|
59
|
+
title="Copy to Clipboard"
|
|
60
|
+
className={classes.Tooltip}
|
|
61
|
+
>
|
|
62
|
+
<IconButton onClick={copyUrl} className={classes.copyIconBtn}>
|
|
63
|
+
<img src={CopyIcon} alt="copy icon" />
|
|
64
|
+
</IconButton>
|
|
65
|
+
</Tooltip>
|
|
66
|
+
</>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default QueryUrl;
|
|
@@ -5,6 +5,7 @@ import clsx from 'clsx';
|
|
|
5
5
|
import { Filter } from '../components/FilterMap';
|
|
6
6
|
import DEFAULT_STYLES from './styles';
|
|
7
7
|
import DEFAULT_CONFIG from './config';
|
|
8
|
+
import QueryUrl from '../components/QueryUrl';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Generate a pre-configured Explore Query Bar component
|
|
@@ -23,15 +24,20 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
|
|
|
23
24
|
? config.maxItems
|
|
24
25
|
: DEFAULT_CONFIG.config.maxItems;
|
|
25
26
|
|
|
27
|
+
const queryURLRootPath = config && typeof config.rootPath === 'string'
|
|
28
|
+
? config.rootPath
|
|
29
|
+
: DEFAULT_CONFIG.config.rootPath;
|
|
30
|
+
|
|
31
|
+
const viewQueryURL = config && typeof config.viewQueryURL === 'boolean'
|
|
32
|
+
? config.viewQueryURL
|
|
33
|
+
: DEFAULT_CONFIG.config.viewQueryURL;
|
|
34
|
+
|
|
26
35
|
const displayAllActiveFilters = config && typeof config.displayAllActiveFilters === 'boolean'
|
|
27
36
|
? config.displayAllActiveFilters
|
|
28
37
|
: DEFAULT_CONFIG.config.displayAllActiveFilters;
|
|
29
38
|
|
|
30
|
-
const group = config && typeof config.group === 'string'
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const count = config && typeof config.count === 'string'
|
|
34
|
-
? config.count : DEFAULT_CONFIG.config.count;
|
|
39
|
+
// const group = config && typeof config.group === 'string'
|
|
40
|
+
// ? config.group : DEFAULT_CONFIG.config.group;
|
|
35
41
|
|
|
36
42
|
const clearAll = functions && typeof functions.clearAll === 'function'
|
|
37
43
|
? functions.clearAll
|
|
@@ -83,35 +89,24 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
|
|
|
83
89
|
.map((facet) => {
|
|
84
90
|
if (facet.type !== CHECKBOX) { return facet; }
|
|
85
91
|
|
|
86
|
-
const {
|
|
92
|
+
const { items } = facet;
|
|
87
93
|
const itemKeys = Object.keys(items);
|
|
88
94
|
itemKeys.sort((a, b) => a.localeCompare(b));
|
|
89
95
|
|
|
90
96
|
/* Find any SELECTED CHECKBOXES that do NOT have any data
|
|
91
97
|
* and remove them from the list of selected checkboxes artificially */
|
|
92
|
-
itemKeys.forEach((item) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
+
// itemKeys.forEach((item) => {
|
|
99
|
+
// if (data.findIndex((d) => d.group === item) < 0) {
|
|
100
|
+
// itemKeys.splice(itemKeys.indexOf(item), 1);
|
|
101
|
+
// }
|
|
102
|
+
// });
|
|
103
|
+
|
|
98
104
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* behavior similar to filter component
|
|
105
|
+
* commenting out line 89-93
|
|
106
|
+
* to display all the active filters in the query bar
|
|
107
|
+
* ICDC-3287
|
|
103
108
|
*/
|
|
104
|
-
|
|
105
|
-
const displayItems = itemKeys.reduce((accumulator, item) => {
|
|
106
|
-
const itemList = data.filter((d) => (d[group] === item && d[count] > 0)) || [];
|
|
107
|
-
if (itemList.length > 0) {
|
|
108
|
-
const labels = itemList.map((filter) => filter[group]);
|
|
109
|
-
accumulator.push(labels);
|
|
110
|
-
}
|
|
111
|
-
return accumulator;
|
|
112
|
-
}, []);
|
|
113
|
-
|
|
114
|
-
return { ...facet, items: displayItems };
|
|
109
|
+
return { ...facet, items: itemKeys };
|
|
115
110
|
})
|
|
116
111
|
.filter((facet) => facet.items.length > 0);
|
|
117
112
|
|
|
@@ -120,131 +115,143 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
|
|
|
120
115
|
}
|
|
121
116
|
|
|
122
117
|
return (
|
|
123
|
-
|
|
124
|
-
<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
{/* Standalone case set button */}
|
|
139
|
-
{(upload.length && !autocomplete.length)
|
|
140
|
-
? (
|
|
141
|
-
<span
|
|
142
|
-
className={clsx(classes.filterCheckboxes, classes.localFindBackground)}
|
|
143
|
-
onClick={clearUpload}
|
|
144
|
-
>
|
|
145
|
-
INPUT CASE SET
|
|
146
|
-
</span>
|
|
147
|
-
) : null}
|
|
148
|
-
{autocomplete.length
|
|
149
|
-
? (
|
|
150
|
-
<span>
|
|
151
|
-
{' '}
|
|
152
|
-
<span
|
|
153
|
-
className={clsx(classes.filterName, classes.localFindBackground)}
|
|
154
|
-
onClick={clearAutocomplete}
|
|
155
|
-
>
|
|
156
|
-
Case IDs
|
|
157
|
-
</span>
|
|
158
|
-
{' '}
|
|
159
|
-
{' '}
|
|
160
|
-
<span className={classes.operators}>
|
|
161
|
-
{(autocomplete.length === 1 && !upload.length) ? 'IS ' : 'IN '}
|
|
162
|
-
</span>
|
|
163
|
-
</span>
|
|
164
|
-
) : null}
|
|
118
|
+
<>
|
|
119
|
+
<div className={classes.queryWrapper}>
|
|
120
|
+
<Button
|
|
121
|
+
className={classes.clearQueryButton}
|
|
122
|
+
color="primary"
|
|
123
|
+
variant="outlined"
|
|
124
|
+
onClick={clearAll}
|
|
125
|
+
>
|
|
126
|
+
Clear Query
|
|
127
|
+
</Button>
|
|
128
|
+
<span className={classes.divider} />
|
|
129
|
+
<span className={classes.queryContainer}>
|
|
130
|
+
{/* Local Find Selections */}
|
|
131
|
+
{/* TODO: Refactor this into a separate component */}
|
|
132
|
+
{(autocomplete.length || upload.length) ? (
|
|
165
133
|
<span>
|
|
166
|
-
{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
{upload.length && autocomplete.length ? (
|
|
170
|
-
<>
|
|
171
|
-
{' '}
|
|
134
|
+
{/* Standalone case set button */}
|
|
135
|
+
{(upload.length && !autocomplete.length)
|
|
136
|
+
? (
|
|
172
137
|
<span
|
|
173
|
-
className={clsx(classes.filterCheckboxes, classes.
|
|
138
|
+
className={clsx(classes.filterCheckboxes, classes.localFindBackground)}
|
|
174
139
|
onClick={clearUpload}
|
|
175
140
|
>
|
|
176
141
|
INPUT CASE SET
|
|
177
142
|
</span>
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
143
|
+
) : null}
|
|
144
|
+
{autocomplete.length
|
|
145
|
+
? (
|
|
146
|
+
<span>
|
|
147
|
+
{' '}
|
|
148
|
+
<span
|
|
149
|
+
className={clsx(classes.filterName, classes.localFindBackground)}
|
|
150
|
+
onClick={clearAutocomplete}
|
|
151
|
+
>
|
|
152
|
+
Case IDs
|
|
153
|
+
</span>
|
|
154
|
+
{' '}
|
|
155
|
+
{' '}
|
|
156
|
+
<span className={classes.operators}>
|
|
157
|
+
{(autocomplete.length === 1 && !upload.length) ? 'IS ' : 'IN '}
|
|
158
|
+
</span>
|
|
159
|
+
</span>
|
|
160
|
+
) : null}
|
|
161
|
+
<span>
|
|
162
|
+
{(((upload.length > 0 ? 1 : 0) + autocomplete.length) > 1)
|
|
163
|
+
? <span className={classes.bracketsOpen}>(</span>
|
|
164
|
+
: null}
|
|
165
|
+
{upload.length && autocomplete.length ? (
|
|
166
|
+
<>
|
|
167
|
+
{' '}
|
|
168
|
+
<span
|
|
169
|
+
className={clsx(classes.filterCheckboxes, classes.localFind)}
|
|
170
|
+
onClick={clearUpload}
|
|
171
|
+
>
|
|
172
|
+
INPUT CASE SET
|
|
173
|
+
</span>
|
|
174
|
+
{' '}
|
|
175
|
+
</>
|
|
176
|
+
) : null}
|
|
177
|
+
{autocomplete.slice(0, noOfItems).map((d, idx) => (
|
|
178
|
+
<>
|
|
179
|
+
<span
|
|
180
|
+
className={clsx(classes.filterCheckboxes, classes.facetSectionCases)}
|
|
181
|
+
key={idx}
|
|
182
|
+
onClick={() => deleteAutocompleteItem(d.title)}
|
|
183
|
+
>
|
|
184
|
+
{d.title}
|
|
185
|
+
</span>
|
|
186
|
+
{idx === (noOfItems - 1) ? null : ' '}
|
|
187
|
+
</>
|
|
188
|
+
))}
|
|
189
|
+
{autocomplete.length > maxItems && (
|
|
190
|
+
<>
|
|
191
|
+
{
|
|
192
|
+
displayAllActiveFilters
|
|
193
|
+
? (
|
|
194
|
+
<span
|
|
195
|
+
className={classes.expandBtn}
|
|
196
|
+
onClick={() => setExpand(!expand)}
|
|
197
|
+
>
|
|
198
|
+
...
|
|
199
|
+
</span>
|
|
200
|
+
)
|
|
201
|
+
: '...'
|
|
202
|
+
}
|
|
203
|
+
</>
|
|
204
|
+
)}
|
|
205
|
+
{(expand && autocomplete.length > maxItems) && (
|
|
183
206
|
<span
|
|
184
|
-
className={
|
|
185
|
-
|
|
186
|
-
onClick={() => deleteAutocompleteItem(d.title)}
|
|
207
|
+
className={classes.collapseBtn}
|
|
208
|
+
onClick={() => setExpand(!expand)}
|
|
187
209
|
>
|
|
188
|
-
{
|
|
210
|
+
{' LESS'}
|
|
189
211
|
</span>
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
{
|
|
196
|
-
displayAllActiveFilters
|
|
197
|
-
? (
|
|
198
|
-
<span
|
|
199
|
-
className={classes.expandBtn}
|
|
200
|
-
onClick={() => setExpand(!expand)}
|
|
201
|
-
>
|
|
202
|
-
...
|
|
203
|
-
</span>
|
|
204
|
-
)
|
|
205
|
-
: '...'
|
|
206
|
-
}
|
|
207
|
-
</>
|
|
208
|
-
)}
|
|
209
|
-
{(expand && autocomplete.length > maxItems) && (
|
|
210
|
-
<span
|
|
211
|
-
className={classes.collapseBtn}
|
|
212
|
-
onClick={() => setExpand(!expand)}
|
|
213
|
-
>
|
|
214
|
-
{' LESS'}
|
|
215
|
-
</span>
|
|
216
|
-
)}
|
|
217
|
-
{(((upload.length > 0 ? 1 : 0) + autocomplete.length) > 1)
|
|
218
|
-
? <span className={classes.bracketsClose}>)</span>
|
|
219
|
-
: null}
|
|
212
|
+
)}
|
|
213
|
+
{(((upload.length > 0 ? 1 : 0) + autocomplete.length) > 1)
|
|
214
|
+
? <span className={classes.bracketsClose}>)</span>
|
|
215
|
+
: null}
|
|
216
|
+
</span>
|
|
220
217
|
</span>
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
218
|
+
) : null}
|
|
219
|
+
|
|
220
|
+
{/* Facet Sidebar Selections */}
|
|
221
|
+
{((autocomplete.length || upload.length) && mappedInputs.length)
|
|
222
|
+
? <span className={classes.operators}> AND </span>
|
|
223
|
+
: null}
|
|
224
|
+
{mappedInputs.map((filter, index) => (
|
|
225
|
+
<span className={clsName(filter.section)}>
|
|
226
|
+
<Filter
|
|
227
|
+
index={index}
|
|
228
|
+
type={filter.type}
|
|
229
|
+
data={filter}
|
|
230
|
+
maxItems={maxItems}
|
|
231
|
+
displayAllActiveFilters={displayAllActiveFilters}
|
|
232
|
+
classes={classes}
|
|
233
|
+
onSectionClick={filter.type === CHECKBOX
|
|
234
|
+
? resetFacetSection
|
|
235
|
+
: resetFacetSlider}
|
|
236
|
+
onItemClick={filter.type === CHECKBOX
|
|
237
|
+
? resetFacetCheckbox
|
|
238
|
+
: resetFacetSlider}
|
|
239
|
+
/>
|
|
240
|
+
</span>
|
|
241
|
+
))}
|
|
242
|
+
</span>
|
|
243
|
+
{
|
|
244
|
+
(viewQueryURL && queryURLRootPath) && (
|
|
245
|
+
<QueryUrl
|
|
236
246
|
classes={classes}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
onItemClick={filter.type === CHECKBOX
|
|
241
|
-
? resetFacetCheckbox
|
|
242
|
-
: resetFacetSlider}
|
|
247
|
+
localFind={localFind}
|
|
248
|
+
filterItems={mappedInputs}
|
|
249
|
+
rootPath={queryURLRootPath}
|
|
243
250
|
/>
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
</
|
|
247
|
-
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
</div>
|
|
254
|
+
</>
|
|
248
255
|
);
|
|
249
256
|
}),
|
|
250
257
|
};
|
package/src/generators/config.js
CHANGED
|
@@ -18,10 +18,15 @@ export default {
|
|
|
18
18
|
*/
|
|
19
19
|
group: 'group',
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* root path of bento app
|
|
22
22
|
* @var {boolean}
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
rootPath: null,
|
|
25
|
+
/**
|
|
26
|
+
* display query URL
|
|
27
|
+
* @var {boolean}
|
|
28
|
+
*/
|
|
29
|
+
viewQueryURL: false,
|
|
25
30
|
},
|
|
26
31
|
|
|
27
32
|
/* Component Helper Functions */
|
package/src/generators/styles.js
CHANGED
|
@@ -114,4 +114,40 @@ export default () => ({
|
|
|
114
114
|
cursor: 'pointer',
|
|
115
115
|
},
|
|
116
116
|
},
|
|
117
|
+
urlContainer: {
|
|
118
|
+
marginTop: '10px',
|
|
119
|
+
},
|
|
120
|
+
link: {
|
|
121
|
+
lineBreak: 'anywhere',
|
|
122
|
+
fontFamily: 'Nunito',
|
|
123
|
+
fontSize: '12px',
|
|
124
|
+
fontWeight: '500',
|
|
125
|
+
lineHeight: '16px',
|
|
126
|
+
letterSpacing: '0em',
|
|
127
|
+
color: '#1D79A8',
|
|
128
|
+
backgroundColor: '#fff',
|
|
129
|
+
padding: '5px',
|
|
130
|
+
borderRadius: '5px',
|
|
131
|
+
marginLeft: '10px',
|
|
132
|
+
},
|
|
133
|
+
viewLinkToggleBtn: {
|
|
134
|
+
height: '20px',
|
|
135
|
+
fontFamily: 'Nunito',
|
|
136
|
+
fontSize: '12px',
|
|
137
|
+
fontWeight: '500',
|
|
138
|
+
lineHeight: '16px',
|
|
139
|
+
letterSpacing: '0em',
|
|
140
|
+
textAlign: 'left',
|
|
141
|
+
backgroundColor: '#1D79A8',
|
|
142
|
+
textTransform: 'none',
|
|
143
|
+
color: '#fff',
|
|
144
|
+
'&:hover': {
|
|
145
|
+
backgroundColor: '#1D79A8',
|
|
146
|
+
color: '#fff',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
copyIconBtn: {
|
|
150
|
+
padding: '0px',
|
|
151
|
+
marginLeft: '10px',
|
|
152
|
+
},
|
|
117
153
|
});
|