mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-15 00:11:15 +03:00
ensure polygon is closed before allowing save
This commit is contained in:
parent
cfcb23fefb
commit
a7761225bc
@ -156,7 +156,7 @@ export default function MotionMaskEditPane({
|
|||||||
message: t("masksAndZones.form.name.error.mustNotBeEmpty"),
|
message: t("masksAndZones.form.name.error.mustNotBeEmpty"),
|
||||||
}),
|
}),
|
||||||
enabled: z.boolean(),
|
enabled: z.boolean(),
|
||||||
isFinished: z.boolean().refine(() => polygon?.isFinished === true, {
|
isFinished: z.boolean().refine((val) => val === true, {
|
||||||
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
|
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
@ -172,6 +172,12 @@ export default function MotionMaskEditPane({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (polygon?.isFinished !== undefined) {
|
||||||
|
form.setValue("isFinished", polygon.isFinished, { shouldValidate: true });
|
||||||
|
}
|
||||||
|
}, [polygon?.isFinished, form]);
|
||||||
|
|
||||||
const saveToConfig = useCallback(
|
const saveToConfig = useCallback(
|
||||||
async ({
|
async ({
|
||||||
name: maskId,
|
name: maskId,
|
||||||
|
|||||||
@ -144,7 +144,7 @@ export default function ObjectMaskEditPane({
|
|||||||
}),
|
}),
|
||||||
enabled: z.boolean(),
|
enabled: z.boolean(),
|
||||||
objects: z.string(),
|
objects: z.string(),
|
||||||
isFinished: z.boolean().refine(() => polygon?.isFinished === true, {
|
isFinished: z.boolean().refine((val) => val === true, {
|
||||||
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
|
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
@ -161,6 +161,12 @@ export default function ObjectMaskEditPane({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (polygon?.isFinished !== undefined) {
|
||||||
|
form.setValue("isFinished", polygon.isFinished, { shouldValidate: true });
|
||||||
|
}
|
||||||
|
}, [polygon?.isFinished, form]);
|
||||||
|
|
||||||
const saveToConfig = useCallback(
|
const saveToConfig = useCallback(
|
||||||
async ({
|
async ({
|
||||||
name: maskId,
|
name: maskId,
|
||||||
|
|||||||
@ -208,7 +208,7 @@ export default function ZoneEditPane({
|
|||||||
})
|
})
|
||||||
.optional()
|
.optional()
|
||||||
.or(z.literal("")),
|
.or(z.literal("")),
|
||||||
isFinished: z.boolean().refine(() => polygon?.isFinished === true, {
|
isFinished: z.boolean().refine((val) => val === true, {
|
||||||
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
|
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
|
||||||
}),
|
}),
|
||||||
objects: z.array(z.string()).optional(),
|
objects: z.array(z.string()).optional(),
|
||||||
@ -334,6 +334,12 @@ export default function ZoneEditPane({
|
|||||||
}
|
}
|
||||||
}, [polygon, form, t, watchSpeedEstimation]);
|
}, [polygon, form, t, watchSpeedEstimation]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (polygon?.isFinished !== undefined) {
|
||||||
|
form.setValue("isFinished", polygon.isFinished, { shouldValidate: true });
|
||||||
|
}
|
||||||
|
}, [polygon?.isFinished, form]);
|
||||||
|
|
||||||
const saveToConfig = useCallback(
|
const saveToConfig = useCallback(
|
||||||
async (
|
async (
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user