rez-table-listing-mui 1.3.4 → 1.3.5
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/index.tsx +234 -95
- package/src/listing/types/filter.ts +26 -0
- package/src/view/ListingView.tsx +37 -1
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
|
}
|
|
@@ -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 {
|
package/src/view/ListingView.tsx
CHANGED
|
@@ -386,13 +386,49 @@ function ListingView() {
|
|
|
386
386
|
component: (
|
|
387
387
|
<CraftTableFilterWrapper
|
|
388
388
|
tableStates={tableStates}
|
|
389
|
-
onClose={() => tableStates.setShowTableFilter(false)}
|
|
390
389
|
columnsData={metaQuery.data || {}}
|
|
391
390
|
dropdownData={dropdownData || []}
|
|
392
391
|
// onUpdateFilter={handleUpdateFilter}
|
|
393
392
|
// onDeleteFilter={handleRemoveFilter}
|
|
394
393
|
// onSaveFilter={handleSaveFilter}
|
|
395
394
|
onChangeFunction={handleChangeFunction}
|
|
395
|
+
filterComponentOptions={{
|
|
396
|
+
showMainHeader: false,
|
|
397
|
+
showTabs: false,
|
|
398
|
+
isRuleEngine: true,
|
|
399
|
+
tabOptions: {
|
|
400
|
+
mainFilter: {
|
|
401
|
+
showSaveButton: true,
|
|
402
|
+
showClearAllButton: true,
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
recordFilterComponentProps: {
|
|
406
|
+
save: {
|
|
407
|
+
title: "Save",
|
|
408
|
+
description: "Are you sure you want to save your changes?",
|
|
409
|
+
button: {
|
|
410
|
+
primary: "Cancel",
|
|
411
|
+
secondary: "Save",
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
edit: {
|
|
415
|
+
title: "Edit",
|
|
416
|
+
description: "Are you sure you want to save your changes?",
|
|
417
|
+
button: {
|
|
418
|
+
primary: "Cancel",
|
|
419
|
+
secondary: "Replace",
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
delete: {
|
|
423
|
+
title: "Delete",
|
|
424
|
+
description: "Are you sure you want to save your changes?",
|
|
425
|
+
button: {
|
|
426
|
+
primary: "Cancel",
|
|
427
|
+
secondary: "Delete",
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
}}
|
|
396
432
|
/>
|
|
397
433
|
),
|
|
398
434
|
}}
|