@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 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
- // const group = config && typeof config.group === 'string'
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
- // itemKeys.forEach((item) => {
91
- // if (data.findIndex((d) => d.group === item) < 0) {
92
- // itemKeys.splice(itemKeys.indexOf(item), 1);
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
- * commenting out line 89-93
98
- * to display all the active filters in the query bar
99
- * ICDC-3287
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: itemKeys
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
- facetSectionCases: {
95
+ facetSectionProjects: {
96
96
  color: '#10A075'
97
97
  },
98
- facetSectionCasesBackground: {
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-icdc.3",
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": "https://github.com/CBIIT/bento-frontend",
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
- // const group = config && typeof config.group === 'string'
31
- // ? config.group : DEFAULT_CONFIG.config.group;
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
- // itemKeys.forEach((item) => {
90
- // if (data.findIndex((d) => d.group === item) < 0) {
91
- // itemKeys.splice(itemKeys.indexOf(item), 1);
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
- * commenting out line 89-93
97
- * to display all the active filters in the query bar
98
- * ICDC-3287
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
- return { ...facet, items: itemKeys };
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
 
@@ -17,6 +17,11 @@ export default {
17
17
  * @var {boolean}
18
18
  */
19
19
  group: 'group',
20
+ /**
21
+ * key to access count value
22
+ * @var {boolean}
23
+ */
24
+ count: 'subjects',
20
25
  },
21
26
 
22
27
  /* Component Helper Functions */
@@ -86,10 +86,10 @@ export default () => ({
86
86
  localFindBackground: {
87
87
  backgroundColor: '#C0E9D7',
88
88
  },
89
- facetSectionCases: {
89
+ facetSectionProjects: {
90
90
  color: '#10A075',
91
91
  },
92
- facetSectionCasesBackground: {
92
+ facetSectionProjectsBackground: {
93
93
  backgroundColor: '#C0E9D7',
94
94
  },
95
95
  facetSectionFiles: {