@bento-core/paginated-table 1.0.1-ccdihub.9 → 1.0.1-ctdc.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.
Files changed (31) hide show
  1. package/Add_ALL_Files__BLUE_ButtonREADME.md +86 -0
  2. package/Add_Selected_Files_Orange_button_README.md +79 -0
  3. package/dist/index.js +13 -0
  4. package/dist/table/ClientController.js +1 -0
  5. package/dist/table/PaginatedTable.js +25 -14
  6. package/dist/table/state/Actions.js +9 -3
  7. package/dist/table/state/Reducer.js +2 -0
  8. package/dist/wrapper/Wrapper.js +4 -2
  9. package/dist/wrapper/WrapperService.js +1 -1
  10. package/dist/wrapper/components/AddAllFiles/AddAllView.js +12 -43
  11. package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +18 -5
  12. package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +1 -0
  13. package/dist/wrapper/components/AddToCartDialog/AddToCartDialogView.js +21 -9
  14. package/dist/wrapper/components/DownloadManifestBtn.js +21 -4
  15. package/dist/wrapper/components/Snackbar/Snackbar.js +1 -1
  16. package/dist/wrapper/components/util.js +33 -0
  17. package/package.json +5 -12
  18. package/src/index.js +4 -0
  19. package/src/table/ClientController.js +1 -0
  20. package/src/table/PaginatedTable.js +24 -13
  21. package/src/table/state/Actions.js +6 -0
  22. package/src/table/state/Reducer.js +5 -0
  23. package/src/wrapper/Wrapper.js +2 -0
  24. package/src/wrapper/WrapperService.js +1 -1
  25. package/src/wrapper/components/AddAllFiles/AddAllView.js +8 -40
  26. package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +16 -4
  27. package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +1 -1
  28. package/src/wrapper/components/AddToCartDialog/AddToCartDialogView.js +37 -14
  29. package/src/wrapper/components/DownloadManifestBtn.js +27 -3
  30. package/src/wrapper/components/Snackbar/Snackbar.js +1 -1
  31. package/src/wrapper/components/util.js +26 -0
