Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
clarani committed May 11, 2023
1 parent cb22a4b commit 769ae51
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion front/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
"show-more-ranges_one": "Voir une section de ligne de plus",
"show-more-ranges_other": "Voir {{count}} sections de lignes de plus",
"speed-limits": "Limitations de vitesses",
"toggle-lpv": "is LPV"
"toggle-lpv": "Limite permanente de vitesse"
}
}
}
Expand Down
13 changes: 12 additions & 1 deletion front/src/applications/editor/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,18 @@ const MapUnplugged: FC<PropsWithChildren<MapProps>> = ({
}

if (activeTool.onMove) {
activeTool.onMove(e, extendedContext);
activeTool.onMove(
nearestResult
? {
...e,
// (don't remove this or TypeScript won't be happy)
preventDefault: e.preventDefault,
// Ensure there is a feature, and the good one:
features: [nearestResult.feature],
}
: e,
extendedContext
);
}

if (!isEmpty(partialToolState)) setToolState(partialToolState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ export const SpeedSectionEditionLayers: FC = () => {
}
}, [hoveredItem]);

const addPopUps = () => (
const popUps = !isOnModeMove(interactionState.type) ? (
<>
{hoveredItem?.speedSectionItemType === 'TrackRangeExtremity' && (
<Popup
Expand Down Expand Up @@ -654,7 +654,7 @@ export const SpeedSectionEditionLayers: FC = () => {
</Popup>
)}
</>
);
) : null;

return (
<>
Expand All @@ -666,7 +666,7 @@ export const SpeedSectionEditionLayers: FC = () => {
layersSettings={layersSettings}
isEmphasized={false}
/>
<Source type="geojson" data={speedSectionsFeature}>
<Source type="geojson" data={speedSectionsFeature} key={isLPV ? 'lpv' : 'speed-section'}>
{layersProps.map((props, i) => (
<Layer {...props} key={i} />
))}
Expand All @@ -681,7 +681,7 @@ export const SpeedSectionEditionLayers: FC = () => {
filter={['has', 'extremity']}
/>
</Source>
{!isOnModeMove(interactionState.type) && addPopUps()}
{popUps}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const LpvPanelCard = ({
</div>
<div className="my-2">
<InputSNCF
type="string"
type="text"
id="track-id"
label={t('Editor.tools.speed-edition.panel-track-id')}
value={!isNil(panel.track) ? panel.track : 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const SpeedSectionEditionTool: Tool<SpeedSectionEditionState> = {
setState({ entity: updatedEntity });
}
}
} else if (hoveredItem) {
} else if (hoveredItem && !e.features?.length) {
setState({ hoveredItem: null });
}
},
Expand Down
14 changes: 13 additions & 1 deletion front/src/applications/editor/tools/speedSectionEdition/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ export function getTrackRangeFeatures(
];
}

/**
* Given a LPV panel and the cached trackSections, generate a point feature to represent a SpeedSection Lpv Panel.
* If the panel's track is not in the trackSectionsCache object, then return null.
* This feature will be used to display the panel on the map.
*/
function generatePointFromLPVPanel(
panel: LPVPanel,
panelIndex: number,
Expand All @@ -258,7 +263,9 @@ function generatePointFromLPVPanel(
return panelPoint as LpvPanelFeature;
}

/** Generate LPV panel Features (Point) from LPV panels and trackSectionCache */
/**
* Given a LPV extension and cached trackSections, generate an array of Point Features to display the LPV panels on the map.
*/
export function generateLpvPanelFeatures(
lpv: LPVExtension,
trackSectionsCache: Record<string, TrackState>
Expand Down Expand Up @@ -290,6 +297,11 @@ export function kmhToMs(v: number): number {
return v / 3.6;
}

/**
* Given a lpvPanel information, update the state to notify that the user is moving the panel.
* - set the interaction state on 'movePanel'
* - store in the interaction state the panel informations
*/
export function selectLpvPanel(
lpvPanel: LpvPanelInformation,
setState: (
Expand Down
4 changes: 4 additions & 0 deletions front/src/applications/editor/tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export function getHoveredTrackRanges(hoverEvent: mapboxgl.MapLayerMouseEvent) {
) as Feature<LineString>[];
}

/**
* Given a point and trackSectionsCache, return the cached trackSection on which the point is.
* If the trackSection is not in the cache, then return null.
*/
export function getTrackSectionEntityFromNearestPoint(
point: NearestPoint,
trackRanges: Feature<LineString>[],
Expand Down

0 comments on commit 769ae51

Please sign in to comment.