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"),
|
||||
}),
|
||||
enabled: z.boolean(),
|
||||
isFinished: z.boolean().refine(() => polygon?.isFinished === true, {
|
||||
isFinished: z.boolean().refine((val) => val === true, {
|
||||
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(
|
||||
async ({
|
||||
name: maskId,
|
||||
|
||||
@ -144,7 +144,7 @@ export default function ObjectMaskEditPane({
|
||||
}),
|
||||
enabled: z.boolean(),
|
||||
objects: z.string(),
|
||||
isFinished: z.boolean().refine(() => polygon?.isFinished === true, {
|
||||
isFinished: z.boolean().refine((val) => val === true, {
|
||||
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(
|
||||
async ({
|
||||
name: maskId,
|
||||
|
||||
@ -208,7 +208,7 @@ export default function ZoneEditPane({
|
||||
})
|
||||
.optional()
|
||||
.or(z.literal("")),
|
||||
isFinished: z.boolean().refine(() => polygon?.isFinished === true, {
|
||||
isFinished: z.boolean().refine((val) => val === true, {
|
||||
message: t("masksAndZones.form.polygonDrawing.error.mustBeFinished"),
|
||||
}),
|
||||
objects: z.array(z.string()).optional(),
|
||||
@ -334,6 +334,12 @@ export default function ZoneEditPane({
|
||||
}
|
||||
}, [polygon, form, t, watchSpeedEstimation]);
|
||||
|
||||
useEffect(() => {
|
||||
if (polygon?.isFinished !== undefined) {
|
||||
form.setValue("isFinished", polygon.isFinished, { shouldValidate: true });
|
||||
}
|
||||
}, [polygon?.isFinished, form]);
|
||||
|
||||
const saveToConfig = useCallback(
|
||||
async (
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user