@@ -0,0 +1,86 @@
1
+
2
+ ### 1 Use bento-core/paginated-table package version publish by ICDC
3
+ Alternative configuratoin for BLUE button
4
+ ```
5
+ // 1.0.1-icdc.3
6
+ npm i @bento-core/paginated-table@1.0.1-icdc.3
7
+
8
+ or in package.json
9
+ {
10
+ @bento-core/paginated-table: '1.0.1-icdc.3'
11
+ }
12
+ ```
13
+ **NOTE: Create a new dashboard page using bento-core components before removing old dashboard page**
14
+ <br>
15
+ <span style="color:red">
16
+ Assuming New Dashboard page have Filter component and table component from bento-core
17
+ </span>.
18
+
19
+
20
+
21
+ ### 2 Configure Add_All_Button Or BLUE Button in Dashboard
22
+
23
+ ```
24
+ import React, { useCallback } from 'react';
25
+ import { ButtonView, btnTypes } from '@bento-core/paginated-table';
26
+
27
+ const AddAllBlueButton = useCallback(() => (
28
+ <ButtonView
29
+ btnType={btnTypes.ADD_ALL_FILES}
30
+ title="Add All Files Btn"
31
+ clsName="add_all_button"
32
+ maxFileLimit={10000}
33
+ addFileQuery={GET_ALL_FILEIDS_CASESTAB_FOR_SELECT_ALL}
34
+ responseKeys={['caseOverview', 'files']}
35
+ activeFilters={activeFilters}
36
+ classes={classes}
37
+ section="toolTipText"
38
+ tooltipCofig={{
39
+ arrow: true,
40
+ clsName: 'addAllTooltip',
41
+ toolTipText: 'Add filtered files associated with all cases',
42
+ icon: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/icdc/images/svgs/Tooltip.SpeechBubble.svg',
43
+ }}
44
+ />
45
+ ), []);
46
+ ```
47
+
48
+ **Add All Button Component or Configuration Properties**
49
+ | Component Props | Required | description | Configuration |
50
+ | :--- | :----:| :----: | ----: |
51
+ | btnType | TRUE | Determines the role of the button, add all files (blue) or add selected files (orange) | btnTypes.ADD_ALL_FILES, btnTypes.ADD_SELECTED_FILES or btnTypes.DOWNLOAD_MANIFEST |
52
+ | title | TRUE | text for the button | 'Add all files' |
53
+ | clsName | TRUE | configure theme with themeprovider | |
54
+ | maxFileLimit | FALSE | limits no of files that can be added to myCart | 0 - 10000 (by default 1000) |
55
+ | addFileQuery | TRUE | query to retrive files or file ids | graphQL query |
56
+ | responseKeys | TRUE | Keys to access file_ids reponse provided by addFileQuery, provided as list to access the nested respose object or list (max depth upto 2) | ['caseOverview', 'files'] |
57
+ | section | TRUE | This key is used for accessing the tootip text provided in tooltipCofig | section="toolTipText" |
58
+ | classes | TRUE | provide class for toltips to override the style | tooltip: classes.customTooltip, arrow: classes.customArrow
59
+ | tooltipCofig | FALSE | displays tooltip if provided, configuration for arrow, clsName, icon, tooltipText | graphQL query |
60
+ | activeFilters | TRUE | filtes the case or sample based on the active filters | graphQL query |
61
+
62
+
63
+ ### 3 Configure Add_All_Button Or BLUE Button in Dashboard
64
+
65
+ ```
66
+ const customTheme = {
67
+ MuiContainer: {
68
+ root: {
69
+ '& img': {
70
+ width: '17px',
71
+ '&.addAllTooltip': {
72
+ verticalAlign: 'top',
73
+ marginTop: '8px',
74
+ },
75
+ },
76
+ },
77
+ },
78
+ };
79
+
80
+ const btnTheme = createTheme({ overrides: { ...customTheme } });
81
+ <ThemeProvider theme={btnTheme}>
82
+ <Container>
83
+ <AddAllBlueButton /> // from step 2
84
+ </Container>
85
+ </ThemeProvider>
86
+ ```
@@ -0,0 +1,79 @@
1
+
2
+ ### 1 Use bento-core/paginated-table package version publish by ICDC
3
+ Alternative configuration for ORANGE button
4
+ ```
5
+ // 1.0.1-icdc.3
6
+ npm i @bento-core/paginated-table@1.0.1-icdc.3
7
+
8
+ or in package.json
9
+ {
10
+ @bento-core/paginated-table: '1.0.1-icdc.3'
11
+ }
12
+ ```
13
+
14
+ <span style="color:red">
15
+ Assuming table component is imported from bento-core/paginated-table
16
+ </span>
17
+
18
+ ### 2 Configure Add_All_Button Or BLUE Button in Dashboard
19
+
20
+ ```
21
+ import React, { useCallback } from 'react';
22
+ import { ButtonView, btnTypes } from '@bento-core/paginated-table';
23
+
24
+ const AddSelectedFilesOrangeButton = useCallback(() => (
25
+ <ButtonView
26
+ btnType={btnTypes.ADD_SELECTED_FILES}
27
+ title="ADD SELECTED FILES Btn"
28
+ clsName="add_selected_button"
29
+ dataKey="case_ids"
30
+ addFileQuery={GET_ALL_FILEIDS_CASESTAB_FOR_SELECT_ALL}
31
+ responseKeys={['caseOverview', 'files']}
32
+ classes={classes}
33
+ tooltipCofig={{
34
+ arrow: true,
35
+ clsName: 'addSelectedFileTooltip',
36
+ tooltipText: 'Add files associated selected cases',
37
+ icon: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/icdc/images/svgs/Tooltip.SpeechBubble.svg',
38
+ }}
39
+ />
40
+ ), []);
41
+ ```
42
+
43
+ **Add All Button Component or Configuration Properties**
44
+ | Component Props | Required | description | Configuration |
45
+ | :--- | :----:| :----: | ----: |
46
+ | btnType | TRUE | Determines the role of the button, add all files (blue) or add selected files (orange) | btnTypes.ADD_ALL_FILES, btnTypes.ADD_SELECTED_FILES or btnTypes.DOWNLOAD_MANIFEST |
47
+ | title | TRUE | text for the button | 'Add Selected files' |
48
+ | clsName | TRUE | configure theme with themeprovider | |
49
+ | addFileQuery | TRUE | query to retrive files or file ids | graphQL query |
50
+ | responseKeys | TRUE | Keys to access file_ids reponse provided by addFileQuery, provided as list to access the nested respose object or list (max depth upto 2) | ['caseOverview', 'files'] |
51
+ | classes | TRUE | provide class for toltips to override the style | tooltip: classes.customTooltip, arrow: classes.customArrow
52
+ | tooltipCofig | FALSE | displays tooltip if provided, configuration for arrow, clsName, icon, tooltipText | graphQL query |
53
+ | dataKey | TRUE | Attribute used for getting selected rows in a table | case_id, file_name or any other column with distinct values |
54
+
55
+
56
+ ### 3 Configure Add_All_Button Or BLUE Button in Dashboard
57
+
58
+ ```
59
+ const customTheme = {
60
+ MuiContainer: {
61
+ root: {
62
+ '& img': {
63
+ width: '17px',
64
+ '&.addAllTooltip': {
65
+ verticalAlign: 'top',
66
+ marginTop: '8px',
67
+ },
68
+ },
69
+ },
70
+ },
71
+ };
72
+
73
+ const btnTheme = createTheme({ overrides: { ...customTheme } });
74
+ <ThemeProvider theme={btnTheme}>
75
+ <Container>
76
+ <AddSelectedFilesOrangeButton /> // from step 2
77
+ </Container>
78
+ </ThemeProvider>
79
+ ```
package/dist/index.js CHANGED
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "ButtonView", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _ButtonView.default;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "TableContext", {
7
13
  enumerable: true,
8
14
  get: function get() {
@@ -33,6 +39,12 @@ Object.defineProperty(exports, "btnTypes", {
33
39
  return _AddFiles.btnTypes;
34
40
  }
35
41
  });
42
+ Object.defineProperty(exports, "customPaginationAction", {
43
+ enumerable: true,
44
+ get: function get() {
45
+ return _Actions.customPaginationAction;
46
+ }
47
+ });
36
48
  Object.defineProperty(exports, "getQueryVariables", {
37
49
  enumerable: true,
38
50
  get: function get() {
@@ -99,6 +111,7 @@ var _Actions = require("./table/state/Actions");
99
111
  var _Wrapper = _interopRequireWildcard(require("./wrapper/Wrapper"));
100
112
  var _AddFiles = require("./wrapper/components/AddFiles");
101
113
  var _WrapperService = require("./wrapper/WrapperService");
114
+ var _ButtonView = _interopRequireDefault(require("./wrapper/components/ButtonView"));
102
115
  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); }
103
116
  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; }
104
117
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -57,6 +57,7 @@ const TableController = props => {
57
57
  const endIndex = startIndex + rowsPerPage;
58
58
  const displayRows = [...sortedRows].slice(startIndex, endIndex);
59
59
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_table.TableView, _extends({}, props, {
60
+ totalRows: tblRows,
60
61
  tableRows: displayRows
61
62
  })));
62
63
  };
@@ -26,7 +26,8 @@ const PaginatedTable = _ref => {
26
26
  initState,
27
27
  activeTab = true,
28
28
  server = true,
29
- tblRows = []
29
+ tblRows = [],
30
+ paginationOptions = {}
30
31
  } = _ref;
