rez-table-listing-mui 1.3.43 → 1.3.45
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 +70 -10
- 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/common/saved-filter-modal/index.tsx +517 -0
- package/src/listing/components/filter/components/attributes-filter.tsx +2 -2
- package/src/listing/components/filter/components/forms/components/Dropdown.tsx +2 -2
- package/src/listing/components/filter/components/forms/components/Filter-criteria.tsx +9 -7
- package/src/listing/components/filter/components/forms/components/Textfield.tsx +2 -4
- package/src/listing/components/filter/components/forms/components/filter-criteria-list.tsx +1 -0
- package/src/listing/components/filter/components/forms/index.tsx +23 -14
- package/src/listing/components/filter/components/forms/utils/filter-date-input-resolver.tsx +3 -3
- package/src/listing/components/filter/components/main-filter.tsx +6 -6
- package/src/listing/components/filter/components/saved-edit-filter.tsx +5 -3
- package/src/listing/components/filter/components/saved-filter.tsx +300 -124
- package/src/listing/components/filter/components/search/index.tsx +1 -0
- package/src/listing/components/filter/components/single-filter-rendering.tsx +3 -3
- package/src/listing/components/filter/index.tsx +130 -5
- package/src/listing/components/index-table.tsx +9 -0
- package/src/listing/components/login/index.tsx +3 -6
- package/src/listing/components/table-dnd.tsx +6 -0
- package/src/listing/components/table-head-dnd-cell.tsx +7 -0
- package/src/listing/components/table-head-popover.tsx +24 -3
- package/src/listing/components/table-head.tsx +10 -0
- package/src/listing/components/table-settings/components/column.tsx +85 -26
- package/src/listing/components/table-settings/components/quick-tab.tsx +395 -77
- package/src/listing/components/table-settings/components/sorting.tsx +60 -20
- package/src/listing/components/table-settings/index.tsx +12 -2
- package/src/listing/components/table.tsx +6 -0
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +20 -5
- package/src/listing/libs/utils/apiColumn.ts +8 -3
- package/src/listing/libs/utils/common.ts +2 -1
- package/src/listing/libs/utils/hydrate-saved-filters.ts +2 -2
- package/src/listing/types/common.ts +1 -0
- package/src/listing/types/filter-settings.ts +8 -2
- package/src/listing/types/filter.ts +51 -4
- package/src/listing/types/table.ts +9 -0
- package/src/view/FIlterWrapper.tsx +15 -0
- package/src/view/ListingView.tsx +178 -63
package/src/view/ListingView.tsx
CHANGED
|
@@ -10,15 +10,20 @@ import { ENTITY_TYPE, MAPPED_ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
|
10
10
|
import {
|
|
11
11
|
useCommonFilterDropdownAPI,
|
|
12
12
|
useEntityTableAPI,
|
|
13
|
+
useGetFilterEntityListAndCriteria,
|
|
13
14
|
useGetLayoutAttributes,
|
|
14
15
|
useGetOperationList,
|
|
16
|
+
useGetSettingsColumnAttributes,
|
|
15
17
|
useGetSettingsDataAPI,
|
|
16
18
|
useSaveSettingsDataAPI,
|
|
17
19
|
useSettingsDropDownAPI,
|
|
18
20
|
} from "../listing/libs/hooks/useEntityTableAPI";
|
|
19
21
|
import { entityTableMetaMaster } from "../listing/libs/utils/apiColumn";
|
|
20
22
|
import { ColumnDef } from "@tanstack/react-table";
|
|
21
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
ColumnTabConfigProps,
|
|
25
|
+
SettingsDataProps,
|
|
26
|
+
} from "../listing/types/filter-settings";
|
|
22
27
|
import TableWrapper from "../listing/components/index-table";
|
|
23
28
|
import { TableTabs } from "../listing/components/tabs";
|
|
24
29
|
import { QuickFilterSettings } from "../listing/components/table-settings";
|
|
@@ -28,6 +33,7 @@ import { hydrateSavedFilters } from "../listing/libs/utils/hydrate-saved-filters
|
|
|
28
33
|
import { useGetNavigationLayoutAPI } from "../listing/libs/hooks/useGetNavigationLayoutAPI";
|
|
29
34
|
import { useQueryClient } from "@tanstack/react-query";
|
|
30
35
|
import { Box, CircularProgress, Typography } from "@mui/material";
|
|
36
|
+
import { ColumnItem } from "../listing/components/table-settings/components/column";
|
|
31
37
|
|
|
32
38
|
function ListingView() {
|
|
33
39
|
// const [mockLoading, setMockLoading] = useState<boolean>(true);
|
|
@@ -55,16 +61,27 @@ function ListingView() {
|
|
|
55
61
|
: metaQuery?.data?.default_filter?.value
|
|
56
62
|
);
|
|
57
63
|
const { saveSettingsDataMutation } = useSaveSettingsDataAPI(ENTITY_TYPE);
|
|
64
|
+
const { settingsColumnAttributes } =
|
|
65
|
+
useGetSettingsColumnAttributes(ENTITY_TYPE);
|
|
58
66
|
const { operationList } = useGetOperationList();
|
|
59
67
|
|
|
60
68
|
const { layoutAttributes: quickTabAttributes } = useGetLayoutAttributes({
|
|
61
69
|
entity_type: ENTITY_TYPE,
|
|
62
|
-
|
|
70
|
+
data_type: "select",
|
|
63
71
|
});
|
|
64
72
|
|
|
65
73
|
const { layoutAttributes: sortingTabAttributes } = useGetLayoutAttributes({
|
|
66
74
|
entity_type: ENTITY_TYPE,
|
|
67
75
|
});
|
|
76
|
+
const isColumnDefault =
|
|
77
|
+
filterSettingStates?.columnTabState?.isDefault || false;
|
|
78
|
+
const activeTabIndex = filterSettingStates?.columnTabState?.tabs?.findIndex(
|
|
79
|
+
(tab) =>
|
|
80
|
+
tab?.tab_name?.value == selectedTab ||
|
|
81
|
+
tab?.tab_name?.label?.toLowerCase() == selectedTab?.toLowerCase()
|
|
82
|
+
);
|
|
83
|
+
const settingsColumnState = (filterSettingStates?.settingsData?.column ||
|
|
84
|
+
{}) as ColumnTabConfigProps;
|
|
68
85
|
|
|
69
86
|
// const { dropdownData } = useCommonDropdownAPI(
|
|
70
87
|
// dropdownColumnList || metaQuery.data.column_list
|
|
@@ -81,77 +98,84 @@ function ListingView() {
|
|
|
81
98
|
const queryClient = useQueryClient();
|
|
82
99
|
const { data: getSettingsAPIData } = useGetNavigationLayoutAPI(ENTITY_TYPE);
|
|
83
100
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
) =>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
101
|
+
const fetchMeta = async () => {
|
|
102
|
+
try {
|
|
103
|
+
const { res: allColumns } = await entityTableMetaMaster(ENTITY_TYPE);
|
|
104
|
+
|
|
105
|
+
const savedColumnSettings = filterSettingStates.settingsData?.column;
|
|
106
|
+
|
|
107
|
+
const getOrderedColumns = (
|
|
108
|
+
showList: { value: string }[],
|
|
109
|
+
filteredColumns: any[]
|
|
110
|
+
) => {
|
|
111
|
+
// Build ordered columns using showList and filteredColumns
|
|
112
|
+
// const orderedColumns = showList
|
|
113
|
+
// ?.map((showItem) => {
|
|
114
|
+
// return filteredColumns.find(
|
|
115
|
+
// (col) => col?.accessorKey === showItem?.value
|
|
116
|
+
// );
|
|
117
|
+
// })
|
|
118
|
+
// ?.filter((col): col is ColumnDef<any> => col !== undefined); // Ensure non-undefined columns are returned
|
|
119
|
+
|
|
120
|
+
// didnt know what above code was doing so rewrote it as below
|
|
121
|
+
const res = showList.map((item: any) => ({
|
|
122
|
+
id: item.value,
|
|
123
|
+
accessorKey: item.value,
|
|
124
|
+
header: item.label,
|
|
125
|
+
}));
|
|
126
|
+
|
|
127
|
+
return res;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
if (
|
|
131
|
+
savedColumnSettings &&
|
|
132
|
+
!savedColumnSettings.isDefault &&
|
|
133
|
+
savedColumnSettings.tabs
|
|
134
|
+
) {
|
|
135
|
+
// Tab-wise view: find the active tab and use its show_list
|
|
136
|
+
const activeTabSettings = savedColumnSettings.tabs.find(
|
|
137
|
+
(tab) => tab.tab_name?.value == selectedTab.toLowerCase()
|
|
138
|
+
);
|
|
118
139
|
|
|
119
|
-
|
|
120
|
-
const visibleColumns = new Set(
|
|
121
|
-
activeTabSettings.show_list.map((c) => c.value)
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
// First, filter columns based on visibleColumns
|
|
125
|
-
const filteredColumns = allColumns.filter((col: any) =>
|
|
126
|
-
visibleColumns.has(col?.accessorKey)
|
|
127
|
-
);
|
|
128
|
-
setColumns(
|
|
129
|
-
getOrderedColumns(activeTabSettings.show_list, filteredColumns)
|
|
130
|
-
);
|
|
131
|
-
} else {
|
|
132
|
-
// Fallback if no specific settings for the active tab are found
|
|
133
|
-
setColumns(allColumns);
|
|
134
|
-
}
|
|
135
|
-
} else if (savedColumnSettings && savedColumnSettings.show_list) {
|
|
136
|
-
// Default view: use the main show_list
|
|
140
|
+
if (activeTabSettings?.show_list) {
|
|
137
141
|
const visibleColumns = new Set(
|
|
138
|
-
|
|
142
|
+
activeTabSettings.show_list.map((c) => c.value)
|
|
139
143
|
);
|
|
140
|
-
|
|
144
|
+
|
|
145
|
+
// First, filter columns based on visibleColumns
|
|
146
|
+
const filteredColumns = allColumns.filter((col: any) =>
|
|
141
147
|
visibleColumns.has(col?.accessorKey)
|
|
142
148
|
);
|
|
143
|
-
|
|
144
149
|
setColumns(
|
|
145
|
-
getOrderedColumns(
|
|
150
|
+
getOrderedColumns(activeTabSettings.show_list, filteredColumns)
|
|
146
151
|
);
|
|
147
152
|
} else {
|
|
148
|
-
//
|
|
153
|
+
// Fallback if no specific settings for the active tab are found
|
|
149
154
|
setColumns(allColumns);
|
|
150
155
|
}
|
|
151
|
-
}
|
|
152
|
-
|
|
156
|
+
} else if (savedColumnSettings && savedColumnSettings.show_list) {
|
|
157
|
+
// Default view: use the main show_list
|
|
158
|
+
const visibleColumns = new Set(
|
|
159
|
+
savedColumnSettings.show_list.map((c) => c.value)
|
|
160
|
+
);
|
|
161
|
+
const filtered = allColumns.filter((col: any) =>
|
|
162
|
+
visibleColumns.has(col?.accessorKey)
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
setColumns(getOrderedColumns(savedColumnSettings.show_list, filtered));
|
|
166
|
+
} else {
|
|
167
|
+
// No settings found, use all columns
|
|
168
|
+
setColumns(allColumns);
|
|
153
169
|
}
|
|
154
|
-
}
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.error("Failed to fetch metadata:", error);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
// setTimeout(() => {
|
|
177
|
+
// setMockLoading(false);
|
|
178
|
+
// }, 1000);
|
|
155
179
|
|
|
156
180
|
fetchMeta();
|
|
157
181
|
}, [selectedTab]);
|
|
@@ -240,6 +264,91 @@ function ListingView() {
|
|
|
240
264
|
);
|
|
241
265
|
}, [tableData, selectedTab]);
|
|
242
266
|
|
|
267
|
+
const moveColumn = (
|
|
268
|
+
columnId: string,
|
|
269
|
+
showList: ColumnItem[],
|
|
270
|
+
hideList: ColumnItem[]
|
|
271
|
+
) => {
|
|
272
|
+
const itemToMove = showList.find((c) => c.value === columnId);
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
newShow: showList.filter((c) => c.value !== columnId),
|
|
276
|
+
newHide: itemToMove
|
|
277
|
+
? [...hideList.filter((c) => c.value !== columnId), itemToMove]
|
|
278
|
+
: hideList,
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const handleSaveSettings = (columnId: string) => {
|
|
283
|
+
let settingsData = filterSettingStates.settingsData;
|
|
284
|
+
|
|
285
|
+
const columnData = settingsData.column;
|
|
286
|
+
const defaultMode = isColumnDefault;
|
|
287
|
+
|
|
288
|
+
if (defaultMode) {
|
|
289
|
+
// Move for default mode
|
|
290
|
+
const { newShow, newHide } = moveColumn(
|
|
291
|
+
columnId,
|
|
292
|
+
columnData.show_list as ColumnItem[],
|
|
293
|
+
columnData.hide_list as ColumnItem[]
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
settingsData = {
|
|
297
|
+
...settingsData,
|
|
298
|
+
column: {
|
|
299
|
+
...columnData,
|
|
300
|
+
show_list: newShow,
|
|
301
|
+
hide_list: newHide,
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
} else {
|
|
305
|
+
// Move inside specific TAB
|
|
306
|
+
const updatedTabs = [...settingsColumnState?.tabs];
|
|
307
|
+
const tab = updatedTabs[activeTabIndex];
|
|
308
|
+
|
|
309
|
+
const { newShow, newHide } = moveColumn(
|
|
310
|
+
columnId,
|
|
311
|
+
tab.show_list,
|
|
312
|
+
tab.hide_list
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
updatedTabs[activeTabIndex] = {
|
|
316
|
+
...tab,
|
|
317
|
+
show_list: newShow,
|
|
318
|
+
hide_list: newHide,
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
settingsData = {
|
|
322
|
+
...settingsData,
|
|
323
|
+
column: {
|
|
324
|
+
...columnData,
|
|
325
|
+
tabs: updatedTabs,
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
setSettingsData(settingsData);
|
|
331
|
+
|
|
332
|
+
saveSettingsDataMutation.mutate(
|
|
333
|
+
{
|
|
334
|
+
payload: {
|
|
335
|
+
entity_type: MAPPED_ENTITY_TYPE,
|
|
336
|
+
mapped_entity_type: ENTITY_TYPE,
|
|
337
|
+
mapped_json: settingsData,
|
|
338
|
+
type: "layout",
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
onSuccess: () => {
|
|
343
|
+
queryClient.invalidateQueries({
|
|
344
|
+
queryKey: ["GET_NAVIGATION_LAYOUT", ENTITY_TYPE],
|
|
345
|
+
});
|
|
346
|
+
fetchMeta();
|
|
347
|
+
},
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
};
|
|
351
|
+
|
|
243
352
|
const handleRenderStatus = ({ value }: any) => {
|
|
244
353
|
const statusValue = value?.toUpperCase();
|
|
245
354
|
return (
|
|
@@ -280,7 +389,7 @@ function ListingView() {
|
|
|
280
389
|
entity_type: MAPPED_ENTITY_TYPE,
|
|
281
390
|
mapped_entity_type: ENTITY_TYPE,
|
|
282
391
|
mapped_json: data,
|
|
283
|
-
type: "
|
|
392
|
+
type: "filter",
|
|
284
393
|
};
|
|
285
394
|
|
|
286
395
|
await saveLayoutAPI(payload);
|
|
@@ -326,8 +435,11 @@ function ListingView() {
|
|
|
326
435
|
) : (
|
|
327
436
|
<TableWrapper
|
|
328
437
|
data={filteredData}
|
|
438
|
+
activeTab={selectedTab}
|
|
329
439
|
columns={columns && columns.length > 0 ? columns : defaultColumns}
|
|
330
440
|
tableStates={tableStates}
|
|
441
|
+
filterSettingStates={filterSettingStates}
|
|
442
|
+
onSaveSettings={handleSaveSettings}
|
|
331
443
|
featureOptions={{
|
|
332
444
|
striped: true,
|
|
333
445
|
compactTable: false,
|
|
@@ -430,11 +542,14 @@ function ListingView() {
|
|
|
430
542
|
columnsDataLoading={metaQuery.isPending}
|
|
431
543
|
quickTabAttributes={quickTabAttributes?.data}
|
|
432
544
|
quickTabAttributesLoading={quickTabAttributes?.isLoading}
|
|
545
|
+
columnTabAttributes={settingsColumnAttributes?.data}
|
|
546
|
+
columnAttributesLoading={settingsColumnAttributes?.isLoading}
|
|
433
547
|
sortingTabAttributes={sortingTabAttributes?.data}
|
|
434
548
|
sortingTabAttributesLoading={sortingTabAttributes?.isLoading}
|
|
435
549
|
tabsApiData={settingsTabDropdownData || []}
|
|
436
550
|
tabsApiDataLoading={settingsTabDropdownPending}
|
|
437
551
|
onSaveSettingsData={handleSaveSettingsData}
|
|
552
|
+
activeTab={selectedTab}
|
|
438
553
|
/>
|
|
439
554
|
</>
|
|
440
555
|
),
|