Skip to content

Commit

Permalink
fixed (#30)
Browse files Browse the repository at this point in the history
* fixed

* inline code doc
  • Loading branch information
aiAdrian authored Mar 19, 2024
1 parent 7a09fc9 commit 7954d1a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/app/services/data/trainrun.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ export class TrainrunService {
if (trainrun1.getId() === trainrun2.getId()) {
return;
}

// update trainrun references (trainrunSections and transitions)
const trainrunSection = port2.getTrainrunSection();
trainrunSection.setTrainrun(trainrun1);
const iterator = this.getIterator(node, trainrunSection);
Expand All @@ -419,12 +421,14 @@ export class TrainrunService {
iterator.current().trainrunSection.setTrainrun(trainrun1);
}

// update trainrun references (1st transition)
const trans1 = node.getTransitionFromPortId(port1.getId());
const trans2 = node.getTransitionFromPortId(port2.getId());
if (trans1 === undefined && trans2 === undefined) {
node.addTransitionAndComputeRouting(port1, port2, trainrun1);
}

// update trainrun references (connection)
const connections2delete = node.getConnections().filter((c: Connection) => {
return (c.getPortId1() === port1.getId() && c.getPortId2() === port2.getId()) ||
(c.getPortId1() === port2.getId() && c.getPortId2() === port1.getId());
Expand All @@ -433,13 +437,18 @@ export class TrainrunService {
node.removeConnection(c.getId());
});

// unselect both trainruns
trainrun1.unselect();
trainrun2.unselect();

this.deleteTrainrun(trainrun2);
// remove empty trainrun
this.deleteTrainrun(trainrun2, false);

// select
trainrun1.select();
this.nodeService.reorderPortsOnNodesForTrainrun(trainrun1);
this.nodeService.reorderPortsOnNodesForTrainrun(trainrun1, false);

// update
this.trainrunsUpdated();
this.nodeService.nodesUpdated();
this.nodeService.connectionsUpdated();
Expand Down

0 comments on commit 7954d1a

Please sign in to comment.