31
32
  /**
32
33
  * Initailize useReducer state
@@ -89,6 +90,15 @@ const PaginatedTable = _ref => {
89
90
  pageNumb: newPage
90
91
  }));
91
92
  };
93
+ // custonize pagination behavior
94
+ const {
95
+ customizeOnRowSelect,
96
+ customizeToggleSelectAll,
97
+ customizeSortByColumn,
98
+ customizeChangePage,
99
+ customizeChangeRowsPerPage,
100
+ customizeColumnViewChange
101
+ } = paginationOptions;
92
102
 
93
103
  /**
94
104
  * update selected Ids
@@ -138,7 +148,7 @@ const PaginatedTable = _ref => {
138
148
  const handleColumnViewChange = column => {
139
149
  const columns = table.columns.map(col => {
140
150
  const updateColumnView = _objectSpread({}, col);
141
- if (col.dataField === column.dataField) {
151
+ if (col.dataField && col.dataField === column.dataField) {
142
152
  updateColumnView.display = !column.display;
143
153
  }
144
154
  return updateColumnView;
@@ -156,12 +166,12 @@ const PaginatedTable = _ref => {
156
166
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ClientController.default, {
157
167
  tblRows: tblRows,
158
168
  table: table,
159
- onRowsPerPageChange: handleChangeRowsPerPage,
160
- onPageChange: handleChangePage,
161
- onRowSelectChange: onRowSelectHandler,
162
- onToggleSelectAll: handleToggleSelectAll,
163
- onSortByColumn: handleSortByColumn,
164
- onColumnViewChange: handleColumnViewChange,
169
+ onRowsPerPageChange: customizeChangeRowsPerPage || handleChangeRowsPerPage,
170
+ onPageChange: customizeChangePage || handleChangePage,
171
+ onRowSelectChange: customizeOnRowSelect || onRowSelectHandler,
172
+ onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
173
+ onSortByColumn: customizeSortByColumn || handleSortByColumn,
174
+ onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
165
175
  themeConfig: themeConfig
166
176
  }));
167
177
  }
@@ -180,12 +190,13 @@ const PaginatedTable = _ref => {
180
190
  queryVariables: queryVariables,
181
191
  totalRowCount: totalRowCount,
182
192
  table: table,
183
- onRowsPerPageChange: handleChangeRowsPerPage,
184
- onPageChange: handleChangePage,
185
- onRowSelectChange: onRowSelectHandler,
186
- onToggleSelectAll: handleToggleSelectAll,
187
- onSortByColumn: handleSortByColumn,
188
- onColumnViewChange: handleColumnViewChange,
193
+ server: server,
194
+ onRowsPerPageChange: customizeChangeRowsPerPage || handleChangeRowsPerPage,
195
+ onPageChange: customizeChangePage || handleChangePage,
196
+ onRowSelectChange: customizeOnRowSelect || onRowSelectHandler,
197
+ onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
198
+ onSortByColumn: customizeSortByColumn || handleSortByColumn,
199
+ onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
189
200
  themeConfig: themeConfig
190
201
  }));
191
202
  };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setTotalRowCount = exports.onRowsPerPageChange = exports.onRowSeclect = exports.onPageChange = exports.onPageAndTotalCountChange = exports.onColumnViewChange = exports.onColumnSort = exports.onChangeSortDirection = exports.actionTypes = void 0;
6
+ exports.setTotalRowCount = exports.onRowsPerPageChange = exports.onRowSeclect = exports.onPageChange = exports.onPageAndTotalCountChange = exports.onColumnViewChange = exports.onColumnSort = exports.onChangeSortDirection = exports.customPaginationAction = exports.actionTypes = void 0;
7
7
  const actionTypes = {
8
8
  VIEW_COLUMN_CHANGE: 'VIEW_COLUMN_CHANGE',
9
9
  ON_COLUMN_SORT: 'ON_COLUMN_SORT',
@@ -12,7 +12,8 @@ const actionTypes = {
12
12
  ON_PAGE_CHANGE: 'ON_PAGE_CHANGE',
13
13
  ON_ROW_SELECT: 'ON_ROW_SELECT',
14
14
  SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
15
- ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE'
15
+ ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE',
16
+ CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION'
16
17
  };
17
18
  exports.actionTypes = actionTypes;
18
19
  const onColumnViewChange = columns => ({
@@ -54,4 +55,9 @@ const setTotalRowCount = count => ({
54
55
  type: actionTypes.SET_TOTAL_ROW_COUNT,
55
56
  payload: count
56
57
  });
57
- exports.setTotalRowCount = setTotalRowCount;
58
+ exports.setTotalRowCount = setTotalRowCount;
59
+ const customPaginationAction = value => ({
60
+ type: actionTypes.CUSTOMIZE_PAGINATION_ACTION,
61
+ payload: value
62
+ });
63
+ exports.customPaginationAction = customPaginationAction;
@@ -16,6 +16,8 @@ const reducer = (state, action) => {
16
16
  payload
17
17
  } = action;
18
18
  switch (type) {
19
+ case _Actions.actionTypes.CUSTOMIZE_PAGINATION_ACTION:
20
+ return _objectSpread(_objectSpread({}, state), payload);
19
21
  case _Actions.actionTypes.ON_COLUMN_SORT:
20
22
  return _objectSpread(_objectSpread({}, state), {}, {
21
23
  sortOrder: payload.sort,
@@ -152,7 +152,8 @@ const CustomWrapper = props => {
152
152
  section,
153
153
  classes,
154
154
  activeFilters,
155
- tblDispatch
155
+ tblDispatch,
156
+ totalRowCount
156
157
  } = props;
157
158
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(CustomLayout, {
158
159
  configs: wrapConfig,
@@ -160,7 +161,8 @@ const CustomWrapper = props => {
160
161
  section: section,
161
162
  classes: classes,
162
163
  activeFilters: activeFilters,
163
- tblDispatch: tblDispatch
164
+ tblDispatch: tblDispatch,
165
+ totalRowCount: totalRowCount
164
166
  }, children));
165
167
  };
166
168
  var _default = CustomWrapper;
@@ -14,7 +14,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
14
14
  */
15
15
  const getQueryVariables = variables => {
16
16
  const queryVariables = _objectSpread({}, variables);
17
- queryVariables.first = 100000;
17
+ queryVariables.first = 10000;
18
18
  return queryVariables;
19
19
  };
20
20
  exports.getQueryVariables = getQueryVariables;
@@ -3,44 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.ToolTipView = void 0;
6
+ exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _toolTip = _interopRequireDefault(require("@bento-core/tool-tip"));
9
8
  var _core = require("@material-ui/core");
10
9
  var _clsx = _interopRequireDefault(require("clsx"));
