@bento-core/table 1.0.1-ccdihub.117 → 1.0.1-ccdihub.118
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/ExtendedView.js +128 -4
- package/dist/TableView.js +7 -3
- package/dist/toolbar/DownloadButtonView.js +30 -4
- package/package.json +1 -1
- package/src/ExtendedView.js +135 -1
- package/src/TableView.js +5 -1
- package/src/toolbar/DownloadButtonView.js +20 -4
package/dist/ExtendedView.js
CHANGED
|
@@ -4,13 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _core = require("@material-ui/core");
|
|
9
|
+
var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
|
|
9
10
|
var _CustomPagination = _interopRequireDefault(require("./pagination/CustomPagination"));
|
|
10
11
|
var _ManageColumnView = _interopRequireDefault(require("./toolbar/ManageColumnView"));
|
|
11
12
|
var _DefaultThemConfig = _interopRequireDefault(require("./DefaultThemConfig"));
|
|
12
13
|
var _DownloadButtonView = _interopRequireDefault(require("./toolbar/DownloadButtonView"));
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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); }
|
|
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; }
|
|
14
17
|
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; }
|
|
15
18
|
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; }
|
|
16
19
|
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; }
|
|
@@ -19,7 +22,46 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
19
22
|
const downloadAreaStyle = {
|
|
20
23
|
display: 'flex',
|
|
21
24
|
borderTop: '1px solid #8A7F7C',
|
|
22
|
-
paddingRight: '48px'
|
|
25
|
+
paddingRight: '48px',
|
|
26
|
+
paddingTop: '5px',
|
|
27
|
+
paddingBottom: '5px'
|
|
28
|
+
};
|
|
29
|
+
const searchBarContainerStyle = {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
marginRight: 'auto',
|
|
33
|
+
paddingLeft: '18px'
|
|
34
|
+
};
|
|
35
|
+
const getSearchBarWrapperStyle = isFocused => ({
|
|
36
|
+
display: 'flex',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
width: '337px',
|
|
39
|
+
height: '30px',
|
|
40
|
+
backgroundColor: '#EAF5F5',
|
|
41
|
+
borderRadius: '8px',
|
|
42
|
+
border: isFocused ? '2px solid #15968E' : '1px solid #CCCCCC',
|
|
43
|
+
paddingLeft: '12px',
|
|
44
|
+
paddingRight: '4px',
|
|
45
|
+
opacity: 1
|
|
46
|
+
});
|
|
47
|
+
const searchInputStyle = {
|
|
48
|
+
flex: 1,
|
|
49
|
+
fontSize: '14px',
|
|
50
|
+
'&::placeholder': {
|
|
51
|
+
color: '#757575',
|
|
52
|
+
opacity: 1
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const clearIconButtonStyle = {
|
|
56
|
+
padding: '4px',
|
|
57
|
+
cursor: 'pointer',
|
|
58
|
+
color: '#15968E'
|
|
59
|
+
};
|
|
60
|
+
const noMatchTextStyle = {
|
|
61
|
+
marginLeft: '16px',
|
|
62
|
+
fontSize: '14px',
|
|
63
|
+
color: '#000000',
|
|
64
|
+
fontWeight: 400
|
|
23
65
|
};
|
|
24
66
|
const ExtendedView = _ref => {
|
|
25
67
|
let {
|
|
@@ -29,8 +71,20 @@ const ExtendedView = _ref => {
|
|
|
29
71
|
onRowsPerPageChange,
|
|
30
72
|
onPageChange,
|
|
31
73
|
customTheme,
|
|
32
|
-
queryVariables
|
|
74
|
+
queryVariables,
|
|
75
|
+
onSearch,
|
|
76
|
+
initialSearchValue = ''
|
|
33
77
|
} = _ref;
|
|
78
|
+
const [searchValue, setSearchValue] = (0, _react.useState)(initialSearchValue);
|
|
79
|
+
const [isSearching, setIsSearching] = (0, _react.useState)(!!initialSearchValue);
|
|
80
|
+
const [hasResults, setHasResults] = (0, _react.useState)(true);
|
|
81
|
+
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
82
|
+
|
|
83
|
+
// Update searchValue when initialSearchValue changes
|
|
84
|
+
_react.default.useEffect(() => {
|
|
85
|
+
setSearchValue(initialSearchValue);
|
|
86
|
+
setIsSearching(!!initialSearchValue);
|
|
87
|
+
}, [initialSearchValue]);
|
|
34
88
|
const {
|
|
35
89
|
extendedViewConfig
|
|
36
90
|
} = table;
|
|
@@ -42,6 +96,50 @@ const ExtendedView = _ref => {
|
|
|
42
96
|
pagination = false,
|
|
43
97
|
hasExport = true
|
|
44
98
|
} = extendedViewConfig;
|
|
99
|
+
|
|
100
|
+
// Check if this is the Files tab
|
|
101
|
+
const isFilesTab = table.paginationAPIField === 'fileOverview' || table.paginationAPIField === 'getFilenames';
|
|
102
|
+
|
|
103
|
+
// Handler for search functionality
|
|
104
|
+
const handleSearch = () => {
|
|
105
|
+
if (searchValue.trim()) {
|
|
106
|
+
setIsSearching(true);
|
|
107
|
+
if (onSearch) {
|
|
108
|
+
onSearch(searchValue.trim());
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
// Clear search
|
|
112
|
+
setIsSearching(false);
|
|
113
|
+
setHasResults(true);
|
|
114
|
+
if (onSearch) {
|
|
115
|
+
onSearch('');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// Handler for Enter key press
|
|
121
|
+
const handleKeyPress = event => {
|
|
122
|
+
if (event.key === 'Enter') {
|
|
123
|
+
handleSearch();
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Handler for clearing search
|
|
128
|
+
const handleClear = () => {
|
|
129
|
+
setSearchValue('');
|
|
130
|
+
setIsSearching(false);
|
|
131
|
+
setHasResults(true);
|
|
132
|
+
if (onSearch) {
|
|
133
|
+
onSearch('');
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Update hasResults based on table totalRowCount
|
|
138
|
+
_react.default.useEffect(() => {
|
|
139
|
+
if (isSearching && table.totalRowCount !== undefined) {
|
|
140
|
+
setHasResults(table.totalRowCount > 0);
|
|
141
|
+
}
|
|
142
|
+
}, [table.totalRowCount, isSearching]);
|
|
45
143
|
const themeConfig = (0, _core.createTheme)({
|
|
46
144
|
overrides: _objectSpread(_objectSpread({}, (0, _DefaultThemConfig.default)()), customTheme)
|
|
47
145
|
});
|
|
@@ -50,7 +148,33 @@ const ExtendedView = _ref => {
|
|
|
50
148
|
}, pagination && /*#__PURE__*/_react.default.createElement("div", {
|
|
51
149
|
className: "downloadArea",
|
|
52
150
|
style: downloadAreaStyle
|
|
53
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
151
|
+
}, isFilesTab && /*#__PURE__*/_react.default.createElement("div", {
|
|
152
|
+
style: searchBarContainerStyle
|
|
153
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
154
|
+
style: getSearchBarWrapperStyle(isFocused)
|
|
155
|
+
}, /*#__PURE__*/_react.default.createElement(_core.InputBase, {
|
|
156
|
+
placeholder: "Search Files",
|
|
157
|
+
value: searchValue,
|
|
158
|
+
onChange: e => setSearchValue(e.target.value),
|
|
159
|
+
onKeyPress: handleKeyPress,
|
|
160
|
+
onFocus: () => setIsFocused(true),
|
|
161
|
+
onBlur: () => setIsFocused(false),
|
|
162
|
+
style: searchInputStyle,
|
|
163
|
+
inputProps: {
|
|
164
|
+
'aria-label': 'search files'
|
|
165
|
+
}
|
|
166
|
+
}), searchValue && /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
167
|
+
onClick: handleClear,
|
|
168
|
+
style: clearIconButtonStyle,
|
|
169
|
+
size: "small",
|
|
170
|
+
"aria-label": "clear search"
|
|
171
|
+
}, /*#__PURE__*/_react.default.createElement(_Close.default, {
|
|
172
|
+
style: {
|
|
173
|
+
fontSize: '18px'
|
|
174
|
+
}
|
|
175
|
+
}))), isSearching && !hasResults && /*#__PURE__*/_react.default.createElement("span", {
|
|
176
|
+
style: noMatchTextStyle
|
|
177
|
+
}, "No Matching Records Found")), /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
|
|
54
178
|
customTheme: customTheme.tblTopPgn,
|
|
55
179
|
rowsPerPageOptions: table.rowsPerPageOptions || [10, 25, 50, 100],
|
|
56
180
|
component: "div",
|
package/dist/TableView.js
CHANGED
|
@@ -41,7 +41,7 @@ const downloadAreaStyle = {
|
|
|
41
41
|
display: 'flex',
|
|
42
42
|
borderTop: '1px solid #8A7F7C',
|
|
43
43
|
borderBottom: '1px solid #8A7F7C',
|
|
44
|
-
paddingRight: '
|
|
44
|
+
paddingRight: '48px'
|
|
45
45
|
};
|
|
46
46
|
const cartDownloadAreaStyle = {
|
|
47
47
|
display: 'flex',
|
|
@@ -84,7 +84,9 @@ const TableView = _ref => {
|
|
|
84
84
|
onAllColumnViewChange,
|
|
85
85
|
themeConfig = {},
|
|
86
86
|
queryVariables,
|
|
87
|
-
navigation
|
|
87
|
+
navigation,
|
|
88
|
+
onSearch,
|
|
89
|
+
searchValue
|
|
88
90
|
} = _ref;
|
|
89
91
|
(0, _react.useEffect)(() => {
|
|
90
92
|
const tableContainer = document.getElementById('tableContainer');
|
|
@@ -118,7 +120,9 @@ const TableView = _ref => {
|
|
|
118
120
|
onPageChange: onPageChange,
|
|
119
121
|
numSelected: (table === null || table === void 0 ? void 0 : (_table$selectedRows = table.selectedRows) === null || _table$selectedRows === void 0 ? void 0 : _table$selectedRows.length) || 0,
|
|
120
122
|
customTheme: themeConfig.extendedView,
|
|
121
|
-
queryVariables: queryVariables
|
|
123
|
+
queryVariables: queryVariables,
|
|
124
|
+
onSearch: onSearch,
|
|
125
|
+
initialSearchValue: searchValue
|
|
122
126
|
}), /*#__PURE__*/_react.default.createElement(_CustomToolbar.default, {
|
|
123
127
|
numSelected: (table === null || table === void 0 ? void 0 : (_table$selectedRows2 = table.selectedRows) === null || _table$selectedRows2 === void 0 ? void 0 : _table$selectedRows2.length) || 0,
|
|
124
128
|
table: table,
|
|
@@ -10,6 +10,8 @@ var _core = require("@material-ui/core");
|
|
|
10
10
|
var _KeyboardArrowDownOutlined = _interopRequireDefault(require("@material-ui/icons/KeyboardArrowDownOutlined"));
|
|
11
11
|
var _icons = require("@material-ui/icons");
|
|
12
12
|
var _downloadTable = require("../util/downloadTable");
|
|
13
|
+
const _excluded = ["filename"],
|
|
14
|
+
_excluded2 = ["filename"];
|
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
16
|
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
17
|
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,6 +20,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
18
20
|
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; }
|
|
19
21
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
20
22
|
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); }
|
|
23
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
24
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
25
|
// const downloadButtonStyle = {
|
|
22
26
|
// color: '#d1d2d3',
|
|
23
27
|
// marginTop: '7px',
|
|
@@ -58,9 +62,15 @@ const DownloadButton = _ref => {
|
|
|
58
62
|
query,
|
|
59
63
|
paginationAPIField
|
|
60
64
|
} = table;
|
|
65
|
+
|
|
66
|
+
// Remove filename parameter for download to only use facet filters
|
|
67
|
+
const {
|
|
68
|
+
filename
|
|
69
|
+
} = queryVariables,
|
|
70
|
+
filteredVariables = _objectWithoutProperties(queryVariables, _excluded);
|
|
61
71
|
const result = await client.query({
|
|
62
72
|
query,
|
|
63
|
-
variables: _objectSpread(_objectSpread({},
|
|
73
|
+
variables: _objectSpread(_objectSpread({}, filteredVariables), {}, {
|
|
64
74
|
page: 0,
|
|
65
75
|
first: 200000,
|
|
66
76
|
order_by: table.sortBy,
|
|
@@ -68,7 +78,12 @@ const DownloadButton = _ref => {
|
|
|
68
78
|
})
|
|
69
79
|
}).then(response => {
|
|
70
80
|
if (paginationAPIField && response && response.data) {
|
|
71
|
-
|
|
81
|
+
const apiResult = response.data[paginationAPIField];
|
|
82
|
+
// Handle getFilenames response structure which has files array nested
|
|
83
|
+
if (paginationAPIField === 'getFilenames' && apiResult && apiResult.files) {
|
|
84
|
+
return apiResult.files;
|
|
85
|
+
}
|
|
86
|
+
return apiResult;
|
|
72
87
|
}
|
|
73
88
|
return response.data;
|
|
74
89
|
});
|
|
@@ -79,9 +94,15 @@ const DownloadButton = _ref => {
|
|
|
79
94
|
query,
|
|
80
95
|
paginationAPIField
|
|
81
96
|
} = table;
|
|
97
|
+
|
|
98
|
+
// Remove filename parameter for download to only use facet filters
|
|
99
|
+
const {
|
|
100
|
+
filename
|
|
101
|
+
} = queryVariables,
|
|
102
|
+
filteredVariables = _objectWithoutProperties(queryVariables, _excluded2);
|
|
82
103
|
const result = await client.query({
|
|
83
104
|
query,
|
|
84
|
-
variables: _objectSpread(_objectSpread({},
|
|
105
|
+
variables: _objectSpread(_objectSpread({}, filteredVariables), {}, {
|
|
85
106
|
page: 0,
|
|
86
107
|
first: 200000,
|
|
87
108
|
order_by: table.sortBy,
|
|
@@ -89,7 +110,12 @@ const DownloadButton = _ref => {
|
|
|
89
110
|
})
|
|
90
111
|
}).then(response => {
|
|
91
112
|
if (paginationAPIField && response && response.data) {
|
|
92
|
-
|
|
113
|
+
const apiResult = response.data[paginationAPIField];
|
|
114
|
+
// Handle getFilenames response structure which has files array nested
|
|
115
|
+
if (paginationAPIField === 'getFilenames' && apiResult && apiResult.files) {
|
|
116
|
+
return apiResult.files;
|
|
117
|
+
}
|
|
118
|
+
return apiResult;
|
|
93
119
|
}
|
|
94
120
|
return response.data;
|
|
95
121
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/table",
|
|
3
|
-
"version": "1.0.1-ccdihub.
|
|
3
|
+
"version": "1.0.1-ccdihub.118",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
|
package/src/ExtendedView.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ThemeProvider,
|
|
4
4
|
createTheme,
|
|
5
|
+
InputBase,
|
|
6
|
+
IconButton,
|
|
5
7
|
} from '@material-ui/core';
|
|
8
|
+
import CloseIcon from '@material-ui/icons/Close';
|
|
6
9
|
import CustomPagination from './pagination/CustomPagination';
|
|
7
10
|
import ManageColumnView from './toolbar/ManageColumnView';
|
|
8
11
|
import defaultTheme from './DefaultThemConfig';
|
|
@@ -12,6 +15,50 @@ const downloadAreaStyle = {
|
|
|
12
15
|
display: 'flex',
|
|
13
16
|
borderTop: '1px solid #8A7F7C',
|
|
14
17
|
paddingRight: '48px',
|
|
18
|
+
paddingTop: '5px',
|
|
19
|
+
paddingBottom: '5px',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const searchBarContainerStyle = {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
marginRight: 'auto',
|
|
26
|
+
paddingLeft: '18px',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getSearchBarWrapperStyle = (isFocused) => ({
|
|
30
|
+
display: 'flex',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
width: '337px',
|
|
33
|
+
height: '30px',
|
|
34
|
+
backgroundColor: '#EAF5F5',
|
|
35
|
+
borderRadius: '8px',
|
|
36
|
+
border: isFocused ? '2px solid #15968E' : '1px solid #CCCCCC',
|
|
37
|
+
paddingLeft: '12px',
|
|
38
|
+
paddingRight: '4px',
|
|
39
|
+
opacity: 1,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const searchInputStyle = {
|
|
43
|
+
flex: 1,
|
|
44
|
+
fontSize: '14px',
|
|
45
|
+
'&::placeholder': {
|
|
46
|
+
color: '#757575',
|
|
47
|
+
opacity: 1,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const clearIconButtonStyle = {
|
|
52
|
+
padding: '4px',
|
|
53
|
+
cursor: 'pointer',
|
|
54
|
+
color: '#15968E',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const noMatchTextStyle = {
|
|
58
|
+
marginLeft: '16px',
|
|
59
|
+
fontSize: '14px',
|
|
60
|
+
color: '#000000',
|
|
61
|
+
fontWeight: 400,
|
|
15
62
|
};
|
|
16
63
|
|
|
17
64
|
const ExtendedView = ({
|
|
@@ -22,7 +69,20 @@ const ExtendedView = ({
|
|
|
22
69
|
onPageChange,
|
|
23
70
|
customTheme,
|
|
24
71
|
queryVariables,
|
|
72
|
+
onSearch,
|
|
73
|
+
initialSearchValue = '',
|
|
25
74
|
}) => {
|
|
75
|
+
const [searchValue, setSearchValue] = useState(initialSearchValue);
|
|
76
|
+
const [isSearching, setIsSearching] = useState(!!initialSearchValue);
|
|
77
|
+
const [hasResults, setHasResults] = useState(true);
|
|
78
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
79
|
+
|
|
80
|
+
// Update searchValue when initialSearchValue changes
|
|
81
|
+
React.useEffect(() => {
|
|
82
|
+
setSearchValue(initialSearchValue);
|
|
83
|
+
setIsSearching(!!initialSearchValue);
|
|
84
|
+
}, [initialSearchValue]);
|
|
85
|
+
|
|
26
86
|
const { extendedViewConfig } = table;
|
|
27
87
|
if (!extendedViewConfig) {
|
|
28
88
|
return null;
|
|
@@ -33,6 +93,50 @@ const ExtendedView = ({
|
|
|
33
93
|
hasExport = true,
|
|
34
94
|
} = extendedViewConfig;
|
|
35
95
|
|
|
96
|
+
// Check if this is the Files tab
|
|
97
|
+
const isFilesTab = table.paginationAPIField === 'fileOverview' || table.paginationAPIField === 'getFilenames';
|
|
98
|
+
|
|
99
|
+
// Handler for search functionality
|
|
100
|
+
const handleSearch = () => {
|
|
101
|
+
if (searchValue.trim()) {
|
|
102
|
+
setIsSearching(true);
|
|
103
|
+
if (onSearch) {
|
|
104
|
+
onSearch(searchValue.trim());
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
// Clear search
|
|
108
|
+
setIsSearching(false);
|
|
109
|
+
setHasResults(true);
|
|
110
|
+
if (onSearch) {
|
|
111
|
+
onSearch('');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// Handler for Enter key press
|
|
117
|
+
const handleKeyPress = (event) => {
|
|
118
|
+
if (event.key === 'Enter') {
|
|
119
|
+
handleSearch();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// Handler for clearing search
|
|
124
|
+
const handleClear = () => {
|
|
125
|
+
setSearchValue('');
|
|
126
|
+
setIsSearching(false);
|
|
127
|
+
setHasResults(true);
|
|
128
|
+
if (onSearch) {
|
|
129
|
+
onSearch('');
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Update hasResults based on table totalRowCount
|
|
134
|
+
React.useEffect(() => {
|
|
135
|
+
if (isSearching && table.totalRowCount !== undefined) {
|
|
136
|
+
setHasResults(table.totalRowCount > 0);
|
|
137
|
+
}
|
|
138
|
+
}, [table.totalRowCount, isSearching]);
|
|
139
|
+
|
|
36
140
|
const themeConfig = createTheme({ overrides: { ...defaultTheme(), ...customTheme } });
|
|
37
141
|
return (
|
|
38
142
|
<ThemeProvider theme={themeConfig}>
|
|
@@ -46,6 +150,36 @@ const ExtendedView = ({
|
|
|
46
150
|
{
|
|
47
151
|
(pagination) && (
|
|
48
152
|
<div className="downloadArea" style={downloadAreaStyle}>
|
|
153
|
+
{/* Search bar - only show for Files tab */}
|
|
154
|
+
{isFilesTab && (
|
|
155
|
+
<div style={searchBarContainerStyle}>
|
|
156
|
+
<div style={getSearchBarWrapperStyle(isFocused)}>
|
|
157
|
+
<InputBase
|
|
158
|
+
placeholder="Search Files"
|
|
159
|
+
value={searchValue}
|
|
160
|
+
onChange={(e) => setSearchValue(e.target.value)}
|
|
161
|
+
onKeyPress={handleKeyPress}
|
|
162
|
+
onFocus={() => setIsFocused(true)}
|
|
163
|
+
onBlur={() => setIsFocused(false)}
|
|
164
|
+
style={searchInputStyle}
|
|
165
|
+
inputProps={{ 'aria-label': 'search files' }}
|
|
166
|
+
/>
|
|
167
|
+
{searchValue && (
|
|
168
|
+
<IconButton
|
|
169
|
+
onClick={handleClear}
|
|
170
|
+
style={clearIconButtonStyle}
|
|
171
|
+
size="small"
|
|
172
|
+
aria-label="clear search"
|
|
173
|
+
>
|
|
174
|
+
<CloseIcon style={{ fontSize: '18px' }} />
|
|
175
|
+
</IconButton>
|
|
176
|
+
)}
|
|
177
|
+
</div>
|
|
178
|
+
{isSearching && !hasResults && (
|
|
179
|
+
<span style={noMatchTextStyle}>No Matching Records Found</span>
|
|
180
|
+
)}
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
49
183
|
<CustomPagination
|
|
50
184
|
customTheme={customTheme.tblTopPgn}
|
|
51
185
|
rowsPerPageOptions={table.rowsPerPageOptions || [10, 25, 50, 100]}
|
package/src/TableView.js
CHANGED
|
@@ -31,7 +31,7 @@ const downloadAreaStyle = {
|
|
|
31
31
|
display: 'flex',
|
|
32
32
|
borderTop: '1px solid #8A7F7C',
|
|
33
33
|
borderBottom: '1px solid #8A7F7C',
|
|
34
|
-
paddingRight: '
|
|
34
|
+
paddingRight: '48px',
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
const cartDownloadAreaStyle = {
|
|
@@ -78,6 +78,8 @@ const TableView = ({
|
|
|
78
78
|
themeConfig = {},
|
|
79
79
|
queryVariables,
|
|
80
80
|
navigation,
|
|
81
|
+
onSearch,
|
|
82
|
+
searchValue,
|
|
81
83
|
}) => {
|
|
82
84
|
useEffect(() => {
|
|
83
85
|
const tableContainer = document.getElementById('tableContainer');
|
|
@@ -112,6 +114,8 @@ const TableView = ({
|
|
|
112
114
|
numSelected={table?.selectedRows?.length || 0}
|
|
113
115
|
customTheme={themeConfig.extendedView}
|
|
114
116
|
queryVariables={queryVariables}
|
|
117
|
+
onSearch={onSearch}
|
|
118
|
+
initialSearchValue={searchValue}
|
|
115
119
|
/>
|
|
116
120
|
<CustomToolbar
|
|
117
121
|
numSelected={table?.selectedRows?.length || 0}
|
|
@@ -56,10 +56,13 @@ const DownloadButton = ({
|
|
|
56
56
|
paginationAPIField,
|
|
57
57
|
} = table;
|
|
58
58
|
|
|
59
|
+
// Remove filename parameter for download to only use facet filters
|
|
60
|
+
const { filename, ...filteredVariables } = queryVariables;
|
|
61
|
+
|
|
59
62
|
const result = await client.query({
|
|
60
63
|
query,
|
|
61
64
|
variables: {
|
|
62
|
-
...
|
|
65
|
+
...filteredVariables,
|
|
63
66
|
page: 0,
|
|
64
67
|
first: 200000,
|
|
65
68
|
order_by: table.sortBy,
|
|
@@ -68,7 +71,12 @@ const DownloadButton = ({
|
|
|
68
71
|
})
|
|
69
72
|
.then((response) => {
|
|
70
73
|
if (paginationAPIField && response && response.data) {
|
|
71
|
-
|
|
74
|
+
const apiResult = response.data[paginationAPIField];
|
|
75
|
+
// Handle getFilenames response structure which has files array nested
|
|
76
|
+
if (paginationAPIField === 'getFilenames' && apiResult && apiResult.files) {
|
|
77
|
+
return apiResult.files;
|
|
78
|
+
}
|
|
79
|
+
return apiResult;
|
|
72
80
|
}
|
|
73
81
|
return response.data;
|
|
74
82
|
});
|
|
@@ -81,10 +89,13 @@ const DownloadButton = ({
|
|
|
81
89
|
paginationAPIField,
|
|
82
90
|
} = table;
|
|
83
91
|
|
|
92
|
+
// Remove filename parameter for download to only use facet filters
|
|
93
|
+
const { filename, ...filteredVariables } = queryVariables;
|
|
94
|
+
|
|
84
95
|
const result = await client.query({
|
|
85
96
|
query,
|
|
86
97
|
variables: {
|
|
87
|
-
...
|
|
98
|
+
...filteredVariables,
|
|
88
99
|
page: 0,
|
|
89
100
|
first: 200000,
|
|
90
101
|
order_by: table.sortBy,
|
|
@@ -93,7 +104,12 @@ const DownloadButton = ({
|
|
|
93
104
|
})
|
|
94
105
|
.then((response) => {
|
|
95
106
|
if (paginationAPIField && response && response.data) {
|
|
96
|
-
|
|
107
|
+
const apiResult = response.data[paginationAPIField];
|
|
108
|
+
// Handle getFilenames response structure which has files array nested
|
|
109
|
+
if (paginationAPIField === 'getFilenames' && apiResult && apiResult.files) {
|
|
110
|
+
return apiResult.files;
|
|
111
|
+
}
|
|
112
|
+
return apiResult;
|
|
97
113
|
}
|
|
98
114
|
return response.data;
|
|
99
115
|
});
|