multi auto complete
This commit is contained in:
@@ -142,16 +142,19 @@ function renderFilterInput(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selected = Array.isArray(value) ? value : [];
|
||||||
return (
|
return (
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
key={fieldName}
|
key={fieldName}
|
||||||
|
multiple
|
||||||
options={options}
|
options={options}
|
||||||
value={value ?? null}
|
value={selected}
|
||||||
onChange={(_, val) => onChange("value", val || undefined)}
|
onChange={(_, val) => onChange("value", val.length > 0 ? val : undefined)}
|
||||||
|
ChipProps={{ size: 'small' }}
|
||||||
renderInput={(params) => (
|
renderInput={(params) => (
|
||||||
<TextField {...params} label={field.label} size="small" />
|
<TextField {...params} label={field.label} size="small" />
|
||||||
)}
|
)}
|
||||||
sx={{ minWidth: 180 }}
|
sx={{ minWidth: 220 }}
|
||||||
size="small"
|
size="small"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function applyClientFilters(
|
|||||||
fields: Record<string, ResourceField>
|
fields: Record<string, ResourceField>
|
||||||
): any[] {
|
): any[] {
|
||||||
const entries = Object.entries(filters).filter(([_, v]) => {
|
const entries = Object.entries(filters).filter(([_, v]) => {
|
||||||
if (v == null || v === "") return false;
|
if (v == null || v === "" || (Array.isArray(v) && v.length === 0)) return false;
|
||||||
if (typeof v === "object" && !Array.isArray(v) && Object.values(v).every((x) => x == null || x === "")) return false;
|
if (typeof v === "object" && !Array.isArray(v) && Object.values(v).every((x) => x == null || x === "")) return false;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -58,6 +58,15 @@ function applyClientFilters(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(filterValue)) {
|
if (Array.isArray(filterValue)) {
|
||||||
|
if (field.type === "array" && Array.isArray(itemValue)) {
|
||||||
|
return itemValue.some((el: any) => {
|
||||||
|
if (el != null && typeof el === "object") {
|
||||||
|
const dispFields = getFilterDisplayFields(field);
|
||||||
|
return dispFields.some((df) => filterValue.includes(String(el[df])));
|
||||||
|
}
|
||||||
|
return filterValue.includes(String(el));
|
||||||
|
});
|
||||||
|
}
|
||||||
if (itemValue && typeof itemValue === "object") {
|
if (itemValue && typeof itemValue === "object") {
|
||||||
const dispFields = getFilterDisplayFields(field);
|
const dispFields = getFilterDisplayFields(field);
|
||||||
const itemDisplay = dispFields.map((df) => itemValue[df]).filter((v) => v != null).join(" ");
|
const itemDisplay = dispFields.map((df) => itemValue[df]).filter((v) => v != null).join(" ");
|
||||||
|
|||||||
Reference in New Issue
Block a user