rez-table-listing-mui 1.3.38 → 1.3.39
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 +2 -45
- 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/forms/components/Date.tsx +25 -4
- package/src/listing/components/filter/components/forms/components/filter-criteria-list.tsx +0 -1
- package/src/listing/components/filter/components/forms/index.tsx +13 -582
- package/src/listing/components/filter/components/main-filter.tsx +6 -6
- package/src/listing/components/filter/components/saved-edit-filter.tsx +3 -5
- package/src/listing/components/filter/components/saved-filter.tsx +124 -300
- package/src/listing/components/filter/components/search/index.tsx +0 -1
- package/src/listing/components/filter/components/single-filter-rendering.tsx +3 -3
- package/src/listing/components/filter/index.tsx +5 -130
- package/src/listing/components/login/index.tsx +6 -3
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +0 -3
- package/src/listing/libs/utils/common.ts +0 -1
- package/src/listing/types/filter.ts +1 -48
- package/src/view/FIlterWrapper.tsx +0 -15
- package/src/view/ListingView.tsx +1 -1
- package/src/listing/components/common/saved-filter-modal/index.tsx +0 -517
|
@@ -36,7 +36,7 @@ const FilterForm = ({
|
|
|
36
36
|
handleRemoveFilter,
|
|
37
37
|
editMode = false,
|
|
38
38
|
tableStates,
|
|
39
|
-
|
|
39
|
+
setSavedFilterModalOpen,
|
|
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
|
+
setSavedFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
52
52
|
setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
53
53
|
onChangeFunction: ({
|
|
54
54
|
updatedFilters,
|
|
@@ -67,7 +67,6 @@ 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;
|
|
71
70
|
|
|
72
71
|
const defaultValues = useMemo(() => {
|
|
73
72
|
const filterValues = filters?.reduce((acc, curr) => {
|
|
@@ -253,18 +252,16 @@ const FilterForm = ({
|
|
|
253
252
|
/>
|
|
254
253
|
)}
|
|
255
254
|
/>
|
|
256
|
-
{
|
|
257
|
-
<
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
</Box>
|
|
267
|
-
)}
|
|
255
|
+
<Box onClick={(e) => e.stopPropagation()}>
|
|
256
|
+
<IconButton
|
|
257
|
+
size="small"
|
|
258
|
+
onClick={() =>
|
|
259
|
+
setDeleteFilterModalOpen && setDeleteFilterModalOpen(true)
|
|
260
|
+
}
|
|
261
|
+
>
|
|
262
|
+
<DeleteIcon />
|
|
263
|
+
</IconButton>
|
|
264
|
+
</Box>
|
|
268
265
|
</Box>
|
|
269
266
|
)}
|
|
270
267
|
|
|
@@ -445,7 +442,7 @@ const FilterForm = ({
|
|
|
445
442
|
},
|
|
446
443
|
}}
|
|
447
444
|
onClick={() => {
|
|
448
|
-
|
|
445
|
+
setSavedFilterModalOpen && setSavedFilterModalOpen(true);
|
|
449
446
|
}}
|
|
450
447
|
>
|
|
451
448
|
Save Filter
|
|
@@ -471,569 +468,3 @@ const FilterForm = ({
|
|
|
471
468
|
};
|
|
472
469
|
|
|
473
470
|
export default FilterForm;
|
|
474
|
-
|
|
475
|
-
// !! PLEASE DO NOT DELETE THIS COMMENTED BLOCK !!
|
|
476
|
-
// import {
|
|
477
|
-
// Box,
|
|
478
|
-
// Button,
|
|
479
|
-
// FormControl,
|
|
480
|
-
// IconButton,
|
|
481
|
-
// TextField,
|
|
482
|
-
// Typography,
|
|
483
|
-
// } from "@mui/material";
|
|
484
|
-
// import { CloseIcon, DeleteIcon } from "../../../../../assets/svg";
|
|
485
|
-
// import {
|
|
486
|
-
// FilterColumnsDataProps,
|
|
487
|
-
// FilterComponentOptions,
|
|
488
|
-
// FilterDropdownDataProps,
|
|
489
|
-
// FilterMasterStateProps,
|
|
490
|
-
// FilterStateProps,
|
|
491
|
-
// } from "../../../../types/filter";
|
|
492
|
-
// import { Controller, useForm } from "react-hook-form";
|
|
493
|
-
// import FormTextfield from "./components/Textfield";
|
|
494
|
-
// import React, { useEffect, useMemo, useCallback } from "react";
|
|
495
|
-
// import FormDatePicker from "./components/Date";
|
|
496
|
-
// import FormDropdown from "./components/Dropdown";
|
|
497
|
-
// import FormMultiSelect from "./components/Multi-Select";
|
|
498
|
-
// import { CraftTableOptionsProps } from "../../../../types/table-options";
|
|
499
|
-
// import FilterCriteria from "./components/Filter-criteria";
|
|
500
|
-
// import CustomSearch from "../search";
|
|
501
|
-
// import { customDebounce } from "../../../../libs/utils/debounce";
|
|
502
|
-
// import { filterFormStyles } from "../../style";
|
|
503
|
-
// import { onFilterChangeFunctionProps } from "../../../../types/common";
|
|
504
|
-
|
|
505
|
-
// interface FormValues {
|
|
506
|
-
// filterName: string;
|
|
507
|
-
// [key: string]:
|
|
508
|
-
// | {
|
|
509
|
-
// value: string | string[];
|
|
510
|
-
// operator: string;
|
|
511
|
-
// }
|
|
512
|
-
// | string;
|
|
513
|
-
// }
|
|
514
|
-
|
|
515
|
-
// const FilterForm = ({
|
|
516
|
-
// columnsData,
|
|
517
|
-
// dropdownData,
|
|
518
|
-
// searchTerm = "",
|
|
519
|
-
// setSearchTerm,
|
|
520
|
-
// handleRemoveFilter,
|
|
521
|
-
// editMode = false,
|
|
522
|
-
// tableStates,
|
|
523
|
-
// setSavedFilterModalOpen,
|
|
524
|
-
// setDeleteFilterModalOpen,
|
|
525
|
-
// onChangeFunction,
|
|
526
|
-
// filterComponentOptions,
|
|
527
|
-
// }: {
|
|
528
|
-
// columnsData: FilterColumnsDataProps;
|
|
529
|
-
// dropdownData: FilterDropdownDataProps;
|
|
530
|
-
// searchTerm?: string;
|
|
531
|
-
// setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
532
|
-
// handleRemoveFilter: (filter_attribute: string) => void;
|
|
533
|
-
// editMode?: boolean;
|
|
534
|
-
// tableStates: CraftTableOptionsProps;
|
|
535
|
-
// setSavedFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
536
|
-
// setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
537
|
-
// onChangeFunction: ({
|
|
538
|
-
// updatedFilters,
|
|
539
|
-
// filterMaster,
|
|
540
|
-
// }: onFilterChangeFunctionProps) => void;
|
|
541
|
-
// filterComponentOptions?: FilterComponentOptions;
|
|
542
|
-
// }) => {
|
|
543
|
-
// const { filterMaster, filters, setFilters, setFilterMaster, setPagination } =
|
|
544
|
-
// tableStates;
|
|
545
|
-
|
|
546
|
-
// const showSaveButton =
|
|
547
|
-
// filterComponentOptions?.tabOptions?.mainFilter?.showSaveButton;
|
|
548
|
-
// const showClearAllButton =
|
|
549
|
-
// filterComponentOptions?.tabOptions?.mainFilter?.showClearAllButton;
|
|
550
|
-
// const customButtons =
|
|
551
|
-
// filterComponentOptions?.tabOptions?.mainFilter?.customButtons;
|
|
552
|
-
|
|
553
|
-
// const filterName = filterMaster?.saved_filters?.selectedName || "";
|
|
554
|
-
|
|
555
|
-
// const defaultValues = useMemo(() => {
|
|
556
|
-
// const filterValues = filters?.reduce((acc, curr) => {
|
|
557
|
-
// if (curr?.filter_attribute_name) {
|
|
558
|
-
// acc[curr?.filter_attribute_name] = {
|
|
559
|
-
// value: curr?.filter_value ?? "",
|
|
560
|
-
// operator:
|
|
561
|
-
// curr?.filter_operator ?? curr?.dropdown_list?.[0]?.value ?? "",
|
|
562
|
-
// };
|
|
563
|
-
// }
|
|
564
|
-
// return acc;
|
|
565
|
-
// }, {} as Record<string, { value: string | string[]; operator: string }>);
|
|
566
|
-
|
|
567
|
-
// return {
|
|
568
|
-
// filterName: filterName ?? "",
|
|
569
|
-
// dummyChange: "",
|
|
570
|
-
// ...filterValues,
|
|
571
|
-
// };
|
|
572
|
-
// }, [filters, filterName]);
|
|
573
|
-
|
|
574
|
-
// const { control, watch, reset, setValue, unregister } = useForm<
|
|
575
|
-
// FormValues & { dummyChange: string }
|
|
576
|
-
// >({
|
|
577
|
-
// mode: "onChange",
|
|
578
|
-
// defaultValues,
|
|
579
|
-
// resetOptions: {
|
|
580
|
-
// keepDirtyValues: false,
|
|
581
|
-
// keepErrors: false,
|
|
582
|
-
// },
|
|
583
|
-
// });
|
|
584
|
-
|
|
585
|
-
// const formValues = watch();
|
|
586
|
-
|
|
587
|
-
// useEffect(() => {
|
|
588
|
-
// reset(defaultValues);
|
|
589
|
-
// }, [filters]);
|
|
590
|
-
|
|
591
|
-
// const debouncedUpdateFilters = useCallback(
|
|
592
|
-
// customDebounce((updatedFilters: FilterStateProps[]) => {
|
|
593
|
-
// setFilters(updatedFilters);
|
|
594
|
-
|
|
595
|
-
// const newState = {
|
|
596
|
-
// filterMaster: filterMaster,
|
|
597
|
-
// filters: updatedFilters,
|
|
598
|
-
// };
|
|
599
|
-
|
|
600
|
-
// onChangeFunction && onChangeFunction(newState);
|
|
601
|
-
// }, 1000),
|
|
602
|
-
// [setFilters]
|
|
603
|
-
// );
|
|
604
|
-
|
|
605
|
-
// const updateFiltersFromForm = useCallback(() => {
|
|
606
|
-
// const updatedFilters = filters?.map((filter) => {
|
|
607
|
-
// if (
|
|
608
|
-
// filter?.filter_attribute_name &&
|
|
609
|
-
// typeof formValues[filter?.filter_attribute_name] === "object"
|
|
610
|
-
// ) {
|
|
611
|
-
// const filterValue = formValues[filter?.filter_attribute_name] as {
|
|
612
|
-
// value: string | string[];
|
|
613
|
-
// operator: string;
|
|
614
|
-
// };
|
|
615
|
-
|
|
616
|
-
// return {
|
|
617
|
-
// ...filter,
|
|
618
|
-
// filter_value: filterValue.value,
|
|
619
|
-
// filter_operator: filterValue.operator,
|
|
620
|
-
// };
|
|
621
|
-
// }
|
|
622
|
-
// return filter;
|
|
623
|
-
// });
|
|
624
|
-
|
|
625
|
-
// setPagination((prev) => ({ ...prev, pageIndex: 0 }));
|
|
626
|
-
// debouncedUpdateFilters(updatedFilters);
|
|
627
|
-
// }, [formValues, filters, debouncedUpdateFilters]);
|
|
628
|
-
|
|
629
|
-
// useEffect(() => {
|
|
630
|
-
// return () => {
|
|
631
|
-
// reset();
|
|
632
|
-
// filters?.forEach((filter) => {
|
|
633
|
-
// if (filter?.filter_attribute_name) {
|
|
634
|
-
// unregister(filter?.filter_attribute_name);
|
|
635
|
-
// }
|
|
636
|
-
// });
|
|
637
|
-
// };
|
|
638
|
-
// }, []);
|
|
639
|
-
|
|
640
|
-
// const groupedFilters = useMemo(() => {
|
|
641
|
-
// return filters?.reduce((acc, filter) => {
|
|
642
|
-
// const key = filter?.filter_entity_name || "";
|
|
643
|
-
// if (!acc[key]) {
|
|
644
|
-
// acc[key] = [];
|
|
645
|
-
// }
|
|
646
|
-
// acc[key].push(filter);
|
|
647
|
-
// return acc;
|
|
648
|
-
// }, {} as Record<string, FilterStateProps[]>);
|
|
649
|
-
// }, [filters]);
|
|
650
|
-
|
|
651
|
-
// const handleRemoveEntityType = (entityType: string) => {
|
|
652
|
-
// const remainingFilters = filters?.filter(
|
|
653
|
-
// (f) => f.filter_entity_name !== entityType
|
|
654
|
-
// );
|
|
655
|
-
|
|
656
|
-
// // unregister all fields belonging to this entity type
|
|
657
|
-
// filters?.forEach((f) => {
|
|
658
|
-
// if (f?.filter_entity_name === entityType && f?.filter_attribute_name) {
|
|
659
|
-
// unregister(`${f?.filter_attribute_name}.value`);
|
|
660
|
-
// unregister(`${f?.filter_attribute_name}.operator`);
|
|
661
|
-
// }
|
|
662
|
-
// });
|
|
663
|
-
|
|
664
|
-
// setFilters(remainingFilters);
|
|
665
|
-
|
|
666
|
-
// const newState = {
|
|
667
|
-
// filterMaster,
|
|
668
|
-
// filters: remainingFilters,
|
|
669
|
-
// };
|
|
670
|
-
|
|
671
|
-
// onChangeFunction && onChangeFunction(newState);
|
|
672
|
-
// };
|
|
673
|
-
|
|
674
|
-
// return (
|
|
675
|
-
// <form
|
|
676
|
-
// onSubmit={(e) => {
|
|
677
|
-
// e.preventDefault(); // This prevents the page from reloading
|
|
678
|
-
// }}
|
|
679
|
-
// >
|
|
680
|
-
// <Box sx={editMode ? filterFormStyles.formEditModeStyle : {}}>
|
|
681
|
-
// {editMode && (
|
|
682
|
-
// <Box
|
|
683
|
-
// sx={{
|
|
684
|
-
// "& .MuiOutlinedInput-root": {
|
|
685
|
-
// borderRadius: "6px",
|
|
686
|
-
// fontSize: "14px",
|
|
687
|
-
// bgcolor: "#fafafa",
|
|
688
|
-
// "& fieldset": { borderColor: "#c1c1c1" },
|
|
689
|
-
// "&.Mui-focused fieldset": { borderColor: "#7A5AF8" },
|
|
690
|
-
// },
|
|
691
|
-
// display: "flex",
|
|
692
|
-
// alignItems: "center",
|
|
693
|
-
// justifyContent: "center",
|
|
694
|
-
// padding: "0.5rem 0 1rem 0",
|
|
695
|
-
// gap: 1,
|
|
696
|
-
// }}
|
|
697
|
-
// >
|
|
698
|
-
// <Controller
|
|
699
|
-
// name="filterName"
|
|
700
|
-
// control={control}
|
|
701
|
-
// render={({ field }) => (
|
|
702
|
-
// <TextField
|
|
703
|
-
// fullWidth
|
|
704
|
-
// size="small"
|
|
705
|
-
// placeholder="Filter Name"
|
|
706
|
-
// value={filterName || field.value}
|
|
707
|
-
// onChange={(e) => {
|
|
708
|
-
// field.onChange(e);
|
|
709
|
-
// if (editMode) {
|
|
710
|
-
// setFilterMaster(
|
|
711
|
-
// (prev) =>
|
|
712
|
-
// ({
|
|
713
|
-
// ...prev,
|
|
714
|
-
// saved_filters: {
|
|
715
|
-
// ...prev?.saved_filters,
|
|
716
|
-
// selectedName: e.target.value,
|
|
717
|
-
// },
|
|
718
|
-
// } as FilterMasterStateProps)
|
|
719
|
-
// );
|
|
720
|
-
// }
|
|
721
|
-
// }}
|
|
722
|
-
// inputRef={field.ref}
|
|
723
|
-
// sx={{
|
|
724
|
-
// maxWidth: 400,
|
|
725
|
-
|
|
726
|
-
// "& .MuiOutlinedInput-root": {
|
|
727
|
-
// bgcolor: "white",
|
|
728
|
-
// borderRadius: "0px",
|
|
729
|
-
// fontSize: "14px",
|
|
730
|
-
// color: "#272524",
|
|
731
|
-
// fontWeight: "500",
|
|
732
|
-
// "& fieldset": { borderColor: "#c5c5c5" },
|
|
733
|
-
// "&.Mui-focused fieldset": { borderColor: "#7A5AF8" },
|
|
734
|
-
// },
|
|
735
|
-
// }}
|
|
736
|
-
// />
|
|
737
|
-
// )}
|
|
738
|
-
// />
|
|
739
|
-
// <Box onClick={(e) => e.stopPropagation()}>
|
|
740
|
-
// <IconButton
|
|
741
|
-
// size="small"
|
|
742
|
-
// onClick={() =>
|
|
743
|
-
// setDeleteFilterModalOpen && setDeleteFilterModalOpen(true)
|
|
744
|
-
// }
|
|
745
|
-
// >
|
|
746
|
-
// <DeleteIcon />
|
|
747
|
-
// </IconButton>
|
|
748
|
-
// </Box>
|
|
749
|
-
// </Box>
|
|
750
|
-
// )}
|
|
751
|
-
|
|
752
|
-
// <Box
|
|
753
|
-
// className="filter-criteria-form"
|
|
754
|
-
// sx={filterFormStyles.formFlexContainer}
|
|
755
|
-
// >
|
|
756
|
-
// <FilterCriteria
|
|
757
|
-
// columnsData={columnsData}
|
|
758
|
-
// tableStates={tableStates}
|
|
759
|
-
// onChangeFunction={onChangeFunction}
|
|
760
|
-
// filterComponentOptions={filterComponentOptions}
|
|
761
|
-
// />
|
|
762
|
-
|
|
763
|
-
// {!editMode && (
|
|
764
|
-
// <CustomSearch value={searchTerm} onChange={setSearchTerm} />
|
|
765
|
-
// )}
|
|
766
|
-
|
|
767
|
-
// <Box
|
|
768
|
-
// className="filter-form-inputs"
|
|
769
|
-
// sx={filterFormStyles.formFlexContainer}
|
|
770
|
-
// >
|
|
771
|
-
// {Object.entries(groupedFilters).map(([entityType, filters]) => (
|
|
772
|
-
// <Box
|
|
773
|
-
// key={entityType}
|
|
774
|
-
// sx={{
|
|
775
|
-
// border: "1px solid #c5c5c5",
|
|
776
|
-
// borderRadius: 2,
|
|
777
|
-
// overflow: "hidden",
|
|
778
|
-
// }}
|
|
779
|
-
// >
|
|
780
|
-
// {/* Group Header */}
|
|
781
|
-
// <Box
|
|
782
|
-
// className="group-header"
|
|
783
|
-
// sx={filterFormStyles.formListSectionHeader}
|
|
784
|
-
// >
|
|
785
|
-
// <Typography fontSize={14}>{entityType}</Typography>
|
|
786
|
-
// <IconButton
|
|
787
|
-
// size="small"
|
|
788
|
-
// onClick={() => handleRemoveEntityType(entityType)}
|
|
789
|
-
// >
|
|
790
|
-
// <CloseIcon />
|
|
791
|
-
// </IconButton>
|
|
792
|
-
// </Box>
|
|
793
|
-
|
|
794
|
-
// {filters
|
|
795
|
-
// .filter(
|
|
796
|
-
// (filter) =>
|
|
797
|
-
// filter?.filter_attribute_name
|
|
798
|
-
// ?.toLowerCase()
|
|
799
|
-
// .includes(searchTerm.toLowerCase()) ||
|
|
800
|
-
// filter.filter_value
|
|
801
|
-
// ?.toString()
|
|
802
|
-
// .toLowerCase()
|
|
803
|
-
// .includes(searchTerm.toLowerCase())
|
|
804
|
-
// )
|
|
805
|
-
// .reverse()
|
|
806
|
-
// .map((filter) => {
|
|
807
|
-
// const dropdown_list = filter.dropdown_list || [];
|
|
808
|
-
// return (
|
|
809
|
-
// <Box
|
|
810
|
-
// key={filter.filter_attribute}
|
|
811
|
-
// sx={filterFormStyles.formListItem}
|
|
812
|
-
// >
|
|
813
|
-
// <Box sx={filterFormStyles.formListItemHeader}>
|
|
814
|
-
// <Typography
|
|
815
|
-
// sx={filterFormStyles.formListItemHeaderName}
|
|
816
|
-
// >
|
|
817
|
-
// {filter?.filter_attribute_name}
|
|
818
|
-
// </Typography>
|
|
819
|
-
// <FormDropdown
|
|
820
|
-
// filter={filter}
|
|
821
|
-
// control={control}
|
|
822
|
-
// setValue={setValue}
|
|
823
|
-
// dropdownList={dropdown_list}
|
|
824
|
-
// sx={filterFormStyles.formListItemHeaderDropdown}
|
|
825
|
-
// onValueChange={updateFiltersFromForm}
|
|
826
|
-
// />
|
|
827
|
-
// <IconButton
|
|
828
|
-
// sx={{ marginLeft: "auto" }}
|
|
829
|
-
// onClick={() => {
|
|
830
|
-
// unregister(
|
|
831
|
-
// `${filter?.filter_attribute_name}.value`
|
|
832
|
-
// );
|
|
833
|
-
// unregister(
|
|
834
|
-
// `${filter?.filter_attribute_name}.operator`
|
|
835
|
-
// );
|
|
836
|
-
|
|
837
|
-
// // Toggle dummy field to force form dirty
|
|
838
|
-
// const dummy = watch("dummyChange");
|
|
839
|
-
// setValue(
|
|
840
|
-
// "dummyChange",
|
|
841
|
-
// dummy === "changed" ? "reset" : "changed",
|
|
842
|
-
// {
|
|
843
|
-
// shouldDirty: true,
|
|
844
|
-
// }
|
|
845
|
-
// );
|
|
846
|
-
|
|
847
|
-
// handleRemoveFilter(filter.filter_attribute);
|
|
848
|
-
// }}
|
|
849
|
-
// size="small"
|
|
850
|
-
// >
|
|
851
|
-
// <CloseIcon />
|
|
852
|
-
// </IconButton>
|
|
853
|
-
// </Box>
|
|
854
|
-
|
|
855
|
-
// <Box>
|
|
856
|
-
// {(() => {
|
|
857
|
-
// const fieldValue = formValues[
|
|
858
|
-
// filter?.filter_attribute_name as string
|
|
859
|
-
// ] as
|
|
860
|
-
// | { value: string | string[]; operator: string }
|
|
861
|
-
// | undefined;
|
|
862
|
-
|
|
863
|
-
// const operator = fieldValue?.operator;
|
|
864
|
-
|
|
865
|
-
// // Operators that should show a Date Picker
|
|
866
|
-
// const dateAllowedOperators = [
|
|
867
|
-
// "equal",
|
|
868
|
-
// "before",
|
|
869
|
-
// "after",
|
|
870
|
-
// "between",
|
|
871
|
-
// "is",
|
|
872
|
-
// "today",
|
|
873
|
-
// "is_before",
|
|
874
|
-
// "is_after",
|
|
875
|
-
// "is_on_or_before",
|
|
876
|
-
// "is_on_or_after",
|
|
877
|
-
// "empty",
|
|
878
|
-
// "not_empty",
|
|
879
|
-
// ];
|
|
880
|
-
|
|
881
|
-
// const showDatePicker =
|
|
882
|
-
// filter?.filter_attribute_data_type === "date" &&
|
|
883
|
-
// operator &&
|
|
884
|
-
// dateAllowedOperators.includes(operator);
|
|
885
|
-
|
|
886
|
-
// if (
|
|
887
|
-
// filter?.filter_attribute_data_type === "text" ||
|
|
888
|
-
// filter?.filter_attribute_data_type === "number"
|
|
889
|
-
// ) {
|
|
890
|
-
// return (
|
|
891
|
-
// <FormTextfield
|
|
892
|
-
// filter={filter}
|
|
893
|
-
// control={control}
|
|
894
|
-
// onValueChange={updateFiltersFromForm}
|
|
895
|
-
// />
|
|
896
|
-
// );
|
|
897
|
-
// }
|
|
898
|
-
|
|
899
|
-
// if (
|
|
900
|
-
// filter?.filter_attribute_data_type === "select"
|
|
901
|
-
// ) {
|
|
902
|
-
// return (
|
|
903
|
-
// <FormMultiSelect
|
|
904
|
-
// filter={filter}
|
|
905
|
-
// control={control}
|
|
906
|
-
// dropdownData={dropdownData}
|
|
907
|
-
// onValueChange={updateFiltersFromForm}
|
|
908
|
-
// />
|
|
909
|
-
// );
|
|
910
|
-
// }
|
|
911
|
-
|
|
912
|
-
// if (
|
|
913
|
-
// filter?.filter_attribute_data_type ===
|
|
914
|
-
// "multiselect"
|
|
915
|
-
// ) {
|
|
916
|
-
// return (
|
|
917
|
-
// <FormMultiSelect
|
|
918
|
-
// filter={filter}
|
|
919
|
-
// control={control}
|
|
920
|
-
// dropdownData={dropdownData}
|
|
921
|
-
// onValueChange={updateFiltersFromForm}
|
|
922
|
-
// />
|
|
923
|
-
// );
|
|
924
|
-
// }
|
|
925
|
-
|
|
926
|
-
// if (filter?.filter_attribute_data_type === "year") {
|
|
927
|
-
// return (
|
|
928
|
-
// <FormDatePicker
|
|
929
|
-
// filter={filter}
|
|
930
|
-
// control={control}
|
|
931
|
-
// views={["year"]}
|
|
932
|
-
// onValueChange={updateFiltersFromForm}
|
|
933
|
-
// />
|
|
934
|
-
// );
|
|
935
|
-
// }
|
|
936
|
-
|
|
937
|
-
// // DATE LOGIC
|
|
938
|
-
// if (showDatePicker) {
|
|
939
|
-
// return (
|
|
940
|
-
// <FormDatePicker
|
|
941
|
-
// filter={filter}
|
|
942
|
-
// control={control}
|
|
943
|
-
// onValueChange={updateFiltersFromForm}
|
|
944
|
-
// />
|
|
945
|
-
// );
|
|
946
|
-
// } else {
|
|
947
|
-
// return (
|
|
948
|
-
// <FormTextfield
|
|
949
|
-
// filter={filter}
|
|
950
|
-
// control={control}
|
|
951
|
-
// onValueChange={updateFiltersFromForm}
|
|
952
|
-
// />
|
|
953
|
-
// );
|
|
954
|
-
// }
|
|
955
|
-
|
|
956
|
-
// return <FormControl fullWidth size="small" />;
|
|
957
|
-
// })()}
|
|
958
|
-
// </Box>
|
|
959
|
-
// </Box>
|
|
960
|
-
// );
|
|
961
|
-
// })}
|
|
962
|
-
// </Box>
|
|
963
|
-
// ))}
|
|
964
|
-
// </Box>
|
|
965
|
-
// </Box>
|
|
966
|
-
// </Box>
|
|
967
|
-
|
|
968
|
-
// {filters?.length > 0 && (showClearAllButton || showSaveButton) && (
|
|
969
|
-
// <Box sx={{ display: "flex", justifyContent: "center", gap: 1, mt: 3 }}>
|
|
970
|
-
// {showClearAllButton && (
|
|
971
|
-
// <Button
|
|
972
|
-
// variant="outlined"
|
|
973
|
-
// sx={{
|
|
974
|
-
// color: "#7A5AF8",
|
|
975
|
-
// border: `1px solid #7A5AF8`,
|
|
976
|
-
// borderRadius: "6px",
|
|
977
|
-
// textTransform: "none",
|
|
978
|
-
// fontSize: "14px",
|
|
979
|
-
// }}
|
|
980
|
-
// fullWidth
|
|
981
|
-
// onClick={() => {
|
|
982
|
-
// setFilters([]);
|
|
983
|
-
|
|
984
|
-
// const filterMaster = {
|
|
985
|
-
// ...tableStates.filterMaster,
|
|
986
|
-
// activeFilterTabIndex: -1,
|
|
987
|
-
// };
|
|
988
|
-
|
|
989
|
-
// const newState = {
|
|
990
|
-
// filterMaster: filterMaster,
|
|
991
|
-
// filters: [],
|
|
992
|
-
// };
|
|
993
|
-
|
|
994
|
-
// onChangeFunction && onChangeFunction(newState);
|
|
995
|
-
// }}
|
|
996
|
-
// >
|
|
997
|
-
// Clear All
|
|
998
|
-
// </Button>
|
|
999
|
-
// )}
|
|
1000
|
-
|
|
1001
|
-
// {showSaveButton && (
|
|
1002
|
-
// <Button
|
|
1003
|
-
// variant="contained"
|
|
1004
|
-
// fullWidth
|
|
1005
|
-
// sx={{
|
|
1006
|
-
// color: "white",
|
|
1007
|
-
// backgroundColor: "#7A5AF8",
|
|
1008
|
-
// "&.Mui-disabled": {
|
|
1009
|
-
// backgroundColor: "#d7cefd",
|
|
1010
|
-
// color: "rgba(255, 255, 255, 0.7)",
|
|
1011
|
-
// },
|
|
1012
|
-
// }}
|
|
1013
|
-
// onClick={() => {
|
|
1014
|
-
// setSavedFilterModalOpen && setSavedFilterModalOpen(true);
|
|
1015
|
-
// }}
|
|
1016
|
-
// >
|
|
1017
|
-
// Save Filter
|
|
1018
|
-
// </Button>
|
|
1019
|
-
// )}
|
|
1020
|
-
|
|
1021
|
-
// {/* Custom buttons from props */}
|
|
1022
|
-
// {customButtons?.map((btn, idx) => (
|
|
1023
|
-
// <Button
|
|
1024
|
-
// key={idx}
|
|
1025
|
-
// fullWidth
|
|
1026
|
-
// variant={btn?.variant ?? "outlined"}
|
|
1027
|
-
// sx={btn?.sx}
|
|
1028
|
-
// {...btn}
|
|
1029
|
-
// >
|
|
1030
|
-
// {btn?.label}
|
|
1031
|
-
// </Button>
|
|
1032
|
-
// ))}
|
|
1033
|
-
// </Box>
|
|
1034
|
-
// )}
|
|
1035
|
-
// </form>
|
|
1036
|
-
// );
|
|
1037
|
-
// };
|
|
1038
|
-
|
|
1039
|
-
// export default FilterForm;
|
|
@@ -11,7 +11,7 @@ const MainFilter = ({
|
|
|
11
11
|
columnsData,
|
|
12
12
|
dropdownData,
|
|
13
13
|
tableStates,
|
|
14
|
-
|
|
14
|
+
setSavedFilterModalOpen,
|
|
15
15
|
onChangeFunction,
|
|
16
16
|
filterComponentOptions,
|
|
17
17
|
}: FilterFormComponentProps) => {
|
|
@@ -22,10 +22,10 @@ const MainFilter = ({
|
|
|
22
22
|
useEffect(() => {
|
|
23
23
|
setFilterMaster(
|
|
24
24
|
(prev) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
({
|
|
26
|
+
...prev,
|
|
27
|
+
activeFilterTabIndex: 0,
|
|
28
|
+
} as FilterMasterStateProps)
|
|
29
29
|
);
|
|
30
30
|
}, []);
|
|
31
31
|
|
|
@@ -61,7 +61,7 @@ const MainFilter = ({
|
|
|
61
61
|
setSearchTerm={setSearchTerm}
|
|
62
62
|
handleRemoveFilter={handleRemoveFilter}
|
|
63
63
|
tableStates={tableStates}
|
|
64
|
-
|
|
64
|
+
setSavedFilterModalOpen={setSavedFilterModalOpen}
|
|
65
65
|
dropdownData={dropdownData}
|
|
66
66
|
onChangeFunction={onChangeFunction}
|
|
67
67
|
filterComponentOptions={filterComponentOptions}
|