add the checkboxes for dropdown list and remove searchbox list inside it
This commit is contained in:
1 parent
6e76e29768
commit
39d666df6b
1 file changed
+9
-24
@@ -222,23 +222,14 @@ const CreateMaintenance = () => {
|
||||
};
|
||||
|
||||
const handleMonitorsChange = (selected) => {
|
||||
if (selected.some((m) => m._id === "__all__")) {
|
||||
if (selectedMonitors.length !== monitors.length) {
|
||||
setSelectedMonitors(monitors);
|
||||
} else {
|
||||
setSelectedMonitors([]);
|
||||
}
|
||||
} else {
|
||||
// Ensure all are objects
|
||||
const selectedObjs = selected
|
||||
.map((sel) =>
|
||||
typeof sel === "string" ? monitors.find((m) => m._id === sel) : sel
|
||||
)
|
||||
.filter(Boolean);
|
||||
setSelectedMonitors(selectedObjs);
|
||||
}
|
||||
// Ensure all are objects
|
||||
const selectedObjs = selected
|
||||
.map((sel) => (typeof sel === "string" ? monitors.find((m) => m._id === sel) : sel))
|
||||
.filter(Boolean);
|
||||
setSelectedMonitors(selectedObjs);
|
||||
|
||||
const { error } = maintenanceWindowValidation.validate(
|
||||
{ monitors: selected },
|
||||
{ monitors: selectedObjs },
|
||||
{ abortEarly: false }
|
||||
);
|
||||
setErrors((prev) => {
|
||||
@@ -246,8 +237,6 @@ const CreateMaintenance = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const allSelected = selectedMonitors.length === monitors.length && monitors.length > 0;
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (hasValidationErrors(form, maintenanceWindowValidation, setErrors)) return;
|
||||
// Build timestamp for maintenance window from startDate and startTime
|
||||
@@ -303,10 +292,6 @@ const CreateMaintenance = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// Add Select All option to the dropdown
|
||||
const selectAllOption = { _id: "__all__", name: t("selectAll") };
|
||||
const monitorOptions = [selectAllOption, ...monitors];
|
||||
|
||||
return (
|
||||
<Box className="create-maintenance">
|
||||
<Breadcrumbs
|
||||
@@ -565,8 +550,8 @@ const CreateMaintenance = () => {
|
||||
id={"monitors"}
|
||||
label={t("addMonitors")}
|
||||
multiple={true}
|
||||
isAdorned={false}
|
||||
options={monitorOptions}
|
||||
isAdorned={true}
|
||||
options={monitors}
|
||||
filteredBy="name"
|
||||
secondaryLabel={"type"}
|
||||
inputValue={search}
|
||||
|
||||
Reference in new issue
Block a user