@bento-core/paginated-table 1.0.1-icdc.7 → 1.0.1-icdc.9
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.
|
@@ -97,7 +97,9 @@ const PaginatedTable = _ref => {
|
|
|
97
97
|
customizeSortByColumn,
|
|
98
98
|
customizeChangePage,
|
|
99
99
|
customizeChangeRowsPerPage,
|
|
100
|
-
customizeColumnViewChange
|
|
100
|
+
customizeColumnViewChange,
|
|
101
|
+
customizeDeleteRow,
|
|
102
|
+
customizeDeleteAllRows
|
|
101
103
|
} = paginationOptions;
|
|
102
104
|
|
|
103
105
|
/**
|
|
@@ -157,6 +159,35 @@ const PaginatedTable = _ref => {
|
|
|
157
159
|
columns
|
|
158
160
|
})));
|
|
159
161
|
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* handle delete row from table
|
|
165
|
+
* remove selected rows
|
|
166
|
+
*/
|
|
167
|
+
const onDeleteRow = row => {
|
|
168
|
+
const delId = row[table.dataKey];
|
|
169
|
+
const selectedIds = table.selectedRows.reduce((acc, id) => {
|
|
170
|
+
if (delId !== id) {
|
|
171
|
+
acc.push(id);
|
|
172
|
+
}
|
|
173
|
+
return acc;
|
|
174
|
+
}, []);
|
|
175
|
+
dispatch((0, _Actions.onRowDelete)({
|
|
176
|
+
deletedRow: delId,
|
|
177
|
+
selectedRows: selectedIds
|
|
178
|
+
}));
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* clear selected rows when all files are removed from myCart/ My file
|
|
183
|
+
*/
|
|
184
|
+
const onDeleteAllRows = () => {
|
|
185
|
+
dispatch((0, _Actions.onClearCart)({
|
|
186
|
+
deletedRows: table.selectedRows,
|
|
187
|
+
selectedRows: []
|
|
188
|
+
}));
|
|
189
|
+
};
|
|
190
|
+
|
|
160
191
|
/**
|
|
161
192
|
* A. client table
|
|
162
193
|
* table data provide by bento app (tblRows)
|
|
@@ -172,6 +203,8 @@ const PaginatedTable = _ref => {
|
|
|
172
203
|
onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
|
|
173
204
|
onSortByColumn: customizeSortByColumn || handleSortByColumn,
|
|
174
205
|
onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
|
|
206
|
+
onDeleteRow: customizeDeleteRow || onDeleteRow,
|
|
207
|
+
onDeleteAllFiles: customizeDeleteAllRows || onDeleteAllRows,
|
|
175
208
|
themeConfig: themeConfig
|
|
176
209
|
}));
|
|
177
210
|
}
|
|
@@ -197,6 +230,8 @@ const PaginatedTable = _ref => {
|
|
|
197
230
|
onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
|
|
198
231
|
onSortByColumn: customizeSortByColumn || handleSortByColumn,
|
|
199
232
|
onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
|
|
233
|
+
onDeleteRow: customizeDeleteRow || onDeleteRow,
|
|
234
|
+
onDeleteAllFiles: customizeDeleteAllRows || onDeleteAllRows,
|
|
200
235
|
themeConfig: themeConfig
|
|
201
236
|
}));
|
|
202
237
|
};
|
|
@@ -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.customPaginationAction = exports.actionTypes = void 0;
|
|
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;
|
|
7
7
|
const actionTypes = {
|
|
8
8
|
VIEW_COLUMN_CHANGE: 'VIEW_COLUMN_CHANGE',
|
|
9
9
|
ON_COLUMN_SORT: 'ON_COLUMN_SORT',
|
|
@@ -13,7 +13,9 @@ const actionTypes = {
|
|
|
13
13
|
ON_ROW_SELECT: 'ON_ROW_SELECT',
|
|
14
14
|
SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
|
|
15
15
|
ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE',
|
|
16
|
-
CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION'
|
|
16
|
+
CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION',
|
|
17
|
+
ON_ROWS_DELETE: 'ON_ROWS_DELETE',
|
|
18
|
+
ON_ROW_DELETE: 'ON_ROW_DELETE'
|
|
17
19
|
};
|
|
18
20
|
exports.actionTypes = actionTypes;
|
|
19
21
|
const onColumnViewChange = columns => ({
|
|
@@ -60,4 +62,14 @@ const customPaginationAction = value => ({
|
|
|
60
62
|
type: actionTypes.CUSTOMIZE_PAGINATION_ACTION,
|
|
61
63
|
payload: value
|
|
62
64
|
});
|
|
63
|
-
exports.customPaginationAction = customPaginationAction;
|
|
65
|
+
exports.customPaginationAction = customPaginationAction;
|
|
66
|
+
const onClearCart = value => ({
|
|
67
|
+
type: actionTypes.ON_ROWS_DELETE,
|
|
68
|
+
payload: value
|
|
69
|
+
});
|
|
70
|
+
exports.onClearCart = onClearCart;
|
|
71
|
+
const onRowDelete = value => ({
|
|
72
|
+
type: actionTypes.ON_ROW_DELETE,
|
|
73
|
+
payload: value
|
|
74
|
+
});
|
|
75
|
+
exports.onRowDelete = onRowDelete;
|
|
@@ -47,6 +47,16 @@ const reducer = (state, action) => {
|
|
|
47
47
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
48
48
|
totalRowCount: payload
|
|
49
49
|
});
|
|
50
|
+
case _Actions.actionTypes.ON_ROW_DELETE:
|
|
51
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
52
|
+
deletedRow: payload.deletedRow,
|
|
53
|
+
selectedRows: payload.selectedRows
|
|
54
|
+
});
|
|
55
|
+
case _Actions.actionTypes.ON_ROWS_DELETE:
|
|
56
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
57
|
+
deletedRows: payload.deleteRows,
|
|
58
|
+
selectedRows: payload.selectedRows
|
|
59
|
+
});
|
|
50
60
|
default:
|
|
51
61
|
return state;
|
|
52
62
|
}
|
package/package.json
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/paginated-table",
|
|
3
|
-
"version": "1.0.1-icdc.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1-icdc.9",
|
|
4
|
+
"description": "",
|
|
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":
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/CBIIT/bento-frontend.git"
|
|
14
|
-
},
|
|
11
|
+
"repository": "https://github.com/CBIIT/bento-frontend",
|
|
15
12
|
"publishConfig": {
|
|
16
13
|
"access": "public"
|
|
17
14
|
},
|
|
18
15
|
"dependencies": {
|
|
19
16
|
"@bento-core/cart": "^1.0.0",
|
|
20
|
-
"@bento-core/table": "
|
|
17
|
+
"@bento-core/table": "1.0.1-icdc.1",
|
|
21
18
|
"@bento-core/tool-tip": "^1.0.0",
|
|
22
19
|
"@bento-core/util": "^1.0.0"
|
|
23
20
|
},
|
|
@@ -30,10 +27,5 @@
|
|
|
30
27
|
"react-redux": "^7.2.1"
|
|
31
28
|
},
|
|
32
29
|
"author": "CTOS Bento Team",
|
|
33
|
-
"license": "ISC"
|
|
34
|
-
"bugs": {
|
|
35
|
-
"url": "https://github.com/CBIIT/bento-frontend/issues"
|
|
36
|
-
},
|
|
37
|
-
"homepage": "https://github.com/CBIIT/bento-frontend#readme",
|
|
38
|
-
"devDependencies": {}
|
|
30
|
+
"license": "ISC"
|
|
39
31
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useContext,
|
|
3
|
+
useEffect,
|
|
4
|
+
useReducer,
|
|
5
|
+
} from 'react';
|
|
2
6
|
import ServerTableView from './ServerController';
|
|
3
7
|
import ClientTableView from './ClientController';
|
|
4
8
|
import {
|
|
@@ -9,6 +13,8 @@ import {
|
|
|
9
13
|
onColumnSort,
|
|
10
14
|
onPageAndTotalCountChange,
|
|
11
15
|
onColumnViewChange,
|
|
16
|
+
onRowDelete,
|
|
17
|
+
onClearCart,
|
|
12
18
|
} from './state/Actions';
|
|
13
19
|
import { TableContext } from './ContextProvider';
|
|
14
20
|
import reducer from './state/Reducer';
|
|
@@ -83,6 +89,8 @@ const PaginatedTable = ({
|
|
|
83
89
|
customizeChangePage,
|
|
84
90
|
customizeChangeRowsPerPage,
|
|
85
91
|
customizeColumnViewChange,
|
|
92
|
+
customizeDeleteRow,
|
|
93
|
+
customizeDeleteAllRows,
|
|
86
94
|
} = paginationOptions;
|
|
87
95
|
|
|
88
96
|
/**
|
|
@@ -140,6 +148,35 @@ const PaginatedTable = ({
|
|
|
140
148
|
columns,
|
|
141
149
|
}));
|
|
142
150
|
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* handle delete row from table
|
|
154
|
+
* remove selected rows
|
|
155
|
+
*/
|
|
156
|
+
const onDeleteRow = (row) => {
|
|
157
|
+
const delId = row[table.dataKey];
|
|
158
|
+
const selectedIds = table.selectedRows.reduce((acc, id) => {
|
|
159
|
+
if (delId !== id) {
|
|
160
|
+
acc.push(id);
|
|
161
|
+
}
|
|
162
|
+
return acc;
|
|
163
|
+
}, []);
|
|
164
|
+
dispatch(onRowDelete({
|
|
165
|
+
deletedRow: delId,
|
|
166
|
+
selectedRows: selectedIds,
|
|
167
|
+
}));
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* clear selected rows when all files are removed from myCart/ My file
|
|
172
|
+
*/
|
|
173
|
+
const onDeleteAllRows = () => {
|
|
174
|
+
dispatch(onClearCart({
|
|
175
|
+
deletedRows: table.selectedRows,
|
|
176
|
+
selectedRows: [],
|
|
177
|
+
}));
|
|
178
|
+
};
|
|
179
|
+
|
|
143
180
|
/**
|
|
144
181
|
* A. client table
|
|
145
182
|
* table data provide by bento app (tblRows)
|
|
@@ -157,6 +194,8 @@ const PaginatedTable = ({
|
|
|
157
194
|
onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
|
|
158
195
|
onSortByColumn={customizeSortByColumn || handleSortByColumn}
|
|
159
196
|
onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
|
|
197
|
+
onDeleteRow={customizeDeleteRow || onDeleteRow}
|
|
198
|
+
onDeleteAllFiles={customizeDeleteAllRows || onDeleteAllRows}
|
|
160
199
|
themeConfig={themeConfig}
|
|
161
200
|
/>
|
|
162
201
|
</>
|
|
@@ -187,6 +226,8 @@ const PaginatedTable = ({
|
|
|
187
226
|
onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
|
|
188
227
|
onSortByColumn={customizeSortByColumn || handleSortByColumn}
|
|
189
228
|
onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
|
|
229
|
+
onDeleteRow={customizeDeleteRow || onDeleteRow}
|
|
230
|
+
onDeleteAllFiles={customizeDeleteAllRows || onDeleteAllRows}
|
|
190
231
|
themeConfig={themeConfig}
|
|
191
232
|
/>
|
|
192
233
|
</>
|
|
@@ -8,6 +8,8 @@ export const actionTypes = {
|
|
|
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
10
|
CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION',
|
|
11
|
+
ON_ROWS_DELETE: 'ON_ROWS_DELETE',
|
|
12
|
+
ON_ROW_DELETE: 'ON_ROW_DELETE',
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export const onColumnViewChange = (columns) => ({
|
|
@@ -54,3 +56,13 @@ export const customPaginationAction = (value) => ({
|
|
|
54
56
|
type: actionTypes.CUSTOMIZE_PAGINATION_ACTION,
|
|
55
57
|
payload: value,
|
|
56
58
|
});
|
|
59
|
+
|
|
60
|
+
export const onClearCart = (value) => ({
|
|
61
|
+
type: actionTypes.ON_ROWS_DELETE,
|
|
62
|
+
payload: value,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export const onRowDelete = (value) => ({
|
|
66
|
+
type: actionTypes.ON_ROW_DELETE,
|
|
67
|
+
payload: value,
|
|
68
|
+
});
|
|
@@ -46,6 +46,18 @@ const reducer = (state, action) => {
|
|
|
46
46
|
...state,
|
|
47
47
|
totalRowCount: payload,
|
|
48
48
|
};
|
|
49
|
+
case actionTypes.ON_ROW_DELETE:
|
|
50
|
+
return {
|
|
51
|
+
...state,
|
|
52
|
+
deletedRow: payload.deletedRow,
|
|
53
|
+
selectedRows: payload.selectedRows,
|
|
54
|
+
};
|
|
55
|
+
case actionTypes.ON_ROWS_DELETE:
|
|
56
|
+
return {
|
|
57
|
+
...state,
|
|
58
|
+
deletedRows: payload.deleteRows,
|
|
59
|
+
selectedRows: payload.selectedRows,
|
|
60
|
+
};
|
|
49
61
|
default:
|
|
50
62
|
return state;
|
|
51
63
|
}
|