@bento-core/paginated-table 1.0.0-alpha.0 → 1.0.1-icdc.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/dist/index.js +13 -0
- package/dist/table/ClientController.js +1 -0
- package/dist/table/PaginatedTable.js +25 -14
- package/dist/table/state/Actions.js +9 -3
- package/dist/table/state/Reducer.js +2 -0
- package/dist/wrapper/WrapperService.js +1 -1
- package/dist/wrapper/components/AddAllFiles/AddAllView.js +11 -13
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +9 -5
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +1 -0
- package/dist/wrapper/components/AddToCartDialog/AddToCartDialogView.js +9 -3
- package/dist/wrapper/components/Snackbar/Snackbar.js +1 -1
- package/dist/wrapper/components/util.js +33 -0
- package/package.json +14 -8
- package/src/index.js +4 -0
- package/src/table/ClientController.js +1 -0
- package/src/table/PaginatedTable.js +24 -13
- package/src/table/state/Actions.js +6 -0
- package/src/table/state/Reducer.js +5 -0
- package/src/wrapper/WrapperService.js +1 -1
- package/src/wrapper/components/AddAllFiles/AddAllView.js +9 -10
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +8 -4
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +1 -1
- package/src/wrapper/components/AddToCartDialog/AddToCartDialogView.js +18 -8
- package/src/wrapper/components/Snackbar/Snackbar.js +1 -1
- package/src/wrapper/components/util.js +26 -0
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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,
|
|
@@ -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 =
|
|
17
|
+
queryVariables.first = 10000;
|
|
18
18
|
return queryVariables;
|
|
19
19
|
};
|
|
20
20
|
exports.getQueryVariables = getQueryVariables;
|
|
@@ -9,6 +9,8 @@ var _core = require("@material-ui/core");
|
|
|
9
9
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
10
10
|
var _WrapperService = require("../../WrapperService");
|
|
11
11
|
var _AddToCartDialogView = _interopRequireDefault(require("../AddToCartDialog/AddToCartDialogView"));
|
|
12
|
+
var _TooltipView = _interopRequireDefault(require("../TooltipView"));
|
|
13
|
+
var _util = _interopRequireDefault(require("../util"));
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
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); }
|
|
14
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; }
|
|
@@ -23,7 +25,10 @@ const AddAllFilesComponent = props => {
|
|
|
23
25
|
addFiles,
|
|
24
26
|
setAlterDisplay,
|
|
25
27
|
setOpenSnackbar,
|
|
26
|
-
client
|
|
28
|
+
client,
|
|
29
|
+
tooltipCofig,
|
|
30
|
+
maxFileLimit = 1000,
|
|
31
|
+
DisplayCustomText
|
|
27
32
|
} = props;
|
|
28
33
|
/**
|
|
29
34
|
* conditionally display dialog view
|
|
@@ -44,16 +49,8 @@ const AddAllFilesComponent = props => {
|
|
|
44
49
|
fileIds().then(response => {
|
|
45
50
|
const data = response[responseKeys[0]];
|
|
46
51
|
if (data && data.length > 0) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
if (id && id[responseKeys[1]]) {
|
|
50
|
-
// if object convert to array
|
|
51
|
-
const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
|
|
52
|
-
acc.push(...items);
|
|
53
|
-
}
|
|
54
|
-
return acc;
|
|
55
|
-
}, []);
|
|
56
|
-
if (ids.length > 1000) {
|
|
52
|
+
const ids = (0, _util.default)(response, responseKeys);
|
|
53
|
+
if (ids.length > maxFileLimit) {
|
|
57
54
|
setAlterDisplay(true);
|
|
58
55
|
} else {
|
|
59
56
|
setOpen(true);
|
|
@@ -78,10 +75,11 @@ const AddAllFilesComponent = props => {
|
|
|
78
75
|
onClick: addAllFiles,
|
|
79
76
|
className: (0, _clsx.default)(clsName, "".concat(clsName, "_").concat(section)),
|
|
80
77
|
disableRipple: true
|
|
81
|
-
}, title), /*#__PURE__*/_react.default.createElement(_AddToCartDialogView.default, {
|
|
78
|
+
}, title), tooltipCofig && /*#__PURE__*/_react.default.createElement(_TooltipView.default, props), /*#__PURE__*/_react.default.createElement(_AddToCartDialogView.default, {
|
|
82
79
|
open: openAddDialog,
|
|
83
80
|
onYesClick: addFilesToCart,
|
|
84
|
-
onNoClick: toggleOpen
|
|
81
|
+
onNoClick: toggleOpen,
|
|
82
|
+
DisplayCustomText: DisplayCustomText
|
|
85
83
|
}));
|
|
86
84
|
};
|
|
87
85
|
var _default = AddAllFilesComponent;
|
|
@@ -12,6 +12,7 @@ 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; }
|
|
@@ -26,7 +27,8 @@ const AddSelectedFilesController = props => {
|
|
|
26
27
|
addFiles,
|
|
27
28
|
setOpenSnackbar,
|
|
28
29
|
setAlterDisplay,
|
|
29
|
-
client
|
|
30
|
+
client,
|
|
31
|
+
maxFileLimit = 1000
|
|
30
32
|
} = props;
|
|
31
33
|
const tableContext = (0, _react.useContext)(_ContextProvider.TableContext);
|
|
32
34
|
const {
|
|
@@ -36,8 +38,10 @@ const AddSelectedFilesController = props => {
|
|
|
36
38
|
selectedRows = [],
|
|
37
39
|
dispatch
|
|
38
40
|
} = context;
|
|
39
|
-
const variables = {
|
|
40
|
-
|
|
41
|
+
const variables = {
|
|
42
|
+
first: 10000,
|
|
43
|
+
[dataKey]: selectedRows
|
|
44
|
+
};
|
|
41
45
|
// add selected files id
|
|
42
46
|
const addSelectedFiles = () => {
|
|
43
47
|
const fileIds = (0, _WrapperService.getFilesID)({
|
|
@@ -47,8 +51,8 @@ const AddSelectedFilesController = props => {
|
|
|
47
51
|
query: addFileQuery
|
|
48
52
|
});
|
|
49
53
|
fileIds().then(response => {
|
|
50
|
-
const ids =
|
|
51
|
-
if (ids.length >=
|
|
54
|
+
const ids = (0, _util.default)(response, responseKeys);
|
|
55
|
+
if (ids.length >= maxFileLimit) {
|
|
52
56
|
setAlterDisplay(true);
|
|
53
57
|
} else {
|
|
54
58
|
addFiles(ids);
|
|
@@ -15,7 +15,8 @@ function AddToCartDialogView(props) {
|
|
|
15
15
|
onYesClick,
|
|
16
16
|
onNoClick,
|
|
17
17
|
cartWillFull = false,
|
|
18
|
-
alertMessage
|
|
18
|
+
alertMessage,
|
|
19
|
+
DisplayCustomText
|
|
19
20
|
} = props;
|
|
20
21
|
if (cartWillFull) {
|
|
21
22
|
return /*#__PURE__*/_react.default.createElement(_AddToCartDialogAlertView.default, {
|
|
@@ -28,9 +29,14 @@ function AddToCartDialogView(props) {
|
|
|
28
29
|
open: open,
|
|
29
30
|
"aria-labelledby": "alert-dialog-title",
|
|
30
31
|
"aria-describedby": "alert-dialog-description"
|
|
31
|
-
}, /*#__PURE__*/_react.default.createElement(_core.DialogContent, null, /*#__PURE__*/_react.default.createElement(
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(_core.DialogContent, null, DisplayCustomText ? /*#__PURE__*/_react.default.createElement(DisplayCustomText, {
|
|
33
|
+
onYesClick: onYesClick,
|
|
34
|
+
onNoClick: onNoClick
|
|
35
|
+
}) : /*#__PURE__*/_react.default.createElement(_core.DialogContentText, {
|
|
32
36
|
id: "alert-dialog-description"
|
|
33
|
-
}, "Are you sure to add All Files", ' ', numberOfFilesSelected, ' ', "to cart")), /*#__PURE__*/_react.default.createElement(_core.DialogActions,
|
|
37
|
+
}, "Are you sure to add All Files", ' ', numberOfFilesSelected, ' ', "to cart")), /*#__PURE__*/_react.default.createElement(_core.DialogActions, {
|
|
38
|
+
className: "dialog_actions"
|
|
39
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
34
40
|
className: "yesBtn",
|
|
35
41
|
onClick: () => onYesClick()
|
|
36
42
|
}, "Yes"), /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
@@ -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
|
|
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,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/paginated-table",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.1-icdc.0",
|
|
5
4
|
"main": "dist/index.js",
|
|
6
5
|
"scripts": {
|
|
7
6
|
"build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
|
|
8
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
8
|
"lint": "eslint src"
|
|
10
9
|
},
|
|
11
|
-
"repository":
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/CBIIT/bento-frontend.git"
|
|
13
|
+
},
|
|
12
14
|
"publishConfig": {
|
|
13
15
|
"access": "public"
|
|
14
16
|
},
|
|
15
17
|
"dependencies": {
|
|
16
|
-
"@bento-core/cart": "^1.0.0
|
|
17
|
-
"@bento-core/table": "^1.0.0
|
|
18
|
-
"@bento-core/tool-tip": "^1.0.0
|
|
19
|
-
"@bento-core/util": "^1.0.0
|
|
18
|
+
"@bento-core/cart": "^1.0.0",
|
|
19
|
+
"@bento-core/table": "^1.0.0",
|
|
20
|
+
"@bento-core/tool-tip": "^1.0.0",
|
|
21
|
+
"@bento-core/util": "^1.0.0"
|
|
20
22
|
},
|
|
21
23
|
"peerDependencies": {
|
|
22
24
|
"@apollo/client": "^3.6.9",
|
|
@@ -28,5 +30,9 @@
|
|
|
28
30
|
},
|
|
29
31
|
"author": "CTOS Bento Team",
|
|
30
32
|
"license": "ISC",
|
|
31
|
-
"
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/CBIIT/bento-frontend/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/CBIIT/bento-frontend#readme",
|
|
37
|
+
"description": ""
|
|
32
38
|
}
|
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';
|
|
@@ -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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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,
|
|
@@ -3,6 +3,8 @@ import { Button } from '@material-ui/core';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { getFilesID } from '../../WrapperService';
|
|
5
5
|
import AddToCartDialogView from '../AddToCartDialog/AddToCartDialogView';
|
|
6
|
+
import ToolTipView from '../TooltipView';
|
|
7
|
+
import addFilesResponseHandler from '../util';
|
|
6
8
|
|
|
7
9
|
const AddAllFilesComponent = (props) => {
|
|
8
10
|
const {
|
|
@@ -16,6 +18,9 @@ const AddAllFilesComponent = (props) => {
|
|
|
16
18
|
setAlterDisplay,
|
|
17
19
|
setOpenSnackbar,
|
|
18
20
|
client,
|
|
21
|
+
tooltipCofig,
|
|
22
|
+
maxFileLimit = 1000,
|
|
23
|
+
DisplayCustomText,
|
|
19
24
|
} = props;
|
|
20
25
|
/**
|
|
21
26
|
* conditionally display dialog view
|
|
@@ -36,16 +41,8 @@ const AddAllFilesComponent = (props) => {
|
|
|
36
41
|
fileIds().then((response) => {
|
|
37
42
|
const data = response[responseKeys[0]];
|
|
38
43
|
if (data && data.length > 0) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
if (id && id[responseKeys[1]]) {
|
|
42
|
-
// if object convert to array
|
|
43
|
-
const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
|
|
44
|
-
acc.push(...items);
|
|
45
|
-
}
|
|
46
|
-
return acc;
|
|
47
|
-
}, []);
|
|
48
|
-
if (ids.length > 1000) {
|
|
44
|
+
const ids = addFilesResponseHandler(response, responseKeys);
|
|
45
|
+
if (ids.length > maxFileLimit) {
|
|
49
46
|
setAlterDisplay(true);
|
|
50
47
|
} else {
|
|
51
48
|
setOpen(true);
|
|
@@ -76,10 +73,12 @@ const AddAllFilesComponent = (props) => {
|
|
|
76
73
|
>
|
|
77
74
|
{title}
|
|
78
75
|
</Button>
|
|
76
|
+
{tooltipCofig && (<ToolTipView {...props} />)}
|
|
79
77
|
<AddToCartDialogView
|
|
80
78
|
open={openAddDialog}
|
|
81
79
|
onYesClick={addFilesToCart}
|
|
82
80
|
onNoClick={toggleOpen}
|
|
81
|
+
DisplayCustomText={DisplayCustomText}
|
|
83
82
|
/>
|
|
84
83
|
</>
|
|
85
84
|
);
|
|
@@ -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,7 @@ const AddSelectedFilesController = (props) => {
|
|
|
18
19
|
setOpenSnackbar,
|
|
19
20
|
setAlterDisplay,
|
|
20
21
|
client,
|
|
22
|
+
maxFileLimit = 1000,
|
|
21
23
|
} = props;
|
|
22
24
|
|
|
23
25
|
const tableContext = useContext(TableContext);
|
|
@@ -26,8 +28,10 @@ const AddSelectedFilesController = (props) => {
|
|
|
26
28
|
selectedRows = [],
|
|
27
29
|
dispatch,
|
|
28
30
|
} = context;
|
|
29
|
-
const variables = {
|
|
30
|
-
|
|
31
|
+
const variables = {
|
|
32
|
+
first: 10000,
|
|
33
|
+
[dataKey]: selectedRows,
|
|
34
|
+
};
|
|
31
35
|
// add selected files id
|
|
32
36
|
const addSelectedFiles = () => {
|
|
33
37
|
const fileIds = getFilesID({
|
|
@@ -38,8 +42,8 @@ const AddSelectedFilesController = (props) => {
|
|
|
38
42
|
});
|
|
39
43
|
|
|
40
44
|
fileIds().then((response) => {
|
|
41
|
-
const ids = response
|
|
42
|
-
if (ids.length >=
|
|
45
|
+
const ids = addFilesResponseHandler(response, responseKeys);
|
|
46
|
+
if (ids.length >= maxFileLimit) {
|
|
43
47
|
setAlterDisplay(true);
|
|
44
48
|
} else {
|
|
45
49
|
addFiles(ids);
|
|
@@ -12,6 +12,7 @@ function AddToCartDialogView(props) {
|
|
|
12
12
|
onNoClick,
|
|
13
13
|
cartWillFull = false,
|
|
14
14
|
alertMessage,
|
|
15
|
+
DisplayCustomText,
|
|
15
16
|
} = props;
|
|
16
17
|
|
|
17
18
|
if (cartWillFull) {
|
|
@@ -32,15 +33,24 @@ function AddToCartDialogView(props) {
|
|
|
32
33
|
aria-describedby="alert-dialog-description"
|
|
33
34
|
>
|
|
34
35
|
<DialogContent>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
{
|
|
37
|
+
DisplayCustomText ? (
|
|
38
|
+
<DisplayCustomText
|
|
39
|
+
onYesClick={onYesClick}
|
|
40
|
+
onNoClick={onNoClick}
|
|
41
|
+
/>
|
|
42
|
+
) : (
|
|
43
|
+
<DialogContentText id="alert-dialog-description">
|
|
44
|
+
Are you sure to add All Files
|
|
45
|
+
{' '}
|
|
46
|
+
{numberOfFilesSelected}
|
|
47
|
+
{' '}
|
|
48
|
+
to cart
|
|
49
|
+
</DialogContentText>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
42
52
|
</DialogContent>
|
|
43
|
-
<DialogActions>
|
|
53
|
+
<DialogActions className="dialog_actions">
|
|
44
54
|
<Button className="yesBtn" onClick={() => onYesClick()}>
|
|
45
55
|
Yes
|
|
46
56
|
</Button>
|
|
@@ -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;
|