11
10
  var _WrapperService = require("../../WrapperService");
12
11
  var _AddToCartDialogView = _interopRequireDefault(require("../AddToCartDialog/AddToCartDialogView"));
12
+ var _TooltipView = _interopRequireDefault(require("../TooltipView"));
13
+ var _util = _interopRequireDefault(require("../util"));
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  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); }
15
16
  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; }
16
- const ToolTipView = props => {
17
- const {
18
- section,
19
- tooltipCofig,
20
- classes
21
- } = props;
22
- const {
23
- icon,
24
- src,
25
- alt,
26
- arrow = false,
27
- tooltipText,
28
- placement
29
- } = tooltipCofig;
30
- return /*#__PURE__*/_react.default.createElement(_toolTip.default, {
31
- placement: placement,
32
- title: tooltipText || "".concat(tooltipCofig[section]),
33
- arrow: arrow,
34
- classes: {
35
- tooltip: classes.customTooltip,
36
- arrow: classes.customArrow
37
- }
38
- }, /*#__PURE__*/_react.default.createElement("img", {
39
- src: icon || src,
40
- alt: alt
41
- }));
42
- };
43
- exports.ToolTipView = ToolTipView;
44
17
  const AddAllFilesComponent = props => {
45
18
  const {
46
19
  title,
@@ -53,7 +26,9 @@ const AddAllFilesComponent = props => {
53
26
  setAlterDisplay,
54
27
  setOpenSnackbar,
55
28
  client,
56
- tooltipCofig
29
+ tooltipCofig,
30
+ maxFileLimit = 1000,
31
+ DisplayCustomText
57
32
  } = props;
58
33
  /**
59
34
  * conditionally display dialog view
@@ -74,16 +49,8 @@ const AddAllFilesComponent = props => {
74
49
  fileIds().then(response => {
75
50
  const data = response[responseKeys[0]];
76
51
  if (data && data.length > 0) {
77
- const isArray = Array.isArray(data[0][responseKeys[1]]);
78
- const ids = data.reduce((acc, id) => {
79
- if (id && id[responseKeys[1]]) {
80
- // if object convert to array
81
- const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
82
- acc.push(...items);
83
- }
84
- return acc;
85
- }, []);
86
- if (ids.length > 1000) {
52
+ const ids = (0, _util.default)(response, responseKeys);
53
+ if (ids.length > maxFileLimit) {
87
54
  setAlterDisplay(true);
88
55
  } else {
89
56
  setOpen(true);
@@ -108,10 +75,12 @@ const AddAllFilesComponent = props => {
108
75
  onClick: addAllFiles,
109
76
  className: (0, _clsx.default)(clsName, "".concat(clsName, "_").concat(section)),
110
77
  disableRipple: true
111
- }, title), tooltipCofig && /*#__PURE__*/_react.default.createElement(ToolTipView, props), /*#__PURE__*/_react.default.createElement(_AddToCartDialogView.default, {
78
+ }, title), tooltipCofig && /*#__PURE__*/_react.default.createElement(_TooltipView.default, props), /*#__PURE__*/_react.default.createElement(_AddToCartDialogView.default, {
112
79
  open: openAddDialog,
113
80
  onYesClick: addFilesToCart,
114
- onNoClick: toggleOpen
81
+ onNoClick: toggleOpen,
82
+ DisplayCustomText: DisplayCustomText,
83
+ activeFilters: activeFilters
115
84
  }));
116
85
  };
117
86
  var _default = AddAllFilesComponent;
@@ -12,10 +12,16 @@ var _ContextProvider = require("../../../table/ContextProvider");
12
12
  var _Actions = require("../../../table/state/Actions");
13
13
  var _AddSelectedFilesView = _interopRequireDefault(require("./AddSelectedFilesView"));
14
14
  var _WrapperService = require("../../WrapperService");
15
+ var _util = _interopRequireDefault(require("../util"));
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17
  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); }
17
18
  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; }
