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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ButtonProps } from "@mui/material";
|
|
1
2
|
import { onFilterChangeFunctionProps } from "./common";
|
|
2
3
|
import { CraftTableOptionsProps } from "./table-options";
|
|
3
4
|
|
|
@@ -11,6 +12,7 @@ type OperationMapProps = {
|
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
export interface FilterOperationListProps {
|
|
15
|
+
code: string;
|
|
14
16
|
label: string;
|
|
15
17
|
value: string;
|
|
16
18
|
}
|
|
@@ -65,6 +67,17 @@ export interface FilterDropdownDataProps {
|
|
|
65
67
|
export interface FilterComponentOptionsMainFilterOptions {
|
|
66
68
|
showSaveButton?: boolean;
|
|
67
69
|
showClearAllButton?: boolean;
|
|
70
|
+
customButtons?: Array<
|
|
71
|
+
{
|
|
72
|
+
label: string;
|
|
73
|
+
onClick: () => void;
|
|
74
|
+
} & Partial<ButtonProps>
|
|
75
|
+
>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface FilterComponentOptionsSavedFilterOptions {
|
|
79
|
+
showBackButton?: boolean;
|
|
80
|
+
editMode?: boolean;
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
// Button config type
|
|
@@ -88,28 +101,33 @@ type RecordFilterComponentProps = {
|
|
|
88
101
|
delete: ModalConfig;
|
|
89
102
|
};
|
|
90
103
|
|
|
104
|
+
export type TabType = "main" | "saved" | "attributes";
|
|
105
|
+
|
|
106
|
+
interface FilterComponentTabOptions {
|
|
107
|
+
mainFilter?: FilterComponentOptionsMainFilterOptions;
|
|
108
|
+
savedFilter?: FilterComponentOptionsSavedFilterOptions;
|
|
109
|
+
isSingleFilter?: boolean;
|
|
110
|
+
showFilter?: TabType;
|
|
111
|
+
}
|
|
112
|
+
|
|
91
113
|
export type FilterComponentOptions =
|
|
92
114
|
| {
|
|
115
|
+
showTabs?: true; // when true → additional fields allowed
|
|
93
116
|
showMainHeader?: boolean;
|
|
94
117
|
mainHeaderTitle?: string;
|
|
95
|
-
showTabs?: true; // when true → additional fields allowed
|
|
96
118
|
showMainFilter?: boolean;
|
|
97
119
|
showSavedFilter?: boolean;
|
|
98
120
|
showAttributesFilter?: boolean;
|
|
99
121
|
isRuleEngine?: boolean;
|
|
100
|
-
tabOptions?:
|
|
101
|
-
mainFilter?: FilterComponentOptionsMainFilterOptions;
|
|
102
|
-
};
|
|
122
|
+
tabOptions?: FilterComponentTabOptions;
|
|
103
123
|
recordFilterComponentProps?: RecordFilterComponentProps;
|
|
104
124
|
}
|
|
105
125
|
| {
|
|
126
|
+
showTabs?: false; // explicitly false or omitted
|
|
106
127
|
showMainHeader?: boolean;
|
|
107
128
|
mainHeaderTitle?: string;
|
|
108
|
-
showTabs?: false; // explicitly false or omitted
|
|
109
129
|
isRuleEngine?: boolean;
|
|
110
|
-
tabOptions?:
|
|
111
|
-
mainFilter?: FilterComponentOptionsMainFilterOptions;
|
|
112
|
-
};
|
|
130
|
+
tabOptions?: FilterComponentTabOptions;
|
|
113
131
|
recordFilterComponentProps?: RecordFilterComponentProps;
|
|
114
132
|
};
|
|
115
133
|
|
|
@@ -231,6 +249,7 @@ export interface FilterMasterStateProps {
|
|
|
231
249
|
saved_filters: {
|
|
232
250
|
selectedId: string;
|
|
233
251
|
selectedName: string;
|
|
252
|
+
selectedCode?: string;
|
|
234
253
|
};
|
|
235
254
|
activeFilterTabIndex: number;
|
|
236
255
|
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Dialog } from "@mui/material";
|
|
2
|
+
import { TableFilter } from "../../listing/components/filter";
|
|
3
|
+
import { useCraftTable } from "../../listing/libs/hooks/useCraftTable";
|
|
4
|
+
import { Dispatch, useEffect } from "react";
|
|
5
|
+
import {
|
|
6
|
+
useDetailsQueryAPI,
|
|
7
|
+
useFetchData,
|
|
8
|
+
} from "../../listing/libs/hooks/useEntityTableHooks";
|
|
9
|
+
import {
|
|
10
|
+
ENTITY_TYPE,
|
|
11
|
+
MAPPED_ENTITY_TYPE,
|
|
12
|
+
} from "../../listing/libs/utils/common";
|
|
13
|
+
import {
|
|
14
|
+
useCommonFilterDropdownAPI,
|
|
15
|
+
useDeleteFilterAPI,
|
|
16
|
+
useGetFilterEntityListAndCriteria,
|
|
17
|
+
useUpdateFilterAPI,
|
|
18
|
+
} from "../../listing/libs/hooks/useEntityTableAPI";
|
|
19
|
+
import { saveLayoutAPI } from "../../listing/libs/services/saveLayoutAPI";
|
|
20
|
+
|
|
21
|
+
const SavedFilterModal = ({
|
|
22
|
+
open,
|
|
23
|
+
setOpen,
|
|
24
|
+
}: {
|
|
25
|
+
open: boolean;
|
|
26
|
+
setOpen: Dispatch<React.SetStateAction<boolean>>;
|
|
27
|
+
}) => {
|
|
28
|
+
const tableStates = useCraftTable();
|
|
29
|
+
const {
|
|
30
|
+
filters,
|
|
31
|
+
setFilters,
|
|
32
|
+
filterMaster,
|
|
33
|
+
filterToDelete,
|
|
34
|
+
selectedFilterEntity,
|
|
35
|
+
setFilterData,
|
|
36
|
+
} = tableStates;
|
|
37
|
+
|
|
38
|
+
const { metaQuery } = useFetchData(ENTITY_TYPE);
|
|
39
|
+
const { detailsQuery } = useDetailsQueryAPI(
|
|
40
|
+
filterMaster?.saved_filters?.selectedId
|
|
41
|
+
);
|
|
42
|
+
const { dropdownFilterData } = useCommonFilterDropdownAPI(filters);
|
|
43
|
+
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
44
|
+
const { deleteMutation } = useDeleteFilterAPI(tableStates);
|
|
45
|
+
|
|
46
|
+
const { filterEntityList, filterEntityWiseCriteria } =
|
|
47
|
+
useGetFilterEntityListAndCriteria({
|
|
48
|
+
entity_type: ENTITY_TYPE,
|
|
49
|
+
selectedFilterEntity,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const data: any = filterEntityList?.data;
|
|
54
|
+
|
|
55
|
+
setFilterData((prev: any) => ({
|
|
56
|
+
...prev,
|
|
57
|
+
mainFilter: {
|
|
58
|
+
...prev?.mainFilter,
|
|
59
|
+
entityList: {
|
|
60
|
+
data: data ?? [],
|
|
61
|
+
isPending: filterEntityList?.isPending ?? false,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
}, [filterEntityList?.data, filterEntityList?.isPending]);
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const data = filterEntityWiseCriteria?.data?.data?.attribute_list;
|
|
69
|
+
|
|
70
|
+
setFilterData((prev: any) => ({
|
|
71
|
+
...prev,
|
|
72
|
+
mainFilter: {
|
|
73
|
+
...prev?.mainFilter,
|
|
74
|
+
entityWiseCriteria: {
|
|
75
|
+
data: data ?? [],
|
|
76
|
+
isPending: filterEntityWiseCriteria?.isPending ?? false,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
80
|
+
}, [filterEntityWiseCriteria?.data, filterEntityWiseCriteria?.isPending]);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
setFilters(detailsQuery.data ?? []);
|
|
84
|
+
}, [detailsQuery.data]);
|
|
85
|
+
|
|
86
|
+
const handleClose = () => setOpen(false);
|
|
87
|
+
|
|
88
|
+
const handleChangeFunction = async (data: any) => {
|
|
89
|
+
const payload = {
|
|
90
|
+
entity_type: MAPPED_ENTITY_TYPE,
|
|
91
|
+
mapped_entity_type: ENTITY_TYPE,
|
|
92
|
+
mapped_json: data,
|
|
93
|
+
type: "filter",
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
await saveLayoutAPI(payload);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const handleUpdateFilter = () => {
|
|
100
|
+
const quickFilter = filters.map((f) => ({ ...f }));
|
|
101
|
+
|
|
102
|
+
const payload = {
|
|
103
|
+
name: filterMaster?.saved_filters?.selectedName, // Name of the filter
|
|
104
|
+
is_default: false,
|
|
105
|
+
id: filterMaster?.saved_filters?.selectedId,
|
|
106
|
+
mapped_entity_type: ENTITY_TYPE,
|
|
107
|
+
status: "ACTIVE",
|
|
108
|
+
entity_type: "SFM",
|
|
109
|
+
filterDetails: quickFilter,
|
|
110
|
+
};
|
|
111
|
+
const entity_type = "SFM";
|
|
112
|
+
updateMutation.mutate({ entity_type, payload });
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const handleRemoveFilter = () => {
|
|
116
|
+
const payload = {
|
|
117
|
+
name: filterToDelete?.label,
|
|
118
|
+
id: filterToDelete?.value,
|
|
119
|
+
is_default: false,
|
|
120
|
+
mapped_entity_type: ENTITY_TYPE,
|
|
121
|
+
status: "INACTIVE",
|
|
122
|
+
entity_type: "SFM",
|
|
123
|
+
};
|
|
124
|
+
const entity_type = "SFM";
|
|
125
|
+
deleteMutation.mutate({ entity_type, payload });
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<Dialog
|
|
130
|
+
open={open}
|
|
131
|
+
onClose={handleClose}
|
|
132
|
+
PaperProps={{
|
|
133
|
+
sx: {
|
|
134
|
+
height: "100%",
|
|
135
|
+
minWidth: { xs: "400px", md: "500px" }, // 100% on mobile, 500px on desktop
|
|
136
|
+
minHeight: { md: "80vh" }, // full height on mobile, 80% of viewport on desktop
|
|
137
|
+
"& .MuiInputAdornment-positionStart": {
|
|
138
|
+
pl: 1,
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
"&& .css-ediul2": {
|
|
142
|
+
maxHeight: "calc(100vh - 340px)",
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
"&& .main-filter-component-wrapper": {
|
|
146
|
+
height: "100%",
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
<TableFilter
|
|
152
|
+
tableStates={tableStates}
|
|
153
|
+
columnsData={metaQuery?.data || {}}
|
|
154
|
+
dropdownData={dropdownFilterData || {}}
|
|
155
|
+
onClose={handleClose}
|
|
156
|
+
onUpdateFilter={handleUpdateFilter}
|
|
157
|
+
onDeleteFilter={handleRemoveFilter}
|
|
158
|
+
onChangeFunction={handleChangeFunction}
|
|
159
|
+
filterComponentOptions={{
|
|
160
|
+
showMainHeader: true,
|
|
161
|
+
mainHeaderTitle: "Add New Filter",
|
|
162
|
+
showTabs: false,
|
|
163
|
+
isRuleEngine: true,
|
|
164
|
+
tabOptions: {
|
|
165
|
+
showFilter: "saved",
|
|
166
|
+
savedFilter: {
|
|
167
|
+
// showBackButton: false,
|
|
168
|
+
editMode: true,
|
|
169
|
+
},
|
|
170
|
+
// mainFilter: {
|
|
171
|
+
// showSaveButton: true,
|
|
172
|
+
// showClearAllButton: true,
|
|
173
|
+
// },
|
|
174
|
+
},
|
|
175
|
+
}}
|
|
176
|
+
/>
|
|
177
|
+
</Dialog>
|
|
178
|
+
);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export default SavedFilterModal;
|