@bento-core/query-bar 1.0.1-icdc.24 → 1.0.1-icdc.26

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.
@@ -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
@@ -63,6 +63,16 @@ const CONFIG = {
63
63
  * @var {boolean}
64
64
  */
65
65
  displayAllActiveFilters: false,
66
+ /**
67
+ * set root path for copy url (COPYURL_README)
68
+ * @var {boolean}
69
+ */
70
+ rootPath: `${window.location.href}/`,
71
+ /**
72
+ * display copy url button (COPYURL_README)
73
+ * @var {boolean}
74
+ */
75
+ viewQueryURL: true,
66
76
  },
67
77
 
68
78
  /* Component Helper Functions */
@@ -16,61 +16,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
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
17
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
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 ViewFullLinkComponent = _ref => {
20
- let {
21
- classes,
22
- url,
23
- maxWidth = 1200
24
- } = _ref;
25
- const linkRef = (0, _react.useRef)(null);
26
- const [collapseLink, setCollapseLink] = (0, _react.useState)(false);
27
-
28
- /**
29
- * Compute url link width based on the windowsize
30
- */
31
- (0, _react.useEffect)(() => {
32
- var _linkRef$current;
33
- const urlWidth = linkRef === null || linkRef === void 0 ? void 0 : (_linkRef$current = linkRef.current) === null || _linkRef$current === void 0 ? void 0 : _linkRef$current.offsetWidth;
34
- if (urlWidth > maxWidth / 2) {
35
- setCollapseLink(true);
36
- }
37
- }, []);
38
- const expandUrl = () => {
39
- setCollapseLink(false);
40
- };
41
- const collapseUrl = () => {
42
- setCollapseLink(true);
43
- };
44
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
45
- ref: linkRef,
46
- className: classes.link
47
- }, /*#__PURE__*/_react.default.createElement("span", {
48
- className: (0, _clsx.default)(classes.viewLink, {
49
- [classes.collapseLink]: collapseLink
50
- })
51
- }, /*#__PURE__*/_react.default.createElement("span", {
52
- className: (0, _clsx.default)(classes.urlView, {
53
- [classes.urlViewBtn]: !collapseLink
54
- }),
55
- type: "button",
56
- onClick: collapseUrl
57
- }, url), collapseLink && /*#__PURE__*/_react.default.createElement("span", {
58
- className: classes.expandLinkBtn,
59
- type: "button",
60
- onClick: expandUrl
61
- }, "..."))));
62
- };
63
- const QueryUrl = _ref2 => {
64
- var _queryRef$current;
19
+ const QueryUrl = _ref => {
65
20
  let {
66
21
  classes,
67
22
  filterItems,
68
23
  localFind = {},
69
24
  rootPath
70
- } = _ref2;
25
+ } = _ref;
71
26
  const [display, setDisplay] = (0, _react.useState)(false);
72
27
  const toggleDisplay = () => setDisplay(!display);
73
- const [expand, setExpand] = (0, _react.useState)(false);
74
28
  const [open, toggleOpen] = (0, _react.useState)(false);
75
29
  const pathFilterParams = filterItems.reduce((acc, item) => {
76
30
  const {
@@ -81,7 +35,7 @@ const QueryUrl = _ref2 => {
81
35
  return acc;
82
36
  }, {});
83
37
  const query = JSON.stringify(_objectSpread(_objectSpread({}, pathFilterParams), localFind));
84
- const url = encodeURI(rootPath.concat(query));
38
+ const url = rootPath + encodeURIComponent(query);
85
39
  const copyUrl = async () => {
86
40
  toggleOpen(!open);
87
41
  await navigator.clipboard.writeText(url);
@@ -93,15 +47,10 @@ const QueryUrl = _ref2 => {
93
47
  }, /*#__PURE__*/_react.default.createElement(_core.Button, {
94
48
  onClick: toggleDisplay,
95
49
  className: classes.viewLinkToggleBtn
96
- }, display ? 'Hide Query URL' : 'Show Query URL'), display && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, expand ? /*#__PURE__*/_react.default.createElement("span", {
50
+ }, display ? 'Hide Query URL' : 'Show Query URL'), display && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
97
51
  type: "button",
98
- onClick: () => setExpand(!expand),
99
- className: (0, _clsx.default)(classes.link, classes.viewLink, classes.expandLink)
100
- }, url) : /*#__PURE__*/_react.default.createElement(ViewFullLinkComponent, {
101
- url: url,
102
- classes: classes,
103
- maxWidth: queryRef === null || queryRef === void 0 ? void 0 : (_queryRef$current = queryRef.current) === null || _queryRef$current === void 0 ? void 0 : _queryRef$current.offsetWidth
104
- }), /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
52
+ className: (0, _clsx.default)(classes.viewLink)
53
+ }, url), /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
105
54
  arrow: true,