18
19
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
20
+ 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; }
21
+ 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; }
22
+ 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; }
23
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
24
+ 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
25
  const AddSelectedFilesController = props => {
20
26
  const {
21
27
  clsName,
@@ -26,7 +32,10 @@ const AddSelectedFilesController = props => {
26
32
  addFiles,
27
33
  setOpenSnackbar,
28
34
  setAlterDisplay,
29
- client
35
+ client,
36
+ maxFileLimit = 1000,
37
+ applyActiveFilter = false,
38
+ activeFilters = {}
30
39
  } = props;
31
40
  const tableContext = (0, _react.useContext)(_ContextProvider.TableContext);
32
41
  const {
@@ -36,8 +45,12 @@ const AddSelectedFilesController = props => {
36
45
  selectedRows = [],
37
46
  dispatch
38
47
  } = context;
39
- const variables = {};
40
- variables[dataKey] = selectedRows;
48
+ const activeFilterItems = applyActiveFilter ? _objectSpread({}, activeFilters) : {};
49
+ const variables = _objectSpread(_objectSpread({
50
+ first: 10000
51
+ }, activeFilterItems), {}, {
52
+ [dataKey]: selectedRows
53
+ });
41
54
  // add selected files id
42
55
  const addSelectedFiles = () => {
43
56
  const fileIds = (0, _WrapperService.getFilesID)({
@@ -47,8 +60,8 @@ const AddSelectedFilesController = props => {
47
60
  query: addFileQuery
48
61
  });
49
62
  fileIds().then(response => {
50
- const ids = response[responseKeys[0]] || [];
51
- if (ids.length >= 1000) {
63
+ const ids = (0, _util.default)(response, responseKeys);
64
+ if (ids.length >= maxFileLimit) {
52
65
  setAlterDisplay(true);
53
66
  } else {
54
67
  addFiles(ids);
@@ -35,6 +35,7 @@ const ToolTipView = props => {
35
35
  arrow: classes.customArrow
36
36
  }
37
37
  }, /*#__PURE__*/_react.default.createElement("img", {
38
+ className: "add_selected_file_tooltip_icon",
38
39
  src: icon || src,
39
40
  alt: alt
40
41
  }));
@@ -15,7 +15,9 @@ function AddToCartDialogView(props) {
15
15
  onYesClick,
16
16
  onNoClick,
17
17
  cartWillFull = false,
18
- alertMessage
18
+ alertMessage,
19
+ DisplayCustomText,
20
+ activeFilters
19
21
  } = props;
20
22
  if (cartWillFull) {
21
23
  return /*#__PURE__*/_react.default.createElement(_AddToCartDialogAlertView.default, {
@@ -24,19 +26,29 @@ function AddToCartDialogView(props) {
24
26
  onClose: () => onNoClick()
25
27
  });
26
28
  }
29
+ const CustomDialog = DisplayCustomText.component;
27
30
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Dialog, {
28
31
  open: open,
29
32
  "aria-labelledby": "alert-dialog-title",
30
33
  "aria-describedby": "alert-dialog-description"
31
- }, /*#__PURE__*/_react.default.createElement(_core.DialogContent, null, /*#__PURE__*/_react.default.createElement(_core.DialogContentText, {
34
+ }, /*#__PURE__*/_react.default.createElement(_core.DialogContent, null, DisplayCustomText ? /*#__PURE__*/_react.default.createElement(CustomDialog, {
35
+ onYesClick: onYesClick,
36
+ onNoClick: onNoClick,
37
+ activeFilters: activeFilters
38
+ }) : /*#__PURE__*/_react.default.createElement(_core.DialogContentText, {
32
39
  id: "alert-dialog-description"
33
- }, "Are you sure to add All Files", ' ', numberOfFilesSelected, ' ', "to cart")), /*#__PURE__*/_react.default.createElement(_core.DialogActions, null, /*#__PURE__*/_react.default.createElement(_core.Button, {
34
- className: "yesBtn",
35
- onClick: () => onYesClick()
36
- }, "Yes"), /*#__PURE__*/_react.default.createElement(_core.Button, {
37
- className: "noBtn",
38
- onClick: () => onNoClick()
39
- }, "No"))));
40
+ }, "Are you sure to add All Files", ' ', numberOfFilesSelected, ' ', "to cart")), /*#__PURE__*/_react.default.createElement(_core.DialogActions, {
41
+ className: "dialog_actions"
42
+ }, DisplayCustomText.actions.map(a => /*#__PURE__*/_react.default.createElement(_core.Button, {
43
+ className: a.className,
44
+ onClick: () => {
45
+ if (a.type === 'Positive') {
46
+ onYesClick();
47
+ } else {
48
+ onNoClick();
49
+ }
50
+ }
51
+ }, a.label)))));
40
52
  }
41
53
  var _default = AddToCartDialogView;
42
54
  exports.default = _default;
@@ -21,8 +21,15 @@ const DownloadManifestView = props => {
21
21
  const {
22
22
  tooltipCofig,
23
23
  clsName,
24
- title
24
+ title,
25
+ totalRowCount
25
26
  } = props;
27
+ const {
28
+ icon,
29
+ alt,
30
+ arrow = false,
31
+ clsName: toolTipClsName
32
+ } = tooltipCofig;
26
33
  /**
27
34
  * get cart state
28
35
  */
@@ -48,7 +55,7 @@ const DownloadManifestView = props => {
48
55
  const fetchResult = await client.query({
49
56
  query: table.api,
50
57
  variables: _objectSpread({}, getQueryVeriables(queryVariables))
51
- }).then(result => result.data.filesInList);
58
+ }).then(result => table.objectKey ? result.data[table.objectKey] : result.data.filesInList);
52
59
  return fetchResult;
53
60
  }
54
61
  async function DocumentDownload() {
@@ -67,8 +74,18 @@ const DownloadManifestView = props => {
67
74
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Button, {
68
75
  className: clsName,
69
76
  disableRipple: true,
70
- onClick: () => DocumentDownload()
71
- }, title), tooltipCofig && /*#__PURE__*/_react.default.createElement(_TooltipView.default, props));
77
+ onClick: () => DocumentDownload(),
78
+ disabled: totalRowCount === 0
79
+ }, title), tooltipCofig && !tooltipCofig.customToolTipComponent && /*#__PURE__*/_react.default.createElement(_TooltipView.default, props), tooltipCofig && tooltipCofig.customToolTipComponent && /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
80
+ arrow: arrow,
81
+ interactive: true,
82
+ title: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tooltipCofig.customToolTipComponent),
83
+ placement: "bottom"
84
+ }, icon && /*#__PURE__*/_react.default.createElement("img", {
85
+ src: icon,
86
+ alt: alt,
87
+ className: toolTipClsName
88
+ })));
72
89
  };
73
90
  var _default = DownloadManifestView;
74
91
  exports.default = _default;
@@ -33,7 +33,7 @@ const SnackbarView = props => {
33
33
  className: "snackBarMessageIcon"
34
34
  }, /*#__PURE__*/_react.default.createElement(_SuccessOutlined.default, null), ' '), /*#__PURE__*/_react.default.createElement("span", {
35
35
  className: "snackBarText"
36
- }, count, ' ', "File(s) successfully added to your cart"))
36
+ }, count, ' ', "File(s) successfully added to My Files."))
37
37
  }));
38
38
  };
39
39
  var _default = SnackbarView;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /**
8
+ * max two response keys
9
+ * add file query response handler
10
+ * return - list of files name/id
11
+ */
12
+ const addFilesResponseHandler = function addFilesResponseHandler(response) {
13
+ let responseKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
14
+ if (responseKeys.length === 2) {
15
+ const data = response[responseKeys[0]];
16
+ if (data && data.length > 0) {
17
+ const isArray = Array.isArray(data[0][responseKeys[1]]);
18
+ const ids = data.reduce((acc, id) => {
19
+ if (id && id[responseKeys[1]]) {
20
+ // if object convert to array
21
+ const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
22
+ acc.push(...items);
23
+ }
24
+ return acc;
25
+ }, []);
26
+ return ids;
27
+ }
28
+ return [];
29
+ }
30
+ return response[responseKeys[0]] || [];
31
+ };
32
+ var _default = addFilesResponseHandler;
33
+ exports.default = _default;
package/package.json CHANGED
@@ -1,22 +1,20 @@
1
1
  {
2
2
  "name": "@bento-core/paginated-table",
3
- "version": "1.0.1-ccdihub.9",
3
+ "version": "1.0.1-ctdc.0",
4
+ "description": "",
4
5
  "main": "dist/index.js",
5
6
  "scripts": {
6
7
  "build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
7
8
  "test": "echo \"Error: no test specified\" && exit 1",
8
9
  "lint": "eslint src"
9
10
  },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/CBIIT/bento-frontend.git"
13
- },
11
+ "repository": "https://github.com/CBIIT/bento-frontend",
14
12
  "publishConfig": {
15
13
  "access": "public"
16
14
  },
