feat: add join route functionality to routes editor

This commit is contained in:
Azgaar 2024-06-24 17:11:41 +02:00
parent 41354a857e
commit 432bc8bf09
2 changed files with 17 additions and 3 deletions

View file

@ -2937,6 +2937,11 @@
data-tip="Create a new route selecting route cells" data-tip="Create a new route selecting route cells"
class="icon-map-pin" class="icon-map-pin"
></button> ></button>
<button
id="routeJoin"
data-tip="Click on control point to join the route to another route that starts or ends there"
class="icon-link"
></button>
<button <button
id="routeSplit" id="routeSplit"
data-tip="Click on a control point to split the route there" data-tip="Click on a control point to split the route there"

View file

@ -36,7 +36,8 @@ function editRoute(id) {
// add listeners // add listeners
byId("routeCreateSelectingCells").on("click", showCreationDialog); byId("routeCreateSelectingCells").on("click", showCreationDialog);
byId("routeSplit").on("click", toggleSplitRoute); byId("routeSplit").on("click", togglePressed);
byId("routeJoin").on("click", togglePressed);
byId("routeElevationProfile").on("click", showRouteElevationProfile); byId("routeElevationProfile").on("click", showRouteElevationProfile);
byId("routeLegend").on("click", editRouteLegend); byId("routeLegend").on("click", editRouteLegend);
byId("routeRemove").on("click", removeRoute); byId("routeRemove").on("click", removeRoute);
@ -173,8 +174,16 @@ function editRoute(id) {
function handleControlPointClick() { function handleControlPointClick() {
const controlPoint = d3.select(this); const controlPoint = d3.select(this);
const isJoinMode = byId("routeJoin").classList.contains("pressed");
if (isJoinMode) return joinRoute(controlPoint);
const isSplitMode = byId("routeSplit").classList.contains("pressed"); const isSplitMode = byId("routeSplit").classList.contains("pressed");
isSplitMode ? splitRoute(controlPoint) : removeControlPoint(controlPoint); if (isSplitMode) return splitRoute(controlPoint);
return removeControlPoint(controlPoint);
function joinRoute(controlPoint) {}
function splitRoute(controlPoint) { function splitRoute(controlPoint) {
const allPoints = debug.selectAll("#controlPoints > *").data(); const allPoints = debug.selectAll("#controlPoints > *").data();
@ -248,7 +257,7 @@ function editRoute(id) {
createRoute(route.group); createRoute(route.group);
} }
function toggleSplitRoute() { function togglePressed() {
this.classList.toggle("pressed"); this.classList.toggle("pressed");
} }