106
55
  title: "Copy to Clipboard"
107
56
  }, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
@@ -127,48 +76,43 @@ const QueryUrl = _ref2 => {
127
76
  const styles = () => ({
128
77
  urlContainer: {
129
78
  display: 'flex',
130
- marginTop: '10px',
79
+ marginTop: '3px',
131
80
  minHeight: '10px'
132
81
  },
133
- link: {
134
- lineBreak: 'anywhere',
82
+ viewLink: {
135
83
  overflow: 'hidden',
84
+ textOverflow: 'ellipsis',
136
85
  fontFamily: 'Nunito',
137
86
  fontSize: '12px',
138
87
  fontWeight: '500',
139
88
  lineHeight: '16px',
140
89
  letterSpacing: '0em',
141
- padding: '5px',
90
+ padding: '2px 5px',
142
91
  borderRadius: '5px',
143
92
  float: 'left',
144
93
  color: '#1D79A8',
145
94
  backgroundColor: '#fff',
146
- maxWidth: '80%'
147
- },
148
- viewLink: {
149
- margin: '0'
95
+ margin: '0',
96
+ whiteSpace: 'nowrap',
97
+ wordBreak: 'break-all',
98
+ '@media (max-width: 2560px)': {
99
+ maxWidth: '1800px'
100
+ },
101
+ '@media (max-width: 2000px)': {
102
+ maxWidth: '1500px'
103
+ },
104
+ '@media (max-width: 1600px)': {
105
+ maxWidth: '1100px'
106
+ },
107
+ '@media (max-width: 1300px)': {
108
+ maxWidth: '900px'
109
+ }
150
110
  },
151
111
  urlViewBtn: {
152
112
  cursor: 'pointer'
153
113
  },
154
- collapseLink: {
155
- maxHeight: '1em',
156
- display: 'block',
157
- // display: '-webkit-box',
158
- '-webkit-box-orient': 'vertical',
159
- '-webkit-line-clamp': '1',
160
- overflow: 'hidden'
161
- },
162
- expandLink: {
163
- cursor: 'pointer'
164
- },
165
- expandLinkBtn: {
166
- float: 'left',
167
- '&:hover': {
168
- cursor: 'pointer'
169
- }
170
- },
171
114
  viewLinkToggleBtn: {
115
+ padding: '5px 10px 5px 10px',
172
116
  height: '20px',
173
117
  fontFamily: 'Nunito',
174
118
  fontSize: '12px',
@@ -181,28 +125,12 @@ const styles = () => ({
181
125
  color: '#fff',
182
126
  float: 'left',
183
127
  margin: '0px 10px 0px 0px',
128
+ whiteSpace: 'nowrap',
184
129
  '&:hover': {
185
130
  backgroundColor: '#1D79A8',
186
131
  color: '#fff'
187
132
  }
188
133
  },
189
- urlView: {
190
- float: 'left',
191
- width: 'calc(100% - 13px)',
192
- minWidth: '840px',
193
- '@media (max-width: 2560px)': {
194
- maxWidth: '1800px'
195
- },
196
- '@media (max-width: 2000px)': {
197
- maxWidth: '1400px'
198
- },
199
- '@media (max-width: 1600px)': {
200
- maxWidth: '1200px'
201
- },
202
- '@media (max-width: 1300px)': {
203
- maxWidth: '1050px'
204
- }
205
- },
206
134
  copyIconBtn: {
207
135
  padding: '0px',
208
136
  height: '20px',
@@ -106,7 +106,7 @@ const QueryBarGenerator = function QueryBarGenerator() {
106
106
  }, "INPUT CASE SET") : null, autocomplete.length ? /*#__PURE__*/_react.default.createElement("span", null, ' ', /*#__PURE__*/_react.default.createElement("span", {
107
107
  className: (0, _clsx.default)(classes.filterName, classes.localFindBackground),
108
108
  onClick: clearAutocomplete
109
- }, "Case ID"), ' ', ' ', /*#__PURE__*/_react.default.createElement("span", {
109
+ }, "Case IDs"), ' ', ' ', /*#__PURE__*/_react.default.createElement("span", {
110
110
  className: classes.operators
111
111
  }, autocomplete.length === 1 && !upload.length ? 'IS ' : 'IN ')) : null, /*#__PURE__*/_react.default.createElement("span", null, (upload.length > 0 ? 1 : 0) + autocomplete.length > 1 ? /*#__PURE__*/_react.default.createElement("span", {
112
112
  className: classes.bracketsOpen
@@ -18,6 +18,15 @@ var _default = {
18
18
  * @var {boolean}
19
19
  */
20
20
  displayAllActiveFilters: false,
21
+ /**
22
+ * set root path for copy url
23
+ * @var {boolean}
24
+ */
25
+ rootPath: "".concat(window.location.href, "/"),
26
+ /**
27
+ * display copy url button
28
+ * @var {boolean}
29
+ */
21
30
  viewQueryURL: false
22
31
  },
23
32
  /* Component Helper Functions */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/query-bar",
3
- "version": "1.0.1-icdc.24",
3
+ "version": "1.0.1-icdc.26",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, useRef } from 'react';
1
+ import React, { useState, useRef } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import {
4
4
  Button,
@@ -12,62 +12,6 @@ import {
12
12
  } from '@material-ui/core';
13
13
  import CopyIcon from '../assets/CopyIcon.svg';
14
14
 
15
- const ViewFullLinkComponent = ({
16
- classes,
17
- url,
18
- maxWidth = 1200,
19
- }) => {
20
- const linkRef = useRef(null);
21
- const [collapseLink, setCollapseLink] = useState(false);
22
-
23
- /**
24
- * Compute url link width based on the windowsize
25
- */
26
- useEffect(() => {
27
- const urlWidth = linkRef?.current?.offsetWidth;
28
- if (urlWidth > maxWidth / 2) {
29
- setCollapseLink(true);
30
- }
31
- }, []);
32
-
33
- const expandUrl = () => {
34
- setCollapseLink(false);
35
- };
36
-
37
- const collapseUrl = () => {
38
- setCollapseLink(true);
39
- };
40
-
41
- return (
42
- <>
43
- <span ref={linkRef} className={classes.link}>
44
- <span
45
- className={clsx(classes.viewLink,
46
- { [classes.collapseLink]: collapseLink })}
47
- >
48
- <span
49
- className={clsx(classes.urlView,
50
- { [classes.urlViewBtn]: !collapseLink })}
51
- type="button"
52
- onClick={collapseUrl}
53
- >
54
- {url}
55
- </span>
56
- {(collapseLink) && (
57
- <span
58
- className={classes.expandLinkBtn}
59
- type="button"
60
- onClick={expandUrl}
61
- >
62
- ...
63
- </span>
64
- )}
65
- </span>
66
- </span>
67
- </>
68
- );
69
- };
70
-
71
15
  const QueryUrl = ({
72
16
  classes,
73
17
  filterItems,
@@ -77,8 +21,6 @@ const QueryUrl = ({
77
21
  const [display, setDisplay] = useState(false);
78
22
  const toggleDisplay = () => setDisplay(!display);
79
23
 
80
- const [expand, setExpand] = useState(false);
81
-
82
24
  const [open, toggleOpen] = useState(false);
83
25
 
84
26
  const pathFilterParams = filterItems.reduce((acc, item) => {
@@ -91,7 +33,8 @@ const QueryUrl = ({
91
33
  ...pathFilterParams,
92
34
  ...localFind,
93
35
  });
94
- const url = encodeURI(rootPath.concat(query));
36
+
37
+ const url = rootPath + encodeURIComponent(query);
95
38
 
96
39
  const copyUrl = async () => {
97
40
  toggleOpen(!open);
@@ -107,26 +50,17 @@ const QueryUrl = ({
107
50
  onClick={toggleDisplay}
108
51
  className={classes.viewLinkToggleBtn}
109
52
  >
110
- { (display) ? 'Hide Query URL' : 'Show Query URL'}
53
+ {(display) ? 'Hide Query URL' : 'Show Query URL'}
111
54
  </Button>
112
55
  {
113
56
  (display) && (
114
57
  <>
115
- {(expand) ? (
116
- <span
117
- type="button"
118
- onClick={() => setExpand(!expand)}
119
- className={clsx(classes.link, classes.viewLink, classes.expandLink)}
120
- >
121
- {url}
122
- </span>
123
- ) : (
124
- <ViewFullLinkComponent
125
- url={url}
126
- classes={classes}
127
- maxWidth={queryRef?.current?.offsetWidth}
128
- />
129
- )}
58
+ <div
59
+ type="button"
60
+ className={clsx(classes.viewLink)}
61
+ >
62
+ {url}
63
+ </div>
130
64
  <Tooltip
131
65
  arrow
132
66
  title="Copy to Clipboard"
@@ -164,48 +98,43 @@ const QueryUrl = ({
164
98
  const styles = () => ({
165
99
  urlContainer: {
166
100
  display: 'flex',
167
- marginTop: '10px',
101
+ marginTop: '3px',
168
102
  minHeight: '10px',
169
103
  },
170
- link: {
171
- lineBreak: 'anywhere',
104
+ viewLink: {
172
105
  overflow: 'hidden',
106
+ textOverflow: 'ellipsis',
173
107
  fontFamily: 'Nunito',
174
108
  fontSize: '12px',
175
109
  fontWeight: '500',
176
110
  lineHeight: '16px',
177
111
  letterSpacing: '0em',
178
- padding: '5px',
112
+ padding: '2px 5px',
179
113
  borderRadius: '5px',
180
114
  float: 'left',
181
115
  color: '#1D79A8',
182
116
  backgroundColor: '#fff',
183
- maxWidth: '80%',
184
- },
185
- viewLink: {
186
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
+ },
187
132
  },
188
133
  urlViewBtn: {
189
134
  cursor: 'pointer',
190
135
  },
191
- collapseLink: {
192
- maxHeight: '1em',
193
- display: 'block',
194
- // display: '-webkit-box',
195
- '-webkit-box-orient': 'vertical',
196
- '-webkit-line-clamp': '1',
197
- overflow: 'hidden',
198
- },
199
- expandLink: {
200
- cursor: 'pointer',
201
- },
202
- expandLinkBtn: {
203
- float: 'left',
204
- '&:hover': {
205
- cursor: 'pointer',
206
- },
207
- },
208
136
  viewLinkToggleBtn: {
137
+ padding: '5px 10px 5px 10px',
209
138
  height: '20px',
210
139
  fontFamily: 'Nunito',
211
140
  fontSize: '12px',
@@ -218,28 +147,12 @@ const styles = () => ({
218
147
  color: '#fff',
219
148
  float: 'left',
220
149
  margin: '0px 10px 0px 0px',
150
+ whiteSpace: 'nowrap',
221
151
  '&:hover': {
222
152
  backgroundColor: '#1D79A8',
223
153
  color: '#fff',
224
154
  },
225
155
  },
226
- urlView: {
227
- float: 'left',
228
- width: 'calc(100% - 13px)',
229
- minWidth: '840px',
230
- '@media (max-width: 2560px)': {
231
- maxWidth: '1800px',
232
- },
233
- '@media (max-width: 2000px)': {
234
- maxWidth: '1400px',
235
- },
236
- '@media (max-width: 1600px)': {
237
- maxWidth: '1200px',
238
- },
239
- '@media (max-width: 1300px)': {
240
- maxWidth: '1050px',
241
- },
242
- },
243
156
  copyIconBtn: {
244
157
  padding: '0px',
245
158
  height: '20px',
@@ -126,7 +126,7 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
126
126
  className={clsx(classes.filterName, classes.localFindBackground)}
127
127
  onClick={clearAutocomplete}
128
128
  >
129
- Case ID
129
+ Case IDs
130
130
  </span>
131
131
  {' '}
132
132
  {' '}
@@ -187,6 +187,7 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
187
187
  </span>
188
188
  </span>
189
189
  ) : null}
190
+
190
191
  {/* Facet Sidebar Selections */}
191
192
  {((autocomplete.length || upload.length) && mappedInputs.length)
192
193
  ? <span className={classes.operators}> AND </span>
@@ -12,6 +12,15 @@ export default {
12
12
  * @var {boolean}
13
13
  */
14
14
  displayAllActiveFilters: false,
15
+ /**
16
+ * set root path for copy url
17
+ * @var {boolean}
18
+ */
19
+ rootPath: `${window.location.href}/`,
20
+ /**
21
+ * display copy url button
22
+ * @var {boolean}
23
+ */
15
24
  viewQueryURL: false,
16
25
  },
17
26