rez-table-listing-mui 1.3.4 → 1.3.6
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 +20 -0
- 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/listing/components/filter/components/forms/components/Multi-Select.tsx +1 -1
- package/src/listing/components/filter/index.tsx +234 -95
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +39 -4
- package/src/listing/types/filter.ts +26 -0
- package/src/view/ListingView.tsx +42 -93
package/src/view/ListingView.tsx
CHANGED
|
@@ -8,18 +8,14 @@ import {
|
|
|
8
8
|
} from "../listing/libs/hooks/useEntityTableHooks";
|
|
9
9
|
import { ENTITY_TYPE, MAPPED_ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
useDeleteFilterAPI,
|
|
11
|
+
useCommonFilterDropdownAPI,
|
|
13
12
|
useEntityTableAPI,
|
|
14
13
|
useGetSettingsDataAPI,
|
|
15
|
-
useSavedFilterAPI,
|
|
16
14
|
useSaveSettingsDataAPI,
|
|
17
15
|
useSettingsDropDownAPI,
|
|
18
|
-
useUpdateFilterAPI,
|
|
19
16
|
} from "../listing/libs/hooks/useEntityTableAPI";
|
|
20
17
|
import { entityTableMetaMaster } from "../listing/libs/utils/apiColumn";
|
|
21
18
|
import { ColumnDef } from "@tanstack/react-table";
|
|
22
|
-
import { FilterMasterStateProps } from "../listing/types/filter";
|
|
23
19
|
import { SettingsDataProps } from "../listing/types/filter-settings";
|
|
24
20
|
import TableWrapper from "../listing/components/index-table";
|
|
25
21
|
import { TableTabs } from "../listing/components/tabs";
|
|
@@ -39,8 +35,7 @@ function ListingView() {
|
|
|
39
35
|
const tableStates = useCraftTable();
|
|
40
36
|
const filterSettingStates = useCraftTableFilterSettings();
|
|
41
37
|
|
|
42
|
-
const { filters, setFilters, filterMaster
|
|
43
|
-
tableStates;
|
|
38
|
+
const { filters, setFilters, filterMaster } = tableStates;
|
|
44
39
|
|
|
45
40
|
const { showListViewSettings, setShowListViewSettings, setSettingsData } =
|
|
46
41
|
filterSettingStates;
|
|
@@ -53,17 +48,13 @@ function ListingView() {
|
|
|
53
48
|
? filterMaster?.saved_filters?.selectedId
|
|
54
49
|
: metaQuery?.data?.default_filter?.value
|
|
55
50
|
);
|
|
56
|
-
|
|
57
|
-
const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
|
|
58
|
-
const { deleteMutation } = useDeleteFilterAPI(tableStates); //API FOR DELETING FILTER
|
|
59
|
-
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
60
51
|
const { saveSettingsDataMutation } = useSaveSettingsDataAPI(ENTITY_TYPE);
|
|
61
|
-
const memoizedFilters = useMemo(() => filters, [filters]);
|
|
62
52
|
|
|
63
53
|
// const { dropdownData } = useCommonDropdownAPI(
|
|
64
54
|
// dropdownColumnList || metaQuery.data.column_list
|
|
65
55
|
// );
|
|
66
|
-
const { dropdownData } = useCommonDropdownAPI(
|
|
56
|
+
// const { dropdownData } = useCommonDropdownAPI(filters);
|
|
57
|
+
const { dropdownFilterData } = useCommonFilterDropdownAPI(filters);
|
|
67
58
|
const { settingsTabDropdownData, settingsTabDropdownPending } =
|
|
68
59
|
useSettingsDropDownAPI({
|
|
69
60
|
entity_type: ENTITY_TYPE,
|
|
@@ -253,47 +244,6 @@ function ListingView() {
|
|
|
253
244
|
);
|
|
254
245
|
}, [newData, searchTerm]);
|
|
255
246
|
|
|
256
|
-
// API to handle saving a filter
|
|
257
|
-
const handleSaveFilter = (name: string) => {
|
|
258
|
-
const quickFilter = filters.map((f) => ({
|
|
259
|
-
filter_attribute: f.filter_attribute,
|
|
260
|
-
filter_operator: f.filter_operator,
|
|
261
|
-
filter_value: f.filter_value,
|
|
262
|
-
}));
|
|
263
|
-
|
|
264
|
-
const payload = {
|
|
265
|
-
name,
|
|
266
|
-
is_default: false,
|
|
267
|
-
mapped_entity_type: ENTITY_TYPE, // For that entity type
|
|
268
|
-
status: "ACTIVE",
|
|
269
|
-
entity_type: "SFM", // FIXED entity type
|
|
270
|
-
filterDetails: quickFilter,
|
|
271
|
-
};
|
|
272
|
-
const entity_type = "SFM";
|
|
273
|
-
savedMutation.mutate(
|
|
274
|
-
{ entity_type, payload },
|
|
275
|
-
{
|
|
276
|
-
onSuccess: (response) => {
|
|
277
|
-
const newFilterId = response?.id;
|
|
278
|
-
if (newFilterId) {
|
|
279
|
-
setFilterMaster(
|
|
280
|
-
(prev) =>
|
|
281
|
-
({
|
|
282
|
-
...prev,
|
|
283
|
-
saved_filters: {
|
|
284
|
-
...prev?.saved_filters,
|
|
285
|
-
selectedId: newFilterId.toString(),
|
|
286
|
-
selectedName: name,
|
|
287
|
-
},
|
|
288
|
-
activeFilterTabIndex: 1,
|
|
289
|
-
} as FilterMasterStateProps)
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
}
|
|
294
|
-
);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
247
|
const handleChangeFunction = async (data: any) => {
|
|
298
248
|
const payload = {
|
|
299
249
|
entity_type: MAPPED_ENTITY_TYPE,
|
|
@@ -305,43 +255,6 @@ function ListingView() {
|
|
|
305
255
|
await saveLayoutAPI(payload);
|
|
306
256
|
};
|
|
307
257
|
|
|
308
|
-
// API to handle removing or deleting a filter
|
|
309
|
-
const handleRemoveFilter = () => {
|
|
310
|
-
const payload = {
|
|
311
|
-
name: filterToDelete?.label,
|
|
312
|
-
id: filterToDelete?.value,
|
|
313
|
-
is_default: false,
|
|
314
|
-
mapped_entity_type: ENTITY_TYPE,
|
|
315
|
-
status: "INACTIVE",
|
|
316
|
-
entity_type: "SFM",
|
|
317
|
-
};
|
|
318
|
-
const entity_type = "SFM";
|
|
319
|
-
deleteMutation.mutate({ entity_type, payload });
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
//API to update the filter
|
|
323
|
-
const handleUpdateFilter = () => {
|
|
324
|
-
console.log("handleUpdateFilter");
|
|
325
|
-
|
|
326
|
-
const quickFilter = filters.map((f) => ({
|
|
327
|
-
filter_attribute: f.filter_attribute,
|
|
328
|
-
filter_operator: f.filter_operator,
|
|
329
|
-
filter_value: f.filter_value,
|
|
330
|
-
}));
|
|
331
|
-
|
|
332
|
-
const payload = {
|
|
333
|
-
name: filterMaster?.saved_filters?.selectedName, // Name of the filter
|
|
334
|
-
is_default: false,
|
|
335
|
-
id: filterMaster?.saved_filters?.selectedId,
|
|
336
|
-
mapped_entity_type: ENTITY_TYPE,
|
|
337
|
-
status: "ACTIVE",
|
|
338
|
-
entity_type: "SFM",
|
|
339
|
-
filterDetails: quickFilter,
|
|
340
|
-
};
|
|
341
|
-
const entity_type = "SFM";
|
|
342
|
-
updateMutation.mutate({ entity_type, payload });
|
|
343
|
-
};
|
|
344
|
-
|
|
345
258
|
const handleSaveSettingsData = (settingsData: SettingsDataProps) => {
|
|
346
259
|
const payload = {
|
|
347
260
|
entity_type: MAPPED_ENTITY_TYPE,
|
|
@@ -386,13 +299,49 @@ function ListingView() {
|
|
|
386
299
|
component: (
|
|
387
300
|
<CraftTableFilterWrapper
|
|
388
301
|
tableStates={tableStates}
|
|
389
|
-
onClose={() => tableStates.setShowTableFilter(false)}
|
|
390
302
|
columnsData={metaQuery.data || {}}
|
|
391
|
-
dropdownData={
|
|
303
|
+
dropdownData={dropdownFilterData || []}
|
|
392
304
|
// onUpdateFilter={handleUpdateFilter}
|
|
393
305
|
// onDeleteFilter={handleRemoveFilter}
|
|
394
306
|
// onSaveFilter={handleSaveFilter}
|
|
395
307
|
onChangeFunction={handleChangeFunction}
|
|
308
|
+
filterComponentOptions={{
|
|
309
|
+
showMainHeader: false,
|
|
310
|
+
showTabs: false,
|
|
311
|
+
isRuleEngine: true,
|
|
312
|
+
tabOptions: {
|
|
313
|
+
mainFilter: {
|
|
314
|
+
showSaveButton: true,
|
|
315
|
+
showClearAllButton: true,
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
recordFilterComponentProps: {
|
|
319
|
+
save: {
|
|
320
|
+
title: "Save",
|
|
321
|
+
description: "Are you sure you want to save your changes?",
|
|
322
|
+
button: {
|
|
323
|
+
primary: "Cancel",
|
|
324
|
+
secondary: "Save",
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
edit: {
|
|
328
|
+
title: "Edit",
|
|
329
|
+
description: "Are you sure you want to save your changes?",
|
|
330
|
+
button: {
|
|
331
|
+
primary: "Cancel",
|
|
332
|
+
secondary: "Replace",
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
delete: {
|
|
336
|
+
title: "Delete",
|
|
337
|
+
description: "Are you sure you want to save your changes?",
|
|
338
|
+
button: {
|
|
339
|
+
primary: "Cancel",
|
|
340
|
+
secondary: "Delete",
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
}}
|
|
396
345
|
/>
|
|
397
346
|
),
|
|
398
347
|
}}
|