rez-table-listing-mui 2.0.10 → 2.0.12
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 +4 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/listing/components/filter/components/attributes-filter.tsx +1 -0
- package/src/listing/components/filter/components/forms/components/Multi-Select.tsx +26 -13
- package/src/listing/components/filter/components/forms/index.tsx +3 -0
- package/src/listing/components/filter/components/forms/utils/filter-date-input-resolver.tsx +3 -0
- package/src/listing/components/filter/components/main-filter.tsx +6 -4
- package/src/listing/components/filter/components/saved-filter.tsx +1 -0
- package/src/listing/components/filter/index.tsx +4 -0
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +5 -1
- package/src/listing/libs/utils/common.ts +1 -1
- package/src/listing/types/common.ts +1 -0
- package/src/listing/types/filter.ts +3 -0
- package/src/view/FIlterWrapper.tsx +3 -0
- package/src/view/ListingView.tsx +2 -0
package/package.json
CHANGED
|
@@ -16,15 +16,21 @@ const FormMultiSelect = ({
|
|
|
16
16
|
dropdownData,
|
|
17
17
|
sx,
|
|
18
18
|
onValueChange,
|
|
19
|
+
isFlatJson,
|
|
19
20
|
}: {
|
|
20
21
|
filter: FilterStateProps;
|
|
21
22
|
control: any;
|
|
22
23
|
dropdownData: Record<string, DropdownOption[]>;
|
|
23
24
|
sx?: SxProps<Theme>;
|
|
24
25
|
onValueChange?: () => void;
|
|
26
|
+
isFlatJson: boolean;
|
|
25
27
|
}) => {
|
|
26
28
|
const options = dropdownData[filter.filter_attribute] || [];
|
|
27
29
|
|
|
30
|
+
// 🔑 single source of truth
|
|
31
|
+
const getOptionValue = (item: DropdownOption) =>
|
|
32
|
+
isFlatJson ? item.label : item.value;
|
|
33
|
+
|
|
28
34
|
return (
|
|
29
35
|
<Controller
|
|
30
36
|
name={`${filter?.filter_attribute_name}.value`}
|
|
@@ -63,23 +69,30 @@ const FormMultiSelect = ({
|
|
|
63
69
|
const filtered = Array.isArray(selected)
|
|
64
70
|
? selected.filter(Boolean)
|
|
65
71
|
: [];
|
|
72
|
+
|
|
66
73
|
return filtered
|
|
67
|
-
.map(
|
|
68
|
-
(
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
.map((val) => {
|
|
75
|
+
const match = options.find(
|
|
76
|
+
(item) => getOptionValue(item) === val
|
|
77
|
+
);
|
|
78
|
+
return match?.label || val;
|
|
79
|
+
})
|
|
71
80
|
.join(", ");
|
|
72
81
|
}}
|
|
73
82
|
>
|
|
74
|
-
{options
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
{options.map((item, idx) => {
|
|
84
|
+
const optionValue = getOptionValue(item);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<MenuItem key={idx} value={optionValue}>
|
|
88
|
+
<Checkbox
|
|
89
|
+
checked={cleanedValue.includes(optionValue)}
|
|
90
|
+
sx={{ marginRight: 1 }}
|
|
91
|
+
/>
|
|
92
|
+
{item.label}
|
|
93
|
+
</MenuItem>
|
|
94
|
+
);
|
|
95
|
+
})}
|
|
83
96
|
</Select>
|
|
84
97
|
</FormControl>
|
|
85
98
|
);
|
|
@@ -40,6 +40,7 @@ const FilterForm = ({
|
|
|
40
40
|
setDeleteFilterModalOpen,
|
|
41
41
|
onChangeFunction,
|
|
42
42
|
filterComponentOptions,
|
|
43
|
+
isFlatJson,
|
|
43
44
|
}: {
|
|
44
45
|
columnsData: FilterColumnsDataProps;
|
|
45
46
|
dropdownData: FilterDropdownDataProps;
|
|
@@ -55,6 +56,7 @@ const FilterForm = ({
|
|
|
55
56
|
filterMaster,
|
|
56
57
|
}: onFilterChangeFunctionProps) => void;
|
|
57
58
|
filterComponentOptions?: FilterComponentOptions;
|
|
59
|
+
isFlatJson: boolean;
|
|
58
60
|
}) => {
|
|
59
61
|
const { filterMaster, filters, setFilters, setFilterMaster, setPagination } =
|
|
60
62
|
tableStates;
|
|
@@ -393,6 +395,7 @@ const FilterForm = ({
|
|
|
393
395
|
control,
|
|
394
396
|
dropdownData,
|
|
395
397
|
updateFiltersFromForm,
|
|
398
|
+
isFlatJson,
|
|
396
399
|
});
|
|
397
400
|
})()}
|
|
398
401
|
</Box>
|
|
@@ -26,12 +26,14 @@ export const resolveFilterInput = ({
|
|
|
26
26
|
control,
|
|
27
27
|
dropdownData,
|
|
28
28
|
updateFiltersFromForm,
|
|
29
|
+
isFlatJson,
|
|
29
30
|
}: {
|
|
30
31
|
filter: FilterStateProps;
|
|
31
32
|
operator: string | undefined;
|
|
32
33
|
control: any;
|
|
33
34
|
dropdownData: any;
|
|
34
35
|
updateFiltersFromForm: () => void;
|
|
36
|
+
isFlatJson: boolean;
|
|
35
37
|
}) => {
|
|
36
38
|
const dataType = filter?.filter_attribute_data_type;
|
|
37
39
|
|
|
@@ -95,6 +97,7 @@ export const resolveFilterInput = ({
|
|
|
95
97
|
control={control}
|
|
96
98
|
dropdownData={dropdownData}
|
|
97
99
|
onValueChange={updateFiltersFromForm}
|
|
100
|
+
isFlatJson={isFlatJson}
|
|
98
101
|
/>
|
|
99
102
|
);
|
|
100
103
|
}
|
|
@@ -14,6 +14,7 @@ const MainFilter = ({
|
|
|
14
14
|
onSaveFilterButtonClick,
|
|
15
15
|
onChangeFunction,
|
|
16
16
|
filterComponentOptions,
|
|
17
|
+
isFlatJson,
|
|
17
18
|
}: FilterFormComponentProps) => {
|
|
18
19
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
|
19
20
|
|
|
@@ -22,10 +23,10 @@ const MainFilter = ({
|
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
setFilterMaster(
|
|
24
25
|
(prev) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
({
|
|
27
|
+
...prev,
|
|
28
|
+
activeFilterTabIndex: 0,
|
|
29
|
+
} as FilterMasterStateProps)
|
|
29
30
|
);
|
|
30
31
|
}, []);
|
|
31
32
|
|
|
@@ -65,6 +66,7 @@ const MainFilter = ({
|
|
|
65
66
|
dropdownData={dropdownData}
|
|
66
67
|
onChangeFunction={onChangeFunction}
|
|
67
68
|
filterComponentOptions={filterComponentOptions}
|
|
69
|
+
isFlatJson={isFlatJson}
|
|
68
70
|
/>
|
|
69
71
|
</Box>
|
|
70
72
|
);
|
|
@@ -27,6 +27,7 @@ export function TableFilter({
|
|
|
27
27
|
dropdownData,
|
|
28
28
|
onChangeFunction,
|
|
29
29
|
filterComponentOptions,
|
|
30
|
+
isFlatJson,
|
|
30
31
|
}: FilterDrawerProps) {
|
|
31
32
|
const [tabValue, setTabValue] = useState(0);
|
|
32
33
|
const [editMode, setEditMode] = useState(false);
|
|
@@ -347,6 +348,7 @@ export function TableFilter({
|
|
|
347
348
|
{...commonProps}
|
|
348
349
|
onSaveFilterButtonClick={handleSaveFilterButtonClick}
|
|
349
350
|
filterComponentOptions={finalComponentOptions}
|
|
351
|
+
isFlatJson={isFlatJson}
|
|
350
352
|
/>
|
|
351
353
|
</CustomTabPanel>
|
|
352
354
|
)}
|
|
@@ -362,6 +364,7 @@ export function TableFilter({
|
|
|
362
364
|
{...savedFilterProps}
|
|
363
365
|
onSaveFilterButtonClick={handleSaveFilterButtonClick}
|
|
364
366
|
filterComponentOptions={finalComponentOptions}
|
|
367
|
+
isFlatJson={isFlatJson}
|
|
365
368
|
/>
|
|
366
369
|
</CustomTabPanel>
|
|
367
370
|
)}
|
|
@@ -376,6 +379,7 @@ export function TableFilter({
|
|
|
376
379
|
{...commonProps}
|
|
377
380
|
{...attributesProps}
|
|
378
381
|
tabValue={tabValue}
|
|
382
|
+
isFlatJson={isFlatJson}
|
|
379
383
|
/>
|
|
380
384
|
</CustomTabPanel>
|
|
381
385
|
)}
|
|
@@ -57,6 +57,7 @@ const entityListingCall = async ({
|
|
|
57
57
|
],
|
|
58
58
|
quickFilter = [],
|
|
59
59
|
attributeFilter = [],
|
|
60
|
+
flatJson,
|
|
60
61
|
}: EntityTableAPIProps): Promise<{
|
|
61
62
|
responseStatus: number;
|
|
62
63
|
data: EntityListingResponse;
|
|
@@ -69,6 +70,7 @@ const entityListingCall = async ({
|
|
|
69
70
|
sortby,
|
|
70
71
|
quickFilter,
|
|
71
72
|
attributeFilter,
|
|
73
|
+
flatJson,
|
|
72
74
|
};
|
|
73
75
|
|
|
74
76
|
const params: APIParamsProps = {
|
|
@@ -99,6 +101,7 @@ export const useEntityTableAPI = ({
|
|
|
99
101
|
},
|
|
100
102
|
],
|
|
101
103
|
attributeFilter = [],
|
|
104
|
+
flatJson,
|
|
102
105
|
}: EntityTableAPIProps) => {
|
|
103
106
|
const { data, isPending: isTableDataPending } = useQuery({
|
|
104
107
|
queryKey: ["entityTable", page, size, tabs, quickFilter],
|
|
@@ -111,6 +114,7 @@ export const useEntityTableAPI = ({
|
|
|
111
114
|
quickFilter,
|
|
112
115
|
sortby,
|
|
113
116
|
attributeFilter,
|
|
117
|
+
flatJson,
|
|
114
118
|
}),
|
|
115
119
|
});
|
|
116
120
|
|
|
@@ -272,7 +276,7 @@ export const useCommonFilterDropdownAPI = (
|
|
|
272
276
|
queryKey: ["commonDropdown", cfg?.dataSourceType],
|
|
273
277
|
queryFn: () =>
|
|
274
278
|
newCommonGetDropdownDataAPI({
|
|
275
|
-
entity_type:
|
|
279
|
+
entity_type: ENTITY_TYPE,
|
|
276
280
|
attribute_key: cfg?.key,
|
|
277
281
|
}),
|
|
278
282
|
enabled: !!cfg?.dataSourceType,
|
|
@@ -78,7 +78,7 @@ export function customDebounce<T extends (...args: any[]) => any>(
|
|
|
78
78
|
|
|
79
79
|
//ENTITY TYPE
|
|
80
80
|
const ENVIRONMENT = "adm_dev";
|
|
81
|
-
export const ENTITY_TYPE = "
|
|
81
|
+
export const ENTITY_TYPE = "SCH";
|
|
82
82
|
export const MAPPED_ENTITY_TYPE = "LYPR"; // LAP OR LYPR
|
|
83
83
|
export const USER_ID = 226;
|
|
84
84
|
|
|
@@ -189,6 +189,7 @@ export interface FilterDrawerProps {
|
|
|
189
189
|
filterMaster,
|
|
190
190
|
}: onFilterChangeFunctionProps) => void;
|
|
191
191
|
filterComponentOptions?: FilterComponentOptions;
|
|
192
|
+
isFlatJson: boolean;
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
export interface FilterCriteria {
|
|
@@ -292,6 +293,7 @@ export interface FilterFormComponentProps {
|
|
|
292
293
|
filterMaster,
|
|
293
294
|
}: onFilterChangeFunctionProps) => void;
|
|
294
295
|
filterComponentOptions?: FilterComponentOptions;
|
|
296
|
+
isFlatJson: boolean;
|
|
295
297
|
}
|
|
296
298
|
|
|
297
299
|
export interface SavedFilterSharingPreference {
|
|
@@ -328,6 +330,7 @@ export interface AttributesFilterProps {
|
|
|
328
330
|
updatedFilters,
|
|
329
331
|
filterMaster,
|
|
330
332
|
}: onFilterChangeFunctionProps) => void;
|
|
333
|
+
isFlatJson: boolean;
|
|
331
334
|
}
|
|
332
335
|
|
|
333
336
|
export interface AttributesFilterSelectProps {
|
|
@@ -24,6 +24,7 @@ const CraftTableFilterWrapper = ({
|
|
|
24
24
|
onChangeFunction,
|
|
25
25
|
columnsData,
|
|
26
26
|
filterComponentOptions,
|
|
27
|
+
isFlatJson,
|
|
27
28
|
}: {
|
|
28
29
|
onClose?: () => void;
|
|
29
30
|
tableStates: CraftTableOptionsProps;
|
|
@@ -34,6 +35,7 @@ const CraftTableFilterWrapper = ({
|
|
|
34
35
|
filterMaster,
|
|
35
36
|
}: onFilterChangeFunctionProps) => void;
|
|
36
37
|
filterComponentOptions?: FilterComponentOptions;
|
|
38
|
+
isFlatJson: boolean;
|
|
37
39
|
}) => {
|
|
38
40
|
const getNavigationLayoutQuery = useGetNavigationLayoutAPI(ENTITY_TYPE);
|
|
39
41
|
|
|
@@ -199,6 +201,7 @@ const CraftTableFilterWrapper = ({
|
|
|
199
201
|
onSaveFilter={handleSaveFilter}
|
|
200
202
|
onChangeFunction={onChangeFunction}
|
|
201
203
|
filterComponentOptions={filterComponentOptions}
|
|
204
|
+
isFlatJson={isFlatJson}
|
|
202
205
|
/>
|
|
203
206
|
);
|
|
204
207
|
};
|
package/src/view/ListingView.tsx
CHANGED
|
@@ -186,6 +186,7 @@ function ListingView() {
|
|
|
186
186
|
},
|
|
187
187
|
],
|
|
188
188
|
attributeFilter: [],
|
|
189
|
+
flatJson: metaQuery.data?.is_flat_json || false,
|
|
189
190
|
});
|
|
190
191
|
|
|
191
192
|
const newData = useMemo(
|
|
@@ -436,6 +437,7 @@ function ListingView() {
|
|
|
436
437
|
tableStates={tableStates}
|
|
437
438
|
columnsData={metaQuery.data || {}}
|
|
438
439
|
dropdownData={dropdownFilterData || []}
|
|
440
|
+
isFlatJson={metaQuery.data?.is_flat_json || false} // Added prop for sending the label instead of value in the dropdown case
|
|
439
441
|
// onUpdateFilter={handleUpdateFilter}
|
|
440
442
|
// onDeleteFilter={handleRemoveFilter}
|
|
441
443
|
// onSaveFilter={handleSaveFilter}
|