rez-table-listing-mui 1.3.10 → 1.3.12
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 +13 -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/listing/components/filter/components/saved-filter.tsx +12 -14
- package/src/listing/components/filter/index.tsx +8 -2
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +11 -0
- package/src/listing/libs/utils/apiColumn.ts +5 -0
- package/src/listing/libs/utils/hydrate-saved-filters.ts +26 -0
- package/src/listing/types/filter.ts +14 -0
- package/src/view/ListingView.tsx +20 -2
package/package.json
CHANGED
|
@@ -39,22 +39,20 @@ const SavedFilter = ({
|
|
|
39
39
|
return () => {
|
|
40
40
|
const editModeFromTabOptions =
|
|
41
41
|
filterComponentOptions?.tabOptions?.savedFilter?.editMode;
|
|
42
|
-
|
|
43
|
-
setFilterMaster(
|
|
44
|
-
(prev) =>
|
|
45
|
-
({
|
|
46
|
-
...prev,
|
|
47
|
-
saved_filters: {
|
|
48
|
-
...prev?.attributes,
|
|
49
|
-
selectedId: "",
|
|
50
|
-
selectedName: "",
|
|
51
|
-
selectedCode: "",
|
|
52
|
-
},
|
|
53
|
-
} as FilterMasterStateProps)
|
|
54
|
-
);
|
|
55
|
-
|
|
56
42
|
if (!editModeFromTabOptions) {
|
|
57
43
|
setEditMode && setEditMode(false);
|
|
44
|
+
setFilterMaster(
|
|
45
|
+
(prev) =>
|
|
46
|
+
({
|
|
47
|
+
...prev,
|
|
48
|
+
saved_filters: {
|
|
49
|
+
...prev?.attributes,
|
|
50
|
+
selectedId: "",
|
|
51
|
+
selectedName: "",
|
|
52
|
+
selectedCode: "",
|
|
53
|
+
},
|
|
54
|
+
} as FilterMasterStateProps)
|
|
55
|
+
);
|
|
58
56
|
}
|
|
59
57
|
};
|
|
60
58
|
}, []);
|
|
@@ -446,7 +446,9 @@ export function TableFilter({
|
|
|
446
446
|
|
|
447
447
|
onUpdateFilter && onUpdateFilter(inputValue || "");
|
|
448
448
|
setSaveFilterModalOpen(false);
|
|
449
|
-
|
|
449
|
+
let isSingleSavedFilterEditMode =
|
|
450
|
+
filterComponentOptions?.tabOptions?.savedFilter?.editMode;
|
|
451
|
+
if (!isSingleSavedFilterEditMode) setEditMode(false);
|
|
450
452
|
return;
|
|
451
453
|
}
|
|
452
454
|
|
|
@@ -500,7 +502,11 @@ export function TableFilter({
|
|
|
500
502
|
onClick: () => {
|
|
501
503
|
onDeleteFilter && onDeleteFilter();
|
|
502
504
|
setDeleteFilterModalOpen(false);
|
|
503
|
-
|
|
505
|
+
let isSingleSavedFilterEditMode =
|
|
506
|
+
filterComponentOptions?.tabOptions?.savedFilter?.editMode;
|
|
507
|
+
if (!isSingleSavedFilterEditMode) {
|
|
508
|
+
setEditMode && setEditMode(false);
|
|
509
|
+
}
|
|
504
510
|
},
|
|
505
511
|
variant: "contained",
|
|
506
512
|
sx: {
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
saveSettingsData,
|
|
22
22
|
updateSavedFilter,
|
|
23
23
|
viewSettingsDropDown,
|
|
24
|
+
getOperationList,
|
|
24
25
|
} from "../utils/apiColumn";
|
|
25
26
|
import {
|
|
26
27
|
FilterDataMainFilterEntityListProps,
|
|
@@ -355,3 +356,13 @@ export const useGetFilterEntityListAndCriteria = ({
|
|
|
355
356
|
|
|
356
357
|
return { filterEntityList, filterEntityWiseCriteria };
|
|
357
358
|
};
|
|
359
|
+
|
|
360
|
+
export const useGetOperationList = () => {
|
|
361
|
+
// First query to get meta data
|
|
362
|
+
const operationList = useQuery({
|
|
363
|
+
queryKey: ["operationList"],
|
|
364
|
+
queryFn: () => getOperationList(),
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
return { operationList };
|
|
368
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FilterStateProps, OperationList } from "../../types/filter";
|
|
2
|
+
|
|
3
|
+
export const hydrateSavedFilters = async (
|
|
4
|
+
savedFilters: FilterStateProps[],
|
|
5
|
+
operationList: OperationList
|
|
6
|
+
) => {
|
|
7
|
+
return savedFilters.map((filter) => {
|
|
8
|
+
// const attribute = tableStates..find(
|
|
9
|
+
// (attr) => attr.attribute_key === filter.filter_attribute
|
|
10
|
+
// );
|
|
11
|
+
if (typeof filter.filter_attribute_data_type === "undefined") {
|
|
12
|
+
return {
|
|
13
|
+
...filter,
|
|
14
|
+
dropdown_list: [],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const matchingDropdownList =
|
|
19
|
+
operationList[filter.filter_attribute_data_type] || [];
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
...filter,
|
|
23
|
+
dropdown_list: matchingDropdownList,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -194,6 +194,20 @@ export interface FilterStateProps {
|
|
|
194
194
|
datasource_list?: string | null;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
export interface OperationOption {
|
|
198
|
+
label: string;
|
|
199
|
+
value: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface OperationList {
|
|
203
|
+
text: OperationOption[];
|
|
204
|
+
number: OperationOption[];
|
|
205
|
+
date: OperationOption[];
|
|
206
|
+
select: OperationOption[];
|
|
207
|
+
multiselect: OperationOption[];
|
|
208
|
+
year: OperationOption[];
|
|
209
|
+
}
|
|
210
|
+
|
|
197
211
|
export interface createSavedFilterPayload {
|
|
198
212
|
name: string;
|
|
199
213
|
organization_id?: number;
|
package/src/view/ListingView.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { ENTITY_TYPE, MAPPED_ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
|
10
10
|
import {
|
|
11
11
|
useCommonFilterDropdownAPI,
|
|
12
12
|
useEntityTableAPI,
|
|
13
|
+
useGetOperationList,
|
|
13
14
|
useGetSettingsDataAPI,
|
|
14
15
|
useSaveSettingsDataAPI,
|
|
15
16
|
useSettingsDropDownAPI,
|
|
@@ -22,6 +23,7 @@ import { TableTabs } from "../listing/components/tabs";
|
|
|
22
23
|
import { QuickFilterSettings } from "../listing/components/table-settings";
|
|
23
24
|
import CraftTableFilterWrapper from "./FIlterWrapper";
|
|
24
25
|
import { saveLayoutAPI } from "../listing/libs/services/saveLayoutAPI";
|
|
26
|
+
import { hydrateSavedFilters } from "../listing/libs/utils/hydrate-saved-filters";
|
|
25
27
|
|
|
26
28
|
function ListingView() {
|
|
27
29
|
// const [mockLoading, setMockLoading] = useState<boolean>(true);
|
|
@@ -49,6 +51,7 @@ function ListingView() {
|
|
|
49
51
|
: metaQuery?.data?.default_filter?.value
|
|
50
52
|
);
|
|
51
53
|
const { saveSettingsDataMutation } = useSaveSettingsDataAPI(ENTITY_TYPE);
|
|
54
|
+
const { operationList } = useGetOperationList();
|
|
52
55
|
|
|
53
56
|
// const { dropdownData } = useCommonDropdownAPI(
|
|
54
57
|
// dropdownColumnList || metaQuery.data.column_list
|
|
@@ -139,8 +142,23 @@ function ListingView() {
|
|
|
139
142
|
fetchMeta();
|
|
140
143
|
}, [selectedTab]);
|
|
141
144
|
|
|
145
|
+
// useEffect(() => {
|
|
146
|
+
// setFilters(detailsQuery.data ?? []);
|
|
147
|
+
// }, [detailsQuery.data]);
|
|
148
|
+
|
|
142
149
|
useEffect(() => {
|
|
143
|
-
|
|
150
|
+
const setFilterDropdown = async () => {
|
|
151
|
+
if (Array.isArray(detailsQuery.data)) {
|
|
152
|
+
const hydrated = await hydrateSavedFilters(
|
|
153
|
+
detailsQuery.data,
|
|
154
|
+
operationList.data
|
|
155
|
+
);
|
|
156
|
+
setFilters(hydrated);
|
|
157
|
+
} else {
|
|
158
|
+
setFilters([]);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
setFilterDropdown();
|
|
144
162
|
}, [detailsQuery.data]);
|
|
145
163
|
|
|
146
164
|
useEffect(() => {
|
|
@@ -307,7 +325,7 @@ function ListingView() {
|
|
|
307
325
|
onChangeFunction={handleChangeFunction}
|
|
308
326
|
filterComponentOptions={{
|
|
309
327
|
showMainHeader: false,
|
|
310
|
-
showTabs:
|
|
328
|
+
showTabs: true,
|
|
311
329
|
isRuleEngine: true,
|
|
312
330
|
tabOptions: {
|
|
313
331
|
mainFilter: {
|