rez-table-listing-mui 1.3.4 → 1.3.6
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 +20 -0
- 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/Multi-Select.tsx +1 -1
- package/src/listing/components/filter/index.tsx +234 -95
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +39 -4
- package/src/listing/types/filter.ts +26 -0
- package/src/view/ListingView.tsx +42 -93
package/package.json
CHANGED
|
@@ -252,109 +252,248 @@ export function TableFilter({
|
|
|
252
252
|
</CustomTabPanel>
|
|
253
253
|
)}
|
|
254
254
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
{
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
255
|
+
{!filterComponentOptions?.isRuleEngine && (
|
|
256
|
+
<ConfirmModal
|
|
257
|
+
open={saveFilterModalOpen}
|
|
258
|
+
onClose={() => setSaveFilterModalOpen(false)}
|
|
259
|
+
title={editMode ? "Replace Existing Filter ?" : "Save Filter"}
|
|
260
|
+
description={
|
|
261
|
+
editMode
|
|
262
|
+
? "You already have a filter applied. Applying a new filter will replace the current one. Do you want to continue?"
|
|
263
|
+
: "Give a name to this filter so you can easily reuse it later."
|
|
264
|
+
}
|
|
265
|
+
buttons={[
|
|
266
|
+
{
|
|
267
|
+
label: "Cancel",
|
|
268
|
+
onClick: () => {
|
|
269
|
+
setSaveFilterModalOpen(false);
|
|
270
|
+
},
|
|
271
|
+
variant: "outlined",
|
|
272
|
+
color: "primary",
|
|
273
|
+
sx: {
|
|
274
|
+
color: "#7A5AF8",
|
|
275
|
+
border: `1px solid #7A5AF8`,
|
|
276
|
+
},
|
|
275
277
|
},
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
278
|
+
{
|
|
279
|
+
label: editMode ? "Replace Filter" : "Save",
|
|
280
|
+
onClick: (inputValue) => {
|
|
281
|
+
if (editMode) {
|
|
282
|
+
const selectedId = filterMaster?.saved_filters?.selectedId;
|
|
283
|
+
const selectedName =
|
|
284
|
+
inputValue || filterMaster?.saved_filters?.selectedName;
|
|
285
|
+
|
|
286
|
+
const newFilterMasterState = {
|
|
287
|
+
...filterMaster,
|
|
288
|
+
saved_filters: {
|
|
289
|
+
...filterMaster?.attributes,
|
|
290
|
+
selectedId,
|
|
291
|
+
selectedName,
|
|
292
|
+
},
|
|
293
|
+
} as FilterMasterStateProps;
|
|
294
|
+
|
|
295
|
+
setFilterMaster(newFilterMasterState);
|
|
296
|
+
|
|
297
|
+
const newState = {
|
|
298
|
+
filterMaster: newFilterMasterState,
|
|
299
|
+
filters: filters,
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
onChangeFunction && onChangeFunction(newState);
|
|
303
|
+
|
|
304
|
+
onUpdateFilter && onUpdateFilter(inputValue || "");
|
|
305
|
+
setSaveFilterModalOpen(false);
|
|
306
|
+
setEditMode(false);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
onSaveFilter && onSaveFilter(inputValue || "");
|
|
304
311
|
setSaveFilterModalOpen(false);
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
312
|
+
setTabValue(1);
|
|
313
|
+
},
|
|
314
|
+
variant: "contained",
|
|
315
|
+
color: "primary",
|
|
316
|
+
sx: {
|
|
317
|
+
color: "white",
|
|
318
|
+
backgroundColor: editMode ? "#7A5AF8" : "#7A5AF8",
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
]}
|
|
322
|
+
input={editMode ? undefined : filterNameInput}
|
|
323
|
+
/>
|
|
324
|
+
)}
|
|
308
325
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
326
|
+
{!filterComponentOptions?.isRuleEngine && (
|
|
327
|
+
<ConfirmModal
|
|
328
|
+
open={deleteFilterModalOpen}
|
|
329
|
+
onClose={() => setDeleteFilterModalOpen(false)}
|
|
330
|
+
title="Delete Saved Filter?"
|
|
331
|
+
description={`You're about to delete the saved filter: "${
|
|
332
|
+
filterToDelete?.label || "[Filter Name]"
|
|
333
|
+
}". This action cannot be undone. Are you sure you want to continue?`}
|
|
334
|
+
buttons={[
|
|
335
|
+
{
|
|
336
|
+
label: "Cancel",
|
|
337
|
+
onClick: () => {
|
|
338
|
+
setDeleteFilterModalOpen(false);
|
|
339
|
+
},
|
|
340
|
+
variant: "outlined",
|
|
341
|
+
color: "primary",
|
|
342
|
+
sx: { color: "#7A5AF8", border: `1px solid #7A5AF8` },
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
label: "Delete",
|
|
346
|
+
onClick: () => {
|
|
347
|
+
onDeleteFilter && onDeleteFilter();
|
|
348
|
+
setDeleteFilterModalOpen(false);
|
|
349
|
+
setEditMode && setEditMode(false);
|
|
350
|
+
},
|
|
351
|
+
variant: "contained",
|
|
352
|
+
sx: {
|
|
353
|
+
color: "white",
|
|
354
|
+
backgroundColor: "#f63d68",
|
|
355
|
+
"&:hover": { backgroundColor: "#f63d68" },
|
|
356
|
+
},
|
|
312
357
|
},
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
358
|
+
]}
|
|
359
|
+
maxWidth="xs"
|
|
360
|
+
/>
|
|
361
|
+
)}
|
|
362
|
+
|
|
363
|
+
{filterComponentOptions?.isRuleEngine && (
|
|
364
|
+
<ConfirmModal
|
|
365
|
+
open={saveFilterModalOpen}
|
|
366
|
+
onClose={() => setSaveFilterModalOpen(false)}
|
|
367
|
+
title={
|
|
368
|
+
editMode
|
|
369
|
+
? filterComponentOptions?.recordFilterComponentProps?.edit
|
|
370
|
+
?.title || "Replace Existing Filter ?"
|
|
371
|
+
: filterComponentOptions?.recordFilterComponentProps?.save
|
|
372
|
+
?.title || "Save Filter"
|
|
373
|
+
}
|
|
374
|
+
description={
|
|
375
|
+
editMode
|
|
376
|
+
? filterComponentOptions?.recordFilterComponentProps?.edit
|
|
377
|
+
?.description ||
|
|
378
|
+
"You already have a filter applied. Applying a new filter will replace the current one. Do you want to continue?"
|
|
379
|
+
: filterComponentOptions?.recordFilterComponentProps?.save
|
|
380
|
+
?.description ||
|
|
381
|
+
"Give a name to this filter so you can easily reuse it later."
|
|
382
|
+
}
|
|
383
|
+
buttons={[
|
|
384
|
+
{
|
|
385
|
+
label:
|
|
386
|
+
filterComponentOptions?.recordFilterComponentProps?.save.button
|
|
387
|
+
?.primary || "Cancel",
|
|
388
|
+
onClick: () => {
|
|
389
|
+
setSaveFilterModalOpen(false);
|
|
390
|
+
},
|
|
391
|
+
variant: "outlined",
|
|
392
|
+
color: "primary",
|
|
393
|
+
sx: {
|
|
394
|
+
color: "#7A5AF8",
|
|
395
|
+
border: `1px solid #7A5AF8`,
|
|
396
|
+
},
|
|
318
397
|
},
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
398
|
+
{
|
|
399
|
+
label: editMode
|
|
400
|
+
? filterComponentOptions?.recordFilterComponentProps?.edit
|
|
401
|
+
.button?.secondary || "Replace Filter"
|
|
402
|
+
: filterComponentOptions?.recordFilterComponentProps?.save
|
|
403
|
+
.button?.secondary || "Save",
|
|
404
|
+
onClick: (inputValue) => {
|
|
405
|
+
if (editMode) {
|
|
406
|
+
const selectedId = filterMaster?.saved_filters?.selectedId;
|
|
407
|
+
const selectedName =
|
|
408
|
+
inputValue || filterMaster?.saved_filters?.selectedName;
|
|
409
|
+
|
|
410
|
+
const newFilterMasterState = {
|
|
411
|
+
...filterMaster,
|
|
412
|
+
saved_filters: {
|
|
413
|
+
...filterMaster?.attributes,
|
|
414
|
+
selectedId,
|
|
415
|
+
selectedName,
|
|
416
|
+
},
|
|
417
|
+
} as FilterMasterStateProps;
|
|
418
|
+
|
|
419
|
+
setFilterMaster(newFilterMasterState);
|
|
420
|
+
|
|
421
|
+
const newState = {
|
|
422
|
+
filterMaster: newFilterMasterState,
|
|
423
|
+
filters: filters,
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
onChangeFunction && onChangeFunction(newState);
|
|
427
|
+
|
|
428
|
+
onUpdateFilter && onUpdateFilter(inputValue || "");
|
|
429
|
+
setSaveFilterModalOpen(false);
|
|
430
|
+
setEditMode(false);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
onSaveFilter && onSaveFilter(inputValue || "");
|
|
435
|
+
setSaveFilterModalOpen(false);
|
|
436
|
+
setTabValue(1);
|
|
437
|
+
},
|
|
438
|
+
variant: "contained",
|
|
439
|
+
color: "primary",
|
|
440
|
+
sx: {
|
|
441
|
+
color: "white",
|
|
442
|
+
backgroundColor: editMode ? "#7A5AF8" : "#7A5AF8",
|
|
443
|
+
},
|
|
336
444
|
},
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
445
|
+
]}
|
|
446
|
+
input={editMode ? undefined : filterNameInput}
|
|
447
|
+
/>
|
|
448
|
+
)}
|
|
449
|
+
|
|
450
|
+
{filterComponentOptions?.isRuleEngine && (
|
|
451
|
+
<ConfirmModal
|
|
452
|
+
open={deleteFilterModalOpen}
|
|
453
|
+
onClose={() => setDeleteFilterModalOpen(false)}
|
|
454
|
+
title={
|
|
455
|
+
filterComponentOptions?.recordFilterComponentProps?.delete.title ||
|
|
456
|
+
"Delete Saved Filter?"
|
|
457
|
+
}
|
|
458
|
+
description={
|
|
459
|
+
filterComponentOptions?.recordFilterComponentProps?.delete
|
|
460
|
+
.description ||
|
|
461
|
+
`You're about to delete the saved filter: "${
|
|
462
|
+
filterToDelete?.label || "[Filter Name]"
|
|
463
|
+
}". This action cannot be undone. Are you sure you want to continue?`
|
|
464
|
+
}
|
|
465
|
+
buttons={[
|
|
466
|
+
{
|
|
467
|
+
label:
|
|
468
|
+
filterComponentOptions?.recordFilterComponentProps?.delete
|
|
469
|
+
.button?.primary || "Cancel",
|
|
470
|
+
onClick: () => {
|
|
471
|
+
setDeleteFilterModalOpen(false);
|
|
472
|
+
},
|
|
473
|
+
variant: "outlined",
|
|
474
|
+
color: "primary",
|
|
475
|
+
sx: { color: "#7A5AF8", border: `1px solid #7A5AF8` },
|
|
347
476
|
},
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
477
|
+
{
|
|
478
|
+
label:
|
|
479
|
+
filterComponentOptions?.recordFilterComponentProps?.delete
|
|
480
|
+
.button?.secondary || "Delete",
|
|
481
|
+
onClick: () => {
|
|
482
|
+
onDeleteFilter && onDeleteFilter();
|
|
483
|
+
setDeleteFilterModalOpen(false);
|
|
484
|
+
setEditMode && setEditMode(false);
|
|
485
|
+
},
|
|
486
|
+
variant: "contained",
|
|
487
|
+
sx: {
|
|
488
|
+
color: "white",
|
|
489
|
+
backgroundColor: "#f63d68",
|
|
490
|
+
"&:hover": { backgroundColor: "#f63d68" },
|
|
491
|
+
},
|
|
353
492
|
},
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
493
|
+
]}
|
|
494
|
+
maxWidth="xs"
|
|
495
|
+
/>
|
|
496
|
+
)}
|
|
358
497
|
</Box>
|
|
359
498
|
);
|
|
360
499
|
}
|
|
@@ -23,12 +23,13 @@ import {
|
|
|
23
23
|
viewSettingsDropDown,
|
|
24
24
|
} from "../utils/apiColumn";
|
|
25
25
|
import {
|
|
26
|
-
FilterColumnsDataProps,
|
|
27
26
|
FilterDataMainFilterEntityListProps,
|
|
28
27
|
FilterMasterStateProps,
|
|
28
|
+
FilterStateProps,
|
|
29
29
|
} from "../../types/filter";
|
|
30
30
|
import { CraftTableOptionsProps } from "../../types/table-options";
|
|
31
31
|
import { saveLayoutAPI } from "../services/saveLayoutAPI";
|
|
32
|
+
import { useMemo } from "react";
|
|
32
33
|
|
|
33
34
|
const entityListingCall = async ({
|
|
34
35
|
page,
|
|
@@ -214,8 +215,8 @@ export const useUpdateFilterAPI = () => {
|
|
|
214
215
|
export const useCommonDropdownAPI = (column_list?: any, value?: string) => {
|
|
215
216
|
// Step 1: Extract all keys and query types
|
|
216
217
|
const dropdownConfigs = (column_list || [])
|
|
217
|
-
|
|
218
|
-
|
|
218
|
+
?.filter((col) => col?.datasource_list)
|
|
219
|
+
?.map((col) => ({
|
|
219
220
|
key: col.attribute_key,
|
|
220
221
|
dataSourceType: value ?? col.datasource_list ?? "STS",
|
|
221
222
|
}));
|
|
@@ -233,13 +234,47 @@ export const useCommonDropdownAPI = (column_list?: any, value?: string) => {
|
|
|
233
234
|
|
|
234
235
|
// Step 3: Map results to keys
|
|
235
236
|
const dropdownData: Record<string, any> = {};
|
|
236
|
-
dropdownConfigs
|
|
237
|
+
dropdownConfigs?.forEach((cfg, idx) => {
|
|
237
238
|
dropdownData[cfg.key] = dropdownResults[idx].data;
|
|
238
239
|
});
|
|
239
240
|
|
|
240
241
|
return { dropdownData };
|
|
241
242
|
};
|
|
242
243
|
|
|
244
|
+
export const useCommonFilterDropdownAPI = (
|
|
245
|
+
filters: FilterStateProps[],
|
|
246
|
+
value?: string
|
|
247
|
+
) => {
|
|
248
|
+
// Step 1: Extract all keys and query types
|
|
249
|
+
const dropdownConfigs = useMemo(() => {
|
|
250
|
+
return filters
|
|
251
|
+
?.filter((col) => col?.filter_attribute_data_type === "select")
|
|
252
|
+
?.map((col) => ({
|
|
253
|
+
key: col?.filter_attribute,
|
|
254
|
+
dataSourceType: value ?? col?.datasource_list ?? "STS",
|
|
255
|
+
}));
|
|
256
|
+
}, [filters]);
|
|
257
|
+
|
|
258
|
+
// Step 2: Use useQueries to fetch them all in parallel
|
|
259
|
+
const dropdownResults = useQueries({
|
|
260
|
+
queries: dropdownConfigs.map((cfg) => {
|
|
261
|
+
return {
|
|
262
|
+
queryKey: ["commonDropdown", cfg?.dataSourceType],
|
|
263
|
+
queryFn: () => commonGetDropdownDataAPI(cfg?.dataSourceType, null),
|
|
264
|
+
enabled: !!cfg?.dataSourceType,
|
|
265
|
+
};
|
|
266
|
+
}),
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Step 3: Map results to keys
|
|
270
|
+
const dropdownFilterData: Record<string, any> = {};
|
|
271
|
+
dropdownConfigs?.forEach((cfg, idx) => {
|
|
272
|
+
dropdownFilterData[cfg.key] = dropdownResults[idx].data;
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
return { dropdownFilterData };
|
|
276
|
+
};
|
|
277
|
+
|
|
243
278
|
//ALL VIEW SETTINGS API
|
|
244
279
|
|
|
245
280
|
export const useSettingsDropDownAPI = ({
|
|
@@ -67,6 +67,27 @@ export interface FilterComponentOptionsMainFilterOptions {
|
|
|
67
67
|
showClearAllButton?: boolean;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// Button config type
|
|
71
|
+
type ButtonConfig = {
|
|
72
|
+
primary: string;
|
|
73
|
+
secondary: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// Modal config type
|
|
77
|
+
type ModalConfig = {
|
|
78
|
+
title?: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
button?: ButtonConfig;
|
|
81
|
+
isInputField?: boolean;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Record filter props type
|
|
85
|
+
type RecordFilterComponentProps = {
|
|
86
|
+
save: ModalConfig;
|
|
87
|
+
edit: ModalConfig;
|
|
88
|
+
delete: ModalConfig;
|
|
89
|
+
};
|
|
90
|
+
|
|
70
91
|
export type FilterComponentOptions =
|
|
71
92
|
| {
|
|
72
93
|
showMainHeader?: boolean;
|
|
@@ -75,17 +96,21 @@ export type FilterComponentOptions =
|
|
|
75
96
|
showMainFilter?: boolean;
|
|
76
97
|
showSavedFilter?: boolean;
|
|
77
98
|
showAttributesFilter?: boolean;
|
|
99
|
+
isRuleEngine?: boolean;
|
|
78
100
|
tabOptions?: {
|
|
79
101
|
mainFilter?: FilterComponentOptionsMainFilterOptions;
|
|
80
102
|
};
|
|
103
|
+
recordFilterComponentProps?: RecordFilterComponentProps;
|
|
81
104
|
}
|
|
82
105
|
| {
|
|
83
106
|
showMainHeader?: boolean;
|
|
84
107
|
mainHeaderTitle?: string;
|
|
85
108
|
showTabs?: false; // explicitly false or omitted
|
|
109
|
+
isRuleEngine?: boolean;
|
|
86
110
|
tabOptions?: {
|
|
87
111
|
mainFilter?: FilterComponentOptionsMainFilterOptions;
|
|
88
112
|
};
|
|
113
|
+
recordFilterComponentProps?: RecordFilterComponentProps;
|
|
89
114
|
};
|
|
90
115
|
|
|
91
116
|
export interface FilterDrawerProps {
|
|
@@ -148,6 +173,7 @@ export interface FilterStateProps {
|
|
|
148
173
|
};
|
|
149
174
|
filter_entity_type?: string;
|
|
150
175
|
filter_entity_name?: string;
|
|
176
|
+
datasource_list?: string | null;
|
|
151
177
|
}
|
|
152
178
|
|
|
153
179
|
export interface createSavedFilterPayload {
|