rez-table-listing-mui 1.3.7 → 1.3.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.
- package/dist/index.d.ts +23 -9
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/App.tsx +12 -0
- package/src/listing/components/filter/components/forms/components/Filter-criteria.tsx +12 -3
- package/src/listing/components/filter/components/forms/index.tsx +16 -6
- package/src/listing/components/filter/components/main-filter.tsx +0 -3
- package/src/listing/components/filter/components/saved-edit-filter.tsx +26 -22
- package/src/listing/components/filter/components/saved-filter.tsx +13 -6
- package/src/listing/components/filter/components/single-filter-rendering.tsx +74 -0
- package/src/listing/components/filter/index.tsx +59 -32
- package/src/listing/components/index.scss +3 -3
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +1 -0
- package/src/listing/libs/hooks/useEntityTableHooks.ts +1 -1
- package/src/listing/libs/utils/apiColumn.ts +1 -1
- package/src/listing/types/filter.ts +27 -8
- package/src/testing-grounds/filter-in-modal/saved-filter-modal.tsx +181 -0
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -2,11 +2,13 @@ import { useState } from "react";
|
|
|
2
2
|
import LoginButton from "./listing/components/login";
|
|
3
3
|
import ListingView from "./view/ListingView";
|
|
4
4
|
import KanbanView from "./view/KanbanView";
|
|
5
|
+
import SavedFilterModal from "./testing-grounds/filter-in-modal/saved-filter-modal";
|
|
5
6
|
|
|
6
7
|
function App() {
|
|
7
8
|
const [currentView, setCurrentView] = useState<"listing" | "kanban">(
|
|
8
9
|
"listing"
|
|
9
10
|
);
|
|
11
|
+
const [openSavedFilterModal, setOpenSavedFilterModal] = useState(false);
|
|
10
12
|
|
|
11
13
|
const renderView = () => {
|
|
12
14
|
switch (currentView) {
|
|
@@ -57,10 +59,20 @@ function App() {
|
|
|
57
59
|
>
|
|
58
60
|
Kanban View
|
|
59
61
|
</button>
|
|
62
|
+
<button
|
|
63
|
+
style={containedBtn}
|
|
64
|
+
onClick={() => setOpenSavedFilterModal(true)}
|
|
65
|
+
>
|
|
66
|
+
Saved Filter modal
|
|
67
|
+
</button>
|
|
60
68
|
</div>
|
|
61
69
|
|
|
62
70
|
{/* Conditional Content */}
|
|
63
71
|
{renderView()}
|
|
72
|
+
<SavedFilterModal
|
|
73
|
+
open={openSavedFilterModal}
|
|
74
|
+
setOpen={setOpenSavedFilterModal}
|
|
75
|
+
/>
|
|
64
76
|
</div>
|
|
65
77
|
);
|
|
66
78
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Box, Button, styled, Paper } from "@mui/material";
|
|
2
|
-
import { useRef } from "react";
|
|
2
|
+
import { useMemo, useRef } from "react";
|
|
3
3
|
import { AddIcon } from "../../../../../../assets/svg";
|
|
4
4
|
import {
|
|
5
5
|
FilterColumnsDataProps,
|
|
6
|
+
FilterComponentOptions,
|
|
6
7
|
FilterDataMainFilterEntityWiseCriteriaProps,
|
|
7
8
|
} from "../../../../../types/filter";
|
|
8
9
|
import { CraftTableOptionsProps } from "../../../../../types/table-options";
|
|
@@ -16,15 +17,15 @@ const FilterCriteria = ({
|
|
|
16
17
|
columnsData,
|
|
17
18
|
tableStates,
|
|
18
19
|
onChangeFunction,
|
|
20
|
+
filterComponentOptions,
|
|
19
21
|
}: {
|
|
20
22
|
columnsData: FilterColumnsDataProps;
|
|
21
23
|
tableStates: CraftTableOptionsProps;
|
|
22
|
-
searchTerm: string;
|
|
23
|
-
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
24
24
|
onChangeFunction: ({
|
|
25
25
|
updatedFilters,
|
|
26
26
|
filterMaster,
|
|
27
27
|
}: onFilterChangeFunctionProps) => void;
|
|
28
|
+
filterComponentOptions?: FilterComponentOptions;
|
|
28
29
|
}) => {
|
|
29
30
|
const FilterButton = styled(Button)(({ theme }) => ({
|
|
30
31
|
borderRadius: 20,
|
|
@@ -100,12 +101,20 @@ const FilterCriteria = ({
|
|
|
100
101
|
setShowFilterOption((prev) => !prev);
|
|
101
102
|
};
|
|
102
103
|
|
|
104
|
+
// Disable button if only one filter is allowed
|
|
105
|
+
const isSingleFilter =
|
|
106
|
+
filterComponentOptions?.tabOptions?.isSingleFilter || false;
|
|
107
|
+
const disableButton = useMemo(() => {
|
|
108
|
+
return isSingleFilter && filters?.length > 0;
|
|
109
|
+
}, [filters?.length, isSingleFilter]);
|
|
110
|
+
|
|
103
111
|
return (
|
|
104
112
|
<Box>
|
|
105
113
|
<FilterButton
|
|
106
114
|
fullWidth
|
|
107
115
|
startIcon={<AddIcon />}
|
|
108
116
|
onClick={toggleFilterOptions}
|
|
117
|
+
disabled={disableButton}
|
|
109
118
|
sx={{
|
|
110
119
|
bgcolor: "#eae4fe",
|
|
111
120
|
borderRadius: "6px",
|
|
@@ -42,8 +42,6 @@ const FilterForm = ({
|
|
|
42
42
|
dropdownData,
|
|
43
43
|
searchTerm = "",
|
|
44
44
|
setSearchTerm,
|
|
45
|
-
criteriaSearchTerm = "",
|
|
46
|
-
setCriteriaSearchTerm,
|
|
47
45
|
handleRemoveFilter,
|
|
48
46
|
editMode = false,
|
|
49
47
|
tableStates,
|
|
@@ -56,8 +54,6 @@ const FilterForm = ({
|
|
|
56
54
|
dropdownData: FilterDropdownDataProps;
|
|
57
55
|
searchTerm?: string;
|
|
58
56
|
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
59
|
-
criteriaSearchTerm?: string;
|
|
60
|
-
setCriteriaSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
61
57
|
handleRemoveFilter: (filter_attribute: string) => void;
|
|
62
58
|
editMode?: boolean;
|
|
63
59
|
tableStates: CraftTableOptionsProps;
|
|
@@ -76,6 +72,8 @@ const FilterForm = ({
|
|
|
76
72
|
filterComponentOptions?.tabOptions?.mainFilter?.showSaveButton;
|
|
77
73
|
const showClearAllButton =
|
|
78
74
|
filterComponentOptions?.tabOptions?.mainFilter?.showClearAllButton;
|
|
75
|
+
const customButtons =
|
|
76
|
+
filterComponentOptions?.tabOptions?.mainFilter?.customButtons;
|
|
79
77
|
|
|
80
78
|
const filterName = filterMaster?.saved_filters?.selectedName || "";
|
|
81
79
|
|
|
@@ -283,9 +281,8 @@ const FilterForm = ({
|
|
|
283
281
|
<FilterCriteria
|
|
284
282
|
columnsData={columnsData}
|
|
285
283
|
tableStates={tableStates}
|
|
286
|
-
searchTerm={criteriaSearchTerm}
|
|
287
|
-
setSearchTerm={setCriteriaSearchTerm}
|
|
288
284
|
onChangeFunction={onChangeFunction}
|
|
285
|
+
filterComponentOptions={filterComponentOptions}
|
|
289
286
|
/>
|
|
290
287
|
|
|
291
288
|
{!editMode && (
|
|
@@ -497,6 +494,19 @@ const FilterForm = ({
|
|
|
497
494
|
Save Filter
|
|
498
495
|
</Button>
|
|
499
496
|
)}
|
|
497
|
+
|
|
498
|
+
{/* Custom buttons from props */}
|
|
499
|
+
{customButtons?.map((btn, idx) => (
|
|
500
|
+
<Button
|
|
501
|
+
key={idx}
|
|
502
|
+
fullWidth
|
|
503
|
+
variant={btn?.variant ?? "outlined"}
|
|
504
|
+
sx={btn?.sx}
|
|
505
|
+
{...btn}
|
|
506
|
+
>
|
|
507
|
+
{btn?.label}
|
|
508
|
+
</Button>
|
|
509
|
+
))}
|
|
500
510
|
</Box>
|
|
501
511
|
)}
|
|
502
512
|
</form>
|
|
@@ -16,7 +16,6 @@ const MainFilter = ({
|
|
|
16
16
|
filterComponentOptions,
|
|
17
17
|
}: FilterFormComponentProps) => {
|
|
18
18
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
|
19
|
-
const [criteriaSearchTerm, setCriteriaSearchTerm] = useState<string>("");
|
|
20
19
|
|
|
21
20
|
const { setFilters, setFilterMaster, filterMaster } = tableStates;
|
|
22
21
|
|
|
@@ -60,8 +59,6 @@ const MainFilter = ({
|
|
|
60
59
|
columnsData={columnsData}
|
|
61
60
|
searchTerm={searchTerm}
|
|
62
61
|
setSearchTerm={setSearchTerm}
|
|
63
|
-
criteriaSearchTerm={criteriaSearchTerm}
|
|
64
|
-
setCriteriaSearchTerm={setCriteriaSearchTerm}
|
|
65
62
|
handleRemoveFilter={handleRemoveFilter}
|
|
66
63
|
tableStates={tableStates}
|
|
67
64
|
setSavedFilterModalOpen={setSavedFilterModalOpen}
|
|
@@ -3,6 +3,7 @@ import FilterForm from "./forms";
|
|
|
3
3
|
import BackArrow from "@mui/icons-material/ArrowBackIosNew";
|
|
4
4
|
import {
|
|
5
5
|
FilterColumnsDataProps,
|
|
6
|
+
FilterComponentOptions,
|
|
6
7
|
FilterDropdownDataProps,
|
|
7
8
|
FilterMasterStateProps,
|
|
8
9
|
} from "../../../types/filter";
|
|
@@ -17,11 +18,10 @@ const SavedFilterEditComponent = ({
|
|
|
17
18
|
setEditMode,
|
|
18
19
|
searchTerm,
|
|
19
20
|
setSearchTerm,
|
|
20
|
-
criteriaSearchTerm,
|
|
21
|
-
setCriteriaSearchTerm,
|
|
22
21
|
setSavedFilterModalOpen,
|
|
23
22
|
setDeleteFilterModalOpen,
|
|
24
23
|
onChangeFunction,
|
|
24
|
+
filterComponentOptions,
|
|
25
25
|
}: {
|
|
26
26
|
columnsData: FilterColumnsDataProps;
|
|
27
27
|
dropdownData: FilterDropdownDataProps;
|
|
@@ -30,17 +30,19 @@ const SavedFilterEditComponent = ({
|
|
|
30
30
|
setEditMode?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
31
31
|
searchTerm?: string;
|
|
32
32
|
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
33
|
-
criteriaSearchTerm?: string;
|
|
34
|
-
setCriteriaSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
35
33
|
setSavedFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
36
34
|
setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
37
35
|
onChangeFunction: ({
|
|
38
36
|
updatedFilters,
|
|
39
37
|
filterMaster,
|
|
40
38
|
}: onFilterChangeFunctionProps) => void;
|
|
39
|
+
filterComponentOptions?: FilterComponentOptions;
|
|
41
40
|
}) => {
|
|
42
41
|
const { setFilters, setFilterMaster } = tableStates;
|
|
43
42
|
|
|
43
|
+
const showBackButton =
|
|
44
|
+
filterComponentOptions?.tabOptions?.savedFilter?.showBackButton;
|
|
45
|
+
|
|
44
46
|
const handleRemoveFilter = (filter_attribute: string) => {
|
|
45
47
|
setFilters((prev) =>
|
|
46
48
|
prev.filter((filter) => filter?.filter_attribute !== filter_attribute)
|
|
@@ -59,6 +61,7 @@ const SavedFilterEditComponent = ({
|
|
|
59
61
|
...prev?.saved_filters,
|
|
60
62
|
selectedId: "",
|
|
61
63
|
selectedName: "",
|
|
64
|
+
selectedCode: "",
|
|
62
65
|
},
|
|
63
66
|
activeFilterTabIndex: -1,
|
|
64
67
|
} as FilterMasterStateProps)
|
|
@@ -67,23 +70,25 @@ const SavedFilterEditComponent = ({
|
|
|
67
70
|
|
|
68
71
|
return (
|
|
69
72
|
<>
|
|
70
|
-
|
|
71
|
-
<Box
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
{showBackButton && (
|
|
74
|
+
<Box>
|
|
75
|
+
<Box
|
|
76
|
+
sx={{
|
|
77
|
+
display: "flex",
|
|
78
|
+
alignItems: "center",
|
|
79
|
+
gap: 1,
|
|
80
|
+
cursor: "pointer",
|
|
81
|
+
mb: 2,
|
|
82
|
+
}}
|
|
83
|
+
onClick={handleBackButtonClick}
|
|
84
|
+
>
|
|
85
|
+
<BackArrow sx={{ width: "13px", height: "13px" }} />
|
|
86
|
+
<Typography variant="body2" sx={{ color: "#8592A3" }}>
|
|
87
|
+
Back To Saved Filters
|
|
88
|
+
</Typography>
|
|
89
|
+
</Box>
|
|
85
90
|
</Box>
|
|
86
|
-
|
|
91
|
+
)}
|
|
87
92
|
|
|
88
93
|
{/* Render selectedFilters state */}
|
|
89
94
|
<FilterForm
|
|
@@ -94,11 +99,10 @@ const SavedFilterEditComponent = ({
|
|
|
94
99
|
dropdownData={dropdownData}
|
|
95
100
|
searchTerm={searchTerm}
|
|
96
101
|
setSearchTerm={setSearchTerm}
|
|
97
|
-
criteriaSearchTerm={criteriaSearchTerm}
|
|
98
|
-
setCriteriaSearchTerm={setCriteriaSearchTerm}
|
|
99
102
|
setSavedFilterModalOpen={setSavedFilterModalOpen}
|
|
100
103
|
setDeleteFilterModalOpen={setDeleteFilterModalOpen}
|
|
101
104
|
onChangeFunction={onChangeFunction}
|
|
105
|
+
filterComponentOptions={filterComponentOptions}
|
|
102
106
|
/>
|
|
103
107
|
</>
|
|
104
108
|
);
|
|
@@ -28,15 +28,18 @@ const SavedFilter = ({
|
|
|
28
28
|
setSavedFilterModalOpen,
|
|
29
29
|
tabValue,
|
|
30
30
|
onChangeFunction,
|
|
31
|
+
filterComponentOptions,
|
|
31
32
|
}: FilterFormComponentProps) => {
|
|
32
33
|
const { filters, filterMaster, setFilterMaster, setFilterToDelete } =
|
|
33
34
|
tableStates;
|
|
34
35
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
|
35
|
-
const [criteriaSearchTerm, setCriteriaSearchTerm] = useState<string>("");
|
|
36
36
|
|
|
37
37
|
// reset savedFilterEditValue when component unmounts
|
|
38
38
|
useEffect(() => {
|
|
39
39
|
return () => {
|
|
40
|
+
const editModeFromTabOptions =
|
|
41
|
+
filterComponentOptions?.tabOptions?.savedFilter?.editMode;
|
|
42
|
+
|
|
40
43
|
setFilterMaster(
|
|
41
44
|
(prev) =>
|
|
42
45
|
({
|
|
@@ -45,11 +48,14 @@ const SavedFilter = ({
|
|
|
45
48
|
...prev?.attributes,
|
|
46
49
|
selectedId: "",
|
|
47
50
|
selectedName: "",
|
|
51
|
+
selectedCode: "",
|
|
48
52
|
},
|
|
49
53
|
} as FilterMasterStateProps)
|
|
50
54
|
);
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
if (!editModeFromTabOptions) {
|
|
57
|
+
setEditMode && setEditMode(false);
|
|
58
|
+
}
|
|
53
59
|
};
|
|
54
60
|
}, []);
|
|
55
61
|
|
|
@@ -60,6 +66,7 @@ const SavedFilter = ({
|
|
|
60
66
|
...filterMaster?.attributes,
|
|
61
67
|
selectedId: filter?.value,
|
|
62
68
|
selectedName: filter?.label,
|
|
69
|
+
selectedCode: filter?.code,
|
|
63
70
|
},
|
|
64
71
|
attributes: {
|
|
65
72
|
...filterMaster?.attributes,
|
|
@@ -89,6 +96,7 @@ const SavedFilter = ({
|
|
|
89
96
|
...filterMaster?.attributes,
|
|
90
97
|
selectedId: filter?.value,
|
|
91
98
|
selectedName: filter?.label,
|
|
99
|
+
selectedCode: filter?.code,
|
|
92
100
|
},
|
|
93
101
|
attributes: {
|
|
94
102
|
...filterMaster?.attributes,
|
|
@@ -213,7 +221,7 @@ const SavedFilter = ({
|
|
|
213
221
|
{/* Render search input and list */}
|
|
214
222
|
{!editMode && renderList()}
|
|
215
223
|
|
|
216
|
-
{editMode
|
|
224
|
+
{editMode && (
|
|
217
225
|
<SavedFilterEditComponent
|
|
218
226
|
columnsData={columnsData}
|
|
219
227
|
dropdownData={dropdownData}
|
|
@@ -222,13 +230,12 @@ const SavedFilter = ({
|
|
|
222
230
|
setEditMode={setEditMode}
|
|
223
231
|
searchTerm={searchTerm}
|
|
224
232
|
setSearchTerm={setSearchTerm}
|
|
225
|
-
criteriaSearchTerm={criteriaSearchTerm}
|
|
226
|
-
setCriteriaSearchTerm={setCriteriaSearchTerm}
|
|
227
233
|
setSavedFilterModalOpen={setSavedFilterModalOpen}
|
|
228
234
|
setDeleteFilterModalOpen={setDeleteFilterModalOpen}
|
|
229
235
|
onChangeFunction={onChangeFunction}
|
|
236
|
+
filterComponentOptions={filterComponentOptions}
|
|
230
237
|
/>
|
|
231
|
-
)
|
|
238
|
+
)}
|
|
232
239
|
</Box>
|
|
233
240
|
);
|
|
234
241
|
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Box } from "@mui/material";
|
|
2
|
+
import { FilterFormComponentProps } from "../../../types/filter";
|
|
3
|
+
import MainFilter from "./main-filter";
|
|
4
|
+
import SavedFilter from "./saved-filter";
|
|
5
|
+
import AttributesFilter from "./attributes-filter";
|
|
6
|
+
|
|
7
|
+
interface Props extends FilterFormComponentProps {
|
|
8
|
+
searchTerm: string;
|
|
9
|
+
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const SingleFilterRendering = ({
|
|
13
|
+
columnsData,
|
|
14
|
+
dropdownData,
|
|
15
|
+
tableStates,
|
|
16
|
+
setSavedFilterModalOpen,
|
|
17
|
+
onChangeFunction,
|
|
18
|
+
filterComponentOptions,
|
|
19
|
+
editMode,
|
|
20
|
+
setEditMode,
|
|
21
|
+
setDeleteFilterModalOpen,
|
|
22
|
+
tabValue,
|
|
23
|
+
searchTerm,
|
|
24
|
+
setSearchTerm,
|
|
25
|
+
}: Props) => {
|
|
26
|
+
const showFilter = filterComponentOptions?.tabOptions?.showFilter;
|
|
27
|
+
|
|
28
|
+
const commonProps = {
|
|
29
|
+
columnsData,
|
|
30
|
+
dropdownData,
|
|
31
|
+
tableStates,
|
|
32
|
+
onChangeFunction,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const editProps = {
|
|
36
|
+
editMode,
|
|
37
|
+
setEditMode,
|
|
38
|
+
setDeleteFilterModalOpen,
|
|
39
|
+
tabValue,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const attributesProps = {
|
|
43
|
+
searchTerm,
|
|
44
|
+
setSearchTerm,
|
|
45
|
+
tabValue,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Box sx={{ padding: "1.5rem 0.75rem", height: "100%" }}>
|
|
50
|
+
{showFilter === "main" && (
|
|
51
|
+
<MainFilter
|
|
52
|
+
{...commonProps}
|
|
53
|
+
setSavedFilterModalOpen={setSavedFilterModalOpen}
|
|
54
|
+
filterComponentOptions={filterComponentOptions}
|
|
55
|
+
/>
|
|
56
|
+
)}
|
|
57
|
+
|
|
58
|
+
{showFilter === "saved" && (
|
|
59
|
+
<SavedFilter
|
|
60
|
+
{...commonProps}
|
|
61
|
+
{...editProps}
|
|
62
|
+
setSavedFilterModalOpen={setSavedFilterModalOpen}
|
|
63
|
+
filterComponentOptions={filterComponentOptions}
|
|
64
|
+
/>
|
|
65
|
+
)}
|
|
66
|
+
|
|
67
|
+
{showFilter === "attributes" && (
|
|
68
|
+
<AttributesFilter {...commonProps} {...attributesProps} />
|
|
69
|
+
)}
|
|
70
|
+
</Box>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default SingleFilterRendering;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { Box, IconButton, Typography } from "@mui/material";
|
|
3
3
|
import CloseIcon from "@mui/icons-material/Close";
|
|
4
4
|
import {
|
|
5
5
|
FilterComponentOptions,
|
|
6
6
|
FilterDrawerProps,
|
|
7
7
|
FilterMasterStateProps,
|
|
8
|
+
TabType,
|
|
8
9
|
} from "../../types/filter";
|
|
9
|
-
|
|
10
10
|
import ConfirmModal, { InputField } from "../common/confirm-modal";
|
|
11
11
|
import CustomTabPanel from "./components/tabs/custom-tab-panel";
|
|
12
12
|
import CustomTabs, { TabItem } from "./components/tabs/index";
|
|
@@ -15,6 +15,7 @@ import SavedFilter from "./components/saved-filter";
|
|
|
15
15
|
import AttributesFilter from "./components/attributes-filter";
|
|
16
16
|
import { filterStyles } from "./style";
|
|
17
17
|
import { deepMergeObjects } from "../../libs/utils/deep-merge-objects";
|
|
18
|
+
import SingleFilterRendering from "./components/single-filter-rendering";
|
|
18
19
|
|
|
19
20
|
export function TableFilter({
|
|
20
21
|
onClose,
|
|
@@ -50,10 +51,16 @@ export function TableFilter({
|
|
|
50
51
|
mainHeaderTitle: "Filter",
|
|
51
52
|
showTabs: true,
|
|
52
53
|
tabOptions: {
|
|
54
|
+
isSingleFilter: false,
|
|
55
|
+
showFilter: "main",
|
|
53
56
|
mainFilter: {
|
|
54
57
|
showSaveButton: true,
|
|
55
58
|
showClearAllButton: true,
|
|
56
59
|
},
|
|
60
|
+
savedFilter: {
|
|
61
|
+
showBackButton: true,
|
|
62
|
+
editMode: false,
|
|
63
|
+
},
|
|
57
64
|
},
|
|
58
65
|
showMainFilter: true,
|
|
59
66
|
showSavedFilter: true,
|
|
@@ -72,8 +79,14 @@ export function TableFilter({
|
|
|
72
79
|
const showSavedFilter = showTabs && finalComponentOptions?.showSavedFilter;
|
|
73
80
|
const showAttributesFilter =
|
|
74
81
|
showTabs && finalComponentOptions?.showAttributesFilter;
|
|
82
|
+
const editModeFromTabOptions =
|
|
83
|
+
finalComponentOptions?.tabOptions?.savedFilter?.editMode;
|
|
75
84
|
|
|
76
|
-
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (editModeFromTabOptions) {
|
|
87
|
+
setEditMode(editModeFromTabOptions);
|
|
88
|
+
}
|
|
89
|
+
}, [editModeFromTabOptions]);
|
|
77
90
|
|
|
78
91
|
// Map tabs to type
|
|
79
92
|
const tabMapping: TabType[] = [];
|
|
@@ -137,7 +150,11 @@ export function TableFilter({
|
|
|
137
150
|
const patches: Partial<FilterMasterStateProps> = {};
|
|
138
151
|
|
|
139
152
|
if (tabType === "saved") {
|
|
140
|
-
patches.saved_filters = {
|
|
153
|
+
patches.saved_filters = {
|
|
154
|
+
selectedId: "",
|
|
155
|
+
selectedName: "",
|
|
156
|
+
selectedCode: "",
|
|
157
|
+
};
|
|
141
158
|
} else if (tabType === "attributes") {
|
|
142
159
|
patches.attributes = { radio: [], selected: "" };
|
|
143
160
|
}
|
|
@@ -154,6 +171,25 @@ export function TableFilter({
|
|
|
154
171
|
onChangeFunction({ filterMaster: newFilterMasterState, filters });
|
|
155
172
|
};
|
|
156
173
|
|
|
174
|
+
const commonProps = {
|
|
175
|
+
columnsData,
|
|
176
|
+
tableStates,
|
|
177
|
+
onChangeFunction,
|
|
178
|
+
dropdownData,
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const savedFilterProps = {
|
|
182
|
+
editMode,
|
|
183
|
+
setEditMode,
|
|
184
|
+
setDeleteFilterModalOpen,
|
|
185
|
+
tabValue,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const attributesProps = {
|
|
189
|
+
searchTerm,
|
|
190
|
+
setSearchTerm,
|
|
191
|
+
};
|
|
192
|
+
|
|
157
193
|
return (
|
|
158
194
|
<Box sx={filterStyles.filterContainer}>
|
|
159
195
|
{showMainHeader && (
|
|
@@ -185,16 +221,13 @@ export function TableFilter({
|
|
|
185
221
|
)}
|
|
186
222
|
|
|
187
223
|
{!showTabs && (
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
filterComponentOptions={finalComponentOptions}
|
|
196
|
-
/>
|
|
197
|
-
</Box>
|
|
224
|
+
<SingleFilterRendering
|
|
225
|
+
{...commonProps}
|
|
226
|
+
{...savedFilterProps}
|
|
227
|
+
{...attributesProps}
|
|
228
|
+
setSavedFilterModalOpen={setSaveFilterModalOpen}
|
|
229
|
+
filterComponentOptions={finalComponentOptions}
|
|
230
|
+
/>
|
|
198
231
|
)}
|
|
199
232
|
|
|
200
233
|
{showMainFilter && (
|
|
@@ -204,11 +237,8 @@ export function TableFilter({
|
|
|
204
237
|
sx={{ p: "1.5rem 0.75rem" }}
|
|
205
238
|
>
|
|
206
239
|
<MainFilter
|
|
207
|
-
|
|
208
|
-
tableStates={tableStates}
|
|
240
|
+
{...commonProps}
|
|
209
241
|
setSavedFilterModalOpen={setSaveFilterModalOpen}
|
|
210
|
-
dropdownData={dropdownData}
|
|
211
|
-
onChangeFunction={onChangeFunction}
|
|
212
242
|
filterComponentOptions={finalComponentOptions}
|
|
213
243
|
/>
|
|
214
244
|
</CustomTabPanel>
|
|
@@ -221,15 +251,10 @@ export function TableFilter({
|
|
|
221
251
|
sx={{ p: "1.5rem 0.75rem" }}
|
|
222
252
|
>
|
|
223
253
|
<SavedFilter
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
editMode={editMode}
|
|
227
|
-
setEditMode={setEditMode}
|
|
228
|
-
setDeleteFilterModalOpen={setDeleteFilterModalOpen}
|
|
254
|
+
{...commonProps}
|
|
255
|
+
{...savedFilterProps}
|
|
229
256
|
setSavedFilterModalOpen={setSaveFilterModalOpen}
|
|
230
|
-
|
|
231
|
-
tabValue={tabValue}
|
|
232
|
-
onChangeFunction={onChangeFunction}
|
|
257
|
+
filterComponentOptions={finalComponentOptions}
|
|
233
258
|
/>
|
|
234
259
|
</CustomTabPanel>
|
|
235
260
|
)}
|
|
@@ -241,13 +266,9 @@ export function TableFilter({
|
|
|
241
266
|
sx={{ p: "1.5rem 0.75rem" }}
|
|
242
267
|
>
|
|
243
268
|
<AttributesFilter
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
dropdownData={dropdownData}
|
|
247
|
-
searchTerm={searchTerm}
|
|
248
|
-
setSearchTerm={setSearchTerm}
|
|
269
|
+
{...commonProps}
|
|
270
|
+
{...attributesProps}
|
|
249
271
|
tabValue={tabValue}
|
|
250
|
-
onChangeFunction={onChangeFunction}
|
|
251
272
|
/>
|
|
252
273
|
</CustomTabPanel>
|
|
253
274
|
)}
|
|
@@ -282,6 +303,8 @@ export function TableFilter({
|
|
|
282
303
|
const selectedId = filterMaster?.saved_filters?.selectedId;
|
|
283
304
|
const selectedName =
|
|
284
305
|
inputValue || filterMaster?.saved_filters?.selectedName;
|
|
306
|
+
const selectedCode =
|
|
307
|
+
filterMaster?.saved_filters?.selectedCode;
|
|
285
308
|
|
|
286
309
|
const newFilterMasterState = {
|
|
287
310
|
...filterMaster,
|
|
@@ -289,6 +312,7 @@ export function TableFilter({
|
|
|
289
312
|
...filterMaster?.attributes,
|
|
290
313
|
selectedId,
|
|
291
314
|
selectedName,
|
|
315
|
+
selectedCode,
|
|
292
316
|
},
|
|
293
317
|
} as FilterMasterStateProps;
|
|
294
318
|
|
|
@@ -406,6 +430,8 @@ export function TableFilter({
|
|
|
406
430
|
const selectedId = filterMaster?.saved_filters?.selectedId;
|
|
407
431
|
const selectedName =
|
|
408
432
|
inputValue || filterMaster?.saved_filters?.selectedName;
|
|
433
|
+
const selectedCode =
|
|
434
|
+
filterMaster?.saved_filters?.selectedCode;
|
|
409
435
|
|
|
410
436
|
const newFilterMasterState = {
|
|
411
437
|
...filterMaster,
|
|
@@ -413,6 +439,7 @@ export function TableFilter({
|
|
|
413
439
|
...filterMaster?.attributes,
|
|
414
440
|
selectedId,
|
|
415
441
|
selectedName,
|
|
442
|
+
selectedCode,
|
|
416
443
|
},
|
|
417
444
|
} as FilterMasterStateProps;
|
|
418
445
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
opacity: 0;
|
|
26
26
|
margin-right: calc(-1 * var(--filter-width));
|
|
27
27
|
transition: all 0.4s ease-in-out;
|
|
28
|
-
max-height: calc(100vh -
|
|
28
|
+
max-height: calc(100vh - 110px);
|
|
29
29
|
}
|
|
30
30
|
.ts__table__filter.show {
|
|
31
31
|
transition: all 0.4s ease-in-out;
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
max-width: var(--filter-width);
|
|
35
35
|
margin-left: 1.25rem;
|
|
36
36
|
margin-right: 0rem;
|
|
37
|
-
min-height: calc(100vh -
|
|
37
|
+
min-height: calc(100vh - 110px);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
|
|
60
60
|
.ts__table__wrapper {
|
|
61
61
|
overflow-x: auto;
|
|
62
|
-
max-height: calc(100vh -
|
|
62
|
+
max-height: calc(100vh - 160px);
|
|
63
63
|
|
|
64
64
|
&.is-fullscreen {
|
|
65
65
|
max-height: calc(100vh - 56px);
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
fetchDetailsByFilterId,
|
|
5
5
|
} from "../utils/apiColumn";
|
|
6
6
|
|
|
7
|
-
export const useDetailsQueryAPI = (value: string) => {
|
|
7
|
+
export const useDetailsQueryAPI = (value: string | undefined) => {
|
|
8
8
|
const detailsQuery = useQuery({
|
|
9
9
|
queryKey: ["details", value],
|
|
10
10
|
queryFn: () => fetchDetailsByFilterId(value),
|
|
@@ -47,7 +47,7 @@ export const entityTableFilterMaster = async (entity_type: string) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
export const fetchDetailsByFilterId = async (filterId: string) => {
|
|
50
|
+
export const fetchDetailsByFilterId = async (filterId: string | undefined) => {
|
|
51
51
|
const response = await api.get(`/filter/${filterId}`);
|
|
52
52
|
return response.data;
|
|
53
53
|
};
|