Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OutilDeMesure] Bouton de validation pour tracé un cercle inactif si les deux champs ne sont pas remplis #891

Merged
merged 6 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ export function CustomCircleRange() {
)

const addCustomCircleRange = useCallback(
(nextCoordinates, nextCircleRadius) => {
dispatch(
async (nextCoordinates, nextCircleRadius) => {
if (!nextCoordinates?.length || !nextCircleRadius?.length) {
return
}

await dispatch(
setCircleMeasurementToAdd({
circleCoordinatesToAdd: nextCoordinates,
circleRadiusToAdd: nextCircleRadius
Expand All @@ -100,6 +104,7 @@ export function CustomCircleRange() {
const extent = transformExtent(boundingExtent([formattedCoordinates]), WSG84_PROJECTION, OPENLAYERS_PROJECTION)
dispatch(setFitToExtent(extent))
dispatch(setMeasurementTypeToAdd(undefined))
dispatch(resetCircleMeasurementInDrawing())
},
[dispatch]
)
Expand Down Expand Up @@ -131,6 +136,7 @@ export function CustomCircleRange() {
<br />
<OkButton
data-cy="measurement-circle-add"
disabled={!circleCoordinates?.length || !circleRadius?.length}
onClick={() => addCustomCircleRange(circleCoordinates, circleRadius)}
>
OK
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/features/missions/MissionForm/MissionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ export function MissionForm({ id, isAlreadyClosed, isNewMission, selectedMission

const closeMission = async () => {
await setFieldValue('isClosed', true)
validateForm().then(errors => {
validateForm().then(async errors => {
if (_.isEmpty(errors)) {
handleSubmit()
} else {
await setFieldValue('isClosed', false)
setShouldValidateOnChange(true)
}
})
Expand Down
Loading