rez-table-listing-mui 1.0.39 → 1.0.41
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 +16 -24
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +22 -15
- package/src/assets/svg.tsx +61 -1
- package/src/components/common/loader/loader.tsx +20 -0
- package/src/components/table-settings/common/draggable-listitem.tsx +7 -6
- package/src/components/table-settings/common/listing-values.tsx +23 -24
- package/src/components/table-settings/components/column.tsx +111 -49
- package/src/components/table-settings/components/quick-tab.tsx +143 -29
- package/src/components/table-settings/components/sorting.tsx +201 -457
- package/src/components/table-settings/components/toggle-button-switch.tsx +1 -0
- package/src/components/table-settings/index.tsx +43 -19
- package/src/components/table-settings/style.ts +1 -4
- package/src/components/table-settings/tabs/vertical/custom-tab-panel.tsx +4 -3
- package/src/index.ts +2 -1
- package/src/libs/hooks/useCraftTableFilterSettings.tsx +25 -6
- package/src/libs/hooks/useEntityTableAPI.tsx +43 -10
- package/src/libs/utils/apiColumn.ts +24 -2
- package/src/main.tsx +12 -1
- package/src/types/filter-settings.ts +10 -0
- package/src/types/table-options.ts +3 -0
|
@@ -33,6 +33,7 @@ export default function CustomToggleSwitchButton({
|
|
|
33
33
|
<ToggleButtonGroup exclusive size="small" color="primary" {...props}>
|
|
34
34
|
{buttons.map((button) => (
|
|
35
35
|
<ToggleButton
|
|
36
|
+
key={button.label}
|
|
36
37
|
value={button?.value}
|
|
37
38
|
disabled={button?.isDisabled}
|
|
38
39
|
sx={selectedTabStyle}
|
|
@@ -18,23 +18,25 @@ import { CustomDialog, DialogTransition } from "./components/custom-dialog";
|
|
|
18
18
|
import { dialogStyles } from "./style";
|
|
19
19
|
import CustomButton from "./components/custom-button";
|
|
20
20
|
import { SETTINGS_TABS } from "./constants";
|
|
21
|
+
import Loader from "../common/loader/loader";
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
export function QuickFilterSettings({
|
|
23
24
|
show,
|
|
24
25
|
filterSettingStates,
|
|
25
26
|
onClose,
|
|
26
27
|
columnsData,
|
|
28
|
+
columnsDataLoading,
|
|
27
29
|
tabsApiData,
|
|
28
30
|
tabsApiDataLoading,
|
|
29
|
-
|
|
31
|
+
onSaveSettingsData,
|
|
32
|
+
}: QuickFilterModalProps) {
|
|
30
33
|
const [tabValue, setTabValue] = useState(0);
|
|
31
34
|
|
|
32
35
|
const {
|
|
33
36
|
showListViewSettings,
|
|
34
|
-
setSettingsData,
|
|
35
37
|
quickTabStates,
|
|
36
|
-
sortingTabState,
|
|
37
38
|
columnTabState,
|
|
39
|
+
sortingTabState,
|
|
38
40
|
} = filterSettingStates;
|
|
39
41
|
|
|
40
42
|
const hasAPIData = Boolean(Object.entries(columnsData).length);
|
|
@@ -43,6 +45,37 @@ const QuickFilterSettings = ({
|
|
|
43
45
|
setTabValue(newValue);
|
|
44
46
|
};
|
|
45
47
|
|
|
48
|
+
const handleSaveSetSettingsData = () => {
|
|
49
|
+
const copyColumnTabState = columnTabState?.isDefault
|
|
50
|
+
? {
|
|
51
|
+
isDefault: true,
|
|
52
|
+
show_list: columnTabState?.show_list || [],
|
|
53
|
+
hide_list: columnTabState?.hide_list || [],
|
|
54
|
+
}
|
|
55
|
+
: {
|
|
56
|
+
isDefault: false,
|
|
57
|
+
tabs: columnTabState?.tabs || [],
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const copySortingTabState = sortingTabState?.isDefault
|
|
61
|
+
? {
|
|
62
|
+
isDefault: true,
|
|
63
|
+
sortby: sortingTabState?.sortby || [],
|
|
64
|
+
}
|
|
65
|
+
: {
|
|
66
|
+
isDefault: false,
|
|
67
|
+
tabs: sortingTabState?.tabs || [],
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const modifiedSettingsData = {
|
|
71
|
+
quick_tab: quickTabStates,
|
|
72
|
+
column: copyColumnTabState,
|
|
73
|
+
sorting: copySortingTabState,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
onSaveSettingsData && onSaveSettingsData(modifiedSettingsData);
|
|
77
|
+
};
|
|
78
|
+
|
|
46
79
|
return (
|
|
47
80
|
<CustomDialog
|
|
48
81
|
open={show || showListViewSettings}
|
|
@@ -66,7 +99,9 @@ const QuickFilterSettings = ({
|
|
|
66
99
|
</DialogTitle>
|
|
67
100
|
|
|
68
101
|
<DialogContent>
|
|
69
|
-
{
|
|
102
|
+
{columnsDataLoading ? (
|
|
103
|
+
<Loader loaderText="Loading settings..." />
|
|
104
|
+
) : !hasAPIData ? ( // check if columns data is available
|
|
70
105
|
<Typography>Please pass meta data in component</Typography>
|
|
71
106
|
) : (
|
|
72
107
|
<>
|
|
@@ -110,24 +145,13 @@ const QuickFilterSettings = ({
|
|
|
110
145
|
)}
|
|
111
146
|
</DialogContent>
|
|
112
147
|
|
|
113
|
-
{hasAPIData && (
|
|
148
|
+
{!columnsDataLoading && hasAPIData && (
|
|
114
149
|
<DialogActions>
|
|
115
|
-
<CustomButton
|
|
116
|
-
onClick={() => {
|
|
117
|
-
setSettingsData((prev: any) => ({
|
|
118
|
-
...prev,
|
|
119
|
-
quick_tab: quickTabStates,
|
|
120
|
-
columns: columnTabState,
|
|
121
|
-
sorting: sortingTabState,
|
|
122
|
-
}));
|
|
123
|
-
}}
|
|
124
|
-
>
|
|
150
|
+
<CustomButton onClick={handleSaveSetSettingsData}>
|
|
125
151
|
Save Quick Filter
|
|
126
152
|
</CustomButton>
|
|
127
153
|
</DialogActions>
|
|
128
154
|
)}
|
|
129
155
|
</CustomDialog>
|
|
130
156
|
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export default QuickFilterSettings;
|
|
157
|
+
}
|
|
@@ -49,13 +49,13 @@ export const listingValuesStyles: ListingValuesStyleProps = {
|
|
|
49
49
|
border: "0.5px solid #0E0C0B1F",
|
|
50
50
|
borderRadius: "8px",
|
|
51
51
|
minHeight: "10rem",
|
|
52
|
+
backgroundColor: "#fdfdfc",
|
|
52
53
|
},
|
|
53
54
|
heading: { fontWeight: 400, color: "#0E0C0BB2", fontSize: "16px" },
|
|
54
55
|
button: { fontSize: "13px", textTransform: "none", color: "#0E0C0BB2" },
|
|
55
56
|
draggableContainer: {
|
|
56
57
|
maxHeight: 200,
|
|
57
58
|
borderRadius: 1,
|
|
58
|
-
p: 1,
|
|
59
59
|
mt: 2,
|
|
60
60
|
transition: "background-color 0.2s ease",
|
|
61
61
|
},
|
|
@@ -76,8 +76,6 @@ export const listingValuesStyles: ListingValuesStyleProps = {
|
|
|
76
76
|
export const TabsStyles: TabStyleProps = {
|
|
77
77
|
mainTabsHeader: {
|
|
78
78
|
fontStyle: "italic",
|
|
79
|
-
mb: 2,
|
|
80
|
-
display: "block",
|
|
81
79
|
fontWeight: 400,
|
|
82
80
|
fontSize: "12px",
|
|
83
81
|
color: "#0E0C0BB2",
|
|
@@ -108,7 +106,6 @@ export const TabsStyles: TabStyleProps = {
|
|
|
108
106
|
},
|
|
109
107
|
|
|
110
108
|
checkboxStyle: {
|
|
111
|
-
p: 2,
|
|
112
109
|
display: "flex",
|
|
113
110
|
flexDirection: "column",
|
|
114
111
|
},
|
|
@@ -14,15 +14,16 @@ const CustomTabPanel = ({
|
|
|
14
14
|
...props
|
|
15
15
|
}: TabPanelProps) => {
|
|
16
16
|
return (
|
|
17
|
-
<
|
|
17
|
+
<Box
|
|
18
18
|
role="tabpanel"
|
|
19
19
|
hidden={value !== index}
|
|
20
20
|
id={`simple-tabpanel-${index}`}
|
|
21
21
|
aria-labelledby={`simple-tab-${index}`}
|
|
22
22
|
{...props}
|
|
23
|
+
sx={{ height: "100%" }}
|
|
23
24
|
>
|
|
24
|
-
{value === index &&
|
|
25
|
-
</
|
|
25
|
+
{value === index && children}
|
|
26
|
+
</Box>
|
|
26
27
|
);
|
|
27
28
|
};
|
|
28
29
|
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { default as TableWrapper } from "./components/index-table";
|
|
2
2
|
export { useCraftTable } from "./libs/hooks/useCraftTable";
|
|
3
|
+
export { useCraftTableFilterSettings } from "./libs/hooks/useCraftTableFilterSettings";
|
|
3
4
|
export { TableTabs as CraftTableTabs } from "./components/tabs";
|
|
4
5
|
export { TableFilter as CraftTableFilter } from "./components/filter";
|
|
6
|
+
export { QuickFilterSettings as CraftTableSettings } from "./components/table-settings";
|
|
5
7
|
|
|
6
8
|
export * from "./types/table";
|
|
7
9
|
export * from "./types/table-options";
|
|
8
|
-
export * from "./types/filter-settings";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
2
|
import { craftTableFilterSettingsOptionsProps } from "../../types/table-options";
|
|
3
3
|
import {
|
|
4
4
|
ColumnTabConfigProps,
|
|
5
5
|
QuickTabConfigProps,
|
|
6
|
+
SavedButtonErrorProps,
|
|
6
7
|
SettingsDataProps,
|
|
7
8
|
SortingConfigProps,
|
|
8
9
|
} from "../../types/filter-settings";
|
|
@@ -148,16 +149,32 @@ export function useCraftTableFilterSettings() {
|
|
|
148
149
|
});
|
|
149
150
|
|
|
150
151
|
// Quick FIlter settings local states
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
);
|
|
152
|
+
|
|
153
|
+
const [quickTabStates, setQuickTabStates] = useState<QuickTabConfigProps>({});
|
|
154
154
|
const [columnTabState, setColumnTabState] = useState<ColumnTabConfigProps>(
|
|
155
|
-
|
|
155
|
+
{}
|
|
156
156
|
);
|
|
157
157
|
const [sortingTabState, setSortingTabState] = useState<SortingConfigProps>(
|
|
158
|
-
|
|
158
|
+
{}
|
|
159
159
|
);
|
|
160
160
|
|
|
161
|
+
// This state will be used for settings validation
|
|
162
|
+
const [saveButtonError, setSaveButtonError] = useState<SavedButtonErrorProps>(
|
|
163
|
+
{ hasError: false, messages: [] }
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (settingsData?.quick_tab) {
|
|
168
|
+
setQuickTabStates(settingsData?.quick_tab);
|
|
169
|
+
}
|
|
170
|
+
if (settingsData?.column) {
|
|
171
|
+
setColumnTabState(settingsData?.column);
|
|
172
|
+
}
|
|
173
|
+
if (settingsData?.sorting) {
|
|
174
|
+
setSortingTabState(settingsData?.sorting);
|
|
175
|
+
}
|
|
176
|
+
}, [settingsData]);
|
|
177
|
+
|
|
161
178
|
const craftTableFilterSettingsOptions: craftTableFilterSettingsOptionsProps =
|
|
162
179
|
{
|
|
163
180
|
settingsData: settingsData,
|
|
@@ -170,6 +187,8 @@ export function useCraftTableFilterSettings() {
|
|
|
170
187
|
setColumnTabState: setColumnTabState,
|
|
171
188
|
sortingTabState: sortingTabState,
|
|
172
189
|
setSortingTabState: setSortingTabState,
|
|
190
|
+
saveButtonError: saveButtonError,
|
|
191
|
+
setSaveButtonError: setSaveButtonError,
|
|
173
192
|
};
|
|
174
193
|
|
|
175
194
|
return craftTableFilterSettingsOptions;
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
commonGetDropdownDataAPI,
|
|
16
16
|
createSavedFilter,
|
|
17
17
|
deleteSavedFilter,
|
|
18
|
+
getSettingsData,
|
|
18
19
|
saveSettingsData,
|
|
19
20
|
updateSavedFilter,
|
|
20
21
|
viewSettingsDropDown,
|
|
@@ -251,16 +252,48 @@ export const useSettingsDropDownAPI = ({
|
|
|
251
252
|
return { settingsTabDropdownData, settingsTabDropdownPending };
|
|
252
253
|
};
|
|
253
254
|
|
|
254
|
-
export const useSaveSettingsDataAPI = ({ payload }: any) => {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
255
|
+
// export const useSaveSettingsDataAPI = ({ payload }: any) => {
|
|
256
|
+
// const { data: saveSettingsAPIData } = useQuery({
|
|
257
|
+
// queryKey: ["saveSettingsData", payload],
|
|
258
|
+
// queryFn: () =>
|
|
259
|
+
// saveSettingsData({
|
|
260
|
+
// entity_type: "LAP",
|
|
261
|
+
// mapped_entity_type: "AYR",
|
|
262
|
+
// layout_json: payload,
|
|
263
|
+
// }),
|
|
264
|
+
// enabled: !!payload && !!Object.entries(payload).length,
|
|
265
|
+
// });
|
|
266
|
+
|
|
267
|
+
// return { saveSettingsAPIData };
|
|
268
|
+
// };
|
|
269
|
+
|
|
270
|
+
export const useSaveSettingsDataAPI = (entity_type: string) => {
|
|
271
|
+
const queryClient = useQueryClient();
|
|
272
|
+
const saveSettingsDataMutation = useMutation({
|
|
273
|
+
mutationKey: ["saveSettingsData", entity_type],
|
|
274
|
+
mutationFn: ({ payload }: { payload: any }) => {
|
|
275
|
+
return saveSettingsData(payload);
|
|
276
|
+
},
|
|
277
|
+
onSuccess: () => {
|
|
278
|
+
queryClient.invalidateQueries({
|
|
279
|
+
queryKey: ["saveSettingsData"],
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
onError: (error: any) => {
|
|
283
|
+
const msg = error?.response?.data?.message;
|
|
284
|
+
console.log("Error in saving settings tab data", msg, error);
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
return { saveSettingsDataMutation };
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export const useGetSettingsDataAPI = (entity_type: string) => {
|
|
292
|
+
const { data: getSettingsAPIData } = useQuery({
|
|
293
|
+
queryKey: ["getSettingsData", entity_type],
|
|
294
|
+
queryFn: () => getSettingsData(entity_type),
|
|
295
|
+
enabled: !!entity_type,
|
|
263
296
|
});
|
|
264
297
|
|
|
265
|
-
return {
|
|
298
|
+
return { getSettingsAPIData };
|
|
266
299
|
};
|
|
@@ -122,9 +122,21 @@ export const updateSavedFilter = async (
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
+
// export const saveSettingsData = async (payload: any) => {
|
|
126
|
+
// try {
|
|
127
|
+
// const response = await api.post(`/layout/create`, payload);
|
|
128
|
+
// return response.data;
|
|
129
|
+
// } catch (error) {
|
|
130
|
+
// console.error("Failed to save settings data:", error);
|
|
131
|
+
// throw error;
|
|
132
|
+
// }
|
|
133
|
+
// };
|
|
134
|
+
|
|
135
|
+
// ALL View Settings API
|
|
136
|
+
|
|
125
137
|
export const saveSettingsData = async (payload: any) => {
|
|
126
138
|
try {
|
|
127
|
-
const response = await api.post(`/
|
|
139
|
+
const response = await api.post(`/entity/create?entity_type=LAP`, payload);
|
|
128
140
|
return response.data;
|
|
129
141
|
} catch (error) {
|
|
130
142
|
console.error("Failed to save settings data:", error);
|
|
@@ -132,7 +144,17 @@ export const saveSettingsData = async (payload: any) => {
|
|
|
132
144
|
}
|
|
133
145
|
};
|
|
134
146
|
|
|
135
|
-
|
|
147
|
+
export const getSettingsData = async (entity_type: any) => {
|
|
148
|
+
try {
|
|
149
|
+
const response = await api.get(
|
|
150
|
+
`layout-preference?entity_type=${entity_type}`
|
|
151
|
+
);
|
|
152
|
+
return response.data;
|
|
153
|
+
} catch (error) {
|
|
154
|
+
console.error("Failed to fetch settings data:", error);
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
136
158
|
|
|
137
159
|
export const viewSettingsDropDown = async ({
|
|
138
160
|
entity_type,
|
package/src/main.tsx
CHANGED
|
@@ -4,7 +4,18 @@ import App from "./App.tsx";
|
|
|
4
4
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
5
|
|
|
6
6
|
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
7
|
-
<QueryClientProvider
|
|
7
|
+
<QueryClientProvider
|
|
8
|
+
client={
|
|
9
|
+
new QueryClient({
|
|
10
|
+
defaultOptions: {
|
|
11
|
+
queries: {
|
|
12
|
+
refetchOnWindowFocus: false,
|
|
13
|
+
retry: 3,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
>
|
|
8
19
|
<React.StrictMode>
|
|
9
20
|
<App />
|
|
10
21
|
</React.StrictMode>
|
|
@@ -6,8 +6,10 @@ export interface QuickFilterModalProps {
|
|
|
6
6
|
filterSettingStates: craftTableFilterSettingsOptionsProps;
|
|
7
7
|
onClose?: () => void;
|
|
8
8
|
columnsData: FilterColumnsDataProps;
|
|
9
|
+
columnsDataLoading: boolean;
|
|
9
10
|
tabsApiData?: string[];
|
|
10
11
|
tabsApiDataLoading?: boolean;
|
|
12
|
+
onSaveSettingsData?: (data: any) => void;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
type TabName = string;
|
|
@@ -95,3 +97,11 @@ export interface ToggleButtonTabsProps {
|
|
|
95
97
|
value: boolean;
|
|
96
98
|
isDisabled: boolean;
|
|
97
99
|
}
|
|
100
|
+
|
|
101
|
+
export interface SavedButtonErrorProps {
|
|
102
|
+
hasError: boolean;
|
|
103
|
+
messages: {
|
|
104
|
+
type: string;
|
|
105
|
+
message: string;
|
|
106
|
+
}[];
|
|
107
|
+
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
ColumnTabConfigProps,
|
|
15
15
|
QuickTabConfigProps,
|
|
16
|
+
SavedButtonErrorProps,
|
|
16
17
|
SettingsDataProps,
|
|
17
18
|
SortingConfigProps,
|
|
18
19
|
} from "./filter-settings";
|
|
@@ -55,6 +56,8 @@ export interface craftTableFilterSettingsOptionsProps {
|
|
|
55
56
|
setColumnTabState: Dispatch<SetStateAction<ColumnTabConfigProps>>;
|
|
56
57
|
sortingTabState: SortingConfigProps;
|
|
57
58
|
setSortingTabState: Dispatch<SetStateAction<SortingConfigProps>>;
|
|
59
|
+
saveButtonError: SavedButtonErrorProps;
|
|
60
|
+
setSaveButtonError: Dispatch<SetStateAction<SavedButtonErrorProps>>;
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
export interface CraftTableFeatureProps {
|