rez-table-listing-mui 1.3.3 → 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 +27 -14
- 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/attributes-filter.tsx +8 -7
- package/src/listing/components/filter/components/forms/components/Date.tsx +1 -1
- package/src/listing/components/filter/components/forms/components/Dropdown.tsx +7 -6
- package/src/listing/components/filter/components/forms/components/Filter-criteria.tsx +5 -3
- package/src/listing/components/filter/components/forms/components/Multi-Select.tsx +1 -1
- package/src/listing/components/filter/components/forms/components/Select.tsx +1 -1
- package/src/listing/components/filter/components/forms/components/Textfield.tsx +2 -2
- package/src/listing/components/filter/components/forms/index.tsx +33 -23
- package/src/listing/components/filter/index.tsx +237 -96
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +2 -5
- package/src/listing/libs/utils/apiColumn.ts +3 -1
- package/src/listing/types/filter.ts +33 -16
- package/src/view/FIlterWrapper.tsx +40 -19
- package/src/view/ListingView.tsx +43 -2
|
@@ -47,6 +47,7 @@ export function TableFilter({
|
|
|
47
47
|
|
|
48
48
|
const defaultOptions: FilterComponentOptions = {
|
|
49
49
|
showMainHeader: true,
|
|
50
|
+
mainHeaderTitle: "Filter",
|
|
50
51
|
showTabs: true,
|
|
51
52
|
tabOptions: {
|
|
52
53
|
mainFilter: {
|
|
@@ -65,6 +66,7 @@ export function TableFilter({
|
|
|
65
66
|
);
|
|
66
67
|
|
|
67
68
|
const showMainHeader = finalComponentOptions?.showMainHeader;
|
|
69
|
+
const mainHeaderTitle = finalComponentOptions?.mainHeaderTitle;
|
|
68
70
|
const showTabs = finalComponentOptions?.showTabs;
|
|
69
71
|
const showMainFilter = showTabs && finalComponentOptions?.showMainFilter;
|
|
70
72
|
const showSavedFilter = showTabs && finalComponentOptions?.showSavedFilter;
|
|
@@ -157,7 +159,7 @@ export function TableFilter({
|
|
|
157
159
|
{showMainHeader && (
|
|
158
160
|
<Box sx={filterStyles.filterMainHeader}>
|
|
159
161
|
<Typography variant="h6" fontWeight="bold" fontSize="18px">
|
|
160
|
-
|
|
162
|
+
{mainHeaderTitle}
|
|
161
163
|
</Typography>
|
|
162
164
|
<IconButton
|
|
163
165
|
onClick={(e) => {
|
|
@@ -250,109 +252,248 @@ export function TableFilter({
|
|
|
250
252
|
</CustomTabPanel>
|
|
251
253
|
)}
|
|
252
254
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
+
},
|
|
273
277
|
},
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
|
|
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 || "");
|
|
302
311
|
setSaveFilterModalOpen(false);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
+
)}
|
|
306
325
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
+
},
|
|
310
357
|
},
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
+
},
|
|
316
397
|
},
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
+
},
|
|
334
444
|
},
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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` },
|
|
345
476
|
},
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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
|
+
},
|
|
351
492
|
},
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
493
|
+
]}
|
|
494
|
+
maxWidth="xs"
|
|
495
|
+
/>
|
|
496
|
+
)}
|
|
356
497
|
</Box>
|
|
357
498
|
);
|
|
358
499
|
}
|
|
@@ -211,12 +211,9 @@ export const useUpdateFilterAPI = () => {
|
|
|
211
211
|
return { updateMutation };
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
export const useCommonDropdownAPI = (
|
|
215
|
-
metaData?: FilterColumnsDataProps,
|
|
216
|
-
value?: string
|
|
217
|
-
) => {
|
|
214
|
+
export const useCommonDropdownAPI = (column_list?: any, value?: string) => {
|
|
218
215
|
// Step 1: Extract all keys and query types
|
|
219
|
-
const dropdownConfigs = (
|
|
216
|
+
const dropdownConfigs = (column_list || [])
|
|
220
217
|
.filter((col) => col?.datasource_list)
|
|
221
218
|
.map((col) => ({
|
|
222
219
|
key: col.attribute_key,
|
|
@@ -163,7 +163,9 @@ export const viewSettingsDropDown = async ({
|
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
export const getFilterEntityList = async (entity_type: string) => {
|
|
166
|
-
const response = await api.get(
|
|
166
|
+
const response = await api.get(
|
|
167
|
+
`/entity-relation/${entity_type}?include=true`
|
|
168
|
+
);
|
|
167
169
|
|
|
168
170
|
return response.data;
|
|
169
171
|
};
|
|
@@ -67,23 +67,50 @@ 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;
|
|
94
|
+
mainHeaderTitle?: string;
|
|
73
95
|
showTabs?: true; // when true → additional fields allowed
|
|
74
96
|
showMainFilter?: boolean;
|
|
75
97
|
showSavedFilter?: boolean;
|
|
76
98
|
showAttributesFilter?: boolean;
|
|
99
|
+
isRuleEngine?: boolean;
|
|
77
100
|
tabOptions?: {
|
|
78
101
|
mainFilter?: FilterComponentOptionsMainFilterOptions;
|
|
79
102
|
};
|
|
103
|
+
recordFilterComponentProps?: RecordFilterComponentProps;
|
|
80
104
|
}
|
|
81
105
|
| {
|
|
82
106
|
showMainHeader?: boolean;
|
|
107
|
+
mainHeaderTitle?: string;
|
|
83
108
|
showTabs?: false; // explicitly false or omitted
|
|
109
|
+
isRuleEngine?: boolean;
|
|
84
110
|
tabOptions?: {
|
|
85
111
|
mainFilter?: FilterComponentOptionsMainFilterOptions;
|
|
86
112
|
};
|
|
113
|
+
recordFilterComponentProps?: RecordFilterComponentProps;
|
|
87
114
|
};
|
|
88
115
|
|
|
89
116
|
export interface FilterDrawerProps {
|
|
@@ -133,8 +160,8 @@ export interface FilterStateProps {
|
|
|
133
160
|
filter_operator: string;
|
|
134
161
|
filter_value: string | string[];
|
|
135
162
|
id: string | number;
|
|
136
|
-
|
|
137
|
-
|
|
163
|
+
filter_attribute_name: string | undefined;
|
|
164
|
+
filter_attribute_data_type: FilterInputDataTypes | undefined;
|
|
138
165
|
attribute_key?: string;
|
|
139
166
|
dropdown_list?: {
|
|
140
167
|
label?: string;
|
|
@@ -146,12 +173,7 @@ export interface FilterStateProps {
|
|
|
146
173
|
};
|
|
147
174
|
filter_entity_type?: string;
|
|
148
175
|
filter_entity_name?: string;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
interface FilterDetail {
|
|
152
|
-
filter_attribute: string;
|
|
153
|
-
filter_operator: string;
|
|
154
|
-
filter_value: string | string[];
|
|
176
|
+
datasource_list?: string | null;
|
|
155
177
|
}
|
|
156
178
|
|
|
157
179
|
export interface createSavedFilterPayload {
|
|
@@ -163,7 +185,7 @@ export interface createSavedFilterPayload {
|
|
|
163
185
|
mapped_entity_type: string;
|
|
164
186
|
status?: string;
|
|
165
187
|
entity_type: string;
|
|
166
|
-
filterDetails:
|
|
188
|
+
filterDetails: FilterStateProps[];
|
|
167
189
|
}
|
|
168
190
|
|
|
169
191
|
export interface deleteSavedFilterPayload {
|
|
@@ -182,13 +204,7 @@ export interface updateSavedFilterPayload {
|
|
|
182
204
|
status?: string;
|
|
183
205
|
entity_type: string;
|
|
184
206
|
mapped_entity_type: string;
|
|
185
|
-
filterDetails:
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
interface FilterDetail {
|
|
189
|
-
filter_attribute: string;
|
|
190
|
-
filter_operator: string;
|
|
191
|
-
filter_value: string | string[];
|
|
207
|
+
filterDetails: FilterStateProps[];
|
|
192
208
|
}
|
|
193
209
|
|
|
194
210
|
export interface FilterFormComponentProps {
|
|
@@ -257,6 +273,7 @@ export interface FilterDataMainFilterEntityWiseCriteriaProps {
|
|
|
257
273
|
name: string;
|
|
258
274
|
attribute_key: string;
|
|
259
275
|
element_type: FilterInputDataTypes;
|
|
276
|
+
datasource_list: any;
|
|
260
277
|
}
|
|
261
278
|
|
|
262
279
|
export interface FilterDataProps {
|
|
@@ -4,7 +4,7 @@ import { useGetNavigationLayoutAPI } from "../listing/libs/hooks/useGetNavigatio
|
|
|
4
4
|
import { ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
5
5
|
import {
|
|
6
6
|
useDeleteFilterAPI,
|
|
7
|
-
|
|
7
|
+
useGetFilterEntityListAndCriteria,
|
|
8
8
|
useSavedFilterAPI,
|
|
9
9
|
useUpdateFilterAPI,
|
|
10
10
|
} from "../listing/libs/hooks/useEntityTableAPI";
|
|
@@ -12,18 +12,19 @@ import {
|
|
|
12
12
|
FilterColumnsDataProps,
|
|
13
13
|
FilterComponentOptions,
|
|
14
14
|
FilterDropdownDataProps,
|
|
15
|
-
FilterDataProps,
|
|
16
15
|
FilterMasterStateProps,
|
|
17
16
|
} from "../listing/types/filter";
|
|
18
17
|
import { onFilterChangeFunctionProps } from "../listing/types/common";
|
|
19
18
|
|
|
20
19
|
const CraftTableFilterWrapper = ({
|
|
20
|
+
onClose,
|
|
21
21
|
tableStates,
|
|
22
22
|
dropdownData,
|
|
23
23
|
onChangeFunction,
|
|
24
24
|
columnsData,
|
|
25
25
|
filterComponentOptions,
|
|
26
26
|
}: {
|
|
27
|
+
onClose?: () => void;
|
|
27
28
|
tableStates: CraftTableOptionsProps;
|
|
28
29
|
columnsData: FilterColumnsDataProps;
|
|
29
30
|
dropdownData: FilterDropdownDataProps;
|
|
@@ -41,34 +42,51 @@ const CraftTableFilterWrapper = ({
|
|
|
41
42
|
setFilterMaster,
|
|
42
43
|
filterToDelete,
|
|
43
44
|
setFilterData,
|
|
45
|
+
selectedFilterEntity,
|
|
44
46
|
} = tableStates;
|
|
45
47
|
|
|
46
48
|
const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
|
|
47
49
|
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
48
50
|
const { deleteMutation } = useDeleteFilterAPI(tableStates); //API FOR DELETING FILTER
|
|
49
|
-
const filterEntityList
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
const { filterEntityList, filterEntityWiseCriteria } =
|
|
52
|
+
useGetFilterEntityListAndCriteria({
|
|
53
|
+
entity_type: ENTITY_TYPE,
|
|
54
|
+
selectedFilterEntity,
|
|
55
|
+
});
|
|
52
56
|
|
|
53
57
|
useEffect(() => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const data: any = filterEntityList?.data;
|
|
59
|
+
|
|
60
|
+
setFilterData((prev: any) => ({
|
|
61
|
+
...prev,
|
|
62
|
+
mainFilter: {
|
|
63
|
+
...prev?.mainFilter,
|
|
64
|
+
entityList: {
|
|
65
|
+
data: data ?? [],
|
|
66
|
+
isPending: filterEntityList?.isPending ?? false,
|
|
60
67
|
},
|
|
61
|
-
}
|
|
62
|
-
}
|
|
68
|
+
},
|
|
69
|
+
}));
|
|
63
70
|
}, [filterEntityList?.data, filterEntityList?.isPending]);
|
|
64
71
|
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
const data = filterEntityWiseCriteria?.data?.data?.attribute_list;
|
|
74
|
+
|
|
75
|
+
setFilterData((prev: any) => ({
|
|
76
|
+
...prev,
|
|
77
|
+
mainFilter: {
|
|
78
|
+
...prev?.mainFilter,
|
|
79
|
+
entityWiseCriteria: {
|
|
80
|
+
data: data ?? [],
|
|
81
|
+
isPending: filterEntityWiseCriteria?.isPending ?? false,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}));
|
|
85
|
+
}, [filterEntityWiseCriteria?.data, filterEntityWiseCriteria?.isPending]);
|
|
86
|
+
|
|
65
87
|
// API to handle saving a filter
|
|
66
88
|
const handleSaveFilter = (name: string) => {
|
|
67
|
-
const quickFilter = filters.map((f: any) => ({
|
|
68
|
-
filter_attribute: f.filter_attribute,
|
|
69
|
-
filter_operator: f.filter_operator,
|
|
70
|
-
filter_value: f.filter_value,
|
|
71
|
-
}));
|
|
89
|
+
const quickFilter = filters.map((f: any) => ({ ...f }));
|
|
72
90
|
|
|
73
91
|
const payload = {
|
|
74
92
|
name,
|
|
@@ -154,7 +172,10 @@ const CraftTableFilterWrapper = ({
|
|
|
154
172
|
return (
|
|
155
173
|
<CraftTableFilter
|
|
156
174
|
tableStates={tableStates}
|
|
157
|
-
onClose={() =>
|
|
175
|
+
onClose={() => {
|
|
176
|
+
tableStates.setShowTableFilter(false);
|
|
177
|
+
onClose && onClose();
|
|
178
|
+
}}
|
|
158
179
|
columnsData={columnsData}
|
|
159
180
|
dropdownData={dropdownData || []}
|
|
160
181
|
onUpdateFilter={handleUpdateFilter}
|
package/src/view/ListingView.tsx
CHANGED
|
@@ -58,7 +58,12 @@ function ListingView() {
|
|
|
58
58
|
const { deleteMutation } = useDeleteFilterAPI(tableStates); //API FOR DELETING FILTER
|
|
59
59
|
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
60
60
|
const { saveSettingsDataMutation } = useSaveSettingsDataAPI(ENTITY_TYPE);
|
|
61
|
-
const
|
|
61
|
+
const memoizedFilters = useMemo(() => filters, [filters]);
|
|
62
|
+
|
|
63
|
+
// const { dropdownData } = useCommonDropdownAPI(
|
|
64
|
+
// dropdownColumnList || metaQuery.data.column_list
|
|
65
|
+
// );
|
|
66
|
+
const { dropdownData } = useCommonDropdownAPI(memoizedFilters);
|
|
62
67
|
const { settingsTabDropdownData, settingsTabDropdownPending } =
|
|
63
68
|
useSettingsDropDownAPI({
|
|
64
69
|
entity_type: ENTITY_TYPE,
|
|
@@ -381,13 +386,49 @@ function ListingView() {
|
|
|
381
386
|
component: (
|
|
382
387
|
<CraftTableFilterWrapper
|
|
383
388
|
tableStates={tableStates}
|
|
384
|
-
onClose={() => tableStates.setShowTableFilter(false)}
|
|
385
389
|
columnsData={metaQuery.data || {}}
|
|
386
390
|
dropdownData={dropdownData || []}
|
|
387
391
|
// onUpdateFilter={handleUpdateFilter}
|
|
388
392
|
// onDeleteFilter={handleRemoveFilter}
|
|
389
393
|
// onSaveFilter={handleSaveFilter}
|
|
390
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
|
+
}}
|
|
391
432
|
/>
|
|
392
433
|
),
|
|
393
434
|
}}
|