rez-table-listing-mui 1.3.31 → 1.3.33
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 +5 -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/common/saved-filter-modal/index.tsx +42 -15
- package/src/listing/components/filter/components/forms/components/Date.tsx +1 -1
- package/src/listing/components/filter/components/forms/components/Dropdown.tsx +2 -135
- package/src/listing/components/filter/components/forms/components/Textfield.tsx +4 -1
- package/src/listing/components/filter/components/forms/index.tsx +105 -57
- package/src/listing/components/filter/components/forms/utils/filter-date-input-resolver.tsx +24 -48
- package/src/listing/components/filter/components/saved-filter.tsx +593 -12
- package/src/listing/components/filter/index.tsx +6 -0
- package/src/listing/components/login/index.tsx +1 -1
- package/src/listing/libs/utils/common.ts +1 -0
- package/src/listing/types/filter.ts +5 -0
- package/src/view/FIlterWrapper.tsx +5 -0
package/package.json
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
FilterMasterStateProps,
|
|
25
25
|
} from "../../../types/filter";
|
|
26
26
|
import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
|
|
27
|
+
import { USER_ID } from "../../../libs/utils/common";
|
|
27
28
|
// import { set } from "react-hook-form";
|
|
28
29
|
|
|
29
30
|
const primary = "#7A5AF8";
|
|
@@ -52,6 +53,8 @@ const SavedFilterModalView = ({
|
|
|
52
53
|
const [shareWithTeam, setShareWithTeam] = useState<boolean>(false);
|
|
53
54
|
const [allowTeamEdit, setAllowTeamEdit] = useState<boolean>(false);
|
|
54
55
|
const filterNameValue = filterMaster?.saved_filters?.selectedName ?? "";
|
|
56
|
+
const discriptionValue = filterMaster?.saved_filters?.description ?? "";
|
|
57
|
+
|
|
55
58
|
const isSaveDisabled =
|
|
56
59
|
!filterNameValue.trim() || (allowTeamEdit && !shareWithTeam);
|
|
57
60
|
|
|
@@ -62,9 +65,11 @@ const SavedFilterModalView = ({
|
|
|
62
65
|
if (!open) return;
|
|
63
66
|
|
|
64
67
|
const filterId = filterMaster?.saved_filters?.selectedId;
|
|
65
|
-
|
|
68
|
+
const filterObj1 = columnsData?.shared_filter?.find(
|
|
69
|
+
(f: any) => f.id === filterId
|
|
70
|
+
);
|
|
66
71
|
// NEW FILTER → RESET everything
|
|
67
|
-
if (!filterId) {
|
|
72
|
+
if (!filterId && !filterObj1) {
|
|
68
73
|
setFilterMaster((prev: any) => {
|
|
69
74
|
if (!prev) return prev;
|
|
70
75
|
return {
|
|
@@ -166,14 +171,13 @@ const SavedFilterModalView = ({
|
|
|
166
171
|
|
|
167
172
|
if (!selectedId) return "Save Filter"; // new filter
|
|
168
173
|
|
|
169
|
-
const filterObj = columnsData?.
|
|
174
|
+
const filterObj = columnsData?.shared_filter?.find(
|
|
170
175
|
(f: any) => f.id === selectedId
|
|
171
176
|
);
|
|
172
177
|
if (filterObj?.is_shared) {
|
|
173
|
-
return "
|
|
178
|
+
return "Shared Filter";
|
|
174
179
|
}
|
|
175
|
-
|
|
176
|
-
return "Shared Filter";
|
|
180
|
+
return "My Filter";
|
|
177
181
|
};
|
|
178
182
|
|
|
179
183
|
const handleSave = () => {
|
|
@@ -190,13 +194,20 @@ const SavedFilterModalView = ({
|
|
|
190
194
|
(f: any) => f.id === selectedFilterId
|
|
191
195
|
);
|
|
192
196
|
|
|
197
|
+
const isOwner = String(selectedSavedFilter?.is_owner) === "true";
|
|
198
|
+
|
|
193
199
|
// Check if we should show prefields
|
|
194
200
|
const showPrefields =
|
|
195
|
-
selectedSavedFilter && selectedSavedFilter.is_editable === "true"
|
|
201
|
+
(selectedSavedFilter && selectedSavedFilter.is_editable === "true") ||
|
|
202
|
+
selectedSavedFilter;
|
|
196
203
|
|
|
197
204
|
// Disable checkboxes if prefields are shown
|
|
198
205
|
const showCheckboxes = !showPrefields;
|
|
199
206
|
|
|
207
|
+
const isNewFilter = !selectedSavedFilter;
|
|
208
|
+
|
|
209
|
+
const isshow = !isOwner;
|
|
210
|
+
|
|
200
211
|
return (
|
|
201
212
|
<Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
|
|
202
213
|
<DialogTitle sx={{ display: "flex", justifyContent: "space-between" }}>
|
|
@@ -252,6 +263,7 @@ const SavedFilterModalView = ({
|
|
|
252
263
|
<TextField
|
|
253
264
|
fullWidth
|
|
254
265
|
minRows={3}
|
|
266
|
+
value={discriptionValue}
|
|
255
267
|
size="small"
|
|
256
268
|
sx={{
|
|
257
269
|
mb: 1,
|
|
@@ -278,7 +290,7 @@ const SavedFilterModalView = ({
|
|
|
278
290
|
(Max. 300 Characters)
|
|
279
291
|
</Typography>
|
|
280
292
|
{/* Sharing Controls */}
|
|
281
|
-
{
|
|
293
|
+
{shouldShowSharingControls && (showCheckboxes || isshow) && (
|
|
282
294
|
<Box
|
|
283
295
|
sx={{
|
|
284
296
|
display: "flex",
|
|
@@ -321,7 +333,7 @@ const SavedFilterModalView = ({
|
|
|
321
333
|
</Box>
|
|
322
334
|
)}
|
|
323
335
|
{/* prefields */}
|
|
324
|
-
{showPrefields && (
|
|
336
|
+
{showPrefields && !isshow && (
|
|
325
337
|
<Box
|
|
326
338
|
sx={{
|
|
327
339
|
display: "grid",
|
|
@@ -344,7 +356,6 @@ const SavedFilterModalView = ({
|
|
|
344
356
|
|
|
345
357
|
<TextField
|
|
346
358
|
fullWidth
|
|
347
|
-
sx={{ bgcolor: "#0E0C0B0F" }}
|
|
348
359
|
size="small"
|
|
349
360
|
value={
|
|
350
361
|
selectedFilter?.created_date
|
|
@@ -358,6 +369,10 @@ const SavedFilterModalView = ({
|
|
|
358
369
|
<CalendarTodayIcon fontSize="small" />
|
|
359
370
|
</IconButton>
|
|
360
371
|
),
|
|
372
|
+
sx: {
|
|
373
|
+
backgroundColor: "#0E0C0B0F",
|
|
374
|
+
borderRadius: "4px",
|
|
375
|
+
},
|
|
361
376
|
}}
|
|
362
377
|
/>
|
|
363
378
|
</Box>
|
|
@@ -375,10 +390,15 @@ const SavedFilterModalView = ({
|
|
|
375
390
|
</Typography>
|
|
376
391
|
<TextField
|
|
377
392
|
fullWidth
|
|
378
|
-
sx={{ bgcolor: "#0E0C0B0F" }}
|
|
379
393
|
size="small"
|
|
380
|
-
value={selectedFilter?.
|
|
381
|
-
InputProps={{
|
|
394
|
+
value={selectedFilter?.created_by || ""}
|
|
395
|
+
InputProps={{
|
|
396
|
+
readOnly: true,
|
|
397
|
+
sx: {
|
|
398
|
+
backgroundColor: "#0E0C0B0F",
|
|
399
|
+
borderRadius: "4px",
|
|
400
|
+
},
|
|
401
|
+
}}
|
|
382
402
|
/>
|
|
383
403
|
</Box>
|
|
384
404
|
|
|
@@ -396,7 +416,6 @@ const SavedFilterModalView = ({
|
|
|
396
416
|
|
|
397
417
|
<TextField
|
|
398
418
|
fullWidth
|
|
399
|
-
sx={{ bgcolor: "#0E0C0B0F" }}
|
|
400
419
|
size="small"
|
|
401
420
|
value={
|
|
402
421
|
selectedFilter?.modified_date
|
|
@@ -410,6 +429,11 @@ const SavedFilterModalView = ({
|
|
|
410
429
|
<CalendarTodayIcon fontSize="small" />
|
|
411
430
|
</IconButton>
|
|
412
431
|
),
|
|
432
|
+
|
|
433
|
+
sx: {
|
|
434
|
+
backgroundColor: "#0E0C0B0F",
|
|
435
|
+
borderRadius: "4px",
|
|
436
|
+
},
|
|
413
437
|
}}
|
|
414
438
|
/>
|
|
415
439
|
</Box>
|
|
@@ -427,11 +451,14 @@ const SavedFilterModalView = ({
|
|
|
427
451
|
</Typography>
|
|
428
452
|
<TextField
|
|
429
453
|
fullWidth
|
|
430
|
-
sx={{ bgcolor: "#0E0C0B0F" }}
|
|
431
454
|
size="small"
|
|
432
455
|
value={selectedFilter?.modified_by || ""}
|
|
433
456
|
InputProps={{
|
|
434
457
|
readOnly: true,
|
|
458
|
+
sx: {
|
|
459
|
+
backgroundColor: "#0E0C0B0F",
|
|
460
|
+
borderRadius: "4px",
|
|
461
|
+
},
|
|
435
462
|
}}
|
|
436
463
|
/>
|
|
437
464
|
</Box>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// !! DON'T DELETE THIS OLD CODE !! //
|
|
2
|
+
|
|
1
3
|
import { FormControl, MenuItem, Select, SxProps, Theme } from "@mui/material";
|
|
2
4
|
import { Controller, UseFormSetValue } from "react-hook-form";
|
|
3
5
|
import { FilterStateProps } from "../../../../../types/filter";
|
|
@@ -16,24 +18,6 @@ interface FormDropdownProps {
|
|
|
16
18
|
onValueChange?: () => void;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
// Allowed date-based operators
|
|
20
|
-
const DATE_ALLOWED_OPERATORS = [
|
|
21
|
-
"equal",
|
|
22
|
-
"before",
|
|
23
|
-
"after",
|
|
24
|
-
"between",
|
|
25
|
-
"is",
|
|
26
|
-
"today",
|
|
27
|
-
"is_day_before",
|
|
28
|
-
"is_day_after",
|
|
29
|
-
"is_month_before",
|
|
30
|
-
"is_month_after",
|
|
31
|
-
"is_before",
|
|
32
|
-
"is_after",
|
|
33
|
-
"is_on_or_before",
|
|
34
|
-
"is_on_or_after",
|
|
35
|
-
];
|
|
36
|
-
|
|
37
21
|
const FormDropdown = ({
|
|
38
22
|
filter,
|
|
39
23
|
control,
|
|
@@ -74,19 +58,6 @@ const FormDropdown = ({
|
|
|
74
58
|
|
|
75
59
|
field.onChange(e);
|
|
76
60
|
|
|
77
|
-
// Reset value if operator switches date → non-date or non-date → date
|
|
78
|
-
if (filter.filter_attribute_data_type === "date") {
|
|
79
|
-
const wasDateOp = DATE_ALLOWED_OPERATORS.includes(oldOperator);
|
|
80
|
-
const isDateOpNow =
|
|
81
|
-
DATE_ALLOWED_OPERATORS.includes(newOperator);
|
|
82
|
-
|
|
83
|
-
if (wasDateOp !== isDateOpNow) {
|
|
84
|
-
setValue(`${filter?.filter_attribute_name}.value`, "", {
|
|
85
|
-
shouldDirty: true,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
61
|
if (
|
|
91
62
|
(filter?.filter_attribute_data_type === "date" ||
|
|
92
63
|
filter?.filter_attribute_data_type === "year") &&
|
|
@@ -130,107 +101,3 @@ const FormDropdown = ({
|
|
|
130
101
|
};
|
|
131
102
|
|
|
132
103
|
export default FormDropdown;
|
|
133
|
-
|
|
134
|
-
// !! DON'T DELETE THIS OLD CODE !! //
|
|
135
|
-
|
|
136
|
-
// import { FormControl, MenuItem, Select, SxProps, Theme } from "@mui/material";
|
|
137
|
-
// import { Controller, UseFormSetValue } from "react-hook-form";
|
|
138
|
-
// import { FilterStateProps } from "../../../../../types/filter";
|
|
139
|
-
// import moment from "moment";
|
|
140
|
-
|
|
141
|
-
// interface FormDropdownProps {
|
|
142
|
-
// filter: FilterStateProps;
|
|
143
|
-
// control: any;
|
|
144
|
-
// setValue: UseFormSetValue<any>;
|
|
145
|
-
// dropdownList: {
|
|
146
|
-
// label?: string;
|
|
147
|
-
// value?: string;
|
|
148
|
-
// }[];
|
|
149
|
-
// isLoading?: boolean;
|
|
150
|
-
// sx?: SxProps<Theme>;
|
|
151
|
-
// onValueChange?: () => void;
|
|
152
|
-
// }
|
|
153
|
-
|
|
154
|
-
// const FormDropdown = ({
|
|
155
|
-
// filter,
|
|
156
|
-
// control,
|
|
157
|
-
// setValue,
|
|
158
|
-
// dropdownList,
|
|
159
|
-
// isLoading = false,
|
|
160
|
-
// sx,
|
|
161
|
-
// onValueChange,
|
|
162
|
-
// }: FormDropdownProps) => {
|
|
163
|
-
// return (
|
|
164
|
-
// <Controller
|
|
165
|
-
// name={`${filter?.filter_attribute_name}.operator`}
|
|
166
|
-
// control={control}
|
|
167
|
-
// defaultValue={filter?.filter_operator || dropdownList?.[0]?.value || ""}
|
|
168
|
-
// render={({ field }) => (
|
|
169
|
-
// <FormControl sx={sx} size="small">
|
|
170
|
-
// <Select
|
|
171
|
-
// {...field}
|
|
172
|
-
// variant="standard"
|
|
173
|
-
// sx={{
|
|
174
|
-
// fontSize: "0.875rem",
|
|
175
|
-
// minWidth: 50,
|
|
176
|
-
// border: "none",
|
|
177
|
-
// boxShadow: "none",
|
|
178
|
-
// "& .MuiSelect-icon": {
|
|
179
|
-
// top: "45%",
|
|
180
|
-
// transform: "translateY(-50%)",
|
|
181
|
-
// "& .MuiOutlinedInput-input": {
|
|
182
|
-
// padding: "12px 20px",
|
|
183
|
-
// },
|
|
184
|
-
// },
|
|
185
|
-
// }}
|
|
186
|
-
// disabled={isLoading}
|
|
187
|
-
// disableUnderline
|
|
188
|
-
// onChange={(e) => {
|
|
189
|
-
// const newOperator = e.target.value;
|
|
190
|
-
// const oldOperator = field.value;
|
|
191
|
-
|
|
192
|
-
// field.onChange(e);
|
|
193
|
-
|
|
194
|
-
// if (
|
|
195
|
-
// (filter?.filter_attribute_data_type === "date" ||
|
|
196
|
-
// filter?.filter_attribute_data_type === "year") &&
|
|
197
|
-
// newOperator !== oldOperator
|
|
198
|
-
// ) {
|
|
199
|
-
// if (newOperator === "today") {
|
|
200
|
-
// setValue(
|
|
201
|
-
// `${filter?.filter_attribute_name}.value`,
|
|
202
|
-
// moment().format("YYYY-MM-DD"),
|
|
203
|
-
// {
|
|
204
|
-
// shouldDirty: true,
|
|
205
|
-
// }
|
|
206
|
-
// );
|
|
207
|
-
// } else if (newOperator === "between") {
|
|
208
|
-
// setValue(`${filter?.filter_attribute_name}.value`, ["", ""], {
|
|
209
|
-
// shouldDirty: true,
|
|
210
|
-
// });
|
|
211
|
-
// } else if (
|
|
212
|
-
// oldOperator === "between" ||
|
|
213
|
-
// oldOperator === "today"
|
|
214
|
-
// ) {
|
|
215
|
-
// setValue(`${filter?.filter_attribute_name}.value`, "", {
|
|
216
|
-
// shouldDirty: true,
|
|
217
|
-
// });
|
|
218
|
-
// }
|
|
219
|
-
// }
|
|
220
|
-
|
|
221
|
-
// onValueChange?.();
|
|
222
|
-
// }}
|
|
223
|
-
// >
|
|
224
|
-
// {dropdownList?.map((item, idx) => (
|
|
225
|
-
// <MenuItem key={idx} value={item.value}>
|
|
226
|
-
// {item.label}
|
|
227
|
-
// </MenuItem>
|
|
228
|
-
// ))}
|
|
229
|
-
// </Select>
|
|
230
|
-
// </FormControl>
|
|
231
|
-
// )}
|
|
232
|
-
// />
|
|
233
|
-
// );
|
|
234
|
-
// };
|
|
235
|
-
|
|
236
|
-
// export default FormDropdown;
|
|
@@ -33,7 +33,10 @@ const FormTextfield = ({
|
|
|
33
33
|
padding: "12px 20px",
|
|
34
34
|
},
|
|
35
35
|
}}
|
|
36
|
-
type={filter?.filter_attribute_data_type || "text"}
|
|
36
|
+
// type={filter?.filter_attribute_data_type || "text" || "number"}
|
|
37
|
+
type={
|
|
38
|
+
filter?.filter_attribute_data_type === "number" ? "number" : "text"
|
|
39
|
+
}
|
|
37
40
|
placeholder={"Enter value"}
|
|
38
41
|
disabled={isLoading}
|
|
39
42
|
onChange={(e) => {
|
|
@@ -350,7 +350,7 @@ const FilterForm = ({
|
|
|
350
350
|
`${filter?.filter_attribute_name}.operator`
|
|
351
351
|
);
|
|
352
352
|
|
|
353
|
-
//
|
|
353
|
+
// Toggle dummy field to force form dirty
|
|
354
354
|
const dummy = watch("dummyChange");
|
|
355
355
|
setValue(
|
|
356
356
|
"dummyChange",
|
|
@@ -469,7 +469,7 @@ const FilterForm = ({
|
|
|
469
469
|
|
|
470
470
|
export default FilterForm;
|
|
471
471
|
|
|
472
|
-
// !! PLEASE DO NOT DELETE THIS
|
|
472
|
+
// !! PLEASE DO NOT DELETE THIS COMMENTED BLOCK !!
|
|
473
473
|
// import {
|
|
474
474
|
// Box,
|
|
475
475
|
// Button,
|
|
@@ -831,7 +831,7 @@ export default FilterForm;
|
|
|
831
831
|
// `${filter?.filter_attribute_name}.operator`
|
|
832
832
|
// );
|
|
833
833
|
|
|
834
|
-
// //
|
|
834
|
+
// // Toggle dummy field to force form dirty
|
|
835
835
|
// const dummy = watch("dummyChange");
|
|
836
836
|
// setValue(
|
|
837
837
|
// "dummyChange",
|
|
@@ -850,60 +850,108 @@ export default FilterForm;
|
|
|
850
850
|
// </Box>
|
|
851
851
|
|
|
852
852
|
// <Box>
|
|
853
|
-
// {
|
|
854
|
-
//
|
|
855
|
-
//
|
|
856
|
-
//
|
|
857
|
-
//
|
|
858
|
-
//
|
|
859
|
-
|
|
860
|
-
//
|
|
861
|
-
|
|
862
|
-
//
|
|
863
|
-
//
|
|
864
|
-
//
|
|
865
|
-
//
|
|
866
|
-
//
|
|
867
|
-
//
|
|
868
|
-
//
|
|
869
|
-
//
|
|
870
|
-
//
|
|
871
|
-
//
|
|
872
|
-
//
|
|
873
|
-
//
|
|
874
|
-
//
|
|
875
|
-
//
|
|
876
|
-
//
|
|
877
|
-
|
|
878
|
-
//
|
|
879
|
-
//
|
|
880
|
-
//
|
|
881
|
-
//
|
|
882
|
-
|
|
883
|
-
//
|
|
884
|
-
// filter
|
|
885
|
-
//
|
|
886
|
-
//
|
|
887
|
-
//
|
|
888
|
-
//
|
|
889
|
-
//
|
|
890
|
-
//
|
|
891
|
-
//
|
|
892
|
-
//
|
|
893
|
-
//
|
|
894
|
-
//
|
|
895
|
-
|
|
896
|
-
//
|
|
897
|
-
//
|
|
898
|
-
//
|
|
899
|
-
//
|
|
900
|
-
//
|
|
901
|
-
//
|
|
902
|
-
//
|
|
903
|
-
//
|
|
904
|
-
//
|
|
905
|
-
//
|
|
906
|
-
//
|
|
853
|
+
// {(() => {
|
|
854
|
+
// const fieldValue = formValues[
|
|
855
|
+
// filter?.filter_attribute_name as string
|
|
856
|
+
// ] as
|
|
857
|
+
// | { value: string | string[]; operator: string }
|
|
858
|
+
// | undefined;
|
|
859
|
+
|
|
860
|
+
// const operator = fieldValue?.operator;
|
|
861
|
+
|
|
862
|
+
// // Operators that should show a Date Picker
|
|
863
|
+
// const dateAllowedOperators = [
|
|
864
|
+
// "equal",
|
|
865
|
+
// "before",
|
|
866
|
+
// "after",
|
|
867
|
+
// "between",
|
|
868
|
+
// "is",
|
|
869
|
+
// "today",
|
|
870
|
+
// "is_before",
|
|
871
|
+
// "is_after",
|
|
872
|
+
// "is_on_or_before",
|
|
873
|
+
// "is_on_or_after",
|
|
874
|
+
// "empty",
|
|
875
|
+
// "not_empty",
|
|
876
|
+
// ];
|
|
877
|
+
|
|
878
|
+
// const showDatePicker =
|
|
879
|
+
// filter?.filter_attribute_data_type === "date" &&
|
|
880
|
+
// operator &&
|
|
881
|
+
// dateAllowedOperators.includes(operator);
|
|
882
|
+
|
|
883
|
+
// if (
|
|
884
|
+
// filter?.filter_attribute_data_type === "text" ||
|
|
885
|
+
// filter?.filter_attribute_data_type === "number"
|
|
886
|
+
// ) {
|
|
887
|
+
// return (
|
|
888
|
+
// <FormTextfield
|
|
889
|
+
// filter={filter}
|
|
890
|
+
// control={control}
|
|
891
|
+
// onValueChange={updateFiltersFromForm}
|
|
892
|
+
// />
|
|
893
|
+
// );
|
|
894
|
+
// }
|
|
895
|
+
|
|
896
|
+
// if (
|
|
897
|
+
// filter?.filter_attribute_data_type === "select"
|
|
898
|
+
// ) {
|
|
899
|
+
// return (
|
|
900
|
+
// <FormMultiSelect
|
|
901
|
+
// filter={filter}
|
|
902
|
+
// control={control}
|
|
903
|
+
// dropdownData={dropdownData}
|
|
904
|
+
// onValueChange={updateFiltersFromForm}
|
|
905
|
+
// />
|
|
906
|
+
// );
|
|
907
|
+
// }
|
|
908
|
+
|
|
909
|
+
// if (
|
|
910
|
+
// filter?.filter_attribute_data_type ===
|
|
911
|
+
// "multiselect"
|
|
912
|
+
// ) {
|
|
913
|
+
// return (
|
|
914
|
+
// <FormMultiSelect
|
|
915
|
+
// filter={filter}
|
|
916
|
+
// control={control}
|
|
917
|
+
// dropdownData={dropdownData}
|
|
918
|
+
// onValueChange={updateFiltersFromForm}
|
|
919
|
+
// />
|
|
920
|
+
// );
|
|
921
|
+
// }
|
|
922
|
+
|
|
923
|
+
// if (filter?.filter_attribute_data_type === "year") {
|
|
924
|
+
// return (
|
|
925
|
+
// <FormDatePicker
|
|
926
|
+
// filter={filter}
|
|
927
|
+
// control={control}
|
|
928
|
+
// views={["year"]}
|
|
929
|
+
// onValueChange={updateFiltersFromForm}
|
|
930
|
+
// />
|
|
931
|
+
// );
|
|
932
|
+
// }
|
|
933
|
+
|
|
934
|
+
// // DATE LOGIC
|
|
935
|
+
// if (showDatePicker) {
|
|
936
|
+
// return (
|
|
937
|
+
// <FormDatePicker
|
|
938
|
+
// filter={filter}
|
|
939
|
+
// control={control}
|
|
940
|
+
// onValueChange={updateFiltersFromForm}
|
|
941
|
+
// />
|
|
942
|
+
// );
|
|
943
|
+
// } else {
|
|
944
|
+
// return (
|
|
945
|
+
// <FormTextfield
|
|
946
|
+
// filter={filter}
|
|
947
|
+
// control={control}
|
|
948
|
+
// onValueChange={updateFiltersFromForm}
|
|
949
|
+
// />
|
|
950
|
+
// );
|
|
951
|
+
// }
|
|
952
|
+
|
|
953
|
+
// return <FormControl fullWidth size="small" />;
|
|
954
|
+
// })()}
|
|
907
955
|
// </Box>
|
|
908
956
|
// </Box>
|
|
909
957
|
// );
|
|
@@ -4,37 +4,20 @@ import FormTextfield from "../components/Textfield";
|
|
|
4
4
|
import FormDatePicker from "../components/Date";
|
|
5
5
|
import FormMultiSelect from "../components/Multi-Select";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
| "before"
|
|
10
|
-
| "after"
|
|
11
|
-
| "between"
|
|
12
|
-
| "is"
|
|
13
|
-
| "today"
|
|
14
|
-
| "is_day_before"
|
|
15
|
-
| "is_day_after"
|
|
16
|
-
| "is_month_before"
|
|
17
|
-
| "is_month_after"
|
|
18
|
-
| "is_before"
|
|
19
|
-
| "is_after"
|
|
20
|
-
| "is_on_or_before"
|
|
21
|
-
| "is_on_or_after";
|
|
22
|
-
|
|
23
|
-
export const DATE_ALLOWED_OPERATORS: DateOperator[] = [
|
|
7
|
+
// Operators that should show a Date Picker
|
|
8
|
+
const dateAllowedOperators = [
|
|
24
9
|
"equal",
|
|
25
10
|
"before",
|
|
26
11
|
"after",
|
|
27
12
|
"between",
|
|
28
13
|
"is",
|
|
29
14
|
"today",
|
|
30
|
-
"is_day_before",
|
|
31
|
-
"is_day_after",
|
|
32
|
-
"is_month_before",
|
|
33
|
-
"is_month_after",
|
|
34
15
|
"is_before",
|
|
35
16
|
"is_after",
|
|
36
17
|
"is_on_or_before",
|
|
37
18
|
"is_on_or_after",
|
|
19
|
+
"empty",
|
|
20
|
+
"not_empty",
|
|
38
21
|
];
|
|
39
22
|
|
|
40
23
|
export const resolveFilterInput = ({
|
|
@@ -50,20 +33,10 @@ export const resolveFilterInput = ({
|
|
|
50
33
|
dropdownData: any;
|
|
51
34
|
updateFiltersFromForm: () => void;
|
|
52
35
|
}) => {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const showDatePicker =
|
|
56
|
-
isDateType && operator && DATE_ALLOWED_OPERATORS.includes(operator as any);
|
|
36
|
+
const dataType = filter?.filter_attribute_data_type;
|
|
57
37
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
(!operator || !DATE_ALLOWED_OPERATORS.includes(operator as any));
|
|
61
|
-
|
|
62
|
-
// TEXT / NUMBER -> Always TextField
|
|
63
|
-
if (
|
|
64
|
-
filter?.filter_attribute_data_type === "text" ||
|
|
65
|
-
filter?.filter_attribute_data_type === "number"
|
|
66
|
-
) {
|
|
38
|
+
// TEXT / NUMBER → always textfield
|
|
39
|
+
if (dataType === "text" || dataType === "number") {
|
|
67
40
|
return (
|
|
68
41
|
<FormTextfield
|
|
69
42
|
filter={filter}
|
|
@@ -73,8 +46,8 @@ export const resolveFilterInput = ({
|
|
|
73
46
|
);
|
|
74
47
|
}
|
|
75
48
|
|
|
76
|
-
// YEAR
|
|
77
|
-
if (
|
|
49
|
+
// YEAR → DatePicker (Year mode)
|
|
50
|
+
if (dataType === "year") {
|
|
78
51
|
return (
|
|
79
52
|
<FormDatePicker
|
|
80
53
|
filter={filter}
|
|
@@ -85,18 +58,21 @@ export const resolveFilterInput = ({
|
|
|
85
58
|
);
|
|
86
59
|
}
|
|
87
60
|
|
|
88
|
-
// DATE
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
61
|
+
// DATE FIELD
|
|
62
|
+
if (dataType === "date") {
|
|
63
|
+
const showDatePicker = operator && dateAllowedOperators.includes(operator);
|
|
64
|
+
|
|
65
|
+
if (showDatePicker) {
|
|
66
|
+
// Date Picker
|
|
67
|
+
return (
|
|
68
|
+
<FormDatePicker
|
|
69
|
+
filter={filter}
|
|
70
|
+
control={control}
|
|
71
|
+
onValueChange={updateFiltersFromForm}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
98
75
|
|
|
99
|
-
if (showTextInsteadOfDate) {
|
|
100
76
|
return (
|
|
101
77
|
<FormTextfield
|
|
102
78
|
filter={filter}
|
|
@@ -106,7 +82,7 @@ export const resolveFilterInput = ({
|
|
|
106
82
|
);
|
|
107
83
|
}
|
|
108
84
|
|
|
109
|
-
//
|
|
85
|
+
// SELECT / MULTISELECT / RADIO / CHECKBOX
|
|
110
86
|
if (
|
|
111
87
|
filter?.filter_attribute_data_type !== undefined &&
|
|
112
88
|
["select", "multiselect", "radio", "checkbox"].includes(
|