Skip to content

Commit f1e5b8b

Browse files
committed
front: add reset button for trackEdition tool
1 parent 5691ca8 commit f1e5b8b

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

front/public/locales/en/translation.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,9 @@
446446
"mode-add-point": "Add a point",
447447
"mode-delete-point": "Delete points",
448448
"mode-move-point": "Move points",
449-
"toggle-anchoring": "Toggle anchoring on/off",
450-
"save-line": "Save the line"
449+
"reset-line": "Reset data",
450+
"save-line": "Save the line",
451+
"toggle-anchoring": "Toggle anchoring on/off"
451452
},
452453
"help": {
453454
"add-anchor-point": "Click to add a point at the end of the track section. Click on the track to add an intermediate point.",

front/public/locales/fr/translation.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,9 @@
446446
"mode-add-point": "Ajouter un point",
447447
"mode-delete-point": "Supprimer des points",
448448
"mode-move-point": "Déplacer les points",
449-
"toggle-anchoring": "Activer / désactiver l'ancrage automatique",
450-
"save-line": "Sauvegarder la ligne"
449+
"reset-line": "Réinitialiser les données",
450+
"save-line": "Sauvegarder la ligne",
451+
"toggle-anchoring": "Activer / désactiver l'ancrage automatique"
451452
},
452453
"help": {
453454
"add-anchor-point": "Cliquez pour ajouter un point au bout de la section de ligne. Cliquez sur la ligne pour ajouter un point intermédiaire.",

front/src/applications/editor/tools/trackEdition/tool.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { cloneDeep, isEmpty, isEqual } from 'lodash';
33
import { MdShowChart } from 'react-icons/md';
44
import { RiDragMoveLine } from 'react-icons/ri';
5-
import { BiAnchor, BiArrowFromLeft, BiArrowToRight } from 'react-icons/bi';
5+
import { BiAnchor, BiArrowFromLeft, BiArrowToRight, BiReset } from 'react-icons/bi';
66
import { Feature, LineString } from 'geojson';
77
import getNearestPoint from '@turf/nearest-point';
88
import { featureCollection } from '@turf/helpers';
@@ -65,6 +65,19 @@ const TrackEditionTool: Tool<TrackEditionState> = {
6565
}
6666
},
6767
},
68+
{
69+
id: 'reset-entity',
70+
icon: BiReset,
71+
labelTranslationKey: `Editor.tools.track-edition.actions.reset-line`,
72+
isDisabled({ state: { track, initialTrack } }) {
73+
return isEqual(track, initialTrack);
74+
},
75+
onClick({ setState, state: { initialTrack } }) {
76+
setState({
77+
track: cloneDeep(initialTrack),
78+
});
79+
},
80+
},
6881
],
6982
[
7083
{

0 commit comments

Comments
 (0)