@bento-core/query-bar 1.0.0-c3dc.1 → 1.0.0-c3dc.3
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/CopyURL_README.md +42 -0
- package/README.md +11 -0
- package/dist/assets/CopyIcon.svg +3 -0
- package/dist/components/QueryUrl.js +143 -0
- package/dist/generators/QueryBarGenerator.js +9 -1
- package/dist/generators/config.js +10 -0
- package/package.json +1 -1
- package/src/assets/CopyIcon.svg +3 -0
- package/src/components/QueryUrl.js +164 -0
- package/src/generators/QueryBarGenerator.js +19 -0
- package/src/generators/config.js +11 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# DQB copy URL button Configuration
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
DashTemplateController.js
|
|
5
|
+
|
|
6
|
+
export const setActiveFilterByPathQuery = (match) => {
|
|
7
|
+
const query = decodeURI(match.params.filterQuery || '');
|
|
8
|
+
const filterObject = JSON.parse(query);
|
|
9
|
+
const { autocomplete = [], upload = [], uploadMetadata } = filterObject;
|
|
10
|
+
|
|
11
|
+
const activeFilterValues = Object.keys(filterObject).reduce((curr, key) => {
|
|
12
|
+
if (Array.isArray(filterObject[key])) {
|
|
13
|
+
const activeFilters = filterObject[key].reduce((value, item) => ({
|
|
14
|
+
...value,
|
|
15
|
+
[item]: true,
|
|
16
|
+
}), {});
|
|
17
|
+
return {
|
|
18
|
+
...curr,
|
|
19
|
+
[key]: activeFilters,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return curr;
|
|
23
|
+
}, {});
|
|
24
|
+
store.dispatch(clearAllAndSelectFacet(activeFilterValues));
|
|
25
|
+
store.dispatch(updateAutocompleteData(autocomplete));
|
|
26
|
+
store.dispatch(updateUploadData(upload));
|
|
27
|
+
store.dispatch(updateUploadMetadata(uploadMetadata));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// redirect
|
|
32
|
+
if (match.params.filterQuery) {
|
|
33
|
+
setActiveFilterByPathQuery(match);
|
|
34
|
+
const redirectUrl = '/explore';
|
|
35
|
+
history.push(redirectUrl);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
# DQB copy URL button theme style
|
|
41
|
+
|
|
42
|
+
``` https://github.com/CBIIT/bento-icdc-frontend/tree/v4.0.1/src/pages/dashboard/filterQueryBar```
|
package/README.md
CHANGED
|
@@ -60,6 +60,17 @@ const CONFIG = {
|
|
|
60
60
|
maxItems: 2,
|
|
61
61
|
},
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* set root path for copy url (COPYURL_README)
|
|
65
|
+
* @var {boolean}
|
|
66
|
+
*/
|
|
67
|
+
rootPath: `${window.location.href}/`,
|
|
68
|
+
/**
|
|
69
|
+
* display copy url button (COPYURL_README)
|
|
70
|
+
* @var {boolean}
|
|
71
|
+
*/
|
|
72
|
+
viewQueryURL: true,
|
|
73
|
+
|
|
63
74
|
/* Component Helper Functions */
|
|
64
75
|
functions: {
|
|
65
76
|
/**
|
|
@@ -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,143 @@
|
|
|
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 _clsx = _interopRequireDefault(require("clsx"));
|
|
9
|
+
var _core = require("@material-ui/core");
|
|
10
|
+
var _CopyIcon = _interopRequireDefault(require("../assets/CopyIcon.svg"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
|
+
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); }
|
|
19
|
+
const QueryUrl = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
classes,
|
|
22
|
+
filterItems,
|
|
23
|
+
localFind = {},
|
|
24
|
+
rootPath
|
|
25
|
+
} = _ref;
|
|
26
|
+
const [display, setDisplay] = (0, _react.useState)(false);
|
|
27
|
+
const toggleDisplay = () => setDisplay(prevDisplay => !prevDisplay);
|
|
28
|
+
const [open, setOpen] = (0, _react.useState)(false);
|
|
29
|
+
const toggleOpen = () => setOpen(prevOpen => !prevOpen);
|
|
30
|
+
const pathFilterParams = filterItems.reduce((acc, item) => {
|
|
31
|
+
const {
|
|
32
|
+
datafield,
|
|
33
|
+
items = []
|
|
34
|
+
} = item;
|
|
35
|
+
acc[datafield] = items;
|
|
36
|
+
return acc;
|
|
37
|
+
}, {});
|
|
38
|
+
const query = JSON.stringify(_objectSpread(_objectSpread({}, pathFilterParams), localFind));
|
|
39
|
+
const url = rootPath.concat(encodeURIComponent(query));
|
|
40
|
+
const copyUrl = async () => {
|
|
41
|
+
toggleOpen();
|
|
42
|
+
await navigator.clipboard.writeText(url);
|
|
43
|
+
};
|
|
44
|
+
const queryRef = (0, _react.useRef)(null);
|
|
45
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
46
|
+
ref: queryRef,
|
|
47
|
+
className: classes.urlContainer
|
|
48
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
49
|
+
onClick: toggleDisplay,
|
|
50
|
+
className: classes.viewLinkToggleBtn
|
|
51
|
+
}, display ? 'Hide Query URL' : 'Show Query URL'), display && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
52
|
+
type: "button",
|
|
53
|
+
className: (0, _clsx.default)(classes.viewLink)
|
|
54
|
+
}, url), /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
55
|
+
arrow: true,
|
|
56
|
+
title: "Copy to Clipboard"
|
|
57
|
+
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
58
|
+
onClick: copyUrl,
|
|
59
|
+
className: classes.copyIconBtn
|
|
60
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
61
|
+
src: _CopyIcon.default,
|
|
62
|
+
alt: "copy icon"
|
|
63
|
+
}))))), /*#__PURE__*/_react.default.createElement(_core.Dialog, {
|
|
64
|
+
open: open,
|
|
65
|
+
onClose: () => toggleOpen(),
|
|
66
|
+
"aria-labelledby": "alert-dialog-title",
|
|
67
|
+
"aria-describedby": "alert-dialog-description",
|
|
68
|
+
className: (0, _clsx.default)(classes.dialogBox, 'dialogBox')
|
|
69
|
+
}, /*#__PURE__*/_react.default.createElement(_core.DialogContent, {
|
|
70
|
+
className: classes.okText
|
|
71
|
+
}, /*#__PURE__*/_react.default.createElement(_core.DialogContentText, {
|
|
72
|
+
id: "alert-dialog-description"
|
|
73
|
+
}, "Your query URL has been copied!")), /*#__PURE__*/_react.default.createElement(_core.DialogActions, null, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
74
|
+
onClick: () => toggleOpen()
|
|
75
|
+
}, "OK"))));
|
|
76
|
+
};
|
|
77
|
+
const styles = () => ({
|
|
78
|
+
urlContainer: {
|
|
79
|
+
display: 'flex',
|
|
80
|
+
marginTop: '3px',
|
|
81
|
+
minHeight: '10px'
|
|
82
|
+
},
|
|
83
|
+
viewLink: {
|
|
84
|
+
overflow: 'hidden',
|
|
85
|
+
textOverflow: 'ellipsis',
|
|
86
|
+
fontFamily: 'Nunito',
|
|
87
|
+
fontSize: '12px',
|
|
88
|
+
fontWeight: '500',
|
|
89
|
+
lineHeight: '16px',
|
|
90
|
+
letterSpacing: '0em',
|
|
91
|
+
padding: '2px 5px',
|
|
92
|
+
borderRadius: '5px',
|
|
93
|
+
float: 'left',
|
|
94
|
+
color: '#1D79A8',
|
|
95
|
+
backgroundColor: '#fff',
|
|
96
|
+
margin: '0',
|
|
97
|
+
whiteSpace: 'nowrap',
|
|
98
|
+
wordBreak: 'break-all',
|
|
99
|
+
'@media (max-width: 2560px)': {
|
|
100
|
+
maxWidth: '1800px'
|
|
101
|
+
},
|
|
102
|
+
'@media (max-width: 2000px)': {
|
|
103
|
+
maxWidth: '1500px'
|
|
104
|
+
},
|
|
105
|
+
'@media (max-width: 1600px)': {
|
|
106
|
+
maxWidth: '1100px'
|
|
107
|
+
},
|
|
108
|
+
'@media (max-width: 1300px)': {
|
|
109
|
+
maxWidth: '900px'
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
urlViewBtn: {
|
|
113
|
+
cursor: 'pointer'
|
|
114
|
+
},
|
|
115
|
+
viewLinkToggleBtn: {
|
|
116
|
+
padding: '5px 10px 5px 10px',
|
|
117
|
+
height: '20px',
|
|
118
|
+
fontFamily: 'Nunito',
|
|
119
|
+
fontSize: '12px',
|
|
120
|
+
fontWeight: '500',
|
|
121
|
+
lineHeight: '16px',
|
|
122
|
+
letterSpacing: '0em',
|
|
123
|
+
textAlign: 'left',
|
|
124
|
+
backgroundColor: '#1D79A8',
|
|
125
|
+
textTransform: 'none',
|
|
126
|
+
color: '#fff',
|
|
127
|
+
float: 'left',
|
|
128
|
+
margin: '0px 10px 0px 0px',
|
|
129
|
+
whiteSpace: 'nowrap',
|
|
130
|
+
'&:hover': {
|
|
131
|
+
backgroundColor: '#1D79A8',
|
|
132
|
+
color: '#fff'
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
copyIconBtn: {
|
|
136
|
+
padding: '0px',
|
|
137
|
+
height: '20px',
|
|
138
|
+
marginLeft: '10px',
|
|
139
|
+
float: 'left'
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
var _default = (0, _core.withStyles)(styles)(QueryUrl);
|
|
143
|
+
exports.default = _default;
|
|
@@ -9,6 +9,7 @@ var _core = require("@material-ui/core");
|
|
|
9
9
|
var _facetFilter = require("@bento-core/facet-filter");
|
|
10
10
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
11
11
|
var _FilterMap = require("../components/FilterMap");
|
|
12
|
+
var _QueryUrl = _interopRequireDefault(require("../components/QueryUrl"));
|
|
12
13
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
13
14
|
var _config = _interopRequireDefault(require("./config"));
|
|
14
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -34,6 +35,8 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
34
35
|
CHECKBOX
|
|
35
36
|
} = _facetFilter.InputTypes;
|
|
36
37
|
const maxItems = config && typeof config.maxItems === 'number' ? config.maxItems : _config.default.config.maxItems;
|
|
38
|
+
const queryURLRootPath = config && typeof config.rootPath === 'string' ? config.rootPath : _config.default.config.rootPath;
|
|
39
|
+
const viewQueryURL = config && typeof config.viewQueryURL === 'boolean' ? config.viewQueryURL : _config.default.config.viewQueryURL;
|
|
37
40
|
const clearAll = functions && typeof functions.clearAll === 'function' ? functions.clearAll : _config.default.functions.clearAll;
|
|
38
41
|
const clearUpload = functions && typeof functions.clearUpload === 'function' ? functions.clearUpload : _config.default.functions.clearUpload;
|
|
39
42
|
const clearAutocomplete = functions && typeof functions.clearAutocomplete === 'function' ? functions.clearAutocomplete : _config.default.functions.clearAutocomplete;
|
|
@@ -121,7 +124,12 @@ const QueryBarGenerator = function QueryBarGenerator() {
|
|
|
121
124
|
classes: classes,
|
|
122
125
|
onSectionClick: filter.type === CHECKBOX ? resetFacetSection : resetFacetSlider,
|
|
123
126
|
onItemClick: filter.type === CHECKBOX ? resetFacetCheckbox : resetFacetSlider
|
|
124
|
-
})))
|
|
127
|
+
}))), viewQueryURL && queryURLRootPath && /*#__PURE__*/_react.default.createElement(_QueryUrl.default, {
|
|
128
|
+
classes: classes,
|
|
129
|
+
localFind: localFind,
|
|
130
|
+
filterItems: mappedInputs,
|
|
131
|
+
rootPath: queryURLRootPath
|
|
132
|
+
}));
|
|
125
133
|
})
|
|
126
134
|
};
|
|
127
135
|
};
|
|
@@ -14,6 +14,16 @@ var _default = {
|
|
|
14
14
|
*/
|
|
15
15
|
maxItems: 2
|
|
16
16
|
},
|
|
17
|
+
/**
|
|
18
|
+
* set root path for copy url
|
|
19
|
+
* @var {boolean}
|
|
20
|
+
*/
|
|
21
|
+
rootPath: "".concat(window.location.href, "/"),
|
|
22
|
+
/**
|
|
23
|
+
* display copy url button
|
|
24
|
+
* @var {boolean}
|
|
25
|
+
*/
|
|
26
|
+
viewQueryURL: false,
|
|
17
27
|
/* Component Helper Functions */
|
|
18
28
|
functions: {
|
|
19
29
|
/**
|
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.3",
|
|
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": {
|
|
@@ -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,164 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
IconButton,
|
|
6
|
+
Tooltip,
|
|
7
|
+
Dialog,
|
|
8
|
+
DialogActions,
|
|
9
|
+
DialogContent,
|
|
10
|
+
DialogContentText,
|
|
11
|
+
withStyles,
|
|
12
|
+
} from '@material-ui/core';
|
|
13
|
+
import CopyIcon from '../assets/CopyIcon.svg';
|
|
14
|
+
|
|
15
|
+
const QueryUrl = ({
|
|
16
|
+
classes,
|
|
17
|
+
filterItems,
|
|
18
|
+
localFind = {},
|
|
19
|
+
rootPath,
|
|
20
|
+
}) => {
|
|
21
|
+
const [display, setDisplay] = useState(false);
|
|
22
|
+
const toggleDisplay = () => setDisplay((prevDisplay) => !prevDisplay);
|
|
23
|
+
|
|
24
|
+
const [open, setOpen] = useState(false);
|
|
25
|
+
const toggleOpen = () => setOpen((prevOpen) => !prevOpen);
|
|
26
|
+
|
|
27
|
+
const pathFilterParams = filterItems.reduce((acc, item) => {
|
|
28
|
+
const { datafield, items = [] } = item;
|
|
29
|
+
acc[datafield] = items;
|
|
30
|
+
return acc;
|
|
31
|
+
}, {});
|
|
32
|
+
|
|
33
|
+
const query = JSON.stringify({
|
|
34
|
+
...pathFilterParams,
|
|
35
|
+
...localFind,
|
|
36
|
+
});
|
|
37
|
+
const url = rootPath.concat(encodeURIComponent(query));
|
|
38
|
+
|
|
39
|
+
const copyUrl = async () => {
|
|
40
|
+
toggleOpen();
|
|
41
|
+
await navigator.clipboard.writeText(url);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const queryRef = useRef(null);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<div ref={queryRef} className={classes.urlContainer}>
|
|
49
|
+
<Button
|
|
50
|
+
onClick={toggleDisplay}
|
|
51
|
+
className={classes.viewLinkToggleBtn}
|
|
52
|
+
>
|
|
53
|
+
{ (display) ? 'Hide Query URL' : 'Show Query URL'}
|
|
54
|
+
</Button>
|
|
55
|
+
{
|
|
56
|
+
(display) && (
|
|
57
|
+
<>
|
|
58
|
+
<div
|
|
59
|
+
type="button"
|
|
60
|
+
className={clsx(classes.viewLink)}
|
|
61
|
+
>
|
|
62
|
+
{url}
|
|
63
|
+
</div>
|
|
64
|
+
<Tooltip
|
|
65
|
+
arrow
|
|
66
|
+
title="Copy to Clipboard"
|
|
67
|
+
>
|
|
68
|
+
<IconButton onClick={copyUrl} className={classes.copyIconBtn}>
|
|
69
|
+
<img src={CopyIcon} alt="copy icon" />
|
|
70
|
+
</IconButton>
|
|
71
|
+
</Tooltip>
|
|
72
|
+
</>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
</div>
|
|
76
|
+
<Dialog
|
|
77
|
+
open={open}
|
|
78
|
+
onClose={() => toggleOpen()}
|
|
79
|
+
aria-labelledby="alert-dialog-title"
|
|
80
|
+
aria-describedby="alert-dialog-description"
|
|
81
|
+
className={clsx(classes.dialogBox, 'dialogBox')}
|
|
82
|
+
>
|
|
83
|
+
<DialogContent className={classes.okText}>
|
|
84
|
+
<DialogContentText id="alert-dialog-description">
|
|
85
|
+
Your query URL has been copied!
|
|
86
|
+
</DialogContentText>
|
|
87
|
+
</DialogContent>
|
|
88
|
+
<DialogActions>
|
|
89
|
+
<Button onClick={() => toggleOpen()}>
|
|
90
|
+
OK
|
|
91
|
+
</Button>
|
|
92
|
+
</DialogActions>
|
|
93
|
+
</Dialog>
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const styles = () => ({
|
|
99
|
+
urlContainer: {
|
|
100
|
+
display: 'flex',
|
|
101
|
+
marginTop: '3px',
|
|
102
|
+
minHeight: '10px',
|
|
103
|
+
},
|
|
104
|
+
viewLink: {
|
|
105
|
+
overflow: 'hidden',
|
|
106
|
+
textOverflow: 'ellipsis',
|
|
107
|
+
fontFamily: 'Nunito',
|
|
108
|
+
fontSize: '12px',
|
|
109
|
+
fontWeight: '500',
|
|
110
|
+
lineHeight: '16px',
|
|
111
|
+
letterSpacing: '0em',
|
|
112
|
+
padding: '2px 5px',
|
|
113
|
+
borderRadius: '5px',
|
|
114
|
+
float: 'left',
|
|
115
|
+
color: '#1D79A8',
|
|
116
|
+
backgroundColor: '#fff',
|
|
117
|
+
margin: '0',
|
|
118
|
+
whiteSpace: 'nowrap',
|
|
119
|
+
wordBreak: 'break-all',
|
|
120
|
+
'@media (max-width: 2560px)': {
|
|
121
|
+
maxWidth: '1800px',
|
|
122
|
+
},
|
|
123
|
+
'@media (max-width: 2000px)': {
|
|
124
|
+
maxWidth: '1500px',
|
|
125
|
+
},
|
|
126
|
+
'@media (max-width: 1600px)': {
|
|
127
|
+
maxWidth: '1100px',
|
|
128
|
+
},
|
|
129
|
+
'@media (max-width: 1300px)': {
|
|
130
|
+
maxWidth: '900px',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
urlViewBtn: {
|
|
134
|
+
cursor: 'pointer',
|
|
135
|
+
},
|
|
136
|
+
viewLinkToggleBtn: {
|
|
137
|
+
padding: '5px 10px 5px 10px',
|
|
138
|
+
height: '20px',
|
|
139
|
+
fontFamily: 'Nunito',
|
|
140
|
+
fontSize: '12px',
|
|
141
|
+
fontWeight: '500',
|
|
142
|
+
lineHeight: '16px',
|
|
143
|
+
letterSpacing: '0em',
|
|
144
|
+
textAlign: 'left',
|
|
145
|
+
backgroundColor: '#1D79A8',
|
|
146
|
+
textTransform: 'none',
|
|
147
|
+
color: '#fff',
|
|
148
|
+
float: 'left',
|
|
149
|
+
margin: '0px 10px 0px 0px',
|
|
150
|
+
whiteSpace: 'nowrap',
|
|
151
|
+
'&:hover': {
|
|
152
|
+
backgroundColor: '#1D79A8',
|
|
153
|
+
color: '#fff',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
copyIconBtn: {
|
|
157
|
+
padding: '0px',
|
|
158
|
+
height: '20px',
|
|
159
|
+
marginLeft: '10px',
|
|
160
|
+
float: 'left',
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
export default withStyles(styles)(QueryUrl);
|
|
@@ -3,6 +3,7 @@ import { withStyles, Button } from '@material-ui/core';
|
|
|
3
3
|
import { InputTypes } from '@bento-core/facet-filter';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { Filter } from '../components/FilterMap';
|
|
6
|
+
import QueryUrl from '../components/QueryUrl';
|
|
6
7
|
import DEFAULT_STYLES from './styles';
|
|
7
8
|
import DEFAULT_CONFIG from './config';
|
|
8
9
|
|
|
@@ -20,6 +21,14 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
|
|
|
20
21
|
? config.maxItems
|
|
21
22
|
: DEFAULT_CONFIG.config.maxItems;
|
|
22
23
|
|
|
24
|
+
const queryURLRootPath = config && typeof config.rootPath === 'string'
|
|
25
|
+
? config.rootPath
|
|
26
|
+
: DEFAULT_CONFIG.config.rootPath;
|
|
27
|
+
|
|
28
|
+
const viewQueryURL = config && typeof config.viewQueryURL === 'boolean'
|
|
29
|
+
? config.viewQueryURL
|
|
30
|
+
: DEFAULT_CONFIG.config.viewQueryURL;
|
|
31
|
+
|
|
23
32
|
const clearAll = functions && typeof functions.clearAll === 'function'
|
|
24
33
|
? functions.clearAll
|
|
25
34
|
: DEFAULT_CONFIG.functions.clearAll;
|
|
@@ -179,6 +188,16 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
|
|
|
179
188
|
/>
|
|
180
189
|
))}
|
|
181
190
|
</span>
|
|
191
|
+
{
|
|
192
|
+
(viewQueryURL && queryURLRootPath) && (
|
|
193
|
+
<QueryUrl
|
|
194
|
+
classes={classes}
|
|
195
|
+
localFind={localFind}
|
|
196
|
+
filterItems={mappedInputs}
|
|
197
|
+
rootPath={queryURLRootPath}
|
|
198
|
+
/>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
182
201
|
</div>
|
|
183
202
|
);
|
|
184
203
|
}),
|
package/src/generators/config.js
CHANGED
|
@@ -9,6 +9,17 @@ export default {
|
|
|
9
9
|
maxItems: 2,
|
|
10
10
|
},
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* set root path for copy url
|
|
14
|
+
* @var {boolean}
|
|
15
|
+
*/
|
|
16
|
+
rootPath: `${window.location.href}/`,
|
|
17
|
+
/**
|
|
18
|
+
* display copy url button
|
|
19
|
+
* @var {boolean}
|
|
20
|
+
*/
|
|
21
|
+
viewQueryURL: false,
|
|
22
|
+
|
|
12
23
|
/* Component Helper Functions */
|
|
13
24
|
functions: {
|
|
14
25
|
/**
|