@bento-core/paginated-table 1.0.0 → 1.0.1-CDS.1
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/Add_ALL_Files__BLUE_ButtonREADME.md +86 -0
- package/Add_Selected_Files_Orange_button_README.md +81 -0
- package/{dist/table/README.md → README.md} +124 -3
- package/dist/index.js +13 -0
- package/dist/table/ClientController.js +1 -0
- package/dist/table/PaginatedTable.js +64 -14
- package/dist/table/TableService.js +5 -2
- package/dist/table/state/Actions.js +21 -3
- package/dist/table/state/Reducer.js +12 -0
- package/dist/wrapper/WrapperService.js +1 -1
- package/dist/wrapper/components/AddAllFiles/AddAllView.js +12 -13
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +19 -5
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +1 -0
- package/dist/wrapper/components/AddToCartDialog/AddToCartDialogView.js +11 -3
- package/dist/wrapper/components/DownloadManifestBtn.js +17 -1
- package/dist/wrapper/components/Snackbar/Snackbar.js +1 -1
- package/dist/wrapper/components/util.js +33 -0
- package/package.json +4 -4
- package/src/index.js +4 -0
- package/src/table/ClientController.js +1 -0
- package/src/table/PaginatedTable.js +70 -14
- package/src/table/TableService.js +5 -2
- package/src/table/state/Actions.js +18 -0
- package/src/table/state/Reducer.js +17 -0
- package/src/wrapper/WrapperService.js +1 -1
- package/src/wrapper/components/AddAllFiles/AddAllView.js +10 -10
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +15 -4
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +1 -1
- package/src/wrapper/components/AddToCartDialog/AddToCartDialogView.js +20 -8
- package/src/wrapper/components/DownloadManifestBtn.js +19 -1
- package/src/wrapper/components/Snackbar/Snackbar.js +1 -1
- package/src/wrapper/components/util.js +26 -0
- package/src/table/README.md +0 -253
|
@@ -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,13 @@ const AddSelectedFilesController = props => {
|
|
|
36
45
|
selectedRows = [],
|
|
37
46
|
dispatch
|
|
38
47
|
} = context;
|
|
39
|
-
const
|
|
40
|
-
variables
|
|
48
|
+
const activeFilterItems = applyActiveFilter ? activeFilters : {};
|
|
49
|
+
const variables = _objectSpread(_objectSpread({
|
|
50
|
+
first: 10000
|
|
51
|
+
}, activeFilterItems), {}, {
|
|
52
|
+
[dataKey]: selectedRows
|
|
53
|
+
});
|
|
54
|
+
|
|
41
55
|
// add selected files id
|
|
42
56
|
const addSelectedFiles = () => {
|
|
43
57
|
const fileIds = (0, _WrapperService.getFilesID)({
|
|
@@ -47,8 +61,8 @@ const AddSelectedFilesController = props => {
|
|
|
47
61
|
query: addFileQuery
|
|
48
62
|
});
|
|
49
63
|
fileIds().then(response => {
|
|
50
|
-
const ids =
|
|
51
|
-
if (ids.length >=
|
|
64
|
+
const ids = (0, _util.default)(response, responseKeys);
|
|
65
|
+
if (ids.length >= maxFileLimit) {
|
|
52
66
|
setAlterDisplay(true);
|
|
53
67
|
} else {
|
|
54
68
|
addFiles(ids);
|
|
@@ -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, {
|
|
@@ -28,9 +30,15 @@ function AddToCartDialogView(props) {
|
|
|
28
30
|
open: open,
|
|
29
31
|
"aria-labelledby": "alert-dialog-title",
|
|
30
32
|
"aria-describedby": "alert-dialog-description"
|
|
31
|
-
}, /*#__PURE__*/_react.default.createElement(_core.DialogContent, null, /*#__PURE__*/_react.default.createElement(
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement(_core.DialogContent, null, DisplayCustomText ? /*#__PURE__*/_react.default.createElement(DisplayCustomText, {
|
|
34
|
+
onYesClick: onYesClick,
|
|
35
|
+
onNoClick: onNoClick,
|
|
36
|
+
activeFilters: activeFilters
|
|
37
|
+
}) : /*#__PURE__*/_react.default.createElement(_core.DialogContentText, {
|
|
32
38
|
id: "alert-dialog-description"
|
|
33
|
-
}, "Are you sure to add All Files", ' ', numberOfFilesSelected, ' ', "to cart")), /*#__PURE__*/_react.default.createElement(_core.DialogActions,
|
|
39
|
+
}, "Are you sure to add All Files", ' ', numberOfFilesSelected, ' ', "to cart")), /*#__PURE__*/_react.default.createElement(_core.DialogActions, {
|
|
40
|
+
className: "dialog_actions"
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
34
42
|
className: "yesBtn",
|
|
35
43
|
onClick: () => onYesClick()
|
|
36
44
|
}, "Yes"), /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
@@ -39,6 +39,13 @@ const DownloadManifestView = props => {
|
|
|
39
39
|
variables.first = 10000;
|
|
40
40
|
return variables;
|
|
41
41
|
};
|
|
42
|
+
const appendStringsToRecord = (records, columnsToAppendString) => records.map(record => {
|
|
43
|
+
const updatedRecord = record;
|
|
44
|
+
columnsToAppendString.forEach(columnConfigObject => {
|
|
45
|
+
updatedRecord[columnConfigObject.dataField] = columnConfigObject.appendString + updatedRecord[columnConfigObject.dataField];
|
|
46
|
+
});
|
|
47
|
+
return updatedRecord;
|
|
48
|
+
});
|
|
42
49
|
const client = (0, _client.useApolloClient)();
|
|
43
50
|
async function fetchData(_ref) {
|
|
44
51
|
let {
|
|
@@ -48,7 +55,16 @@ 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 => result.data.filesInList).then(result => {
|
|
59
|
+
const {
|
|
60
|
+
columns
|
|
61
|
+
} = table;
|
|
62
|
+
const columnsToAppendString = columns.filter(colum => colum.appendString);
|
|
63
|
+
if (Object.keys(columnsToAppendString).length > 0) {
|
|
64
|
+
return appendStringsToRecord(result, columnsToAppendString);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
});
|
|
52
68
|
return fetchResult;
|
|
53
69
|
}
|
|
54
70
|
async function DocumentDownload() {
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/paginated-table",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-CDS.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@bento-core/cart": "^1.0.0",
|
|
17
|
-
"@bento-core/table": "^1.0.0",
|
|
16
|
+
"@bento-core/cart": "^1.0.1-CDS.0",
|
|
17
|
+
"@bento-core/table": "^1.0.1-CDS.0",
|
|
18
18
|
"@bento-core/tool-tip": "^1.0.0",
|
|
19
19
|
"@bento-core/util": "^1.0.0"
|
|
20
20
|
},
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
},
|
|
29
29
|
"author": "CTOS Bento Team",
|
|
30
30
|
"license": "ISC",
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "6bf5d5f8401ae0e964127a5d8880ef633732a0f1"
|
|
32
32
|
}
|
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';
|
|
@@ -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';
|
|
@@ -21,6 +27,7 @@ const PaginatedTable = ({
|
|
|
21
27
|
activeTab = true,
|
|
22
28
|
server = true,
|
|
23
29
|
tblRows = [],
|
|
30
|
+
paginationOptions = {},
|
|
24
31
|
}) => {
|
|
25
32
|
/**
|
|
26
33
|
* Initailize useReducer state
|
|
@@ -74,6 +81,17 @@ const PaginatedTable = ({
|
|
|
74
81
|
const handleChangePage = (event, newPage) => {
|
|
75
82
|
dispatch(onPageChange({ pageNumb: newPage }));
|
|
76
83
|
};
|
|
84
|
+
// custonize pagination behavior
|
|
85
|
+
const {
|
|
86
|
+
customizeOnRowSelect,
|
|
87
|
+
customizeToggleSelectAll,
|
|
88
|
+
customizeSortByColumn,
|
|
89
|
+
customizeChangePage,
|
|
90
|
+
customizeChangeRowsPerPage,
|
|
91
|
+
customizeColumnViewChange,
|
|
92
|
+
customizeDeleteRow,
|
|
93
|
+
customizeDeleteAllRows,
|
|
94
|
+
} = paginationOptions;
|
|
77
95
|
|
|
78
96
|
/**
|
|
79
97
|
* update selected Ids
|
|
@@ -120,7 +138,7 @@ const PaginatedTable = ({
|
|
|
120
138
|
const handleColumnViewChange = (column) => {
|
|
121
139
|
const columns = table.columns.map((col) => {
|
|
122
140
|
const updateColumnView = { ...col };
|
|
123
|
-
if (col.dataField === column.dataField) {
|
|
141
|
+
if (col.dataField && col.dataField === column.dataField) {
|
|
124
142
|
updateColumnView.display = !column.display;
|
|
125
143
|
}
|
|
126
144
|
return updateColumnView;
|
|
@@ -130,6 +148,39 @@ const PaginatedTable = ({
|
|
|
130
148
|
columns,
|
|
131
149
|
}));
|
|
132
150
|
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* handle delete row from table
|
|
154
|
+
* remove selected rows
|
|
155
|
+
*/
|
|
156
|
+
const onDeleteRow = (row) => {
|
|
157
|
+
let selectedIds = table.selectedRows;
|
|
158
|
+
// if del row is selected remove from selected rows
|
|
159
|
+
if (row.isChecked) {
|
|
160
|
+
const delId = row[table.dataKey];
|
|
161
|
+
selectedIds = table.selectedRows.reduce((acc, id) => {
|
|
162
|
+
if (delId !== id) {
|
|
163
|
+
acc.push(id);
|
|
164
|
+
}
|
|
165
|
+
return acc;
|
|
166
|
+
}, []);
|
|
167
|
+
}
|
|
168
|
+
dispatch(onRowDelete({
|
|
169
|
+
deletedRow: row,
|
|
170
|
+
selectedRows: selectedIds,
|
|
171
|
+
}));
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* clear selected rows when all files are removed from myCart/ My file
|
|
176
|
+
*/
|
|
177
|
+
const onDeleteAllRows = () => {
|
|
178
|
+
dispatch(onClearCart({
|
|
179
|
+
deletedRows: table.selectedRows,
|
|
180
|
+
selectedRows: [],
|
|
181
|
+
}));
|
|
182
|
+
};
|
|
183
|
+
|
|
133
184
|
/**
|
|
134
185
|
* A. client table
|
|
135
186
|
* table data provide by bento app (tblRows)
|
|
@@ -141,12 +192,14 @@ const PaginatedTable = ({
|
|
|
141
192
|
<ClientTableView
|
|
142
193
|
tblRows={tblRows}
|
|
143
194
|
table={table}
|
|
144
|
-
onRowsPerPageChange={handleChangeRowsPerPage}
|
|
145
|
-
onPageChange={handleChangePage}
|
|
146
|
-
onRowSelectChange={onRowSelectHandler}
|
|
147
|
-
onToggleSelectAll={handleToggleSelectAll}
|
|
148
|
-
onSortByColumn={handleSortByColumn}
|
|
149
|
-
onColumnViewChange={handleColumnViewChange}
|
|
195
|
+
onRowsPerPageChange={customizeChangeRowsPerPage || handleChangeRowsPerPage}
|
|
196
|
+
onPageChange={customizeChangePage || handleChangePage}
|
|
197
|
+
onRowSelectChange={customizeOnRowSelect || onRowSelectHandler}
|
|
198
|
+
onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
|
|
199
|
+
onSortByColumn={customizeSortByColumn || handleSortByColumn}
|
|
200
|
+
onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
|
|
201
|
+
onDeleteRow={customizeDeleteRow || onDeleteRow}
|
|
202
|
+
onDeleteAllFiles={customizeDeleteAllRows || onDeleteAllRows}
|
|
150
203
|
themeConfig={themeConfig}
|
|
151
204
|
/>
|
|
152
205
|
</>
|
|
@@ -170,12 +223,15 @@ const PaginatedTable = ({
|
|
|
170
223
|
queryVariables={queryVariables}
|
|
171
224
|
totalRowCount={totalRowCount}
|
|
172
225
|
table={table}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
226
|
+
server={server}
|
|
227
|
+
onRowsPerPageChange={customizeChangeRowsPerPage || handleChangeRowsPerPage}
|
|
228
|
+
onPageChange={customizeChangePage || handleChangePage}
|
|
229
|
+
onRowSelectChange={customizeOnRowSelect || onRowSelectHandler}
|
|
230
|
+
onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
|
|
231
|
+
onSortByColumn={customizeSortByColumn || handleSortByColumn}
|
|
232
|
+
onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
|
|
233
|
+
onDeleteRow={customizeDeleteRow || onDeleteRow}
|
|
234
|
+
onDeleteAllFiles={customizeDeleteAllRows || onDeleteAllRows}
|
|
179
235
|
themeConfig={themeConfig}
|
|
180
236
|
/>
|
|
181
237
|
</>
|
|
@@ -8,10 +8,13 @@ import { useEffect, useState } from 'react';
|
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
export const setSelectedRows = (rows = [], table) => {
|
|
11
|
-
const { selectedRows, dataKey } = table;
|
|
11
|
+
const { selectedRows, dataKey, deletedRow } = table;
|
|
12
|
+
// checked selected row if deleted
|
|
13
|
+
const checkedRows = deletedRow?.isChecked
|
|
14
|
+
? [...selectedRows, deletedRow[dataKey]] : selectedRows;
|
|
12
15
|
const updateRows = [...rows].map((row) => {
|
|
13
16
|
const isChecked = dataKey
|
|
14
|
-
? (
|
|
17
|
+
? (checkedRows.indexOf(row[dataKey]) !== -1) : false;
|
|
15
18
|
return { ...row, isChecked };
|
|
16
19
|
}, []);
|
|
17
20
|
return updateRows;
|
|
@@ -7,6 +7,9 @@ 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',
|
|
11
|
+
ON_ROWS_DELETE: 'ON_ROWS_DELETE',
|
|
12
|
+
ON_ROW_DELETE: 'ON_ROW_DELETE',
|
|
10
13
|
};
|
|
11
14
|
|
|
12
15
|
export const onColumnViewChange = (columns) => ({
|
|
@@ -48,3 +51,18 @@ export const setTotalRowCount = (count) => ({
|
|
|
48
51
|
type: actionTypes.SET_TOTAL_ROW_COUNT,
|
|
49
52
|
payload: count,
|
|
50
53
|
});
|
|
54
|
+
|
|
55
|
+
export const customPaginationAction = (value) => ({
|
|
56
|
+
type: actionTypes.CUSTOMIZE_PAGINATION_ACTION,
|
|
57
|
+
payload: value,
|
|
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
|
+
});
|
|
@@ -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,
|
|
@@ -41,6 +46,18 @@ const reducer = (state, action) => {
|
|
|
41
46
|
...state,
|
|
42
47
|
totalRowCount: payload,
|
|
43
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
|
+
};
|
|
44
61
|
default:
|
|
45
62
|
return state;
|
|
46
63
|
}
|
|
@@ -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,13 @@ 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}
|
|
82
|
+
activeFilters={activeFilters}
|
|
83
83
|
/>
|
|
84
84
|
</>
|
|
85
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,15 @@ const AddSelectedFilesController = (props) => {
|
|
|
26
30
|
selectedRows = [],
|
|
27
31
|
dispatch,
|
|
28
32
|
} = context;
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
|
|
34
|
+
const activeFilterItems = applyActiveFilter ? activeFilters : {};
|
|
35
|
+
|
|
36
|
+
const variables = {
|
|
37
|
+
first: 10000,
|
|
38
|
+
...activeFilterItems,
|
|
39
|
+
[dataKey]: selectedRows,
|
|
40
|
+
};
|
|
41
|
+
|
|
31
42
|
// add selected files id
|
|
32
43
|
const addSelectedFiles = () => {
|
|
33
44
|
const fileIds = getFilesID({
|
|
@@ -38,8 +49,8 @@ const AddSelectedFilesController = (props) => {
|
|
|
38
49
|
});
|
|
39
50
|
|
|
40
51
|
fileIds().then((response) => {
|
|
41
|
-
const ids = response
|
|
42
|
-
if (ids.length >=
|
|
52
|
+
const ids = addFilesResponseHandler(response, responseKeys);
|
|
53
|
+
if (ids.length >= maxFileLimit) {
|
|
43
54
|
setAlterDisplay(true);
|
|
44
55
|
} else {
|
|
45
56
|
addFiles(ids);
|
|
@@ -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) {
|
|
@@ -32,15 +34,25 @@ function AddToCartDialogView(props) {
|
|
|
32
34
|
aria-describedby="alert-dialog-description"
|
|
33
35
|
>
|
|
34
36
|
<DialogContent>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
{
|
|
38
|
+
DisplayCustomText ? (
|
|
39
|
+
<DisplayCustomText
|
|
40
|
+
onYesClick={onYesClick}
|
|
41
|
+
onNoClick={onNoClick}
|
|
42
|
+
activeFilters={activeFilters}
|
|
43
|
+
/>
|
|
44
|
+
) : (
|
|
45
|
+
<DialogContentText id="alert-dialog-description">
|
|
46
|
+
Are you sure to add All Files
|
|
47
|
+
{' '}
|
|
48
|
+
{numberOfFilesSelected}
|
|
49
|
+
{' '}
|
|
50
|
+
to cart
|
|
51
|
+
</DialogContentText>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
42
54
|
</DialogContent>
|
|
43
|
-
<DialogActions>
|
|
55
|
+
<DialogActions className="dialog_actions">
|
|
44
56
|
<Button className="yesBtn" onClick={() => onYesClick()}>
|
|
45
57
|
Yes
|
|
46
58
|
</Button>
|
|
@@ -29,6 +29,15 @@ const DownloadManifestView = (props) => {
|
|
|
29
29
|
return variables;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const appendStringsToRecord = (records, columnsToAppendString) => records.map((record) => {
|
|
33
|
+
const updatedRecord = record;
|
|
34
|
+
columnsToAppendString.forEach((columnConfigObject) => {
|
|
35
|
+
updatedRecord[columnConfigObject.dataField] = columnConfigObject.appendString
|
|
36
|
+
+ updatedRecord[columnConfigObject.dataField];
|
|
37
|
+
});
|
|
38
|
+
return updatedRecord;
|
|
39
|
+
});
|
|
40
|
+
|
|
32
41
|
const client = useApolloClient();
|
|
33
42
|
async function fetchData({ queryVariables, table }) {
|
|
34
43
|
const fetchResult = await client
|
|
@@ -38,7 +47,16 @@ const DownloadManifestView = (props) => {
|
|
|
38
47
|
...getQueryVeriables(queryVariables),
|
|
39
48
|
},
|
|
40
49
|
})
|
|
41
|
-
.then((result) => result.data.filesInList)
|
|
50
|
+
.then((result) => result.data.filesInList)
|
|
51
|
+
.then((result) => {
|
|
52
|
+
const { columns } = table;
|
|
53
|
+
const columnsToAppendString = columns.filter((colum) => colum.appendString);
|
|
54
|
+
if (Object.keys(columnsToAppendString).length > 0) {
|
|
55
|
+
return appendStringsToRecord(result, columnsToAppendString);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return result;
|
|
59
|
+
});
|
|
42
60
|
return fetchResult;
|
|
43
61
|
}
|
|
44
62
|
|
|
@@ -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;
|