rez-table-listing-mui 1.3.17 → 1.3.19
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 +18 -5
- 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/kanban/index.tsx +8 -10
- package/src/listing/components/filter/components/forms/components/Dropdown.tsx +135 -0
- package/src/listing/components/filter/components/forms/index.tsx +538 -66
- package/src/listing/components/filter/components/forms/utils/filter-date-input-resolver.tsx +127 -0
- package/src/listing/components/login/index.tsx +66 -24
- package/src/listing/components/table-settings/common/listing-values.tsx +22 -19
- package/src/listing/components/table-settings/components/column.tsx +13 -8
- package/src/listing/components/table-settings/components/group-by.tsx +1 -1
- package/src/listing/components/table-settings/components/lane.tsx +1 -1
- package/src/listing/components/table-settings/components/quick-tab.tsx +45 -35
- package/src/listing/components/table-settings/components/sorting.tsx +90 -68
- package/src/listing/components/table-settings/index.tsx +6 -2
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +22 -1
- package/src/listing/libs/services/getLayoutAPI.tsx +1 -1
- package/src/listing/libs/utils/apiColumn.ts +18 -0
- package/src/listing/libs/utils/common.ts +2 -2
- package/src/listing/types/filter-settings.ts +13 -9
- package/src/view/KanbanView.tsx +1 -1
- package/src/view/ListingView.tsx +55 -11
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Button,
|
|
4
|
-
FormControl,
|
|
5
|
-
IconButton,
|
|
6
|
-
TextField,
|
|
7
|
-
Typography,
|
|
8
|
-
} from "@mui/material";
|
|
1
|
+
import { Box, Button, IconButton, TextField, Typography } from "@mui/material";
|
|
9
2
|
import { CloseIcon, DeleteIcon } from "../../../../../assets/svg";
|
|
10
3
|
import {
|
|
11
4
|
FilterColumnsDataProps,
|
|
@@ -15,17 +8,15 @@ import {
|
|
|
15
8
|
FilterStateProps,
|
|
16
9
|
} from "../../../../types/filter";
|
|
17
10
|
import { Controller, useForm } from "react-hook-form";
|
|
18
|
-
import FormTextfield from "./components/Textfield";
|
|
19
11
|
import React, { useEffect, useMemo, useCallback } from "react";
|
|
20
|
-
import FormDatePicker from "./components/Date";
|
|
21
12
|
import FormDropdown from "./components/Dropdown";
|
|
22
|
-
import FormMultiSelect from "./components/Multi-Select";
|
|
23
13
|
import { CraftTableOptionsProps } from "../../../../types/table-options";
|
|
24
14
|
import FilterCriteria from "./components/Filter-criteria";
|
|
25
15
|
import CustomSearch from "../search";
|
|
26
16
|
import { customDebounce } from "../../../../libs/utils/debounce";
|
|
27
17
|
import { filterFormStyles } from "../../style";
|
|
28
18
|
import { onFilterChangeFunctionProps } from "../../../../types/common";
|
|
19
|
+
import { resolveFilterInput } from "./utils/filter-date-input-resolver";
|
|
29
20
|
|
|
30
21
|
interface FormValues {
|
|
31
22
|
filterName: string;
|
|
@@ -199,7 +190,7 @@ const FilterForm = ({
|
|
|
199
190
|
return (
|
|
200
191
|
<form
|
|
201
192
|
onSubmit={(e) => {
|
|
202
|
-
e.preventDefault(); //
|
|
193
|
+
e.preventDefault(); // This prevents the page from reloading
|
|
203
194
|
}}
|
|
204
195
|
>
|
|
205
196
|
<Box sx={editMode ? filterFormStyles.formEditModeStyle : {}}>
|
|
@@ -378,60 +369,23 @@ const FilterForm = ({
|
|
|
378
369
|
</Box>
|
|
379
370
|
|
|
380
371
|
<Box>
|
|
381
|
-
{
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
control={control}
|
|
399
|
-
onValueChange={updateFiltersFromForm}
|
|
400
|
-
/>
|
|
401
|
-
) : filter?.filter_attribute_data_type ===
|
|
402
|
-
"select" ? (
|
|
403
|
-
<FormMultiSelect
|
|
404
|
-
filter={filter}
|
|
405
|
-
control={control}
|
|
406
|
-
dropdownData={dropdownData}
|
|
407
|
-
onValueChange={updateFiltersFromForm}
|
|
408
|
-
/>
|
|
409
|
-
) : filter?.filter_attribute_data_type ===
|
|
410
|
-
"multiselect" ? (
|
|
411
|
-
<FormMultiSelect
|
|
412
|
-
filter={filter}
|
|
413
|
-
control={control}
|
|
414
|
-
dropdownData={dropdownData}
|
|
415
|
-
onValueChange={updateFiltersFromForm}
|
|
416
|
-
/>
|
|
417
|
-
) : filter?.filter_attribute_data_type === "radio" ? (
|
|
418
|
-
<FormMultiSelect
|
|
419
|
-
filter={filter}
|
|
420
|
-
control={control}
|
|
421
|
-
dropdownData={dropdownData}
|
|
422
|
-
onValueChange={updateFiltersFromForm}
|
|
423
|
-
/>
|
|
424
|
-
) : filter?.filter_attribute_data_type ===
|
|
425
|
-
"checkbox" ? (
|
|
426
|
-
<FormMultiSelect
|
|
427
|
-
filter={filter}
|
|
428
|
-
control={control}
|
|
429
|
-
dropdownData={dropdownData}
|
|
430
|
-
onValueChange={updateFiltersFromForm}
|
|
431
|
-
/>
|
|
432
|
-
) : (
|
|
433
|
-
<FormControl fullWidth size="small" />
|
|
434
|
-
)}
|
|
372
|
+
{(() => {
|
|
373
|
+
const fieldValue = formValues[
|
|
374
|
+
filter?.filter_attribute_name as keyof FormValues
|
|
375
|
+
] as
|
|
376
|
+
| { value: string | string[]; operator: string }
|
|
377
|
+
| undefined;
|
|
378
|
+
|
|
379
|
+
const operator = fieldValue?.operator;
|
|
380
|
+
|
|
381
|
+
return resolveFilterInput({
|
|
382
|
+
filter,
|
|
383
|
+
operator,
|
|
384
|
+
control,
|
|
385
|
+
dropdownData,
|
|
386
|
+
updateFiltersFromForm,
|
|
387
|
+
});
|
|
388
|
+
})()}
|
|
435
389
|
</Box>
|
|
436
390
|
</Box>
|
|
437
391
|
);
|
|
@@ -514,3 +468,521 @@ const FilterForm = ({
|
|
|
514
468
|
};
|
|
515
469
|
|
|
516
470
|
export default FilterForm;
|
|
471
|
+
|
|
472
|
+
// !! PLEASE DO NOT DELETE THIS COMMENT BLOCK !!
|
|
473
|
+
// import {
|
|
474
|
+
// Box,
|
|
475
|
+
// Button,
|
|
476
|
+
// FormControl,
|
|
477
|
+
// IconButton,
|
|
478
|
+
// TextField,
|
|
479
|
+
// Typography,
|
|
480
|
+
// } from "@mui/material";
|
|
481
|
+
// import { CloseIcon, DeleteIcon } from "../../../../../assets/svg";
|
|
482
|
+
// import {
|
|
483
|
+
// FilterColumnsDataProps,
|
|
484
|
+
// FilterComponentOptions,
|
|
485
|
+
// FilterDropdownDataProps,
|
|
486
|
+
// FilterMasterStateProps,
|
|
487
|
+
// FilterStateProps,
|
|
488
|
+
// } from "../../../../types/filter";
|
|
489
|
+
// import { Controller, useForm } from "react-hook-form";
|
|
490
|
+
// import FormTextfield from "./components/Textfield";
|
|
491
|
+
// import React, { useEffect, useMemo, useCallback } from "react";
|
|
492
|
+
// import FormDatePicker from "./components/Date";
|
|
493
|
+
// import FormDropdown from "./components/Dropdown";
|
|
494
|
+
// import FormMultiSelect from "./components/Multi-Select";
|
|
495
|
+
// import { CraftTableOptionsProps } from "../../../../types/table-options";
|
|
496
|
+
// import FilterCriteria from "./components/Filter-criteria";
|
|
497
|
+
// import CustomSearch from "../search";
|
|
498
|
+
// import { customDebounce } from "../../../../libs/utils/debounce";
|
|
499
|
+
// import { filterFormStyles } from "../../style";
|
|
500
|
+
// import { onFilterChangeFunctionProps } from "../../../../types/common";
|
|
501
|
+
|
|
502
|
+
// interface FormValues {
|
|
503
|
+
// filterName: string;
|
|
504
|
+
// [key: string]:
|
|
505
|
+
// | {
|
|
506
|
+
// value: string | string[];
|
|
507
|
+
// operator: string;
|
|
508
|
+
// }
|
|
509
|
+
// | string;
|
|
510
|
+
// }
|
|
511
|
+
|
|
512
|
+
// const FilterForm = ({
|
|
513
|
+
// columnsData,
|
|
514
|
+
// dropdownData,
|
|
515
|
+
// searchTerm = "",
|
|
516
|
+
// setSearchTerm,
|
|
517
|
+
// handleRemoveFilter,
|
|
518
|
+
// editMode = false,
|
|
519
|
+
// tableStates,
|
|
520
|
+
// setSavedFilterModalOpen,
|
|
521
|
+
// setDeleteFilterModalOpen,
|
|
522
|
+
// onChangeFunction,
|
|
523
|
+
// filterComponentOptions,
|
|
524
|
+
// }: {
|
|
525
|
+
// columnsData: FilterColumnsDataProps;
|
|
526
|
+
// dropdownData: FilterDropdownDataProps;
|
|
527
|
+
// searchTerm?: string;
|
|
528
|
+
// setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
529
|
+
// handleRemoveFilter: (filter_attribute: string) => void;
|
|
530
|
+
// editMode?: boolean;
|
|
531
|
+
// tableStates: CraftTableOptionsProps;
|
|
532
|
+
// setSavedFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
533
|
+
// setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
534
|
+
// onChangeFunction: ({
|
|
535
|
+
// updatedFilters,
|
|
536
|
+
// filterMaster,
|
|
537
|
+
// }: onFilterChangeFunctionProps) => void;
|
|
538
|
+
// filterComponentOptions?: FilterComponentOptions;
|
|
539
|
+
// }) => {
|
|
540
|
+
// const { filterMaster, filters, setFilters, setFilterMaster, setPagination } =
|
|
541
|
+
// tableStates;
|
|
542
|
+
|
|
543
|
+
// const showSaveButton =
|
|
544
|
+
// filterComponentOptions?.tabOptions?.mainFilter?.showSaveButton;
|
|
545
|
+
// const showClearAllButton =
|
|
546
|
+
// filterComponentOptions?.tabOptions?.mainFilter?.showClearAllButton;
|
|
547
|
+
// const customButtons =
|
|
548
|
+
// filterComponentOptions?.tabOptions?.mainFilter?.customButtons;
|
|
549
|
+
|
|
550
|
+
// const filterName = filterMaster?.saved_filters?.selectedName || "";
|
|
551
|
+
|
|
552
|
+
// const defaultValues = useMemo(() => {
|
|
553
|
+
// const filterValues = filters?.reduce((acc, curr) => {
|
|
554
|
+
// if (curr?.filter_attribute_name) {
|
|
555
|
+
// acc[curr?.filter_attribute_name] = {
|
|
556
|
+
// value: curr?.filter_value ?? "",
|
|
557
|
+
// operator:
|
|
558
|
+
// curr?.filter_operator ?? curr?.dropdown_list?.[0]?.value ?? "",
|
|
559
|
+
// };
|
|
560
|
+
// }
|
|
561
|
+
// return acc;
|
|
562
|
+
// }, {} as Record<string, { value: string | string[]; operator: string }>);
|
|
563
|
+
|
|
564
|
+
// return {
|
|
565
|
+
// filterName: filterName ?? "",
|
|
566
|
+
// dummyChange: "",
|
|
567
|
+
// ...filterValues,
|
|
568
|
+
// };
|
|
569
|
+
// }, [filters, filterName]);
|
|
570
|
+
|
|
571
|
+
// const { control, watch, reset, setValue, unregister } = useForm<
|
|
572
|
+
// FormValues & { dummyChange: string }
|
|
573
|
+
// >({
|
|
574
|
+
// mode: "onChange",
|
|
575
|
+
// defaultValues,
|
|
576
|
+
// resetOptions: {
|
|
577
|
+
// keepDirtyValues: false,
|
|
578
|
+
// keepErrors: false,
|
|
579
|
+
// },
|
|
580
|
+
// });
|
|
581
|
+
|
|
582
|
+
// const formValues = watch();
|
|
583
|
+
|
|
584
|
+
// useEffect(() => {
|
|
585
|
+
// reset(defaultValues);
|
|
586
|
+
// }, [filters]);
|
|
587
|
+
|
|
588
|
+
// const debouncedUpdateFilters = useCallback(
|
|
589
|
+
// customDebounce((updatedFilters: FilterStateProps[]) => {
|
|
590
|
+
// setFilters(updatedFilters);
|
|
591
|
+
|
|
592
|
+
// const newState = {
|
|
593
|
+
// filterMaster: filterMaster,
|
|
594
|
+
// filters: updatedFilters,
|
|
595
|
+
// };
|
|
596
|
+
|
|
597
|
+
// onChangeFunction && onChangeFunction(newState);
|
|
598
|
+
// }, 1000),
|
|
599
|
+
// [setFilters]
|
|
600
|
+
// );
|
|
601
|
+
|
|
602
|
+
// const updateFiltersFromForm = useCallback(() => {
|
|
603
|
+
// const updatedFilters = filters?.map((filter) => {
|
|
604
|
+
// if (
|
|
605
|
+
// filter?.filter_attribute_name &&
|
|
606
|
+
// typeof formValues[filter?.filter_attribute_name] === "object"
|
|
607
|
+
// ) {
|
|
608
|
+
// const filterValue = formValues[filter?.filter_attribute_name] as {
|
|
609
|
+
// value: string | string[];
|
|
610
|
+
// operator: string;
|
|
611
|
+
// };
|
|
612
|
+
|
|
613
|
+
// return {
|
|
614
|
+
// ...filter,
|
|
615
|
+
// filter_value: filterValue.value,
|
|
616
|
+
// filter_operator: filterValue.operator,
|
|
617
|
+
// };
|
|
618
|
+
// }
|
|
619
|
+
// return filter;
|
|
620
|
+
// });
|
|
621
|
+
|
|
622
|
+
// setPagination((prev) => ({ ...prev, pageIndex: 0 }));
|
|
623
|
+
// debouncedUpdateFilters(updatedFilters);
|
|
624
|
+
// }, [formValues, filters, debouncedUpdateFilters]);
|
|
625
|
+
|
|
626
|
+
// useEffect(() => {
|
|
627
|
+
// return () => {
|
|
628
|
+
// reset();
|
|
629
|
+
// filters?.forEach((filter) => {
|
|
630
|
+
// if (filter?.filter_attribute_name) {
|
|
631
|
+
// unregister(filter?.filter_attribute_name);
|
|
632
|
+
// }
|
|
633
|
+
// });
|
|
634
|
+
// };
|
|
635
|
+
// }, []);
|
|
636
|
+
|
|
637
|
+
// const groupedFilters = useMemo(() => {
|
|
638
|
+
// return filters?.reduce((acc, filter) => {
|
|
639
|
+
// const key = filter?.filter_entity_name || "";
|
|
640
|
+
// if (!acc[key]) {
|
|
641
|
+
// acc[key] = [];
|
|
642
|
+
// }
|
|
643
|
+
// acc[key].push(filter);
|
|
644
|
+
// return acc;
|
|
645
|
+
// }, {} as Record<string, FilterStateProps[]>);
|
|
646
|
+
// }, [filters]);
|
|
647
|
+
|
|
648
|
+
// const handleRemoveEntityType = (entityType: string) => {
|
|
649
|
+
// const remainingFilters = filters?.filter(
|
|
650
|
+
// (f) => f.filter_entity_name !== entityType
|
|
651
|
+
// );
|
|
652
|
+
|
|
653
|
+
// // unregister all fields belonging to this entity type
|
|
654
|
+
// filters?.forEach((f) => {
|
|
655
|
+
// if (f?.filter_entity_name === entityType && f?.filter_attribute_name) {
|
|
656
|
+
// unregister(`${f?.filter_attribute_name}.value`);
|
|
657
|
+
// unregister(`${f?.filter_attribute_name}.operator`);
|
|
658
|
+
// }
|
|
659
|
+
// });
|
|
660
|
+
|
|
661
|
+
// setFilters(remainingFilters);
|
|
662
|
+
|
|
663
|
+
// const newState = {
|
|
664
|
+
// filterMaster,
|
|
665
|
+
// filters: remainingFilters,
|
|
666
|
+
// };
|
|
667
|
+
|
|
668
|
+
// onChangeFunction && onChangeFunction(newState);
|
|
669
|
+
// };
|
|
670
|
+
|
|
671
|
+
// return (
|
|
672
|
+
// <form
|
|
673
|
+
// onSubmit={(e) => {
|
|
674
|
+
// e.preventDefault(); // This prevents the page from reloading
|
|
675
|
+
// }}
|
|
676
|
+
// >
|
|
677
|
+
// <Box sx={editMode ? filterFormStyles.formEditModeStyle : {}}>
|
|
678
|
+
// {editMode && (
|
|
679
|
+
// <Box
|
|
680
|
+
// sx={{
|
|
681
|
+
// "& .MuiOutlinedInput-root": {
|
|
682
|
+
// borderRadius: "6px",
|
|
683
|
+
// fontSize: "14px",
|
|
684
|
+
// bgcolor: "#fafafa",
|
|
685
|
+
// "& fieldset": { borderColor: "#c1c1c1" },
|
|
686
|
+
// "&.Mui-focused fieldset": { borderColor: "#7A5AF8" },
|
|
687
|
+
// },
|
|
688
|
+
// display: "flex",
|
|
689
|
+
// alignItems: "center",
|
|
690
|
+
// justifyContent: "center",
|
|
691
|
+
// padding: "0.5rem 0 1rem 0",
|
|
692
|
+
// gap: 1,
|
|
693
|
+
// }}
|
|
694
|
+
// >
|
|
695
|
+
// <Controller
|
|
696
|
+
// name="filterName"
|
|
697
|
+
// control={control}
|
|
698
|
+
// render={({ field }) => (
|
|
699
|
+
// <TextField
|
|
700
|
+
// fullWidth
|
|
701
|
+
// size="small"
|
|
702
|
+
// placeholder="Filter Name"
|
|
703
|
+
// value={filterName || field.value}
|
|
704
|
+
// onChange={(e) => {
|
|
705
|
+
// field.onChange(e);
|
|
706
|
+
// if (editMode) {
|
|
707
|
+
// setFilterMaster(
|
|
708
|
+
// (prev) =>
|
|
709
|
+
// ({
|
|
710
|
+
// ...prev,
|
|
711
|
+
// saved_filters: {
|
|
712
|
+
// ...prev?.saved_filters,
|
|
713
|
+
// selectedName: e.target.value,
|
|
714
|
+
// },
|
|
715
|
+
// } as FilterMasterStateProps)
|
|
716
|
+
// );
|
|
717
|
+
// }
|
|
718
|
+
// }}
|
|
719
|
+
// inputRef={field.ref}
|
|
720
|
+
// sx={{
|
|
721
|
+
// maxWidth: 400,
|
|
722
|
+
|
|
723
|
+
// "& .MuiOutlinedInput-root": {
|
|
724
|
+
// bgcolor: "white",
|
|
725
|
+
// borderRadius: "0px",
|
|
726
|
+
// fontSize: "14px",
|
|
727
|
+
// color: "#272524",
|
|
728
|
+
// fontWeight: "500",
|
|
729
|
+
// "& fieldset": { borderColor: "#c5c5c5" },
|
|
730
|
+
// "&.Mui-focused fieldset": { borderColor: "#7A5AF8" },
|
|
731
|
+
// },
|
|
732
|
+
// }}
|
|
733
|
+
// />
|
|
734
|
+
// )}
|
|
735
|
+
// />
|
|
736
|
+
// <Box onClick={(e) => e.stopPropagation()}>
|
|
737
|
+
// <IconButton
|
|
738
|
+
// size="small"
|
|
739
|
+
// onClick={() =>
|
|
740
|
+
// setDeleteFilterModalOpen && setDeleteFilterModalOpen(true)
|
|
741
|
+
// }
|
|
742
|
+
// >
|
|
743
|
+
// <DeleteIcon />
|
|
744
|
+
// </IconButton>
|
|
745
|
+
// </Box>
|
|
746
|
+
// </Box>
|
|
747
|
+
// )}
|
|
748
|
+
|
|
749
|
+
// <Box
|
|
750
|
+
// className="filter-criteria-form"
|
|
751
|
+
// sx={filterFormStyles.formFlexContainer}
|
|
752
|
+
// >
|
|
753
|
+
// <FilterCriteria
|
|
754
|
+
// columnsData={columnsData}
|
|
755
|
+
// tableStates={tableStates}
|
|
756
|
+
// onChangeFunction={onChangeFunction}
|
|
757
|
+
// filterComponentOptions={filterComponentOptions}
|
|
758
|
+
// />
|
|
759
|
+
|
|
760
|
+
// {!editMode && (
|
|
761
|
+
// <CustomSearch value={searchTerm} onChange={setSearchTerm} />
|
|
762
|
+
// )}
|
|
763
|
+
|
|
764
|
+
// <Box
|
|
765
|
+
// className="filter-form-inputs"
|
|
766
|
+
// sx={filterFormStyles.formFlexContainer}
|
|
767
|
+
// >
|
|
768
|
+
// {Object.entries(groupedFilters).map(([entityType, filters]) => (
|
|
769
|
+
// <Box
|
|
770
|
+
// key={entityType}
|
|
771
|
+
// sx={{
|
|
772
|
+
// border: "1px solid #c5c5c5",
|
|
773
|
+
// borderRadius: 2,
|
|
774
|
+
// overflow: "hidden",
|
|
775
|
+
// }}
|
|
776
|
+
// >
|
|
777
|
+
// {/* Group Header */}
|
|
778
|
+
// <Box
|
|
779
|
+
// className="group-header"
|
|
780
|
+
// sx={filterFormStyles.formListSectionHeader}
|
|
781
|
+
// >
|
|
782
|
+
// <Typography fontSize={14}>{entityType}</Typography>
|
|
783
|
+
// <IconButton
|
|
784
|
+
// size="small"
|
|
785
|
+
// onClick={() => handleRemoveEntityType(entityType)}
|
|
786
|
+
// >
|
|
787
|
+
// <CloseIcon />
|
|
788
|
+
// </IconButton>
|
|
789
|
+
// </Box>
|
|
790
|
+
|
|
791
|
+
// {filters
|
|
792
|
+
// .filter(
|
|
793
|
+
// (filter) =>
|
|
794
|
+
// filter?.filter_attribute_name
|
|
795
|
+
// ?.toLowerCase()
|
|
796
|
+
// .includes(searchTerm.toLowerCase()) ||
|
|
797
|
+
// filter.filter_value
|
|
798
|
+
// ?.toString()
|
|
799
|
+
// .toLowerCase()
|
|
800
|
+
// .includes(searchTerm.toLowerCase())
|
|
801
|
+
// )
|
|
802
|
+
// .reverse()
|
|
803
|
+
// .map((filter) => {
|
|
804
|
+
// const dropdown_list = filter.dropdown_list || [];
|
|
805
|
+
// return (
|
|
806
|
+
// <Box
|
|
807
|
+
// key={filter.filter_attribute}
|
|
808
|
+
// sx={filterFormStyles.formListItem}
|
|
809
|
+
// >
|
|
810
|
+
// <Box sx={filterFormStyles.formListItemHeader}>
|
|
811
|
+
// <Typography
|
|
812
|
+
// sx={filterFormStyles.formListItemHeaderName}
|
|
813
|
+
// >
|
|
814
|
+
// {filter?.filter_attribute_name}
|
|
815
|
+
// </Typography>
|
|
816
|
+
// <FormDropdown
|
|
817
|
+
// filter={filter}
|
|
818
|
+
// control={control}
|
|
819
|
+
// setValue={setValue}
|
|
820
|
+
// dropdownList={dropdown_list}
|
|
821
|
+
// sx={filterFormStyles.formListItemHeaderDropdown}
|
|
822
|
+
// onValueChange={updateFiltersFromForm}
|
|
823
|
+
// />
|
|
824
|
+
// <IconButton
|
|
825
|
+
// sx={{ marginLeft: "auto" }}
|
|
826
|
+
// onClick={() => {
|
|
827
|
+
// unregister(
|
|
828
|
+
// `${filter?.filter_attribute_name}.value`
|
|
829
|
+
// );
|
|
830
|
+
// unregister(
|
|
831
|
+
// `${filter?.filter_attribute_name}.operator`
|
|
832
|
+
// );
|
|
833
|
+
|
|
834
|
+
// // ✅ Toggle dummy field to force form dirty
|
|
835
|
+
// const dummy = watch("dummyChange");
|
|
836
|
+
// setValue(
|
|
837
|
+
// "dummyChange",
|
|
838
|
+
// dummy === "changed" ? "reset" : "changed",
|
|
839
|
+
// {
|
|
840
|
+
// shouldDirty: true,
|
|
841
|
+
// }
|
|
842
|
+
// );
|
|
843
|
+
|
|
844
|
+
// handleRemoveFilter(filter.filter_attribute);
|
|
845
|
+
// }}
|
|
846
|
+
// size="small"
|
|
847
|
+
// >
|
|
848
|
+
// <CloseIcon />
|
|
849
|
+
// </IconButton>
|
|
850
|
+
// </Box>
|
|
851
|
+
|
|
852
|
+
// <Box>
|
|
853
|
+
// {filter?.filter_attribute_data_type === "text" ||
|
|
854
|
+
// filter?.filter_attribute_data_type === "number" ? (
|
|
855
|
+
// <FormTextfield
|
|
856
|
+
// filter={filter}
|
|
857
|
+
// control={control}
|
|
858
|
+
// onValueChange={updateFiltersFromForm}
|
|
859
|
+
// />
|
|
860
|
+
// ) : filter?.filter_attribute_data_type === "year" ? (
|
|
861
|
+
// <FormDatePicker
|
|
862
|
+
// filter={filter}
|
|
863
|
+
// control={control}
|
|
864
|
+
// views={["year"]}
|
|
865
|
+
// onValueChange={updateFiltersFromForm}
|
|
866
|
+
// />
|
|
867
|
+
// ) : filter?.filter_attribute_data_type === "date" ? (
|
|
868
|
+
// <FormDatePicker
|
|
869
|
+
// filter={filter}
|
|
870
|
+
// control={control}
|
|
871
|
+
// onValueChange={updateFiltersFromForm}
|
|
872
|
+
// />
|
|
873
|
+
// ) : filter?.filter_attribute_data_type ===
|
|
874
|
+
// "select" ? (
|
|
875
|
+
// <FormMultiSelect
|
|
876
|
+
// filter={filter}
|
|
877
|
+
// control={control}
|
|
878
|
+
// dropdownData={dropdownData}
|
|
879
|
+
// onValueChange={updateFiltersFromForm}
|
|
880
|
+
// />
|
|
881
|
+
// ) : filter?.filter_attribute_data_type ===
|
|
882
|
+
// "multiselect" ? (
|
|
883
|
+
// <FormMultiSelect
|
|
884
|
+
// filter={filter}
|
|
885
|
+
// control={control}
|
|
886
|
+
// dropdownData={dropdownData}
|
|
887
|
+
// onValueChange={updateFiltersFromForm}
|
|
888
|
+
// />
|
|
889
|
+
// ) : filter?.filter_attribute_data_type === "radio" ? (
|
|
890
|
+
// <FormMultiSelect
|
|
891
|
+
// filter={filter}
|
|
892
|
+
// control={control}
|
|
893
|
+
// dropdownData={dropdownData}
|
|
894
|
+
// onValueChange={updateFiltersFromForm}
|
|
895
|
+
// />
|
|
896
|
+
// ) : filter?.filter_attribute_data_type ===
|
|
897
|
+
// "checkbox" ? (
|
|
898
|
+
// <FormMultiSelect
|
|
899
|
+
// filter={filter}
|
|
900
|
+
// control={control}
|
|
901
|
+
// dropdownData={dropdownData}
|
|
902
|
+
// onValueChange={updateFiltersFromForm}
|
|
903
|
+
// />
|
|
904
|
+
// ) : (
|
|
905
|
+
// <FormControl fullWidth size="small" />
|
|
906
|
+
// )}
|
|
907
|
+
// </Box>
|
|
908
|
+
// </Box>
|
|
909
|
+
// );
|
|
910
|
+
// })}
|
|
911
|
+
// </Box>
|
|
912
|
+
// ))}
|
|
913
|
+
// </Box>
|
|
914
|
+
// </Box>
|
|
915
|
+
// </Box>
|
|
916
|
+
|
|
917
|
+
// {filters?.length > 0 && (showClearAllButton || showSaveButton) && (
|
|
918
|
+
// <Box sx={{ display: "flex", justifyContent: "center", gap: 1, mt: 3 }}>
|
|
919
|
+
// {showClearAllButton && (
|
|
920
|
+
// <Button
|
|
921
|
+
// variant="outlined"
|
|
922
|
+
// sx={{
|
|
923
|
+
// color: "#7A5AF8",
|
|
924
|
+
// border: `1px solid #7A5AF8`,
|
|
925
|
+
// borderRadius: "6px",
|
|
926
|
+
// textTransform: "none",
|
|
927
|
+
// fontSize: "14px",
|
|
928
|
+
// }}
|
|
929
|
+
// fullWidth
|
|
930
|
+
// onClick={() => {
|
|
931
|
+
// setFilters([]);
|
|
932
|
+
|
|
933
|
+
// const filterMaster = {
|
|
934
|
+
// ...tableStates.filterMaster,
|
|
935
|
+
// activeFilterTabIndex: -1,
|
|
936
|
+
// };
|
|
937
|
+
|
|
938
|
+
// const newState = {
|
|
939
|
+
// filterMaster: filterMaster,
|
|
940
|
+
// filters: [],
|
|
941
|
+
// };
|
|
942
|
+
|
|
943
|
+
// onChangeFunction && onChangeFunction(newState);
|
|
944
|
+
// }}
|
|
945
|
+
// >
|
|
946
|
+
// Clear All
|
|
947
|
+
// </Button>
|
|
948
|
+
// )}
|
|
949
|
+
|
|
950
|
+
// {showSaveButton && (
|
|
951
|
+
// <Button
|
|
952
|
+
// variant="contained"
|
|
953
|
+
// fullWidth
|
|
954
|
+
// sx={{
|
|
955
|
+
// color: "white",
|
|
956
|
+
// backgroundColor: "#7A5AF8",
|
|
957
|
+
// "&.Mui-disabled": {
|
|
958
|
+
// backgroundColor: "#d7cefd",
|
|
959
|
+
// color: "rgba(255, 255, 255, 0.7)",
|
|
960
|
+
// },
|
|
961
|
+
// }}
|
|
962
|
+
// onClick={() => {
|
|
963
|
+
// setSavedFilterModalOpen && setSavedFilterModalOpen(true);
|
|
964
|
+
// }}
|
|
965
|
+
// >
|
|
966
|
+
// Save Filter
|
|
967
|
+
// </Button>
|
|
968
|
+
// )}
|
|
969
|
+
|
|
970
|
+
// {/* Custom buttons from props */}
|
|
971
|
+
// {customButtons?.map((btn, idx) => (
|
|
972
|
+
// <Button
|
|
973
|
+
// key={idx}
|
|
974
|
+
// fullWidth
|
|
975
|
+
// variant={btn?.variant ?? "outlined"}
|
|
976
|
+
// sx={btn?.sx}
|
|
977
|
+
// {...btn}
|
|
978
|
+
// >
|
|
979
|
+
// {btn?.label}
|
|
980
|
+
// </Button>
|
|
981
|
+
// ))}
|
|
982
|
+
// </Box>
|
|
983
|
+
// )}
|
|
984
|
+
// </form>
|
|
985
|
+
// );
|
|
986
|
+
// };
|
|
987
|
+
|
|
988
|
+
// export default FilterForm;
|