17
15
  "dependencies": {
18
16
  "@bento-core/cart": "^1.0.0",
19
- "@bento-core/table": "1.0.1-ccdihub.8",
17
+ "@bento-core/table": "1.0.1-ctdc.0",
20
18
  "@bento-core/tool-tip": "^1.0.0",
21
19
  "@bento-core/util": "^1.0.0"
22
20
  },
@@ -29,10 +27,5 @@
29
27
  "react-redux": "^7.2.1"
30
28
  },
31
29
  "author": "CTOS Bento Team",
32
- "license": "ISC",
33
- "bugs": {
34
- "url": "https://github.com/CBIIT/bento-frontend/issues"
35
- },
36
- "homepage": "https://github.com/CBIIT/bento-frontend#readme",
37
- "description": ""
30
+ "license": "ISC"
38
31
  }
package/src/index.js CHANGED
@@ -12,7 +12,11 @@ export {
12
12
  onPageChange,
13
13
  onRowSeclect,
14
14
  setTotalRowCount,
15
+ customPaginationAction,
15
16
  } from './table/state/Actions';
16
17
  export { default as Wrapper, types } from './wrapper/Wrapper';
17
18
  export { btnTypes } from './wrapper/components/AddFiles';
18
19
  export { getQueryVariables } from './wrapper/WrapperService';
