rez-table-listing-mui 1.2.16 → 1.2.18
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/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 +78 -44
- package/src/listing/components/index.scss +1 -1
- package/src/listing/components/login/index.tsx +1 -1
- package/src/listing/components/table-head.tsx +2 -6
- 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 +39 -27
- 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 -3
- 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 +130 -0
- package/src/view/ListingView.tsx +23 -10
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { CraftTableFilter } from "..";
|
|
3
|
+
import { useGetNavigationLayoutAPI } from "../listing/libs/hooks/useGetNavigationLayoutAPI";
|
|
4
|
+
import { ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
5
|
+
import {
|
|
6
|
+
useDeleteFilterAPI,
|
|
7
|
+
useSavedFilterAPI,
|
|
8
|
+
useUpdateFilterAPI,
|
|
9
|
+
} from "../listing/libs/hooks/useEntityTableAPI";
|
|
10
|
+
import { FilterMasterStateProps } from "../listing/types/filter";
|
|
11
|
+
|
|
12
|
+
const CraftTableFilterWrapper = ({
|
|
13
|
+
tableStates,
|
|
14
|
+
dropdownData,
|
|
15
|
+
onChangeFunction,
|
|
16
|
+
columnsData,
|
|
17
|
+
}: any) => {
|
|
18
|
+
const getNavigationLayoutQuery = useGetNavigationLayoutAPI(ENTITY_TYPE);
|
|
19
|
+
|
|
20
|
+
const { filters, filterMaster, setFilterMaster, filterToDelete } =
|
|
21
|
+
tableStates;
|
|
22
|
+
|
|
23
|
+
const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
|
|
24
|
+
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
25
|
+
const { deleteMutation } = useDeleteFilterAPI(tableStates); //API FOR DELETING FILTER
|
|
26
|
+
|
|
27
|
+
// API to handle saving a filter
|
|
28
|
+
const handleSaveFilter = (name: string) => {
|
|
29
|
+
const quickFilter = filters.map((f: any) => ({
|
|
30
|
+
filter_attribute: f.filter_attribute,
|
|
31
|
+
filter_operator: f.filter_operator,
|
|
32
|
+
filter_value: f.filter_value,
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
const payload = {
|
|
36
|
+
name,
|
|
37
|
+
is_default: false,
|
|
38
|
+
mapped_entity_type: ENTITY_TYPE, // For that entity type
|
|
39
|
+
status: "ACTIVE",
|
|
40
|
+
entity_type: "SFM", // FIXED entity type
|
|
41
|
+
filterDetails: quickFilter,
|
|
42
|
+
};
|
|
43
|
+
const entity_type = "SFM";
|
|
44
|
+
savedMutation.mutate(
|
|
45
|
+
{ entity_type, payload },
|
|
46
|
+
{
|
|
47
|
+
onSuccess: (response) => {
|
|
48
|
+
const newFilterId = response?.id;
|
|
49
|
+
if (newFilterId) {
|
|
50
|
+
setFilterMaster(
|
|
51
|
+
(prev: FilterMasterStateProps) =>
|
|
52
|
+
({
|
|
53
|
+
...prev,
|
|
54
|
+
saved_filters: {
|
|
55
|
+
...prev?.saved_filters,
|
|
56
|
+
selectedId: newFilterId.toString(),
|
|
57
|
+
selectedName: name,
|
|
58
|
+
},
|
|
59
|
+
activeFilterTabIndex: 1,
|
|
60
|
+
} as FilterMasterStateProps)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const handleUpdateFilter = () => {
|
|
69
|
+
const quickFilter = filters.map((f: any) => ({
|
|
70
|
+
filter_attribute: f.filter_attribute,
|
|
71
|
+
filter_operator: f.filter_operator,
|
|
72
|
+
filter_value: f.filter_value,
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
const payload = {
|
|
76
|
+
name: filterMaster?.saved_filters?.selectedName, // Name of the filter
|
|
77
|
+
is_default: false,
|
|
78
|
+
id: filterMaster?.saved_filters?.selectedId,
|
|
79
|
+
mapped_entity_type: ENTITY_TYPE,
|
|
80
|
+
status: "ACTIVE",
|
|
81
|
+
entity_type: "SFM",
|
|
82
|
+
filterDetails: quickFilter,
|
|
83
|
+
};
|
|
84
|
+
const entity_type = "SFM";
|
|
85
|
+
updateMutation.mutate({ entity_type, payload });
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const handleRemoveFilter = () => {
|
|
89
|
+
const payload = {
|
|
90
|
+
name: filterToDelete?.label,
|
|
91
|
+
id: filterToDelete?.value,
|
|
92
|
+
is_default: false,
|
|
93
|
+
mapped_entity_type: ENTITY_TYPE,
|
|
94
|
+
status: "INACTIVE",
|
|
95
|
+
entity_type: "SFM",
|
|
96
|
+
};
|
|
97
|
+
const entity_type = "SFM";
|
|
98
|
+
deleteMutation.mutate({ entity_type, payload });
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (getNavigationLayoutQuery.isSuccess) {
|
|
103
|
+
const { setFilters, setFilterMaster } = tableStates;
|
|
104
|
+
const filters = getNavigationLayoutQuery?.data?.filters || [];
|
|
105
|
+
const filterMaster = getNavigationLayoutQuery?.data?.filterMaster || {};
|
|
106
|
+
|
|
107
|
+
if (filters.length > 0) {
|
|
108
|
+
tableStates.setShowTableFilter(true);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
setFilters(filters);
|
|
112
|
+
setFilterMaster(filterMaster);
|
|
113
|
+
}
|
|
114
|
+
}, [getNavigationLayoutQuery.isSuccess, getNavigationLayoutQuery.data]);
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<CraftTableFilter
|
|
118
|
+
tableStates={tableStates}
|
|
119
|
+
onClose={() => tableStates.setShowTableFilter(false)}
|
|
120
|
+
columnsData={columnsData}
|
|
121
|
+
dropdownData={dropdownData || []}
|
|
122
|
+
onUpdateFilter={handleUpdateFilter}
|
|
123
|
+
onDeleteFilter={handleRemoveFilter}
|
|
124
|
+
onSaveFilter={handleSaveFilter}
|
|
125
|
+
onChangeFunction={onChangeFunction}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export default CraftTableFilterWrapper;
|
package/src/view/ListingView.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useDetailsQueryAPI,
|
|
7
7
|
useFetchData,
|
|
8
8
|
} from "../listing/libs/hooks/useEntityTableHooks";
|
|
9
|
-
import { ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
9
|
+
import { ENTITY_TYPE, MAPPED_ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
10
10
|
import {
|
|
11
11
|
useCommonDropdownAPI,
|
|
12
12
|
useDeleteFilterAPI,
|
|
@@ -22,9 +22,10 @@ import { ColumnDef } from "@tanstack/react-table";
|
|
|
22
22
|
import { FilterMasterStateProps } from "../listing/types/filter";
|
|
23
23
|
import { SettingsDataProps } from "../listing/types/filter-settings";
|
|
24
24
|
import TableWrapper from "../listing/components/index-table";
|
|
25
|
-
import { CraftTableFilter } from "..";
|
|
26
25
|
import { TableTabs } from "../listing/components/tabs";
|
|
27
26
|
import { QuickFilterSettings } from "../listing/components/table-settings";
|
|
27
|
+
import CraftTableFilterWrapper from "./FIlterWrapper";
|
|
28
|
+
import { saveLayoutAPI } from "../listing/libs/services/saveLayoutAPI";
|
|
28
29
|
|
|
29
30
|
function ListingView() {
|
|
30
31
|
// const [mockLoading, setMockLoading] = useState<boolean>(true);
|
|
@@ -54,7 +55,7 @@ function ListingView() {
|
|
|
54
55
|
);
|
|
55
56
|
|
|
56
57
|
const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
|
|
57
|
-
const { deleteMutation } = useDeleteFilterAPI(); //API FOR DELETING FILTER
|
|
58
|
+
const { deleteMutation } = useDeleteFilterAPI(tableStates); //API FOR DELETING FILTER
|
|
58
59
|
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
59
60
|
const { saveSettingsDataMutation } = useSaveSettingsDataAPI(ENTITY_TYPE);
|
|
60
61
|
const { dropdownData } = useCommonDropdownAPI(metaQuery.data);
|
|
@@ -288,6 +289,17 @@ function ListingView() {
|
|
|
288
289
|
);
|
|
289
290
|
};
|
|
290
291
|
|
|
292
|
+
const handleChangeFunction = async (data: any) => {
|
|
293
|
+
const payload = {
|
|
294
|
+
entity_type: MAPPED_ENTITY_TYPE,
|
|
295
|
+
mapped_entity_type: ENTITY_TYPE,
|
|
296
|
+
mapped_json: data,
|
|
297
|
+
type: "filter",
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
await saveLayoutAPI(payload);
|
|
301
|
+
};
|
|
302
|
+
|
|
291
303
|
// API to handle removing or deleting a filter
|
|
292
304
|
const handleRemoveFilter = () => {
|
|
293
305
|
const payload = {
|
|
@@ -304,6 +316,8 @@ function ListingView() {
|
|
|
304
316
|
|
|
305
317
|
//API to update the filter
|
|
306
318
|
const handleUpdateFilter = () => {
|
|
319
|
+
console.log("handleUpdateFilter");
|
|
320
|
+
|
|
307
321
|
const quickFilter = filters.map((f) => ({
|
|
308
322
|
filter_attribute: f.filter_attribute,
|
|
309
323
|
filter_operator: f.filter_operator,
|
|
@@ -325,7 +339,7 @@ function ListingView() {
|
|
|
325
339
|
|
|
326
340
|
const handleSaveSettingsData = (settingsData: SettingsDataProps) => {
|
|
327
341
|
const payload = {
|
|
328
|
-
entity_type:
|
|
342
|
+
entity_type: MAPPED_ENTITY_TYPE,
|
|
329
343
|
mapped_entity_type: ENTITY_TYPE,
|
|
330
344
|
layout_json: settingsData,
|
|
331
345
|
};
|
|
@@ -336,8 +350,6 @@ function ListingView() {
|
|
|
336
350
|
return (
|
|
337
351
|
<TableWrapper
|
|
338
352
|
data={filteredData}
|
|
339
|
-
// data={data}
|
|
340
|
-
// columns={defaultColumns}
|
|
341
353
|
columns={columns && columns.length > 0 ? columns : defaultColumns}
|
|
342
354
|
tableStates={tableStates}
|
|
343
355
|
featureOptions={{
|
|
@@ -367,14 +379,15 @@ function ListingView() {
|
|
|
367
379
|
filterOptions={{
|
|
368
380
|
show: tableStates?.showTableFilter,
|
|
369
381
|
component: (
|
|
370
|
-
<
|
|
382
|
+
<CraftTableFilterWrapper
|
|
371
383
|
tableStates={tableStates}
|
|
372
384
|
onClose={() => tableStates.setShowTableFilter(false)}
|
|
373
|
-
onUpdateFilter={handleUpdateFilter}
|
|
374
385
|
columnsData={metaQuery.data || {}}
|
|
375
386
|
dropdownData={dropdownData || []}
|
|
376
|
-
|
|
377
|
-
|
|
387
|
+
// onUpdateFilter={handleUpdateFilter}
|
|
388
|
+
// onDeleteFilter={handleRemoveFilter}
|
|
389
|
+
// onSaveFilter={handleSaveFilter}
|
|
390
|
+
onChangeFunction={handleChangeFunction}
|
|
378
391
|
/>
|
|
379
392
|
),
|
|
380
393
|
}}
|