@bento-core/paginated-table 1.0.1-icdc.20 → 1.0.1-icdc.22

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.
@@ -1,22 +1,10 @@
1
-
2
- ### 1 Use latest or 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
1
  **NOTE: Create a new dashboard page using bento-core components before removing old dashboard page**
14
2
  <br>
15
3
  <span style="color:yellow">
16
4
  Assuming New Dashboard page have Filter component and table component from bento-core
17
5
  </span>.
18
6
 
19
- ### 2 Configure Add_All_Button Or BLUE Button in Dashboard
7
+ ### 1 Configure Add_All_Button Or BLUE Button in Dashboard
20
8
 
21
9
  ```
22
10
  import React, { useCallback } from 'react';
@@ -56,7 +44,7 @@ import { ButtonView, btnTypes, TableContextProvider } from '@bento-core/paginate
56
44
  | activeFilters | TRUE | filtes the case or sample based on the active filters | graphQL query |
57
45
 
58
46
 
59
- ### 3 Configure Add_All_Button Or BLUE Button in Dashboard
47
+ ### 2 Configure Add_All_Button Or BLUE Button in Dashboard
60
48
 
61
49
  ```
62
50
  const customTheme = {
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # PAGINATED TABLE COMPONENT DESIGN
2
2
 
3
3
  ```diff
4
- - After updating to latest version remove transform: 'rotateX(180deg)) in red
4
+ - After updating to latest version remove transform: 'rotateX(180deg)
5
+ - rotateX(180deg) is copied over from Bento 3.0 table which flips the table. So to correct all the bento project is currently adding rotateX(180deg) to flip back to correct position.
5
6
  ```
6
7
  ### Bento core paginated table design:
7
8
 
@@ -244,7 +245,7 @@ Wrapper component around table compnent.
244
245
  * Configuration display component based on index
245
246
  * CAUTION: If table is in wrapper component provide position of table component
246
247
  */
247
- export const tableLayout = [{
248
+ export const wrapperConfig = [{
248
249
  container: 'buttons',
249
250
  size: 'xl',
250
251
  clsName: 'container_header',
@@ -323,7 +324,7 @@ headerConfig - upper component on the table
323
324
  | tooltipCofig | FALSE | appears on side of the refers button | dashboardTabData/ tooltipContent |
324
325
 
325
326
 
326
- ####
327
+ ####
327
328
 
328
329
  ## 5 Customize Pagination Action:
329
330
  Customize paginated action is provided to add event in addition to update of the table state. It will override default paginated action.
@@ -0,0 +1,30 @@
1
+ ### Row Grouping Configure
2
+ ```
3
+ export const config = {
4
+ title: 'program',
5
+ dataField: 'studiesByProgram',
6
+ // select column for row grouping
7
+ groupBy: 'arm',
8
+
9
+ extendedViewConfig: {
10
+ download: {
11
+ customDownload: false,
12
+ downloadFileName: 'ICDC_ARMS_AND_COHORTS_download',
13
+ downloadCsv: 'Download Table Contents As CSV',
14
+ },
15
+ manageViewColumns: {
16
+ title: 'View Columns',
17
+ },
18
+ },
19
+ columns: [
20
+ {
21
+ dataField: 'arm',
22
+ header: 'Arm',
23
+ display: true,
24
+ tooltipText: 'sort',
25
+ cellType: cellTypes.CUSTOM_ELEM,
26
+ },
27
+ // other columns
28
+ ]
29
+ }
30
+ ```
@@ -38,7 +38,8 @@ const TableController = props => {
38
38
  rowsPerPage = 10,
39
39
  sortBy,
40
40
  sortOrder,
41
- groupBy
41
+ groupBy,
42
+ searchQuery
42
43
  } = table;
43
44
 
44
45
  /**
@@ -120,13 +121,30 @@ const TableController = props => {
120
121
  return alphaNumericSort(b, a);
121
122
  };
122
123
 
124
+ // filter rows based on input serch query
125
+ const filterBySearchQuery = rows => {
126
+ if (!searchQuery) return rows;
127
+ const query = searchQuery.toLowerCase();
128
+ const viewRows = rows.filter(row => {
129
+ const rowValues = Object.keys(row).map(key => "".concat(row[key]).toLowerCase()).join(' ');
130
+ return rowValues.includes(query);
131
+ });
132
+ return viewRows;
133
+ };
134
+
123
135
  // sort based on row grouping
124
136
  // groupBy column name
125
137
  const sortedRows = groupBy ? sortWithRowGrouping(updateRows) : [...updateRows].sort((a, b) => sortRows(a, b));
138
+
139
+ // filter by search Query
140
+ const filterRows = filterBySearchQuery(sortedRows);
126
141
  const startIndex = page * rowsPerPage;
127
142
  const endIndex = startIndex + rowsPerPage;
128
- const displayRows = [...sortedRows].slice(startIndex, endIndex);
143
+ const displayRows = [...filterRows].slice(startIndex, endIndex);
129
144
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_table.TableView, _extends({}, props, {
145
+ table: _objectSpread(_objectSpread({}, table), {}, {
146
+ totalRowCount: filterRows.length
147
+ }),
130
148
  totalRows: tblRows,
131
149
  tableRows: displayRows
132
150
  })));
@@ -99,7 +99,8 @@ const PaginatedTable = _ref => {
99
99
  customizeChangeRowsPerPage,
100
100
  customizeColumnViewChange,
101
101
  customizeDeleteRow,
102
- customizeDeleteAllRows
102
+ customizeDeleteAllRows,
103
+ customizeSearchQueryChange
103
104
  } = paginationOptions;
104
105
 
105
106
  /**
@@ -192,6 +193,15 @@ const PaginatedTable = _ref => {
192
193
  }));
193
194
  };
194
195
 
196
+ /**
197
+ * Filter table rows based on Search query
198
+ */
199
+ const handleSeachQueryChange = value => {
200
+ dispatch((0, _Actions.onSearchQueryChange)({
201
+ searchQuery: value
202
+ }));
203
+ };
204
+
195
205
  /**
196
206
  * A. client table
197
207
  * table data provide by bento app (tblRows)
@@ -209,6 +219,7 @@ const PaginatedTable = _ref => {
209
219
  onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
210
220
  onDeleteRow: customizeDeleteRow || onDeleteRow,
211
221
  onDeleteAllFiles: customizeDeleteAllRows || onDeleteAllRows,
222
+ onSearchQueryChange: customizeSearchQueryChange || handleSeachQueryChange,
212
223
  themeConfig: themeConfig
213
224
  }));
214
225
  }
@@ -236,6 +247,7 @@ const PaginatedTable = _ref => {
236
247
  onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
237
248
  onDeleteRow: customizeDeleteRow || onDeleteRow,
238
249
  onDeleteAllFiles: customizeDeleteAllRows || onDeleteAllRows,
250
+ onSearchQueryChange: customizeSearchQueryChange || handleSeachQueryChange,
239
251
  themeConfig: themeConfig
240
252
  }));
241
253
  };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setTotalRowCount = exports.onRowsPerPageChange = exports.onRowSeclect = exports.onRowDelete = exports.onPageChange = exports.onPageAndTotalCountChange = exports.onColumnViewChange = exports.onColumnSort = exports.onClearCart = exports.onChangeSortDirection = exports.customPaginationAction = exports.actionTypes = void 0;
6
+ exports.setTotalRowCount = exports.onSearchQueryChange = exports.onRowsPerPageChange = exports.onRowSeclect = exports.onRowDelete = exports.onPageChange = exports.onPageAndTotalCountChange = exports.onColumnViewChange = exports.onColumnSort = exports.onClearCart = 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',
@@ -15,7 +15,8 @@ const actionTypes = {
15
15
  ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE',
16
16
  CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION',
17
17
  ON_ROWS_DELETE: 'ON_ROWS_DELETE',
18
- ON_ROW_DELETE: 'ON_ROW_DELETE'
18
+ ON_ROW_DELETE: 'ON_ROW_DELETE',
19
+ ON_SEARCH_QUERY_CHANGE: 'ON_SEARCH_QUERY_CHANGE'
19
20
  };
20
21
  exports.actionTypes = actionTypes;
21
22
  const onColumnViewChange = columns => ({
@@ -72,4 +73,9 @@ const onRowDelete = value => ({
72
73
  type: actionTypes.ON_ROW_DELETE,
73
74
  payload: value
74
75
  });
75
- exports.onRowDelete = onRowDelete;
76
+ exports.onRowDelete = onRowDelete;
77
+ const onSearchQueryChange = value => ({
78
+ type: actionTypes.ON_SEARCH_QUERY_CHANGE,
79
+ payload: value
80
+ });
81
+ exports.onSearchQueryChange = onSearchQueryChange;
@@ -57,6 +57,10 @@ const reducer = (state, action) => {
57
57
  deletedRows: payload.deleteRows,
58
58
  selectedRows: payload.selectedRows
59
59
  });
60
+ case _Actions.actionTypes.ON_SEARCH_QUERY_CHANGE:
61
+ return _objectSpread(_objectSpread({}, state), {}, {
62
+ searchQuery: payload.searchQuery
63
+ });
60
64
  default:
61
65
  return state;
62
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/paginated-table",
3
- "version": "1.0.1-icdc.20",
3
+ "version": "1.0.1-icdc.22",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -20,7 +20,7 @@
20
20
  "react-dom": "^17.0.0",
21
21
  "react-redux": "^7.2.1",
22
22
  "@bento-core/cart": "^1.0.0",
23
- "@bento-core/table": "1.0.1-icdc.0",
23
+ "@bento-core/table": "^1.0.0",
24
24
  "@bento-core/tool-tip": "^1.0.0",
25
25
  "@bento-core/util": "^1.0.0"
26
26
  },
@@ -26,6 +26,7 @@ const TableController = ((props) => {
26
26
  sortBy,
27
27
  sortOrder,
28
28
  groupBy,
29
+ searchQuery,
29
30
  } = table;
30
31
 
31
32
  /**
@@ -115,18 +116,38 @@ const TableController = ((props) => {
115
116
  return alphaNumericSort(b, a);
116
117
  };
117
118
 
119
+ // filter rows based on input serch query
120
+ const filterBySearchQuery = (rows) => {
121
+ if (!searchQuery) return rows;
122
+ const query = searchQuery.toLowerCase();
123
+ const viewRows = rows.filter((row) => {
124
+ const rowValues = Object.keys(row)
125
+ .map((key) => `${row[key]}`.toLowerCase()).join(' ');
126
+ return rowValues.includes(query);
127
+ });
128
+ return viewRows;
129
+ };
130
+
118
131
  // sort based on row grouping
119
132
  // groupBy column name
120
133
  const sortedRows = (groupBy) ? sortWithRowGrouping(updateRows)
121
134
  : [...updateRows].sort((a, b) => sortRows(a, b));
135
+
136
+ // filter by search Query
137
+ const filterRows = filterBySearchQuery(sortedRows);
138
+
122
139
  const startIndex = page * rowsPerPage;
123
140
  const endIndex = startIndex + rowsPerPage;
124
- const displayRows = [...sortedRows].slice(startIndex, endIndex);
141
+ const displayRows = [...filterRows].slice(startIndex, endIndex);
125
142
 
126
143
  return (
127
144
  <>
128
145
  <TableView
129
146
  {...props}
147
+ table={{
148
+ ...table,
149
+ totalRowCount: filterRows.length,
150
+ }}
130
151
  totalRows={tblRows}
131
152
  tableRows={displayRows}
132
153
  />
@@ -15,6 +15,7 @@ import {
15
15
  onColumnViewChange,
16
16
  onRowDelete,
17
17
  onClearCart,
18
+ onSearchQueryChange,
18
19
  } from './state/Actions';
19
20
  import { TableContext } from './ContextProvider';
20
21
  import reducer from './state/Reducer';
@@ -91,6 +92,7 @@ const PaginatedTable = ({
91
92
  customizeColumnViewChange,
92
93
  customizeDeleteRow,
93
94
  customizeDeleteAllRows,
95
+ customizeSearchQueryChange,
94
96
  } = paginationOptions;
95
97
 
96
98
  /**
@@ -181,6 +183,15 @@ const PaginatedTable = ({
181
183
  }));
182
184
  };
183
185
 
186
+ /**
187
+ * Filter table rows based on Search query
188
+ */
189
+ const handleSeachQueryChange = (value) => {
190
+ dispatch(onSearchQueryChange({
191
+ searchQuery: value,
192
+ }));
193
+ };
194
+
184
195
  /**
185
196
  * A. client table
186
197
  * table data provide by bento app (tblRows)
@@ -200,6 +211,7 @@ const PaginatedTable = ({
200
211
  onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
201
212
  onDeleteRow={customizeDeleteRow || onDeleteRow}
202
213
  onDeleteAllFiles={customizeDeleteAllRows || onDeleteAllRows}
214
+ onSearchQueryChange={customizeSearchQueryChange || handleSeachQueryChange}
203
215
  themeConfig={themeConfig}
204
216
  />
205
217
  </>
@@ -232,6 +244,7 @@ const PaginatedTable = ({
232
244
  onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
233
245
  onDeleteRow={customizeDeleteRow || onDeleteRow}
234
246
  onDeleteAllFiles={customizeDeleteAllRows || onDeleteAllRows}
247
+ onSearchQueryChange={customizeSearchQueryChange || handleSeachQueryChange}
235
248
  themeConfig={themeConfig}
236
249
  />
237
250
  </>
@@ -10,6 +10,7 @@ export const actionTypes = {
10
10
  CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION',
11
11
  ON_ROWS_DELETE: 'ON_ROWS_DELETE',
12
12
  ON_ROW_DELETE: 'ON_ROW_DELETE',
13
+ ON_SEARCH_QUERY_CHANGE: 'ON_SEARCH_QUERY_CHANGE',
13
14
  };
14
15
 
15
16
  export const onColumnViewChange = (columns) => ({
@@ -66,3 +67,8 @@ export const onRowDelete = (value) => ({
66
67
  type: actionTypes.ON_ROW_DELETE,
67
68
  payload: value,
68
69
  });
70
+
71
+ export const onSearchQueryChange = (value) => ({
72
+ type: actionTypes.ON_SEARCH_QUERY_CHANGE,
73
+ payload: value,
74
+ });
@@ -58,6 +58,11 @@ const reducer = (state, action) => {
58
58
  deletedRows: payload.deleteRows,
59
59
  selectedRows: payload.selectedRows,
60
60
  };
61
+ case actionTypes.ON_SEARCH_QUERY_CHANGE:
62
+ return {
63
+ ...state,
64
+ searchQuery: payload.searchQuery,
65
+ };
61
66
  default:
62
67
  return state;
63
68
  }