20
+ export {
21
+ default as ButtonView,
22
+ } from './wrapper/components/ButtonView';
@@ -55,6 +55,7 @@ const TableController = ((props) => {
55
55
  <>
56
56
  <TableView
57
57
  {...props}
58
+ totalRows={tblRows}
58
59
  tableRows={displayRows}
59
60
  />
60
61
  </>
@@ -21,6 +21,7 @@ const PaginatedTable = ({
21
21
  activeTab = true,
22
22
  server = true,
23
23
  tblRows = [],
24
+ paginationOptions = {},
24
25
  }) => {
25
26
  /**
26
27
  * Initailize useReducer state
@@ -74,6 +75,15 @@ const PaginatedTable = ({
74
75
  const handleChangePage = (event, newPage) => {
75
76
  dispatch(onPageChange({ pageNumb: newPage }));
76
77
  };
78
+ // custonize pagination behavior
79
+ const {
80
+ customizeOnRowSelect,
81
+ customizeToggleSelectAll,
82
+ customizeSortByColumn,
83
+ customizeChangePage,
84
+ customizeChangeRowsPerPage,
85
+ customizeColumnViewChange,
86
+ } = paginationOptions;
77
87
 
78
88
  /**
79
89
  * update selected Ids
@@ -120,7 +130,7 @@ const PaginatedTable = ({
120
130
  const handleColumnViewChange = (column) => {
121
131
  const columns = table.columns.map((col) => {
122
132
  const updateColumnView = { ...col };
123
- if (col.dataField === column.dataField) {
133
+ if (col.dataField && col.dataField === column.dataField) {
124
134
  updateColumnView.display = !column.display;
125
135
  }
126
136
  return updateColumnView;
@@ -141,12 +151,12 @@ const PaginatedTable = ({
141
151
  <ClientTableView
142
152
  tblRows={tblRows}
143
153
  table={table}
144
- onRowsPerPageChange={handleChangeRowsPerPage}
145
- onPageChange={handleChangePage}
146
- onRowSelectChange={onRowSelectHandler}
147
- onToggleSelectAll={handleToggleSelectAll}
148
- onSortByColumn={handleSortByColumn}
149
- onColumnViewChange={handleColumnViewChange}
154
+ onRowsPerPageChange={customizeChangeRowsPerPage || handleChangeRowsPerPage}
155
+ onPageChange={customizeChangePage || handleChangePage}
156
+ onRowSelectChange={customizeOnRowSelect || onRowSelectHandler}
157
+ onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
158
+ onSortByColumn={customizeSortByColumn || handleSortByColumn}
159
+ onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
150
160
  themeConfig={themeConfig}
151
161
  />
152
162
  </>
@@ -170,12 +180,13 @@ const PaginatedTable = ({
170
180
  queryVariables={queryVariables}
171
181
  totalRowCount={totalRowCount}
172
182
  table={table}
173
- onRowsPerPageChange={handleChangeRowsPerPage}
174
- onPageChange={handleChangePage}
175
- onRowSelectChange={onRowSelectHandler}
176
- onToggleSelectAll={handleToggleSelectAll}
177
- onSortByColumn={handleSortByColumn}
178
- onColumnViewChange={handleColumnViewChange}
183
+ server={server}
184
+ onRowsPerPageChange={customizeChangeRowsPerPage || handleChangeRowsPerPage}
185
+ onPageChange={customizeChangePage || handleChangePage}
186
+ onRowSelectChange={customizeOnRowSelect || onRowSelectHandler}
187
+ onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
188
+ onSortByColumn={customizeSortByColumn || handleSortByColumn}
189
+ onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
179
190
  themeConfig={themeConfig}
180
191
  />
181
192
  </>
@@ -7,6 +7,7 @@ export const actionTypes = {
7
7
  ON_ROW_SELECT: 'ON_ROW_SELECT',
8
8
  SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
9
9
  ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE',
10
+ CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION',
10
11
  };
11
12
 
12
13
  export const onColumnViewChange = (columns) => ({
@@ -48,3 +49,8 @@ export const setTotalRowCount = (count) => ({
48
49
  type: actionTypes.SET_TOTAL_ROW_COUNT,
49
50
  payload: count,
50
51
  });
52
+
53
+ export const customPaginationAction = (value) => ({
54
+ type: actionTypes.CUSTOMIZE_PAGINATION_ACTION,
55
+ payload: value,
56
+ });
@@ -3,6 +3,11 @@ import { actionTypes } from './Actions';
3
3
  const reducer = (state, action) => {
4
4
  const { type, payload } = action;
5
5
  switch (type) {
6
+ case actionTypes.CUSTOMIZE_PAGINATION_ACTION:
7
+ return {
8
+ ...state,
9
+ ...payload,
10
+ };
6
11
  case actionTypes.ON_COLUMN_SORT:
7
12
  return {
8
13
  ...state,
@@ -150,6 +150,7 @@ const CustomWrapper = (props) => {
150
150
  classes,
151
151
  activeFilters,
152
152
  tblDispatch,
153
+ totalRowCount,
153
154
  } = props;
154
155
  return (
155
156
  <>
@@ -160,6 +161,7 @@ const CustomWrapper = (props) => {
160
161
  classes={classes}
161
162
  activeFilters={activeFilters}
162
163
  tblDispatch={tblDispatch}
164
+ totalRowCount={totalRowCount}
163
165
  >
164
166
  {children}
165
167
  </CustomLayout>
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const getQueryVariables = (variables) => {
5
5
  const queryVariables = { ...variables };
6
- queryVariables.first = 100000;
6
+ queryVariables.first = 10000;
7
7
  return queryVariables;
8
8
  };
9
9
 
@@ -1,38 +1,10 @@
1
1
  import React, { useState } from 'react';
2
- import ToolTip from '@bento-core/tool-tip';
3
2
  import { Button } from '@material-ui/core';
4
3
  import clsx from 'clsx';
5
4
  import { getFilesID } from '../../WrapperService';
6
5
  import AddToCartDialogView from '../AddToCartDialog/AddToCartDialogView';
7
-
8
- export const ToolTipView = (props) => {
9
- const {
10
- section,
11
- tooltipCofig,
12
- classes,
13
- } = props;
14
- const {
15
- icon,
16
- src,
17
- alt,
18
- arrow = false,
19
- tooltipText,
20
- placement,
21
- } = tooltipCofig;
22
- return (
23
- <ToolTip
24
- placement={placement}
25
- title={tooltipText || `${tooltipCofig[section]}`}
26
- arrow={arrow}
27
- classes={{
28
- tooltip: classes.customTooltip,
29
- arrow: classes.customArrow,
30
- }}
31
- >
32
- <img src={icon || src} alt={alt} />
33
- </ToolTip>
34
- );
35
- };
6
+ import ToolTipView from '../TooltipView';
7
+ import addFilesResponseHandler from '../util';
36
8
 
37
9
  const AddAllFilesComponent = (props) => {
38
10
  const {
@@ -47,6 +19,8 @@ const AddAllFilesComponent = (props) => {
47
19
  setOpenSnackbar,
48
20
  client,
49
21
  tooltipCofig,
22
+ maxFileLimit = 1000,
23
+ DisplayCustomText,
50
24
  } = props;
51
25
  /**
52
26
  * conditionally display dialog view
@@ -67,16 +41,8 @@ const AddAllFilesComponent = (props) => {
67
41
  fileIds().then((response) => {
68
42
  const data = response[responseKeys[0]];
69
43
  if (data && data.length > 0) {
70
- const isArray = Array.isArray(data[0][responseKeys[1]]);
71
- const ids = data.reduce((acc, id) => {
72
- if (id && id[responseKeys[1]]) {
73
- // if object convert to array
74
- const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
75
- acc.push(...items);
76
- }
77
- return acc;
78
- }, []);
79
- if (ids.length > 1000) {
44
+ const ids = addFilesResponseHandler(response, responseKeys);
45
+ if (ids.length > maxFileLimit) {
80
46
  setAlterDisplay(true);
81
47
  } else {
82
48
  setOpen(true);
@@ -112,6 +78,8 @@ const AddAllFilesComponent = (props) => {
112
78
  open={openAddDialog}
113
79
  onYesClick={addFilesToCart}
114
80
  onNoClick={toggleOpen}
81
+ DisplayCustomText={DisplayCustomText}
82
+ activeFilters={activeFilters}
115
83
  />
116
84
  </>
117
85
  );
@@ -6,6 +6,7 @@ import { TableContext } from '../../../table/ContextProvider';
6
6
  import { onRowSeclect } from '../../../table/state/Actions';
7
7
  import AddSelectedFileComponent from './AddSelectedFilesView';
8
8
  import { getFilesID } from '../../WrapperService';
9
+ import addFilesResponseHandler from '../util';
9
10
 
10
11
  const AddSelectedFilesController = (props) => {
11
12
  const {
@@ -18,6 +19,9 @@ const AddSelectedFilesController = (props) => {
18
19
  setOpenSnackbar,
19
20
  setAlterDisplay,
20
21
  client,
22
+ maxFileLimit = 1000,
23
+ applyActiveFilter = false,
24
+ activeFilters = {},
21
25
  } = props;
22
26
 
23
27
  const tableContext = useContext(TableContext);
@@ -26,8 +30,16 @@ const AddSelectedFilesController = (props) => {
26
30
  selectedRows = [],
27
31
  dispatch,
28
32
  } = context;
29
- const variables = {};
30
- variables[dataKey] = selectedRows;
33
+
34
+ const activeFilterItems = applyActiveFilter ? {
35
+ ...activeFilters,
36
+ } : {};
37
+
38
+ const variables = {
39
+ first: 10000,
40
+ ...activeFilterItems,
41
+ [dataKey]: selectedRows,
42
+ };
31
43
  // add selected files id
32
44
  const addSelectedFiles = () => {
33
45
  const fileIds = getFilesID({
@@ -38,8 +50,8 @@ const AddSelectedFilesController = (props) => {
38
50
  });
39
51
 
40
52
  fileIds().then((response) => {
41
- const ids = response[responseKeys[0]] || [];
42
- if (ids.length >= 1000) {
53
+ const ids = addFilesResponseHandler(response, responseKeys);
54
+ if (ids.length >= maxFileLimit) {
43
55
  setAlterDisplay(true);
44
56
  } else {
45
57
  addFiles(ids);
@@ -30,7 +30,7 @@ export const ToolTipView = (props) => {
30
30
  arrow: classes.customArrow,
31
31
  }}
32
32
  >
33
- <img src={icon || src} alt={alt} />
33
+ <img className="add_selected_file_tooltip_icon" src={icon || src} alt={alt} />
34
34
  </ToolTip>
35
35
  );
36
36
  };
@@ -12,6 +12,8 @@ function AddToCartDialogView(props) {
12
12
  onNoClick,
13
13
  cartWillFull = false,
14
14
  alertMessage,
15
+ DisplayCustomText,
16
+ activeFilters,
15
17
  } = props;
16
18
 
17
19
  if (cartWillFull) {
@@ -24,6 +26,8 @@ function AddToCartDialogView(props) {
24
26
  );
25
27
  }
26
28
 
29
+ const CustomDialog = DisplayCustomText.component;
30
+
27
31
  return (
28
32
  <>
29
33
  <Dialog
@@ -32,21 +36,40 @@ function AddToCartDialogView(props) {
32
36
  aria-describedby="alert-dialog-description"
33
37
  >
34
38
  <DialogContent>
35
- <DialogContentText id="alert-dialog-description">
36
- Are you sure to add All Files
37
- {' '}
38
- {numberOfFilesSelected}
39
- {' '}
40
- to cart
41
- </DialogContentText>
39
+ {
40
+ DisplayCustomText ? (
41
+ <CustomDialog
42
+ onYesClick={onYesClick}
43
+ onNoClick={onNoClick}
44
+ activeFilters={activeFilters}
45
+ />
46
+ ) : (
47
+ <DialogContentText id="alert-dialog-description">
48
+ Are you sure to add All Files
49
+ {' '}
50
+ {numberOfFilesSelected}
51
+ {' '}
52
+ to cart
53
+ </DialogContentText>
54
+ )
55
+ }
42
56
  </DialogContent>
43
- <DialogActions>
44
- <Button className="yesBtn" onClick={() => onYesClick()}>
45
- Yes
46
- </Button>
47
- <Button className="noBtn" onClick={() => onNoClick()}>
48
- No
49
- </Button>
57
+ <DialogActions className="dialog_actions">
58
+ { DisplayCustomText.actions.map((a) => (
59
+ <Button
60
+ className={a.className}
61
+ onClick={() => {
62
+ if (a.type === 'Positive') {
63
+ onYesClick();
64
+ } else {
65
+ onNoClick();
66
+ }
67
+ }}
68
+ >
69
+
70
+ {a.label}
71
+ </Button>
72
+ ))}
50
73
  </DialogActions>
51
74
  </Dialog>
52
75
  </>
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { Button } from '@material-ui/core';
2
+ import { Button, Tooltip } from '@material-ui/core';
3
3
  import { useApolloClient } from '@apollo/client';
4
4
  import {
5
5
  downloadJson,
@@ -12,7 +12,15 @@ const DownloadManifestView = (props) => {
12
12
  tooltipCofig,
13
13
  clsName,
14
14
  title,
15
+ totalRowCount,
15
16
  } = props;
17
+
18
+ const {
19
+ icon,
20
+ alt,
21
+ arrow = false,
22
+ clsName: toolTipClsName,
23
+ } = tooltipCofig;
16
24
  /**
17
25
  * get cart state
18
26
  */
@@ -38,7 +46,7 @@ const DownloadManifestView = (props) => {
38
46
  ...getQueryVeriables(queryVariables),
39
47
  },
40
48
  })
41
- .then((result) => result.data.filesInList);
49
+ .then((result) => (table.objectKey ? result.data[table.objectKey] : result.data.filesInList));
42
50
  return fetchResult;
43
51
  }
