rez-table-listing-mui 2.0.7 → 2.0.9
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 +3 -3
- 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/filter-criteria-entity-list.tsx +1 -1
- package/src/listing/components/table-body/table-body.styles.ts +1 -1
- package/src/listing/components/table-head/table-head.styles.ts +1 -1
- package/src/listing/components/table-settings/components/column.tsx +14 -1
- package/src/listing/components/table-settings/components/quick-tab.tsx +9 -1
- package/src/listing/components/tabs/index.tsx +15 -15
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +54 -4
- package/src/listing/libs/utils/apiColumn.ts +46 -5
- package/src/view/ListingView.tsx +20 -13
package/package.json
CHANGED
package/src/listing/components/filter/components/forms/components/filter-criteria-entity-list.tsx
CHANGED
|
@@ -42,7 +42,7 @@ const FilterCriteriaEntityList = ({
|
|
|
42
42
|
|
|
43
43
|
// Case 2: default behavior (apply search filter)
|
|
44
44
|
return allEntities.filter((entity) =>
|
|
45
|
-
entity.label
|
|
45
|
+
entity.label?.toLowerCase().includes(searchTerm?.toLowerCase())
|
|
46
46
|
);
|
|
47
47
|
}, [isSingleEntity, filters, allEntities, searchTerm]);
|
|
48
48
|
|
|
@@ -47,7 +47,7 @@ export const TableBodyCell = styled("td", {
|
|
|
47
47
|
wrap?: boolean;
|
|
48
48
|
}>(({ theme, compact, isDragging, wrap }) => ({
|
|
49
49
|
fontSize: theme.typography.pxToRem(14),
|
|
50
|
-
padding: compact ? theme.spacing(0.
|
|
50
|
+
padding: compact ? theme.spacing(0.5, 0.75) : theme.spacing(0.75, 1.25),
|
|
51
51
|
borderBottom: `1px solid ${theme.palette.grey[200]}`,
|
|
52
52
|
|
|
53
53
|
...(wrap && {
|
|
@@ -96,7 +96,7 @@ export const TableHeadCell = styled("th", {
|
|
|
96
96
|
sticky?: boolean;
|
|
97
97
|
}>(({ theme, compact, isDragging, isPinned, sticky }) => ({
|
|
98
98
|
position: "relative",
|
|
99
|
-
padding: compact ? theme.spacing(0.
|
|
99
|
+
padding: compact ? theme.spacing(0.5, 0.75) : theme.spacing(0.75, 1.25),
|
|
100
100
|
border: `0.5px solid ${theme.palette.grey[200]}`,
|
|
101
101
|
cursor: "pointer",
|
|
102
102
|
backgroundColor: theme.palette.common.white,
|
|
@@ -190,11 +190,24 @@ const ColumnTab = ({
|
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
+
const constructHideList = (): ColumnItem[] => {
|
|
194
|
+
return (
|
|
195
|
+
columnTabAttributes
|
|
196
|
+
?.map((column) => ({
|
|
197
|
+
label: column?.name,
|
|
198
|
+
value: column?.attribute_key,
|
|
199
|
+
}))
|
|
200
|
+
?.filter(
|
|
201
|
+
(tab) =>
|
|
202
|
+
!settingsColumnState?.show_list?.find((i) => i.value === tab.value)
|
|
203
|
+
) || []
|
|
204
|
+
);
|
|
205
|
+
};
|
|
193
206
|
const getCurrentLists = () => {
|
|
194
207
|
if (settingsColumnState?.isDefault) {
|
|
195
208
|
return {
|
|
196
209
|
showList: settingsColumnState.show_list || [],
|
|
197
|
-
hideList:
|
|
210
|
+
hideList: constructHideList() || [],
|
|
198
211
|
};
|
|
199
212
|
} else {
|
|
200
213
|
const currentTab = settingsColumnState?.tabs?.[selectedTabIndex];
|
|
@@ -106,6 +106,8 @@ const QuickTab = ({
|
|
|
106
106
|
show_list: [],
|
|
107
107
|
},
|
|
108
108
|
}));
|
|
109
|
+
|
|
110
|
+
setCurrentQuickAttribute("");
|
|
109
111
|
}
|
|
110
112
|
}, [tabsApiData]);
|
|
111
113
|
|
|
@@ -174,8 +176,14 @@ const QuickTab = ({
|
|
|
174
176
|
];
|
|
175
177
|
|
|
176
178
|
// Convert show_list/hide_list to FilterValue[] for rendering only
|
|
179
|
+
|
|
180
|
+
const constructHideList = () => {
|
|
181
|
+
return tabsApiData?.filter(
|
|
182
|
+
(tab) => !showListValues?.find((i) => i.value === tab.value)
|
|
183
|
+
);
|
|
184
|
+
};
|
|
177
185
|
const showListValues = quickTabStates?.show_list || [];
|
|
178
|
-
const hideListValues =
|
|
186
|
+
const hideListValues = constructHideList() || [];
|
|
179
187
|
|
|
180
188
|
const sensors = useSensors(
|
|
181
189
|
useSensor(MouseSensor),
|
|
@@ -6,14 +6,14 @@ import { TableTab, TableTabCount, TableTabsRoot } from "./tabs.styles";
|
|
|
6
6
|
import { SettingsOutlined } from "@mui/icons-material";
|
|
7
7
|
|
|
8
8
|
interface TabDataProps {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
tab_name: string | null;
|
|
10
|
+
count?: string | number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
interface TableTabsProps {
|
|
14
14
|
loading?: boolean;
|
|
15
15
|
tabsData?: TabDataProps[];
|
|
16
|
-
activeTab?:
|
|
16
|
+
activeTab?: TabDataProps;
|
|
17
17
|
tableStates: CraftTableOptionsProps;
|
|
18
18
|
onClick: (state: string) => void;
|
|
19
19
|
settingsOptions?: settingsOptionsProps;
|
|
@@ -22,7 +22,7 @@ interface TableTabsProps {
|
|
|
22
22
|
export function TableTabs({
|
|
23
23
|
loading = false,
|
|
24
24
|
tabsData = [],
|
|
25
|
-
activeTab = "All",
|
|
25
|
+
activeTab = { tab_name: "All", count: 0 },
|
|
26
26
|
onClick,
|
|
27
27
|
tableStates,
|
|
28
28
|
settingsOptions,
|
|
@@ -39,22 +39,22 @@ export function TableTabs({
|
|
|
39
39
|
|
|
40
40
|
const normalizedTabs = useMemo(() => {
|
|
41
41
|
return tabsData
|
|
42
|
-
?.filter((tab) => tab.
|
|
42
|
+
?.filter((tab) => tab.tab_name !== null)
|
|
43
43
|
?.map((tab) => ({
|
|
44
44
|
...tab,
|
|
45
|
-
|
|
45
|
+
tab_name: tab.tab_name,
|
|
46
46
|
}));
|
|
47
47
|
}, [tabsData]);
|
|
48
48
|
|
|
49
49
|
const defaultTab = useMemo(() => {
|
|
50
50
|
return (
|
|
51
|
-
normalizedTabs.find((t) => t.
|
|
52
|
-
normalizedTabs[0]?.
|
|
51
|
+
normalizedTabs.find((t) => t.tab_name === "All")?.tab_name ||
|
|
52
|
+
normalizedTabs[0]?.tab_name ||
|
|
53
53
|
""
|
|
54
54
|
);
|
|
55
55
|
}, [normalizedTabs]);
|
|
56
56
|
|
|
57
|
-
const selectedTab = activeTab || defaultTab;
|
|
57
|
+
const selectedTab = activeTab?.tab_name || defaultTab;
|
|
58
58
|
|
|
59
59
|
return (
|
|
60
60
|
<Box display="flex" alignItems="center" justifyContent="flex-start">
|
|
@@ -73,21 +73,21 @@ export function TableTabs({
|
|
|
73
73
|
scrollButtons="auto"
|
|
74
74
|
>
|
|
75
75
|
{normalizedTabs.map((tab) => {
|
|
76
|
-
const isSelected = activeTab === tab?.
|
|
76
|
+
const isSelected = activeTab?.tab_name === tab?.tab_name;
|
|
77
77
|
|
|
78
78
|
return (
|
|
79
79
|
<TableTab
|
|
80
|
-
key={tab?.
|
|
81
|
-
value={tab
|
|
80
|
+
key={tab?.tab_name}
|
|
81
|
+
value={tab}
|
|
82
82
|
label={
|
|
83
83
|
<Box display="flex" alignItems="center" gap={1}>
|
|
84
84
|
<Box sx={{ color: isSelected ? "#000" : "" }}>
|
|
85
|
-
{tab?.
|
|
85
|
+
{tab?.tab_name}
|
|
86
86
|
</Box>
|
|
87
87
|
<TableTabCount selected={isSelected}>
|
|
88
|
-
{tab?.
|
|
88
|
+
{tab?.count == 0
|
|
89
89
|
? "0"
|
|
90
|
-
: String(tab?.
|
|
90
|
+
: String(tab?.count).padStart(2, "0")}
|
|
91
91
|
</TableTabCount>
|
|
92
92
|
</Box>
|
|
93
93
|
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
getLayoutAttributes,
|
|
26
26
|
getAttributes,
|
|
27
27
|
getTableTabs,
|
|
28
|
+
newCommonGetDropdownDataAPI,
|
|
28
29
|
} from "../utils/apiColumn";
|
|
29
30
|
import {
|
|
30
31
|
FilterDataMainFilterEntityListProps,
|
|
@@ -269,7 +270,11 @@ export const useCommonFilterDropdownAPI = (
|
|
|
269
270
|
queries: dropdownConfigs.map((cfg) => {
|
|
270
271
|
return {
|
|
271
272
|
queryKey: ["commonDropdown", cfg?.dataSourceType],
|
|
272
|
-
queryFn: () =>
|
|
273
|
+
queryFn: () =>
|
|
274
|
+
newCommonGetDropdownDataAPI({
|
|
275
|
+
entity_type: "ROL",
|
|
276
|
+
attribute_key: cfg?.key,
|
|
277
|
+
}),
|
|
273
278
|
enabled: !!cfg?.dataSourceType,
|
|
274
279
|
};
|
|
275
280
|
}),
|
|
@@ -364,10 +369,14 @@ export const useGetFilterEntityListAndCriteria = ({
|
|
|
364
369
|
return { filterEntityList, filterEntityWiseCriteria };
|
|
365
370
|
};
|
|
366
371
|
|
|
367
|
-
export const useGetAttributes = (
|
|
372
|
+
export const useGetAttributes = (
|
|
373
|
+
entity_type: string,
|
|
374
|
+
element_type?: string
|
|
375
|
+
) => {
|
|
368
376
|
const attributes = useQuery({
|
|
369
|
-
queryKey: ["attributes", entity_type],
|
|
370
|
-
queryFn: () => getAttributes(entity_type),
|
|
377
|
+
queryKey: ["attributes", entity_type, element_type],
|
|
378
|
+
queryFn: () => getAttributes(entity_type, element_type),
|
|
379
|
+
enabled: !!entity_type, // optional safety
|
|
371
380
|
});
|
|
372
381
|
|
|
373
382
|
return { attributes };
|
|
@@ -409,6 +418,47 @@ export const useGetTableTabs = (payload: any) => {
|
|
|
409
418
|
});
|
|
410
419
|
return { tableTabs, isLoading };
|
|
411
420
|
};
|
|
421
|
+
|
|
422
|
+
export const useDropdownAPI = ({
|
|
423
|
+
entity_type,
|
|
424
|
+
attribute_key,
|
|
425
|
+
inactiveIds,
|
|
426
|
+
parentId,
|
|
427
|
+
data,
|
|
428
|
+
enabled = true,
|
|
429
|
+
}: {
|
|
430
|
+
entity_type: string;
|
|
431
|
+
attribute_key?: string;
|
|
432
|
+
inactiveIds?: string | null;
|
|
433
|
+
parentId?: number | string;
|
|
434
|
+
data?: any;
|
|
435
|
+
enabled?: boolean;
|
|
436
|
+
}) => {
|
|
437
|
+
const query = useQuery({
|
|
438
|
+
queryKey: [
|
|
439
|
+
"commonDropdown",
|
|
440
|
+
entity_type,
|
|
441
|
+
attribute_key,
|
|
442
|
+
inactiveIds,
|
|
443
|
+
parentId,
|
|
444
|
+
],
|
|
445
|
+
queryFn: () =>
|
|
446
|
+
newCommonGetDropdownDataAPI({
|
|
447
|
+
entity_type,
|
|
448
|
+
attribute_key,
|
|
449
|
+
inactiveIds,
|
|
450
|
+
parentId,
|
|
451
|
+
data,
|
|
452
|
+
}),
|
|
453
|
+
enabled, // prevents auto call unless needed
|
|
454
|
+
staleTime: 5 * 60 * 1000, // cache for 5 mins
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
return {
|
|
458
|
+
...query,
|
|
459
|
+
dropdownData: query.data || [],
|
|
460
|
+
};
|
|
461
|
+
};
|
|
412
462
|
// export const useGetSettingsColumnAttributes = (entity_type: string) => {
|
|
413
463
|
// // First query to get meta data
|
|
414
464
|
// const settingsColumnAttributes = useQuery({
|
|
@@ -209,11 +209,17 @@ export const getLayoutAttributes = async ({
|
|
|
209
209
|
return response.data;
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
-
export const getAttributes = async (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
export const getAttributes = async (
|
|
213
|
+
entity_type: string,
|
|
214
|
+
element_type?: string
|
|
215
|
+
) => {
|
|
216
|
+
const response = await api.get("/meta/attribute-master/getAttributes", {
|
|
217
|
+
params: {
|
|
218
|
+
// direct: false, // commented as per requirement
|
|
219
|
+
entity_type,
|
|
220
|
+
...(element_type && { element_type }),
|
|
221
|
+
},
|
|
222
|
+
});
|
|
217
223
|
|
|
218
224
|
return response.data;
|
|
219
225
|
};
|
|
@@ -222,3 +228,38 @@ export const getTableTabs = async (payload: any) => {
|
|
|
222
228
|
const response = await api.post(`filter/adm/tabs`, payload);
|
|
223
229
|
return response.data;
|
|
224
230
|
};
|
|
231
|
+
|
|
232
|
+
export const newCommonGetDropdownDataAPI = async ({
|
|
233
|
+
entity_type,
|
|
234
|
+
attribute_key,
|
|
235
|
+
// organization_id,
|
|
236
|
+
data,
|
|
237
|
+
inactiveIds,
|
|
238
|
+
parentId,
|
|
239
|
+
}: {
|
|
240
|
+
entity_type: string | undefined;
|
|
241
|
+
attribute_key?: string;
|
|
242
|
+
// organization_id?: string | null;
|
|
243
|
+
data?: any;
|
|
244
|
+
inactiveIds?: string | null;
|
|
245
|
+
parentId?: number | string;
|
|
246
|
+
}) => {
|
|
247
|
+
// Body can still accept optional custom data if needed
|
|
248
|
+
const requestBody = data || {};
|
|
249
|
+
|
|
250
|
+
// Build query params dynamically
|
|
251
|
+
const queryParams: string[] = [];
|
|
252
|
+
|
|
253
|
+
if (entity_type) queryParams.push(`entity_type=${entity_type}`);
|
|
254
|
+
if (attribute_key) queryParams.push(`attribute_key=${attribute_key}`);
|
|
255
|
+
if (!Number.isNaN(Number(inactiveIds)) && inactiveIds)
|
|
256
|
+
queryParams.push(`inactiveIds=${inactiveIds}`);
|
|
257
|
+
if (parentId !== undefined && parentId !== null)
|
|
258
|
+
queryParams.push(`parent=${parentId}`);
|
|
259
|
+
|
|
260
|
+
const queryString = queryParams.length > 0 ? `?${queryParams.join("&")}` : "";
|
|
261
|
+
|
|
262
|
+
return await api
|
|
263
|
+
.post(`entity/getAttributeDropdown${queryString}`, requestBody)
|
|
264
|
+
.then((response) => response.data);
|
|
265
|
+
};
|
package/src/view/ListingView.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "../listing/libs/utils/common";
|
|
14
14
|
import {
|
|
15
15
|
useCommonFilterDropdownAPI,
|
|
16
|
+
useDropdownAPI,
|
|
16
17
|
useEntityTableAPI,
|
|
17
18
|
useGetAttributes,
|
|
18
19
|
useGetOperationList,
|
|
@@ -92,6 +93,10 @@ function ListingView() {
|
|
|
92
93
|
const { operationList } = useGetOperationList();
|
|
93
94
|
|
|
94
95
|
const { attributes } = useGetAttributes(ENTITY_TYPE);
|
|
96
|
+
const { attributes: quickTabAttributes } = useGetAttributes(
|
|
97
|
+
ENTITY_TYPE,
|
|
98
|
+
"select"
|
|
99
|
+
);
|
|
95
100
|
|
|
96
101
|
const isColumnDefault =
|
|
97
102
|
filterSettingStates?.columnTabState?.isDefault || false;
|
|
@@ -106,12 +111,14 @@ function ListingView() {
|
|
|
106
111
|
// );
|
|
107
112
|
// const { dropdownData } = useCommonDropdownAPI(filters);
|
|
108
113
|
const { dropdownFilterData } = useCommonFilterDropdownAPI(filters);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
|
|
115
|
+
const {
|
|
116
|
+
data: settingsTabDropdownData,
|
|
117
|
+
isLoading: settingsTabDropdownPending,
|
|
118
|
+
} = useDropdownAPI({
|
|
119
|
+
entity_type: ENTITY_TYPE,
|
|
120
|
+
attribute_key: filterSettingStates?.quickTabStates?.attribute,
|
|
121
|
+
});
|
|
115
122
|
|
|
116
123
|
const queryClient = useQueryClient();
|
|
117
124
|
|
|
@@ -399,7 +406,7 @@ function ListingView() {
|
|
|
399
406
|
filterSettingStates={filterSettingStates}
|
|
400
407
|
onSaveSettings={handleSaveSettings}
|
|
401
408
|
featureOptions={{
|
|
402
|
-
|
|
409
|
+
striped: true,
|
|
403
410
|
compactTable: false,
|
|
404
411
|
enableSorting: !enableServerSideSorting,
|
|
405
412
|
enableColumnReordering: true,
|
|
@@ -498,7 +505,7 @@ function ListingView() {
|
|
|
498
505
|
onClose={() => setShowListViewSettings(false)}
|
|
499
506
|
columnsData={metaQuery.data || {}}
|
|
500
507
|
columnsDataLoading={metaQuery.isPending}
|
|
501
|
-
quickTabAttributes={
|
|
508
|
+
quickTabAttributes={quickTabAttributes?.data?.map((item) => ({
|
|
502
509
|
label: item.name,
|
|
503
510
|
value: item.attribute_key,
|
|
504
511
|
}))}
|
|
@@ -518,13 +525,13 @@ function ListingView() {
|
|
|
518
525
|
),
|
|
519
526
|
searchValue: searchTerm,
|
|
520
527
|
onSearchChange: (val) => setSearchTerm(val),
|
|
521
|
-
showFilterToggle:
|
|
528
|
+
showFilterToggle: false,
|
|
522
529
|
onFilterButtonClick: () =>
|
|
523
530
|
tableStates.setShowTableFilter(!tableStates.showTableFilter),
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
531
|
+
showColumnToggle: false,
|
|
532
|
+
showSearch: false,
|
|
533
|
+
showChangeLayoutToggle: false,
|
|
534
|
+
showSortingToggle: false,
|
|
528
535
|
// viewMoreToggle: true,
|
|
529
536
|
// showCompactTableToggle: false,
|
|
530
537
|
}}
|