Skip to content

Commit 89f15a8

Browse files
authored
front: edition - fixing issues (#2614)
* front: editor - adding tooltip on button to select a tracksection on the map #2503 * front: editor - fix issue when clicking on button 'select a tracksection' and you hovera signal for example (bug 4-bis in #2503) * front: editor - when changing the position of a signal in the form, the item is also moved on the map * front: editor - fix new entity popin by not displaying default id & click on line for signals
1 parent c5e5290 commit 89f15a8

File tree

5 files changed

+29
-16
lines changed

5 files changed

+29
-16
lines changed

front/public/locales/fr/translation.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@
9999
"label": "Outil \"Aiguillage\",",
100100
"actions": {
101101
"delete-switch": "Supprimer l'aiguillage",
102-
"new-switch": "Créer un nouvel aiguillage"
102+
"new-switch": "Créer un nouvel aiguillage",
103+
"pick-track": "Outil de sélection d'une ligne sur la carte",
104+
"pick-track-cancel": "Annuler la sélection d'une ligne"
103105
},
104106
"help": {
105107
"no-move": "Les aiguillages ne peuvent pas être déplacer, et sont automatiquement placés sur leur premier port.",

front/src/applications/editor/Map.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,11 @@ const MapUnplugged: FC<PropsWithChildren<MapProps>> = ({
128128
? editorState.entitiesIndex[feature.properties.id]
129129
: undefined;
130130
partialToolState.hovered = entity || null;
131+
setToolState({ ...toolState, ...partialToolState });
131132
}
132133
} else if (activeTool.onMove) {
133134
activeTool.onMove(e, extendedContext);
134135
}
135-
136-
setToolState({ ...toolState, ...partialToolState });
137136
setMapState((prev) => ({ ...prev, ...partialMapState }));
138137
}}
139138
onLoad={(e) => {

front/src/applications/editor/components/EntitySumUp.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
33
import { flatMap, uniq } from 'lodash';
44
import cx from 'classnames';
55

6+
import { NEW_ENTITY_ID } from '../data/utils';
67
import {
78
BufferStopEntity,
89
EditorEntity,
@@ -128,7 +129,7 @@ const EntitySumUp: FC<{
128129
<div>
129130
<div className={cx(classes.muted, classes.small)}>{type}</div>
130131
<div>
131-
<span className={classes.strong}>{text}</span>
132+
{text !== NEW_ENTITY_ID && <span className={classes.strong}>{text}</span>}
132133
{status && ` (${t(`Editor.item-statuses.${status}`)})`}
133134
</div>
134135
{subtexts.map((s, i) => (

front/src/applications/editor/tools/pointEdition/components.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const PointEditionLeftPanel: FC = <Entity extends EditorEntity>() => {
7171

7272
const newPosition = entity.properties?.position;
7373
const oldPosition = state.entity.properties?.position;
74-
const trackId = entity.properties?.track?.id;
74+
const trackId = entity.properties?.track;
7575
if (
7676
typeof trackId === 'string' &&
7777
typeof newPosition === 'number' &&

front/src/applications/editor/tools/switchEdition/components.tsx

+22-11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { featureCollection, point } from '@turf/helpers';
1111
import nearestPoint from '@turf/nearest-point';
1212

1313
import EditorContext from '../../context';
14+
import Tipped from '../../components/Tipped';
1415
import { ExtendedEditorContextType, OSRDConf } from '../types';
1516
import {
1617
CreateEntityOperation,
@@ -141,14 +142,23 @@ export const TrackSectionEndpointSelector: FC<FieldProps> = ({
141142
</div>
142143
)}
143144
</div>
144-
<button
145-
type="button"
146-
className="btn btn-primary px-3"
147-
onClick={startPickingPort}
148-
disabled={isDisabled}
149-
>
150-
{isPicking ? <FaTimesCircle /> : <FaMapMarkedAlt />}
151-
</button>
145+
<Tipped mode="left">
146+
<button
147+
type="button"
148+
className="btn btn-primary px-3"
149+
onClick={startPickingPort}
150+
disabled={isDisabled}
151+
>
152+
{isPicking ? <FaTimesCircle /> : <FaMapMarkedAlt />}
153+
</button>
154+
<span>
155+
{t(
156+
`Editor.tools.switch-edition.actions.${
157+
isPicking ? 'pick-track-cancel' : 'pick-track'
158+
}`
159+
)}
160+
</span>
161+
</Tipped>
152162
</div>
153163
</div>
154164
);
@@ -305,9 +315,10 @@ export const SwitchEditionLayers: FC = () => {
305315
const nameLayerProps = getSwitchesNameLayerProps({
306316
colors: colors[mapStyle],
307317
});
308-
const hoveredTrack = hovered
309-
? (entitiesIndex[hovered.properties.id] as TrackSectionEntity)
310-
: null;
318+
const hoveredTrack =
319+
hovered && hovered.objType === 'TrackSection'
320+
? (entitiesIndex[hovered.properties.id] as TrackSectionEntity)
321+
: null;
311322

312323
const closest =
313324
portEditionState.type === 'selection' && hoveredTrack && mousePosition

0 commit comments

Comments
 (0)