44
52
 
@@ -54,10 +62,26 @@ const DownloadManifestView = (props) => {
54
62
  className={clsName}
55
63
  disableRipple
56
64
  onClick={() => DocumentDownload()}
65
+ disabled={totalRowCount === 0}
57
66
  >
58
67
  {title}
59
68
  </Button>
60
- {tooltipCofig && (<ToolTipView {...props} />)}
69
+ {(tooltipCofig && !tooltipCofig.customToolTipComponent) && (<ToolTipView {...props} />)}
70
+ {(tooltipCofig && tooltipCofig.customToolTipComponent) && (
71
+ <Tooltip
72
+ arrow={arrow}
73
+ interactive
74
+ title={(
75
+ <>
76
+ {tooltipCofig.customToolTipComponent}
77
+ </>
78
+ )}
79
+ placement="bottom"
80
+ >
81
+ {icon && (<img src={icon} alt={alt} className={toolTipClsName} />)}
82
+ </Tooltip>
83
+ )}
84
+
61
85
  </>
62
86
  );
63
87
  };
@@ -31,7 +31,7 @@ const SnackbarView = (props) => {
31
31
  <span className="snackBarText">
32
32
  {count}
33
33
  {' '}
34
- File(s) successfully added to your cart
34
+ File(s) successfully added to My Files.
35
35
  </span>
36
36
  </div>
37
37
  )}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * max two response keys
3
+ * add file query response handler
4
+ * return - list of files name/id
5
+ */
6
+ const addFilesResponseHandler = (response, responseKeys = []) => {
7
+ if (responseKeys.length === 2) {
8
+ const data = response[responseKeys[0]];
9
+ if (data && data.length > 0) {
10
+ const isArray = Array.isArray(data[0][responseKeys[1]]);
11
+ const ids = data.reduce((acc, id) => {
12
+ if (id && id[responseKeys[1]]) {
13
+ // if object convert to array
14
+ const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
15
+ acc.push(...items);
16
+ }
17
+ return acc;
18
+ }, []);
19
+ return ids;
20
+ }
21
+ return [];
22
+ }
23
+ return response[responseKeys[0]] || [];
24
+ };
25
+
26
+ export default addFilesResponseHandler;