rez-table-listing-mui 1.2.15 → 1.2.17
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 +8 -1
- 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/assets/svg.tsx +2 -1
- package/src/kanban/index.tsx +11 -2
- package/src/listing/components/common/index.scss +1 -1
- package/src/listing/components/filter/components/attributes-filter.tsx +156 -50
- package/src/listing/components/filter/components/forms/components/Filter-criteria.tsx +21 -2
- package/src/listing/components/filter/components/forms/index.tsx +29 -9
- package/src/listing/components/filter/components/main-filter.tsx +16 -1
- package/src/listing/components/filter/components/saved-edit-filter.tsx +27 -0
- package/src/listing/components/filter/components/saved-filter.tsx +66 -25
- package/src/listing/components/filter/index.tsx +56 -44
- package/src/listing/components/index.scss +1 -3
- package/src/listing/components/login/index.tsx +1 -1
- package/src/listing/components/table-head.tsx +2 -6
- package/src/listing/components/table-settings/components/column.tsx +0 -5
- package/src/listing/components/table-settings/components/group-by.tsx +3 -5
- package/src/listing/components/table-settings/components/lane.tsx +2 -4
- package/src/listing/components/table-settings/components/sorting.tsx +0 -2
- package/src/listing/components/tabs/index.scss +1 -1
- package/src/listing/components/topbar/index.scss +0 -1
- package/src/listing/components/topbar/index.tsx +66 -20
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +66 -5
- package/src/listing/libs/hooks/useGetNavigationLayoutAPI.tsx +12 -0
- package/src/listing/libs/services/getLayoutAPI.tsx +17 -0
- package/src/listing/libs/services/saveLayoutAPI.tsx +20 -0
- package/src/listing/libs/utils/apiColumn.ts +2 -2
- package/src/listing/libs/utils/common.ts +1 -0
- package/src/listing/types/common.ts +8 -0
- package/src/listing/types/filter.ts +13 -0
- package/src/view/FIlterWrapper.tsx +46 -0
- package/src/view/ListingView.tsx +18 -7
package/package.json
CHANGED
package/src/assets/svg.tsx
CHANGED
|
@@ -664,7 +664,7 @@ export const SortingIcon = () => {
|
|
|
664
664
|
);
|
|
665
665
|
};
|
|
666
666
|
|
|
667
|
-
export const FilterationIcon = ({ color = "#1C1B1F" }) => {
|
|
667
|
+
export const FilterationIcon = ({ color = "#1C1B1F", ...props }) => {
|
|
668
668
|
return (
|
|
669
669
|
<svg
|
|
670
670
|
width="20"
|
|
@@ -688,6 +688,7 @@ export const FilterationIcon = ({ color = "#1C1B1F" }) => {
|
|
|
688
688
|
<path
|
|
689
689
|
d="M8.33333 15V13.3333H11.6667V15H8.33333ZM5 10.8333V9.16667H15V10.8333H5ZM2.5 6.66667V5H17.5V6.66667H2.5Z"
|
|
690
690
|
fill={color}
|
|
691
|
+
{...props}
|
|
691
692
|
/>
|
|
692
693
|
</g>
|
|
693
694
|
</svg>
|
package/src/kanban/index.tsx
CHANGED
|
@@ -102,7 +102,10 @@ const Kanban = ({
|
|
|
102
102
|
<Loader />
|
|
103
103
|
) : (
|
|
104
104
|
<Box>
|
|
105
|
-
<Box
|
|
105
|
+
<Box
|
|
106
|
+
className="kanban-container"
|
|
107
|
+
sx={{ width: "100%", bgcolor: "white", overflowX: "auto" }}
|
|
108
|
+
>
|
|
106
109
|
{/* Header */}
|
|
107
110
|
<Box sx={kanbanStyles.topHeader}>
|
|
108
111
|
<IconButton
|
|
@@ -188,7 +191,13 @@ const Kanban = ({
|
|
|
188
191
|
fontWeight="medium"
|
|
189
192
|
sx={{ ml: 1.5 }}
|
|
190
193
|
>
|
|
191
|
-
{swim_lane
|
|
194
|
+
{swim_lane?.name} (
|
|
195
|
+
{
|
|
196
|
+
data.filter(
|
|
197
|
+
(lead: any) => lead?.lead_status_id == swim_lane?.id
|
|
198
|
+
).length
|
|
199
|
+
}
|
|
200
|
+
)
|
|
192
201
|
</Typography>
|
|
193
202
|
</AccordionSummary>
|
|
194
203
|
|
|
@@ -21,46 +21,129 @@ const AttributesFilter = ({
|
|
|
21
21
|
searchTerm,
|
|
22
22
|
setSearchTerm,
|
|
23
23
|
tabValue,
|
|
24
|
+
onChangeFunction,
|
|
24
25
|
}: AttributesFilterProps) => {
|
|
25
26
|
const { filterMaster, setFilterMaster, filters, setFilters } = tableStates;
|
|
26
27
|
|
|
27
28
|
const selectedAttribute = filterMaster?.attributes?.selected;
|
|
28
29
|
|
|
29
30
|
// Get the current filter value (single selection)
|
|
30
|
-
const currentFilterValue = useMemo(() => {
|
|
31
|
-
|
|
31
|
+
// const currentFilterValue = useMemo(() => {
|
|
32
|
+
// if (!selectedAttribute) return [];
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// const matchingColumn = columnsData?.column_list?.find(
|
|
35
|
+
// (column) => column.datasource_list === selectedAttribute
|
|
36
|
+
// );
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
// if (!matchingColumn) return [];
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
// const existingFilter = filters.find(
|
|
41
|
+
// (filter) => filter.filter_attribute === matchingColumn.attribute_key
|
|
42
|
+
// );
|
|
43
|
+
|
|
44
|
+
// return Array.isArray(existingFilter?.filter_value)
|
|
45
|
+
// ? existingFilter?.filter_value
|
|
46
|
+
// : [];
|
|
47
|
+
// }, [selectedAttribute, filters, columnsData]);
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
const currentRadio = useMemo(() => {
|
|
50
|
+
return Array.isArray(filterMaster?.attributes?.radio)
|
|
51
|
+
? (filterMaster!.attributes!.radio as string[])
|
|
45
52
|
: [];
|
|
46
|
-
}, [
|
|
53
|
+
}, [filterMaster?.attributes?.radio]);
|
|
47
54
|
|
|
48
55
|
const handleSelectChange = (event: SelectChangeEvent) => {
|
|
49
56
|
const attributeKey = event.target.value as string;
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
const newFilterMasterState = {
|
|
59
|
+
...filterMaster,
|
|
60
|
+
attributes: {
|
|
61
|
+
...filterMaster?.attributes,
|
|
62
|
+
selected: attributeKey,
|
|
63
|
+
radio: [],
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
setFilterMaster(newFilterMasterState as FilterMasterStateProps);
|
|
68
|
+
|
|
69
|
+
const newState = {
|
|
70
|
+
filterMaster: newFilterMasterState,
|
|
71
|
+
filters: filters,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
onChangeFunction && onChangeFunction(newState);
|
|
62
75
|
};
|
|
63
76
|
|
|
77
|
+
// const setFiltersForRadio = (
|
|
78
|
+
// value: string,
|
|
79
|
+
// columnsData: FilterColumnsDataProps,
|
|
80
|
+
// prevFilters: FilterStateProps[]
|
|
81
|
+
// ) => {
|
|
82
|
+
// const selectedAttr = filterMaster?.attributes.selected;
|
|
83
|
+
// if (!selectedAttr) return;
|
|
84
|
+
|
|
85
|
+
// const matchingColumn = columnsData?.column_list?.find(
|
|
86
|
+
// (column) => column.datasource_list === selectedAttr
|
|
87
|
+
// );
|
|
88
|
+
// if (!matchingColumn) return;
|
|
89
|
+
|
|
90
|
+
// const defaultOperator =
|
|
91
|
+
// columnsData.operation_list[matchingColumn.data_type]?.[0]?.value || "in";
|
|
92
|
+
|
|
93
|
+
// const newFilter = {
|
|
94
|
+
// filter_attribute: matchingColumn.attribute_key,
|
|
95
|
+
// filter_operator: defaultOperator,
|
|
96
|
+
// filter_value: [value], // single selection
|
|
97
|
+
// };
|
|
98
|
+
|
|
99
|
+
// const exists = prevFilters.some(
|
|
100
|
+
// (f) => f.filter_attribute === matchingColumn.attribute_key
|
|
101
|
+
// );
|
|
102
|
+
// if (exists) {
|
|
103
|
+
// return prevFilters.map((f) =>
|
|
104
|
+
// f.filter_attribute === matchingColumn.attribute_key ? newFilter : f
|
|
105
|
+
// );
|
|
106
|
+
// } else {
|
|
107
|
+
// return [...prevFilters, newFilter];
|
|
108
|
+
// }
|
|
109
|
+
// };
|
|
110
|
+
|
|
111
|
+
// const setFilterMasterForRadio = (
|
|
112
|
+
// value: string,
|
|
113
|
+
// prevFilterMaster: FilterMasterStateProps | null
|
|
114
|
+
// ) => {
|
|
115
|
+
// /**
|
|
116
|
+
// * If no attribute is selected, return the previous state without changes
|
|
117
|
+
// * This prevents errors when trying to access properties of undefined
|
|
118
|
+
// */
|
|
119
|
+
// if (!prevFilterMaster || !prevFilterMaster.attributes.selected)
|
|
120
|
+
// return prevFilterMaster;
|
|
121
|
+
|
|
122
|
+
// return {
|
|
123
|
+
// ...prevFilterMaster,
|
|
124
|
+
// attributes: {
|
|
125
|
+
// ...prevFilterMaster.attributes,
|
|
126
|
+
// radio: [value],
|
|
127
|
+
// },
|
|
128
|
+
// activeFilterTabIndex: tabValue as number,
|
|
129
|
+
// };
|
|
130
|
+
// };
|
|
131
|
+
|
|
132
|
+
// const handleSingleRadioSelect = (value: string) => {
|
|
133
|
+
// const newFiltersState = setFiltersForRadio(value, columnsData, filters);
|
|
134
|
+
// setFilters(newFiltersState || []);
|
|
135
|
+
|
|
136
|
+
// const newFilterMasterState = setFilterMasterForRadio(value, filterMaster);
|
|
137
|
+
// setFilterMaster(newFilterMasterState as FilterMasterStateProps);
|
|
138
|
+
|
|
139
|
+
// const newState = {
|
|
140
|
+
// filterMaster: newFilterMasterState,
|
|
141
|
+
// filters: newFiltersState,
|
|
142
|
+
// };
|
|
143
|
+
|
|
144
|
+
// onChangeFunction && onChangeFunction(newState);
|
|
145
|
+
// };
|
|
146
|
+
|
|
64
147
|
const handleSingleRadioSelect = (value: string) => {
|
|
65
148
|
const selectedAttr = filterMaster?.attributes.selected;
|
|
66
149
|
if (!selectedAttr) return;
|
|
@@ -70,40 +153,58 @@ const AttributesFilter = ({
|
|
|
70
153
|
);
|
|
71
154
|
if (!matchingColumn) return;
|
|
72
155
|
|
|
73
|
-
|
|
74
|
-
|
|
156
|
+
let updatedFilters = [...filters];
|
|
157
|
+
let updatedRadio: string[] = [];
|
|
75
158
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
159
|
+
if (value === "") {
|
|
160
|
+
// If deselecting, remove the filter
|
|
161
|
+
updatedFilters = filters.filter(
|
|
162
|
+
(f) => f.filter_attribute !== matchingColumn.attribute_key
|
|
163
|
+
);
|
|
164
|
+
} else {
|
|
165
|
+
// Else, replace with new single selection
|
|
166
|
+
const defaultOperator =
|
|
167
|
+
columnsData.operation_list[matchingColumn.data_type]?.[0]?.value ||
|
|
168
|
+
"in";
|
|
169
|
+
|
|
170
|
+
const newFilter = {
|
|
171
|
+
filter_attribute: matchingColumn.attribute_key,
|
|
172
|
+
filter_operator: defaultOperator,
|
|
173
|
+
filter_value: [value],
|
|
174
|
+
};
|
|
81
175
|
|
|
82
|
-
|
|
83
|
-
const exists = prevFilters.some(
|
|
176
|
+
const exists = filters.some(
|
|
84
177
|
(f) => f.filter_attribute === matchingColumn.attribute_key
|
|
85
178
|
);
|
|
86
179
|
if (exists) {
|
|
87
|
-
|
|
180
|
+
updatedFilters = filters.map((f) =>
|
|
88
181
|
f.filter_attribute === matchingColumn.attribute_key ? newFilter : f
|
|
89
182
|
);
|
|
90
183
|
} else {
|
|
91
|
-
|
|
184
|
+
updatedFilters = [...filters, newFilter];
|
|
92
185
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
186
|
+
|
|
187
|
+
updatedRadio = [value];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
setFilters(updatedFilters);
|
|
191
|
+
|
|
192
|
+
const updatedFilterMaster = {
|
|
193
|
+
...filterMaster,
|
|
194
|
+
attributes: {
|
|
195
|
+
...filterMaster.attributes,
|
|
196
|
+
radio: updatedRadio,
|
|
197
|
+
},
|
|
198
|
+
activeFilterTabIndex: tabValue as number,
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
setFilterMaster(updatedFilterMaster);
|
|
202
|
+
|
|
203
|
+
onChangeFunction &&
|
|
204
|
+
onChangeFunction({
|
|
205
|
+
filters: updatedFilters,
|
|
206
|
+
filterMaster: updatedFilterMaster,
|
|
207
|
+
});
|
|
107
208
|
};
|
|
108
209
|
|
|
109
210
|
const selectedAttributeOptions = useMemo(() => {
|
|
@@ -192,7 +293,8 @@ const AttributesFilter = ({
|
|
|
192
293
|
.includes(searchTerm.toLowerCase());
|
|
193
294
|
})
|
|
194
295
|
.map((option) => {
|
|
195
|
-
const isSelected =
|
|
296
|
+
const isSelected = currentRadio.includes(option.value);
|
|
297
|
+
// const isSelected = currentFilterValue.includes(option.value);
|
|
196
298
|
|
|
197
299
|
return (
|
|
198
300
|
<FormControlLabel
|
|
@@ -200,7 +302,11 @@ const AttributesFilter = ({
|
|
|
200
302
|
control={
|
|
201
303
|
<Radio
|
|
202
304
|
checked={isSelected}
|
|
203
|
-
|
|
305
|
+
onClick={() =>
|
|
306
|
+
isSelected
|
|
307
|
+
? handleSingleRadioSelect("")
|
|
308
|
+
: handleSingleRadioSelect(option.value)
|
|
309
|
+
}
|
|
204
310
|
/>
|
|
205
311
|
}
|
|
206
312
|
label={option.label}
|
|
@@ -18,6 +18,7 @@ import { CraftTableOptionsProps } from "../../../../../types/table-options";
|
|
|
18
18
|
import CustomSearch from "../../search";
|
|
19
19
|
import { filterStyles } from "../../../style";
|
|
20
20
|
import useElementWidth from "../../../../../libs/hooks/useElementWidth";
|
|
21
|
+
import { onFilterChangeFunctionProps } from "../../../../../types/common";
|
|
21
22
|
|
|
22
23
|
const FilterCriteria = ({
|
|
23
24
|
columnsData,
|
|
@@ -25,6 +26,7 @@ const FilterCriteria = ({
|
|
|
25
26
|
setSelectedFilters,
|
|
26
27
|
searchTerm,
|
|
27
28
|
setSearchTerm,
|
|
29
|
+
onChangeFunction,
|
|
28
30
|
}: {
|
|
29
31
|
columnsData: FilterColumnsDataProps;
|
|
30
32
|
tableStates: CraftTableOptionsProps;
|
|
@@ -33,6 +35,10 @@ const FilterCriteria = ({
|
|
|
33
35
|
>;
|
|
34
36
|
searchTerm: string;
|
|
35
37
|
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
38
|
+
onChangeFunction: ({
|
|
39
|
+
updatedFilters,
|
|
40
|
+
filterMaster,
|
|
41
|
+
}: onFilterChangeFunctionProps) => void;
|
|
36
42
|
}) => {
|
|
37
43
|
const FilterButton = styled(Button)(({ theme }) => ({
|
|
38
44
|
borderRadius: 20,
|
|
@@ -45,8 +51,13 @@ const FilterCriteria = ({
|
|
|
45
51
|
},
|
|
46
52
|
}));
|
|
47
53
|
|
|
48
|
-
const {
|
|
49
|
-
|
|
54
|
+
const {
|
|
55
|
+
filters,
|
|
56
|
+
setFilters,
|
|
57
|
+
showFilterOptions,
|
|
58
|
+
setShowFilterOption,
|
|
59
|
+
filterMaster,
|
|
60
|
+
} = tableStates;
|
|
50
61
|
|
|
51
62
|
const filterButtonRef = useRef<HTMLButtonElement>(null);
|
|
52
63
|
|
|
@@ -86,6 +97,14 @@ const FilterCriteria = ({
|
|
|
86
97
|
// setSelectedFilters((prev) => [...prev, newSelectedFilter]);
|
|
87
98
|
// }
|
|
88
99
|
|
|
100
|
+
const newFilterState = [...filters, newFilter];
|
|
101
|
+
const newState = {
|
|
102
|
+
filterMaster: filterMaster,
|
|
103
|
+
filters: newFilterState,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
onChangeFunction && onChangeFunction(newState);
|
|
107
|
+
|
|
89
108
|
setShowFilterOption(false);
|
|
90
109
|
};
|
|
91
110
|
|
|
@@ -24,6 +24,7 @@ import FilterCriteria from "./components/Filter-criteria";
|
|
|
24
24
|
import CustomSearch from "../search";
|
|
25
25
|
import { customDebounce } from "../../../../libs/utils/debounce";
|
|
26
26
|
import { filterFormStyles } from "../../style";
|
|
27
|
+
import { onFilterChangeFunctionProps } from "../../../../types/common";
|
|
27
28
|
|
|
28
29
|
interface FormValues {
|
|
29
30
|
filterName: string;
|
|
@@ -49,6 +50,7 @@ const FilterForm = ({
|
|
|
49
50
|
tableStates,
|
|
50
51
|
setSavedFilterModalOpen,
|
|
51
52
|
setDeleteFilterModalOpen,
|
|
53
|
+
onChangeFunction,
|
|
52
54
|
}: {
|
|
53
55
|
columnsData: FilterColumnsDataProps;
|
|
54
56
|
dropdownData: FilterDropdownDataProps;
|
|
@@ -65,6 +67,10 @@ const FilterForm = ({
|
|
|
65
67
|
tableStates: CraftTableOptionsProps;
|
|
66
68
|
setSavedFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
67
69
|
setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
70
|
+
onChangeFunction: ({
|
|
71
|
+
updatedFilters,
|
|
72
|
+
filterMaster,
|
|
73
|
+
}: onFilterChangeFunctionProps) => void;
|
|
68
74
|
}) => {
|
|
69
75
|
const { filterMaster, setFilters, setFilterMaster, setPagination } =
|
|
70
76
|
tableStates;
|
|
@@ -90,14 +96,9 @@ const FilterForm = ({
|
|
|
90
96
|
};
|
|
91
97
|
}, [selectedFilters, filterName]);
|
|
92
98
|
|
|
93
|
-
const {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
reset,
|
|
97
|
-
// formState: { isDirty },
|
|
98
|
-
setValue,
|
|
99
|
-
unregister,
|
|
100
|
-
} = useForm<FormValues & { dummyChange: string }>({
|
|
99
|
+
const { control, watch, reset, setValue, unregister } = useForm<
|
|
100
|
+
FormValues & { dummyChange: string }
|
|
101
|
+
>({
|
|
101
102
|
mode: "onChange",
|
|
102
103
|
defaultValues,
|
|
103
104
|
resetOptions: {
|
|
@@ -116,6 +117,13 @@ const FilterForm = ({
|
|
|
116
117
|
customDebounce((updatedFilters: UpdatedFilterStateProps[]) => {
|
|
117
118
|
setSelectedFilters(updatedFilters);
|
|
118
119
|
setFilters(updatedFilters);
|
|
120
|
+
|
|
121
|
+
const newState = {
|
|
122
|
+
filterMaster: filterMaster,
|
|
123
|
+
filters: updatedFilters,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
onChangeFunction && onChangeFunction(newState);
|
|
119
127
|
}, 1000),
|
|
120
128
|
[setSelectedFilters, setFilters]
|
|
121
129
|
);
|
|
@@ -240,6 +248,7 @@ const FilterForm = ({
|
|
|
240
248
|
setSelectedFilters={setSelectedFilters}
|
|
241
249
|
searchTerm={criteriaSearchTerm}
|
|
242
250
|
setSearchTerm={setCriteriaSearchTerm}
|
|
251
|
+
onChangeFunction={onChangeFunction}
|
|
243
252
|
/>
|
|
244
253
|
|
|
245
254
|
{!editMode && (
|
|
@@ -380,6 +389,18 @@ const FilterForm = ({
|
|
|
380
389
|
onClick={() => {
|
|
381
390
|
setFilters([]);
|
|
382
391
|
setSelectedFilters([]);
|
|
392
|
+
|
|
393
|
+
const filterMaster = {
|
|
394
|
+
...tableStates.filterMaster,
|
|
395
|
+
activeFilterTabIndex: -1,
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
const newState = {
|
|
399
|
+
filterMaster: filterMaster,
|
|
400
|
+
filters: [],
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
onChangeFunction && onChangeFunction(newState);
|
|
383
404
|
}}
|
|
384
405
|
>
|
|
385
406
|
Clear All
|
|
@@ -388,7 +409,6 @@ const FilterForm = ({
|
|
|
388
409
|
<Button
|
|
389
410
|
variant="contained"
|
|
390
411
|
fullWidth
|
|
391
|
-
// disabled={!isDirty && editMode}
|
|
392
412
|
sx={{
|
|
393
413
|
color: "white",
|
|
394
414
|
backgroundColor: "#7A5AF8",
|
|
@@ -14,11 +14,12 @@ const MainFilter = ({
|
|
|
14
14
|
selectedFilters,
|
|
15
15
|
setSelectedFilters,
|
|
16
16
|
setSavedFilterModalOpen,
|
|
17
|
+
onChangeFunction,
|
|
17
18
|
}: FilterFormComponentProps) => {
|
|
18
19
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
|
19
20
|
const [criteriaSearchTerm, setCriteriaSearchTerm] = useState<string>("");
|
|
20
21
|
|
|
21
|
-
const { setFilters, setFilterMaster } = tableStates;
|
|
22
|
+
const { setFilters, setFilterMaster, filterMaster } = tableStates;
|
|
22
23
|
|
|
23
24
|
useEffect(() => {
|
|
24
25
|
setFilterMaster(
|
|
@@ -37,6 +38,19 @@ const MainFilter = ({
|
|
|
37
38
|
setSelectedFilters((prev) =>
|
|
38
39
|
prev.filter((filter) => filter.filter_attribute !== filter_attribute)
|
|
39
40
|
);
|
|
41
|
+
setFilters((prev) => {
|
|
42
|
+
const next = prev.filter((f) => f.filter_attribute !== filter_attribute);
|
|
43
|
+
setSelectedFilters((prevSel) =>
|
|
44
|
+
prevSel.filter((f) => f.filter_attribute !== filter_attribute)
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
onChangeFunction &&
|
|
48
|
+
onChangeFunction({
|
|
49
|
+
filterMaster: filterMaster,
|
|
50
|
+
filters: next,
|
|
51
|
+
});
|
|
52
|
+
return next;
|
|
53
|
+
});
|
|
40
54
|
};
|
|
41
55
|
|
|
42
56
|
const mainBoxStyles = {
|
|
@@ -61,6 +75,7 @@ const MainFilter = ({
|
|
|
61
75
|
tableStates={tableStates}
|
|
62
76
|
setSavedFilterModalOpen={setSavedFilterModalOpen}
|
|
63
77
|
dropdownData={dropdownData}
|
|
78
|
+
onChangeFunction={onChangeFunction}
|
|
64
79
|
/>
|
|
65
80
|
</Box>
|
|
66
81
|
);
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
UpdatedFilterStateProps,
|
|
9
9
|
} from "../../../types/filter";
|
|
10
10
|
import { CraftTableOptionsProps } from "../../../types/table-options";
|
|
11
|
+
import { onFilterChangeFunctionProps } from "../../../types/common";
|
|
11
12
|
|
|
12
13
|
const SavedFilterEditComponent = ({
|
|
13
14
|
columnsData,
|
|
@@ -23,6 +24,7 @@ const SavedFilterEditComponent = ({
|
|
|
23
24
|
setCriteriaSearchTerm,
|
|
24
25
|
setSavedFilterModalOpen,
|
|
25
26
|
setDeleteFilterModalOpen,
|
|
27
|
+
onChangeFunction,
|
|
26
28
|
}: {
|
|
27
29
|
columnsData: FilterColumnsDataProps;
|
|
28
30
|
dropdownData: FilterDropdownDataProps;
|
|
@@ -39,6 +41,10 @@ const SavedFilterEditComponent = ({
|
|
|
39
41
|
setCriteriaSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
40
42
|
setSavedFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
41
43
|
setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
44
|
+
onChangeFunction: ({
|
|
45
|
+
updatedFilters,
|
|
46
|
+
filterMaster,
|
|
47
|
+
}: onFilterChangeFunctionProps) => void;
|
|
42
48
|
}) => {
|
|
43
49
|
const { setFilters, setFilterMaster } = tableStates;
|
|
44
50
|
|
|
@@ -54,6 +60,26 @@ const SavedFilterEditComponent = ({
|
|
|
54
60
|
const handleBackButtonClick = () => {
|
|
55
61
|
setEditMode && setEditMode(false);
|
|
56
62
|
setFilters([]);
|
|
63
|
+
|
|
64
|
+
// const newFilterMasterState = {
|
|
65
|
+
// ...filterMaster,
|
|
66
|
+
// saved_filters: {
|
|
67
|
+
// ...filterMaster?.saved_filters,
|
|
68
|
+
// selectedId: "",
|
|
69
|
+
// selectedName: "",
|
|
70
|
+
// },
|
|
71
|
+
// activeFilterTabIndex: -1,
|
|
72
|
+
// } as FilterMasterStateProps;
|
|
73
|
+
|
|
74
|
+
// setFilterMaster(newFilterMasterState);
|
|
75
|
+
|
|
76
|
+
// const newState = {
|
|
77
|
+
// filterMaster: newFilterMasterState,
|
|
78
|
+
// filters: filters,
|
|
79
|
+
// };
|
|
80
|
+
|
|
81
|
+
// onChangeFunction && onChangeFunction(newState);
|
|
82
|
+
|
|
57
83
|
setFilterMaster(
|
|
58
84
|
(prev) =>
|
|
59
85
|
({
|
|
@@ -103,6 +129,7 @@ const SavedFilterEditComponent = ({
|
|
|
103
129
|
setCriteriaSearchTerm={setCriteriaSearchTerm}
|
|
104
130
|
setSavedFilterModalOpen={setSavedFilterModalOpen}
|
|
105
131
|
setDeleteFilterModalOpen={setDeleteFilterModalOpen}
|
|
132
|
+
onChangeFunction={onChangeFunction}
|
|
106
133
|
/>
|
|
107
134
|
</>
|
|
108
135
|
);
|