rez-table-listing-mui 1.3.44 → 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 -9
- 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 -3
- package/src/listing/types/table.ts +9 -0
- package/src/view/FIlterWrapper.tsx +15 -0
- package/src/view/ListingView.tsx +179 -63
package/package.json
CHANGED
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
Dispatch,
|
|
4
|
+
SetStateAction,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
} from "react";
|
|
8
|
+
import {
|
|
9
|
+
Box,
|
|
10
|
+
Button,
|
|
11
|
+
Checkbox,
|
|
12
|
+
Dialog,
|
|
13
|
+
DialogContent,
|
|
14
|
+
DialogTitle,
|
|
15
|
+
Divider,
|
|
16
|
+
FormControlLabel,
|
|
17
|
+
IconButton,
|
|
18
|
+
TextField,
|
|
19
|
+
Typography,
|
|
20
|
+
} from "@mui/material";
|
|
21
|
+
import { CloseIcon } from "../../../../assets/svg";
|
|
22
|
+
import {
|
|
23
|
+
FilterFormComponentProps,
|
|
24
|
+
FilterMasterStateProps,
|
|
25
|
+
} from "../../../types/filter";
|
|
26
|
+
import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
|
|
27
|
+
import { USER_ID } from "../../../libs/utils/common";
|
|
28
|
+
// import { set } from "react-hook-form";
|
|
29
|
+
|
|
30
|
+
const primary = "#7A5AF8";
|
|
31
|
+
|
|
32
|
+
interface SavedFilterModalViewProps {
|
|
33
|
+
open: boolean;
|
|
34
|
+
onClose: () => void;
|
|
35
|
+
onSave: () => void;
|
|
36
|
+
filterMaster: FilterMasterStateProps | null;
|
|
37
|
+
setFilterMaster: Dispatch<SetStateAction<FilterMasterStateProps | null>>;
|
|
38
|
+
columnsData: FilterFormComponentProps | undefined;
|
|
39
|
+
hasSavedFilters?: boolean;
|
|
40
|
+
forceShowSharingControls?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const SavedFilterModalView = ({
|
|
44
|
+
open,
|
|
45
|
+
onClose,
|
|
46
|
+
onSave,
|
|
47
|
+
filterMaster,
|
|
48
|
+
setFilterMaster,
|
|
49
|
+
columnsData,
|
|
50
|
+
|
|
51
|
+
forceShowSharingControls = false,
|
|
52
|
+
}: SavedFilterModalViewProps) => {
|
|
53
|
+
const [shareWithTeam, setShareWithTeam] = useState<boolean>(false);
|
|
54
|
+
const [allowTeamEdit, setAllowTeamEdit] = useState<boolean>(false);
|
|
55
|
+
const filterNameValue = filterMaster?.saved_filters?.selectedName ?? "";
|
|
56
|
+
const discriptionValue = filterMaster?.saved_filters?.description ?? "";
|
|
57
|
+
|
|
58
|
+
const isSaveDisabled =
|
|
59
|
+
!filterNameValue.trim() || (allowTeamEdit && !shareWithTeam);
|
|
60
|
+
|
|
61
|
+
const selectedFilterId = filterMaster?.saved_filters?.selectedId || "";
|
|
62
|
+
|
|
63
|
+
// Reset modal state when modal opens for a new filter
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!open) return;
|
|
66
|
+
|
|
67
|
+
const filterId = filterMaster?.saved_filters?.selectedId;
|
|
68
|
+
const filterObj1 = columnsData?.shared_filter?.find(
|
|
69
|
+
(f: any) => f.id === filterId
|
|
70
|
+
);
|
|
71
|
+
// NEW FILTER → RESET everything
|
|
72
|
+
if (!filterId && !filterObj1) {
|
|
73
|
+
setFilterMaster((prev: any) => {
|
|
74
|
+
if (!prev) return prev;
|
|
75
|
+
return {
|
|
76
|
+
...prev,
|
|
77
|
+
saved_filters: {
|
|
78
|
+
...(prev.saved_filters ?? {}),
|
|
79
|
+
selectedId: null,
|
|
80
|
+
selectedName: "",
|
|
81
|
+
description: "",
|
|
82
|
+
is_shared: false,
|
|
83
|
+
is_editable: false,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
setShareWithTeam(false);
|
|
88
|
+
setAllowTeamEdit(false);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// EXISTING FILTER → Load from columnsData.saved_filter
|
|
93
|
+
const filterObj = columnsData?.shared_filter?.find(
|
|
94
|
+
(f: any) => f.id === filterId
|
|
95
|
+
);
|
|
96
|
+
if (filterObj) {
|
|
97
|
+
setFilterMaster((prev) => {
|
|
98
|
+
if (!prev) return prev;
|
|
99
|
+
return {
|
|
100
|
+
...prev,
|
|
101
|
+
saved_filters: {
|
|
102
|
+
...(prev.saved_filters ?? {}),
|
|
103
|
+
selectedId: filterId,
|
|
104
|
+
selectedName: filterObj.name || "",
|
|
105
|
+
description: filterObj.description || "",
|
|
106
|
+
is_shared: filterObj.is_shared || false,
|
|
107
|
+
is_editable: filterObj.is_editable === "true",
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
// const initialShare = filterObj.is_shared ?? false;
|
|
112
|
+
// const initialAllow = initialShare
|
|
113
|
+
// ? filterObj.is_editable === "true"
|
|
114
|
+
// : false;
|
|
115
|
+
// setShareWithTeam(initialShare);
|
|
116
|
+
// setAllowTeamEdit(initialAllow);
|
|
117
|
+
const initialShare =
|
|
118
|
+
filterObj.is_shared === true || filterObj.is_shared === "true";
|
|
119
|
+
const initialAllow =
|
|
120
|
+
initialShare &&
|
|
121
|
+
(filterObj.is_editable === true || filterObj.is_editable === "true");
|
|
122
|
+
|
|
123
|
+
setShareWithTeam(initialShare);
|
|
124
|
+
setAllowTeamEdit(initialAllow);
|
|
125
|
+
|
|
126
|
+
persistPreferences(initialShare, initialAllow);
|
|
127
|
+
}
|
|
128
|
+
}, [
|
|
129
|
+
open,
|
|
130
|
+
columnsData,
|
|
131
|
+
filterMaster?.saved_filters?.selectedId,
|
|
132
|
+
setFilterMaster,
|
|
133
|
+
]); // Added dependencies for loading
|
|
134
|
+
|
|
135
|
+
// Persist toggle state to filterMaster
|
|
136
|
+
const persistPreferences = (sharedValue: boolean, editableValue: boolean) => {
|
|
137
|
+
setFilterMaster((prev) => {
|
|
138
|
+
if (!prev) return prev;
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
...prev,
|
|
142
|
+
saved_filters: {
|
|
143
|
+
...(prev.saved_filters ?? {}),
|
|
144
|
+
is_shared: sharedValue,
|
|
145
|
+
is_editable: editableValue,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// Handle Share Toggle
|
|
152
|
+
|
|
153
|
+
const handleShareToggle = (
|
|
154
|
+
_: ChangeEvent<HTMLInputElement>,
|
|
155
|
+
checked: boolean
|
|
156
|
+
) => {
|
|
157
|
+
setShareWithTeam(checked);
|
|
158
|
+
|
|
159
|
+
const nextAllow = checked ? allowTeamEdit : false;
|
|
160
|
+
setAllowTeamEdit(nextAllow);
|
|
161
|
+
|
|
162
|
+
persistPreferences(checked, nextAllow);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// Handle Allow Edit Toggle
|
|
166
|
+
|
|
167
|
+
const handleAllowEditToggle = (
|
|
168
|
+
_: ChangeEvent<HTMLInputElement>,
|
|
169
|
+
checked: boolean
|
|
170
|
+
) => {
|
|
171
|
+
if (!shareWithTeam) return; // Cannot enable edit without sharing
|
|
172
|
+
|
|
173
|
+
setAllowTeamEdit(checked);
|
|
174
|
+
persistPreferences(shareWithTeam, checked);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const shouldShowSharingControls = forceShowSharingControls || true; // always show
|
|
178
|
+
|
|
179
|
+
const getModalTitle = () => {
|
|
180
|
+
const selectedId = filterMaster?.saved_filters?.selectedId;
|
|
181
|
+
|
|
182
|
+
if (!selectedId) return "Save Filter"; // new filter
|
|
183
|
+
|
|
184
|
+
const filterObj = columnsData?.shared_filter?.find(
|
|
185
|
+
(f: any) => f.id === selectedId
|
|
186
|
+
);
|
|
187
|
+
if (filterObj?.is_shared) {
|
|
188
|
+
return "Shared Filter";
|
|
189
|
+
}
|
|
190
|
+
return "My Filter";
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const handleSave = () => {
|
|
194
|
+
persistPreferences(shareWithTeam, allowTeamEdit);
|
|
195
|
+
onSave(); // call original save handler
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// Get the selected filter object from columnsData.saved_filter
|
|
199
|
+
const selectedFilter = columnsData?.shared_filter?.find(
|
|
200
|
+
(f: any) => f.id === selectedFilterId
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const selectedSavedFilter = columnsData?.shared_filter?.find(
|
|
204
|
+
(f: any) => f.id === selectedFilterId
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
const isOwner = String(selectedSavedFilter?.is_owner) === "true";
|
|
208
|
+
|
|
209
|
+
// Check if we should show prefields
|
|
210
|
+
const showPrefields =
|
|
211
|
+
(selectedSavedFilter && selectedSavedFilter.is_editable === "true") ||
|
|
212
|
+
selectedSavedFilter;
|
|
213
|
+
|
|
214
|
+
// Disable checkboxes if prefields are shown
|
|
215
|
+
const showCheckboxes = !showPrefields;
|
|
216
|
+
|
|
217
|
+
const isNewFilter = !selectedSavedFilter;
|
|
218
|
+
|
|
219
|
+
const isshow = isOwner;
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
|
|
223
|
+
<DialogTitle sx={{ display: "flex", justifyContent: "space-between" }}>
|
|
224
|
+
<Typography fontSize={18} fontWeight={600} marginTop={1}>
|
|
225
|
+
{getModalTitle()}
|
|
226
|
+
</Typography>
|
|
227
|
+
<Box onClick={onClose} sx={{ cursor: "pointer" }}>
|
|
228
|
+
<CloseIcon />
|
|
229
|
+
</Box>
|
|
230
|
+
</DialogTitle>
|
|
231
|
+
|
|
232
|
+
<Divider sx={{ mx: "25px", my: "2px", bgcolor: "#f9f7f727" }} />
|
|
233
|
+
|
|
234
|
+
<DialogContent sx={{ pt: 0 }}>
|
|
235
|
+
<Typography my={1} fontSize={"14px"}>
|
|
236
|
+
Give a name to this filter so you can easily reuse it later.
|
|
237
|
+
</Typography>
|
|
238
|
+
{/* Filter Name */}
|
|
239
|
+
<Typography mt={2} fontSize={11}>
|
|
240
|
+
Filter Name
|
|
241
|
+
</Typography>
|
|
242
|
+
<TextField
|
|
243
|
+
fullWidth
|
|
244
|
+
size="small"
|
|
245
|
+
value={filterNameValue}
|
|
246
|
+
onChange={(e) =>
|
|
247
|
+
setFilterMaster((prev) => {
|
|
248
|
+
if (!prev) return prev;
|
|
249
|
+
return {
|
|
250
|
+
...prev,
|
|
251
|
+
saved_filters: {
|
|
252
|
+
...(prev.saved_filters ?? {}),
|
|
253
|
+
selectedName: e.target.value,
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
})
|
|
257
|
+
}
|
|
258
|
+
sx={{
|
|
259
|
+
mb: 0,
|
|
260
|
+
"& .MuiOutlinedInput-root": {
|
|
261
|
+
width: "50%",
|
|
262
|
+
"& fieldset": { borderColor: "#888" },
|
|
263
|
+
"&:hover fieldset": { borderColor: "black" },
|
|
264
|
+
"&.Mui-focused fieldset": { borderColor: primary },
|
|
265
|
+
"& .MuiInputBase-input": { fontSize: "12px" },
|
|
266
|
+
},
|
|
267
|
+
}}
|
|
268
|
+
/>
|
|
269
|
+
{/* Description */}
|
|
270
|
+
<Typography mt={2} fontSize={11}>
|
|
271
|
+
Description
|
|
272
|
+
</Typography>
|
|
273
|
+
<TextField
|
|
274
|
+
fullWidth
|
|
275
|
+
minRows={3}
|
|
276
|
+
value={discriptionValue}
|
|
277
|
+
size="small"
|
|
278
|
+
sx={{
|
|
279
|
+
mb: 1,
|
|
280
|
+
"& .MuiOutlinedInput-root": {
|
|
281
|
+
"& fieldset": { borderColor: "#888" },
|
|
282
|
+
"&:hover fieldset": { borderColor: "black" },
|
|
283
|
+
"&.Mui-focused fieldset": { borderColor: primary },
|
|
284
|
+
},
|
|
285
|
+
}}
|
|
286
|
+
onChange={(e) =>
|
|
287
|
+
setFilterMaster((prev) => {
|
|
288
|
+
if (!prev) return prev;
|
|
289
|
+
return {
|
|
290
|
+
...prev,
|
|
291
|
+
saved_filters: {
|
|
292
|
+
...(prev.saved_filters ?? {}),
|
|
293
|
+
description: e.target.value,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
})
|
|
297
|
+
}
|
|
298
|
+
/>
|
|
299
|
+
<Typography sx={{ mb: 1, fontSize: 12, color: "#888" }}>
|
|
300
|
+
(Max. 300 Characters)
|
|
301
|
+
</Typography>
|
|
302
|
+
{/* Sharing Controls */}
|
|
303
|
+
{shouldShowSharingControls && (showCheckboxes || isshow) && (
|
|
304
|
+
<Box
|
|
305
|
+
sx={{
|
|
306
|
+
display: "flex",
|
|
307
|
+
flexDirection: "column",
|
|
308
|
+
gap: 0.5,
|
|
309
|
+
"& .MuiFormControlLabel-label": { fontSize: "14px" },
|
|
310
|
+
}}
|
|
311
|
+
>
|
|
312
|
+
<FormControlLabel
|
|
313
|
+
control={
|
|
314
|
+
<Checkbox
|
|
315
|
+
size="small"
|
|
316
|
+
checked={shareWithTeam}
|
|
317
|
+
onChange={handleShareToggle}
|
|
318
|
+
sx={{
|
|
319
|
+
color: "black",
|
|
320
|
+
"&.Mui-checked": { color: "black" },
|
|
321
|
+
}}
|
|
322
|
+
/>
|
|
323
|
+
}
|
|
324
|
+
label="Share with team member."
|
|
325
|
+
/>
|
|
326
|
+
|
|
327
|
+
{shareWithTeam && (
|
|
328
|
+
<FormControlLabel
|
|
329
|
+
control={
|
|
330
|
+
<Checkbox
|
|
331
|
+
size="small"
|
|
332
|
+
checked={allowTeamEdit}
|
|
333
|
+
onChange={handleAllowEditToggle}
|
|
334
|
+
sx={{
|
|
335
|
+
color: "black",
|
|
336
|
+
"&.Mui-checked": { color: "black" },
|
|
337
|
+
}}
|
|
338
|
+
/>
|
|
339
|
+
}
|
|
340
|
+
label="Allow editing to Team member"
|
|
341
|
+
/>
|
|
342
|
+
)}
|
|
343
|
+
</Box>
|
|
344
|
+
)}
|
|
345
|
+
{/* prefields */}
|
|
346
|
+
{showPrefields && !isshow && (
|
|
347
|
+
<Box
|
|
348
|
+
sx={{
|
|
349
|
+
display: "grid",
|
|
350
|
+
gridTemplateColumns: "1fr 1fr",
|
|
351
|
+
gap: 3,
|
|
352
|
+
mt: 2,
|
|
353
|
+
}}
|
|
354
|
+
>
|
|
355
|
+
<Box>
|
|
356
|
+
<Typography
|
|
357
|
+
sx={{
|
|
358
|
+
fontSize: "14px",
|
|
359
|
+
fontWeight: 500,
|
|
360
|
+
color: "#6b6b6b",
|
|
361
|
+
mb: 0.5,
|
|
362
|
+
}}
|
|
363
|
+
>
|
|
364
|
+
Created On*
|
|
365
|
+
</Typography>
|
|
366
|
+
|
|
367
|
+
<TextField
|
|
368
|
+
fullWidth
|
|
369
|
+
size="small"
|
|
370
|
+
value={
|
|
371
|
+
selectedFilter?.created_date
|
|
372
|
+
? new Date(selectedFilter.created_date).toLocaleString()
|
|
373
|
+
: ""
|
|
374
|
+
} // format date
|
|
375
|
+
InputProps={{
|
|
376
|
+
readOnly: true,
|
|
377
|
+
endAdornment: (
|
|
378
|
+
<IconButton size="small">
|
|
379
|
+
<CalendarTodayIcon fontSize="small" />
|
|
380
|
+
</IconButton>
|
|
381
|
+
),
|
|
382
|
+
sx: {
|
|
383
|
+
backgroundColor: "#0E0C0B0F",
|
|
384
|
+
borderRadius: "4px",
|
|
385
|
+
},
|
|
386
|
+
}}
|
|
387
|
+
/>
|
|
388
|
+
</Box>
|
|
389
|
+
|
|
390
|
+
<Box>
|
|
391
|
+
<Typography
|
|
392
|
+
sx={{
|
|
393
|
+
fontSize: "14px",
|
|
394
|
+
fontWeight: 500,
|
|
395
|
+
color: "#6b6b6b",
|
|
396
|
+
mb: 0.5,
|
|
397
|
+
}}
|
|
398
|
+
>
|
|
399
|
+
Created By*
|
|
400
|
+
</Typography>
|
|
401
|
+
<TextField
|
|
402
|
+
fullWidth
|
|
403
|
+
size="small"
|
|
404
|
+
value={selectedFilter?.created_by || ""}
|
|
405
|
+
InputProps={{
|
|
406
|
+
readOnly: true,
|
|
407
|
+
sx: {
|
|
408
|
+
backgroundColor: "#0E0C0B0F",
|
|
409
|
+
borderRadius: "4px",
|
|
410
|
+
},
|
|
411
|
+
}}
|
|
412
|
+
/>
|
|
413
|
+
</Box>
|
|
414
|
+
|
|
415
|
+
<Box>
|
|
416
|
+
<Typography
|
|
417
|
+
sx={{
|
|
418
|
+
fontSize: "14px",
|
|
419
|
+
fontWeight: 500,
|
|
420
|
+
color: "#6b6b6b",
|
|
421
|
+
mb: 0.5,
|
|
422
|
+
}}
|
|
423
|
+
>
|
|
424
|
+
Modified On*
|
|
425
|
+
</Typography>
|
|
426
|
+
|
|
427
|
+
<TextField
|
|
428
|
+
fullWidth
|
|
429
|
+
size="small"
|
|
430
|
+
value={
|
|
431
|
+
selectedFilter?.modified_date
|
|
432
|
+
? new Date(selectedFilter.modified_date).toLocaleString()
|
|
433
|
+
: ""
|
|
434
|
+
}
|
|
435
|
+
InputProps={{
|
|
436
|
+
readOnly: true,
|
|
437
|
+
endAdornment: (
|
|
438
|
+
<IconButton size="small">
|
|
439
|
+
<CalendarTodayIcon fontSize="small" />
|
|
440
|
+
</IconButton>
|
|
441
|
+
),
|
|
442
|
+
|
|
443
|
+
sx: {
|
|
444
|
+
backgroundColor: "#0E0C0B0F",
|
|
445
|
+
borderRadius: "4px",
|
|
446
|
+
},
|
|
447
|
+
}}
|
|
448
|
+
/>
|
|
449
|
+
</Box>
|
|
450
|
+
|
|
451
|
+
<Box>
|
|
452
|
+
<Typography
|
|
453
|
+
sx={{
|
|
454
|
+
fontSize: "14px",
|
|
455
|
+
fontWeight: 500,
|
|
456
|
+
color: "#6b6b6b",
|
|
457
|
+
mb: 0.5,
|
|
458
|
+
}}
|
|
459
|
+
>
|
|
460
|
+
Modified By*
|
|
461
|
+
</Typography>
|
|
462
|
+
<TextField
|
|
463
|
+
fullWidth
|
|
464
|
+
size="small"
|
|
465
|
+
value={selectedFilter?.modified_by || ""}
|
|
466
|
+
InputProps={{
|
|
467
|
+
readOnly: true,
|
|
468
|
+
sx: {
|
|
469
|
+
backgroundColor: "#0E0C0B0F",
|
|
470
|
+
borderRadius: "4px",
|
|
471
|
+
},
|
|
472
|
+
}}
|
|
473
|
+
/>
|
|
474
|
+
</Box>
|
|
475
|
+
</Box>
|
|
476
|
+
)}
|
|
477
|
+
{/* Buttons */}
|
|
478
|
+
<Box
|
|
479
|
+
sx={{ display: "flex", justifyContent: "flex-end", gap: 1, mt: 3 }}
|
|
480
|
+
>
|
|
481
|
+
<Button
|
|
482
|
+
variant="outlined"
|
|
483
|
+
onClick={onClose}
|
|
484
|
+
sx={{
|
|
485
|
+
borderColor: primary,
|
|
486
|
+
color: primary,
|
|
487
|
+
"&:hover": {
|
|
488
|
+
borderColor: primary,
|
|
489
|
+
backgroundColor: "rgba(122, 90, 248, 0.04)",
|
|
490
|
+
},
|
|
491
|
+
}}
|
|
492
|
+
>
|
|
493
|
+
Cancel
|
|
494
|
+
</Button>
|
|
495
|
+
|
|
496
|
+
<Button
|
|
497
|
+
variant="contained"
|
|
498
|
+
onClick={handleSave}
|
|
499
|
+
disabled={isSaveDisabled}
|
|
500
|
+
sx={{
|
|
501
|
+
backgroundColor: primary,
|
|
502
|
+
"&:hover": { backgroundColor: "#6A4DE8" },
|
|
503
|
+
"&.Mui-disabled": {
|
|
504
|
+
backgroundColor: "#d7cefd",
|
|
505
|
+
color: "rgba(255, 255, 255, 0.7)",
|
|
506
|
+
},
|
|
507
|
+
}}
|
|
508
|
+
>
|
|
509
|
+
Save
|
|
510
|
+
</Button>
|
|
511
|
+
</Box>
|
|
512
|
+
</DialogContent>
|
|
513
|
+
</Dialog>
|
|
514
|
+
);
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
export default SavedFilterModalView;
|
|
@@ -76,7 +76,7 @@ const AttributesFilter = ({
|
|
|
76
76
|
} else {
|
|
77
77
|
// Else, replace with new single selection
|
|
78
78
|
const defaultOperator =
|
|
79
|
-
columnsData?.operation_list[matchingColumn.
|
|
79
|
+
columnsData?.operation_list[matchingColumn.data_type]?.[0]?.value ||
|
|
80
80
|
"in";
|
|
81
81
|
|
|
82
82
|
const newFilter = {
|
|
@@ -173,7 +173,7 @@ const AttributesFilter = ({
|
|
|
173
173
|
}}
|
|
174
174
|
>
|
|
175
175
|
{columnsData?.column_list
|
|
176
|
-
?.filter((column) => column.
|
|
176
|
+
?.filter((column) => column.data_type.includes("select"))
|
|
177
177
|
.map((column, index) => (
|
|
178
178
|
<MenuItem
|
|
179
179
|
key={index}
|
|
@@ -59,8 +59,8 @@ const FormDropdown = ({
|
|
|
59
59
|
field.onChange(e);
|
|
60
60
|
|
|
61
61
|
if (
|
|
62
|
-
(filter?.
|
|
63
|
-
filter?.
|
|
62
|
+
(filter?.filter_attribute_data_type === "date" ||
|
|
63
|
+
filter?.filter_attribute_data_type === "year") &&
|
|
64
64
|
newOperator !== oldOperator
|
|
65
65
|
) {
|
|
66
66
|
if (newOperator === "today") {
|
|
@@ -62,15 +62,14 @@ const FilterCriteria = ({
|
|
|
62
62
|
const handleAddFilter = (
|
|
63
63
|
attribute: FilterDataMainFilterEntityWiseCriteriaProps
|
|
64
64
|
) => {
|
|
65
|
-
const dropdownOptions =
|
|
66
|
-
columnsData?.operation_list[attribute?.element_type];
|
|
65
|
+
const dropdownOptions = columnsData?.operation_list[attribute?.data_type];
|
|
67
66
|
|
|
68
|
-
const defaultValue = attribute.
|
|
67
|
+
const defaultValue = attribute.data_type === "multiselect" ? [] : "";
|
|
69
68
|
|
|
70
69
|
const defaultOperator = dropdownOptions?.[0]?.value || "";
|
|
71
70
|
|
|
72
71
|
const matchingDropdownList =
|
|
73
|
-
columnsData?.operation_list[attribute.
|
|
72
|
+
columnsData?.operation_list[attribute.data_type] || [];
|
|
74
73
|
|
|
75
74
|
const newFilter = {
|
|
76
75
|
filter_attribute: attribute.attribute_key,
|
|
@@ -83,8 +82,8 @@ const FilterCriteria = ({
|
|
|
83
82
|
...newFilter,
|
|
84
83
|
// id: attribute?.id,
|
|
85
84
|
filter_attribute_name: attribute?.name,
|
|
86
|
-
|
|
87
|
-
attribute?.
|
|
85
|
+
filter_attribute_data_type:
|
|
86
|
+
attribute?.data_type || attribute?.element_type,
|
|
88
87
|
datasource_list: attribute?.datasource_list,
|
|
89
88
|
dropdown_list: matchingDropdownList,
|
|
90
89
|
filter_entity_name: selectedFilterEntity?.label,
|
|
@@ -145,11 +144,14 @@ const FilterCriteria = ({
|
|
|
145
144
|
>
|
|
146
145
|
<Box
|
|
147
146
|
sx={{
|
|
148
|
-
maxHeight:
|
|
147
|
+
maxHeight: filterMaster?.saved_filters?.selectedId
|
|
148
|
+
? `calc(100vh - 601px)`
|
|
149
|
+
: `calc(100vh - 440px)`,
|
|
149
150
|
overflowY: "auto",
|
|
150
151
|
width: "100%",
|
|
151
152
|
...filterStyles.scrollbarCustom,
|
|
152
153
|
}}
|
|
154
|
+
className="filter-criteria-list-box"
|
|
153
155
|
>
|
|
154
156
|
{selectedFilterEntity ? (
|
|
155
157
|
<FilterCriteriaList
|
|
@@ -33,11 +33,9 @@ const FormTextfield = ({
|
|
|
33
33
|
padding: "12px 20px",
|
|
34
34
|
},
|
|
35
35
|
}}
|
|
36
|
-
// type={filter?.
|
|
36
|
+
// type={filter?.filter_attribute_data_type || "text" || "number"}
|
|
37
37
|
type={
|
|
38
|
-
filter?.
|
|
39
|
-
? "number"
|
|
40
|
-
: "text"
|
|
38
|
+
filter?.filter_attribute_data_type === "number" ? "number" : "text"
|
|
41
39
|
}
|
|
42
40
|
placeholder={"Enter value"}
|
|
43
41
|
disabled={isLoading}
|
|
@@ -36,7 +36,7 @@ const FilterForm = ({
|
|
|
36
36
|
handleRemoveFilter,
|
|
37
37
|
editMode = false,
|
|
38
38
|
tableStates,
|
|
39
|
-
|
|
39
|
+
onSaveFilterButtonClick,
|
|
40
40
|
setDeleteFilterModalOpen,
|
|
41
41
|
onChangeFunction,
|
|
42
42
|
filterComponentOptions,
|
|
@@ -48,7 +48,7 @@ const FilterForm = ({
|
|
|
48
48
|
handleRemoveFilter: (filter_attribute: string) => void;
|
|
49
49
|
editMode?: boolean;
|
|
50
50
|
tableStates: CraftTableOptionsProps;
|
|
51
|
-
|
|
51
|
+
onSaveFilterButtonClick?: () => void;
|
|
52
52
|
setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
53
53
|
onChangeFunction: ({
|
|
54
54
|
updatedFilters,
|
|
@@ -67,6 +67,7 @@ const FilterForm = ({
|
|
|
67
67
|
filterComponentOptions?.tabOptions?.mainFilter?.customButtons;
|
|
68
68
|
|
|
69
69
|
const filterName = filterMaster?.saved_filters?.selectedName || "";
|
|
70
|
+
const isOwner = filterMaster?.saved_filters?.is_owner || false;
|
|
70
71
|
|
|
71
72
|
const defaultValues = useMemo(() => {
|
|
72
73
|
const filterValues = filters?.reduce((acc, curr) => {
|
|
@@ -252,22 +253,30 @@ const FilterForm = ({
|
|
|
252
253
|
/>
|
|
253
254
|
)}
|
|
254
255
|
/>
|
|
255
|
-
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
256
|
+
{isOwner && (
|
|
257
|
+
<Box onClick={(e) => e.stopPropagation()}>
|
|
258
|
+
<IconButton
|
|
259
|
+
size="small"
|
|
260
|
+
onClick={() =>
|
|
261
|
+
setDeleteFilterModalOpen && setDeleteFilterModalOpen(true)
|
|
262
|
+
}
|
|
263
|
+
>
|
|
264
|
+
<DeleteIcon />
|
|
265
|
+
</IconButton>
|
|
266
|
+
</Box>
|
|
267
|
+
)}
|
|
265
268
|
</Box>
|
|
266
269
|
)}
|
|
267
270
|
|
|
268
271
|
<Box
|
|
269
272
|
className="filter-criteria-form"
|
|
270
|
-
sx={
|
|
273
|
+
sx={{
|
|
274
|
+
...filterFormStyles.formFlexContainer,
|
|
275
|
+
...(editMode && {
|
|
276
|
+
maxHeight: "calc(100vh - 570px)",
|
|
277
|
+
overflowY: "auto",
|
|
278
|
+
}),
|
|
279
|
+
}}
|
|
271
280
|
>
|
|
272
281
|
<FilterCriteria
|
|
273
282
|
columnsData={columnsData}
|
|
@@ -442,7 +451,7 @@ const FilterForm = ({
|
|
|
442
451
|
},
|
|
443
452
|
}}
|
|
444
453
|
onClick={() => {
|
|
445
|
-
|
|
454
|
+
onSaveFilterButtonClick && onSaveFilterButtonClick();
|
|
446
455
|
}}
|
|
447
456
|
>
|
|
448
457
|
Save Filter
|