@bento-core/query-bar 1.0.1-ccdihub.13 → 1.0.1-ccdihub.15

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.
@@ -14,14 +14,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
14
14
  const QueryUrl = _ref => {
15
15
  let {
16
16
  classes,
17
- rootPath,
18
17
  queryUrlCharacterLimit = 70
19
18
  } = _ref;
20
19
  const [display, setDisplay] = (0, _react.useState)(false);
21
20
  const toggleDisplay = () => setDisplay(prevDisplay => !prevDisplay);
22
21
  const [open, setOpen] = (0, _react.useState)(false);
23
22
  const toggleOpen = () => setOpen(prevOpen => !prevOpen);
24
- const url = rootPath.slice(0, rootPath.length - 1);
23
+ const url = window.location.href;
25
24
  const copyUrl = async () => {
26
25
  toggleOpen();
27
26
  await navigator.clipboard.writeText(url);
@@ -35,13 +35,13 @@ const QueryBarGenerator = function QueryBarGenerator() {
35
35
  } = _facetFilter.InputTypes;
36
36
  const maxItems = config && typeof config.maxItems === 'number' ? config.maxItems : _config.default.config.maxItems;
37
37
  const clearAll = functions && typeof functions.clearAll === 'function' ? functions.clearAll : _config.default.functions.clearAll;
38
+ const clearImportFrom = functions && typeof functions.clearImportFrom === 'function' ? functions.clearImportFrom : _config.default.functions.clearImportFrom;
38
39
  const clearUpload = functions && typeof functions.clearUpload === 'function' ? functions.clearUpload : _config.default.functions.clearUpload;
39
40
  const clearAutocomplete = functions && typeof functions.clearAutocomplete === 'function' ? functions.clearAutocomplete : _config.default.functions.clearAutocomplete;
40
41
  const deleteAutocompleteItem = functions && typeof functions.deleteAutocompleteItem === 'function' ? functions.deleteAutocompleteItem : _config.default.functions.deleteAutocompleteItem;
41
42
  const resetFacetSection = functions && typeof functions.resetFacetSection === 'function' ? functions.resetFacetSection : _config.default.functions.resetFacetSection;
42
43
  const resetFacetCheckbox = functions && typeof functions.resetFacetCheckbox === 'function' ? functions.resetFacetCheckbox : _config.default.functions.resetFacetCheckbox;
43
44
  const resetFacetSlider = functions && typeof functions.resetFacetSlider === 'function' ? functions.resetFacetSlider : _config.default.functions.resetFacetSlider;
44
- const queryURLRootPath = config && typeof config.rootPath === 'string' ? config.rootPath : _config.default.config.rootPath;
45
45
  const viewQueryURL = config && typeof config.viewQueryURL === 'boolean' ? config.viewQueryURL : _config.default.config.viewQueryURL;
46
46
  const queryUrlCharacterLimit = config && typeof config.queryUrlCharacterLimit === 'number' ? config.queryUrlCharacterLimit : _config.default.config.queryUrlCharacterLimit;
47
47
  return {
@@ -49,6 +49,7 @@ const QueryBarGenerator = function QueryBarGenerator() {
49
49
  withTheme: true
50
50
  })(props => {
51
51
  const {
52
+ hasImportFrom,
52
53
  statusReducer,
53
54
  localFind,
54
55
  classes
@@ -81,7 +82,7 @@ const QueryBarGenerator = function QueryBarGenerator() {
81
82
  items: itemKeys
82
83
  });
83
84
  }).filter(facet => facet.items.length > 0);
84
- if ((mappedInputs.length || autocomplete.length || upload.length) <= 0) {
85
+ if (!hasImportFrom && (mappedInputs.length || autocomplete.length || upload.length) <= 0) {
85
86
  return null;
86
87
  }
87
88
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -95,7 +96,12 @@ const QueryBarGenerator = function QueryBarGenerator() {
95
96
  className: classes.divider
96
97
  }), /*#__PURE__*/_react.default.createElement("span", {
97
98
  className: classes.queryContainer
98
- }, autocomplete.length || upload.length ? /*#__PURE__*/_react.default.createElement("span", null, upload.length && !autocomplete.length ? /*#__PURE__*/_react.default.createElement("span", {
99
+ }, hasImportFrom && /*#__PURE__*/_react.default.createElement("span", {
100
+ className: (0, _clsx.default)(classes.filterCheckboxes, classes.localFindBackground),
101
+ onClick: clearImportFrom
102
+ }, "IMPORT PARTICIPANT SET"), (autocomplete.length || upload.length) && mappedInputs.length ? /*#__PURE__*/_react.default.createElement("span", {
103
+ className: classes.operators
104
+ }, " AND ") : null, autocomplete.length || upload.length ? /*#__PURE__*/_react.default.createElement("span", null, upload.length && !autocomplete.length ? /*#__PURE__*/_react.default.createElement("span", {
99
105
  className: (0, _clsx.default)(classes.filterCheckboxes, classes.localFindBackground),
100
106
  onClick: clearUpload
101
107
  }, "INPUT PARTICIPANT SET") : null, autocomplete.length ? /*#__PURE__*/_react.default.createElement("span", null, ' ', /*#__PURE__*/_react.default.createElement("span", {
@@ -124,11 +130,10 @@ const QueryBarGenerator = function QueryBarGenerator() {
124
130
  classes: classes,
125
131
  onSectionClick: filter.type === CHECKBOX ? resetFacetSection : resetFacetSlider,
126
132
  onItemClick: filter.type === CHECKBOX ? resetFacetCheckbox : resetFacetSlider
127
- }))), viewQueryURL && queryURLRootPath && /*#__PURE__*/_react.default.createElement(_QueryUrl.default, {
133
+ }))), viewQueryURL && /*#__PURE__*/_react.default.createElement(_QueryUrl.default, {
128
134
  classes: classes,
129
135
  localFind: localFind,
130
136
  filterItems: mappedInputs,
131
- rootPath: queryURLRootPath,
132
137
  queryUrlCharacterLimit: queryUrlCharacterLimit
133
138
  }));
134
139
  })
@@ -13,11 +13,6 @@ var _default = {
13
13
  * @var {number}
14
14
  */
15
15
  maxItems: 2,
16
- /**
17
- * set root path for copy url
18
- * @var {boolean}
19
- */
20
- rootPath: "".concat(window.location.href, "/"),
21
16
  /**
22
17
  * display copy url button
23
18
  * @var {boolean}
@@ -37,6 +32,12 @@ var _default = {
37
32
  * @returns {void}
38
33
  */
39
34
  clearAll: () => {},
35
+ /**
36
+ * Clear import from filter
37
+ *
38
+ * @returns {void}
39
+ */
40
+ clearImportFrom: () => {},
40
41
  /**
41
42
  * Clear all active Local Find file upload filters
42
43
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/query-bar",
3
- "version": "1.0.1-ccdihub.13",
3
+ "version": "1.0.1-ccdihub.15",
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": {
@@ -14,7 +14,6 @@ import CopyIcon from '../assets/CopyIcon.svg';
14
14
 
15
15
  const QueryUrl = ({
16
16
  classes,
17
- rootPath,
18
17
  queryUrlCharacterLimit = 70,
19
18
  }) => {
20
19
  const [display, setDisplay] = useState(false);
@@ -23,7 +22,7 @@ const QueryUrl = ({
23
22
  const [open, setOpen] = useState(false);
24
23
  const toggleOpen = () => setOpen((prevOpen) => !prevOpen);
25
24
 
26
- const url = rootPath.slice(0, rootPath.length - 1);
25
+ const url = window.location.href;
27
26
 
28
27
  const copyUrl = async () => {
29
28
  toggleOpen();
@@ -39,7 +38,7 @@ const QueryUrl = ({
39
38
  onClick={toggleDisplay}
40
39
  className={classes.viewLinkToggleBtn}
41
40
  >
42
- { (display) ? 'Hide Query URL' : 'Show Query URL'}
41
+ {(display) ? 'Hide Query URL' : 'Show Query URL'}
43
42
  </Button>
44
43
  {
45
44
  (display) && (
@@ -25,6 +25,10 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
25
25
  ? functions.clearAll
26
26
  : DEFAULT_CONFIG.functions.clearAll;
27
27
 
28
+ const clearImportFrom = functions && typeof functions.clearImportFrom === 'function'
29
+ ? functions.clearImportFrom
30
+ : DEFAULT_CONFIG.functions.clearImportFrom;
31
+
28
32
  const clearUpload = functions && typeof functions.clearUpload === 'function'
29
33
  ? functions.clearUpload
30
34
  : DEFAULT_CONFIG.functions.clearUpload;
@@ -49,10 +53,6 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
49
53
  ? functions.resetFacetSlider
50
54
  : DEFAULT_CONFIG.functions.resetFacetSlider;
51
55
 
52
- const queryURLRootPath = config && typeof config.rootPath === 'string'
53
- ? config.rootPath
54
- : DEFAULT_CONFIG.config.rootPath;
55
-
56
56
  const viewQueryURL = config && typeof config.viewQueryURL === 'boolean'
57
57
  ? config.viewQueryURL
58
58
  : DEFAULT_CONFIG.config.viewQueryURL;
@@ -63,8 +63,9 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
63
63
 
64
64
  return {
65
65
  QueryBar: withStyles(DEFAULT_STYLES, { withTheme: true })((props) => {
66
- const { statusReducer, localFind, classes } = props;
67
-
66
+ const {
67
+ hasImportFrom, statusReducer, localFind, classes,
68
+ } = props;
68
69
  const { autocomplete, upload } = localFind;
69
70
 
70
71
  // Remove any sections without checkboxes selected
@@ -88,7 +89,7 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
88
89
  })
89
90
  .filter((facet) => facet.items.length > 0);
90
91
 
91
- if ((mappedInputs.length || autocomplete.length || upload.length) <= 0) {
92
+ if (!hasImportFrom && (mappedInputs.length || autocomplete.length || upload.length) <= 0) {
92
93
  return null;
93
94
  }
94
95
 
@@ -106,6 +107,20 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
106
107
  <span className={classes.queryContainer}>
107
108
  {/* Local Find Selections */}
108
109
  {/* TODO: Refactor this into a separate component */}
110
+ {
111
+ hasImportFrom
112
+ && (
113
+ <span
114
+ className={clsx(classes.filterCheckboxes, classes.localFindBackground)}
115
+ onClick={clearImportFrom}
116
+ >
117
+ IMPORTED PARTICIPANT SET
118
+ </span>
119
+ )
120
+ }
121
+ {((autocomplete.length || upload.length) && mappedInputs.length)
122
+ ? <span className={classes.operators}> AND </span>
123
+ : null}
109
124
  {(autocomplete.length || upload.length) ? (
110
125
  <span>
111
126
  {/* Standalone case set button */}
@@ -192,12 +207,11 @@ export const QueryBarGenerator = (uiConfig = DEFAULT_CONFIG) => {
192
207
  ))}
193
208
  </span>
194
209
  {
195
- (viewQueryURL && queryURLRootPath) && (
210
+ viewQueryURL && (
196
211
  <QueryUrl
197
212
  classes={classes}
198
213
  localFind={localFind}
199
214
  filterItems={mappedInputs}
200
- rootPath={queryURLRootPath}
201
215
  queryUrlCharacterLimit={queryUrlCharacterLimit}
202
216
  />
203
217
  )
@@ -7,11 +7,6 @@ export default {
7
7
  * @var {number}
8
8
  */
9
9
  maxItems: 2,
10
- /**
11
- * set root path for copy url
12
- * @var {boolean}
13
- */
14
- rootPath: `${window.location.href}/`,
15
10
  /**
16
11
  * display copy url button
17
12
  * @var {boolean}
@@ -33,6 +28,13 @@ export default {
33
28
  */
34
29
  clearAll: () => { },
35
30
 
31
+ /**
32
+ * Clear import from filter
33
+ *
34
+ * @returns {void}
35
+ */
36
+ clearImportFrom: () => { },
37
+
36
38
  /**
37
39
  * Clear all active Local Find file upload filters
38
40
  *