Skip to content

Commit 5aebc21

Browse files
committed
Store full trainrun section chain in TrainrunSectionViewObject
This makes it clear that there isn't a single trainrun section per TrainrunSectionViewObject: a single TrainrunSectionViewObject can hold multiple sections. The full collapsed chain is stored. For now, blindly replace trainrunSection with trainrunSections[0], to be cleaned up in future commits. Signed-off-by: Simon Ser <[email protected]>
1 parent 6d600a3 commit 5aebc21

File tree

3 files changed

+125
-126
lines changed

3 files changed

+125
-126
lines changed

src/app/view/editor-main-view/data-views/d3.utils.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ export class D3Utils {
9090
d3.selectAll(StaticDomTags.EDGE_LINE_ARROW_DOM_REF)
9191
.filter(
9292
(d: TrainrunSectionViewObject) =>
93-
d !== undefined && d.trainrunSection.getTrainrunId() === trainrunSection.getTrainrunId(),
93+
d !== undefined && d.trainrunSections[0].getTrainrunId() === trainrunSection.getTrainrunId(),
9494
)
9595
.classed(StaticDomTags.TAG_HOVER, false);
9696
d3.selectAll(StaticDomTags.EDGE_LINE_DOM_REF)
9797
.filter(
9898
(d: TrainrunSectionViewObject) =>
99-
d !== undefined && d.trainrunSection.getTrainrunId() === trainrunSection.getTrainrunId(),
99+
d !== undefined && d.trainrunSections[0].getTrainrunId() === trainrunSection.getTrainrunId(),
100100
)
101101
.classed(StaticDomTags.TAG_HOVER, false);
102102

103103
d3.selectAll(StaticDomTags.EDGE_ROOT_CONTAINER_DOM_REF)
104104
.filter(
105105
(d: TrainrunSectionViewObject) =>
106-
d !== undefined && d.trainrunSection.getTrainrunId() === trainrunSection.getTrainrunId(),
106+
d !== undefined && d.trainrunSections[0].getTrainrunId() === trainrunSection.getTrainrunId(),
107107
)
108108
.classed(StaticDomTags.TAG_HOVER, false);
109109

@@ -347,7 +347,7 @@ export class D3Utils {
347347
if (d === undefined) {
348348
return false;
349349
}
350-
return d.trainrunSection.getId() === trainrunSection.getId();
350+
return d.trainrunSections[0].getId() === trainrunSection.getId();
351351
})
352352
.classed(StaticDomTags.TAG_SELECTED, false)
353353
.classed(StaticDomTags.TAG_HOVER, false)
@@ -359,7 +359,7 @@ export class D3Utils {
359359
if (d === undefined) {
360360
return false;
361361
}
362-
return d.trainrunSection.getId() === trainrunSection.getId();
362+
return d.trainrunSections[0].getId() === trainrunSection.getId();
363363
})
364364
.classed(StaticDomTags.TAG_SELECTED, false)
365365
.classed(StaticDomTags.TAG_HOVER, false)
@@ -371,7 +371,7 @@ export class D3Utils {
371371
if (d === undefined) {
372372
return false;
373373
}
374-
return d.trainrunSection.getId() === trainrunSection.getId();
374+
return d.trainrunSections[0].getId() === trainrunSection.getId();
375375
})
376376
.classed(StaticDomTags.TAG_SELECTED, false)
377377
.classed(StaticDomTags.TAG_HOVER, false)
@@ -383,7 +383,7 @@ export class D3Utils {
383383
if (d === undefined) {
384384
return false;
385385
}
386-
return d.trainrunSection.getId() === trainrunSection.getId();
386+
return d.trainrunSections[0].getId() === trainrunSection.getId();
387387
})
388388
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, true);
389389

@@ -394,8 +394,8 @@ export class D3Utils {
394394
return false;
395395
}
396396
return (
397-
d.trainrunSection.getId() === trainrunSection.getId() &&
398-
d.trainrunSection.getSourceNodeId() === grayoutEdgeLinePinNode.getId()
397+
d.trainrunSections[0].getId() === trainrunSection.getId() &&
398+
d.trainrunSections[0].getSourceNodeId() === grayoutEdgeLinePinNode.getId()
399399
);
400400
})
401401
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, true);
@@ -405,8 +405,8 @@ export class D3Utils {
405405
return false;
406406
}
407407
return (
408-
d.trainrunSection.getId() === trainrunSection.getId() &&
409-
d.trainrunSection.getTargetNodeId() === grayoutEdgeLinePinNode.getId()
408+
d.trainrunSections[0].getId() === trainrunSection.getId() &&
409+
d.trainrunSections[0].getTargetNodeId() === grayoutEdgeLinePinNode.getId()
410410
);
411411
})
412412
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, true);
@@ -419,7 +419,7 @@ export class D3Utils {
419419
if (d === undefined) {
420420
return false;
421421
}
422-
return d.trainrunSection.getId() === trainrunSection.getId();
422+
return d.trainrunSections[0].getId() === trainrunSection.getId();
423423
})
424424
.classed(StaticDomTags.TAG_SELECTED, true)
425425
.classed(StaticDomTags.TAG_HOVER, false)
@@ -431,7 +431,7 @@ export class D3Utils {
431431
if (d === undefined) {
432432
return false;
433433
}
434-
return d.trainrunSection.getId() === trainrunSection.getId();
434+
return d.trainrunSections[0].getId() === trainrunSection.getId();
435435
})
436436
.classed(StaticDomTags.TAG_SELECTED, true)
437437
.classed(StaticDomTags.TAG_HOVER, false)
@@ -443,7 +443,7 @@ export class D3Utils {
443443
if (d === undefined) {
444444
return false;
445445
}
446-
return d.trainrunSection.getId() === trainrunSection.getId();
446+
return d.trainrunSections[0].getId() === trainrunSection.getId();
447447
})
448448
.classed(StaticDomTags.TAG_SELECTED, true)
449449
.classed(StaticDomTags.TAG_HOVER, false)
@@ -455,7 +455,7 @@ export class D3Utils {
455455
if (d === undefined) {
456456
return false;
457457
}
458-
return d.trainrunSection.getId() === trainrunSection.getId();
458+
return d.trainrunSections[0].getId() === trainrunSection.getId();
459459
})
460460
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, false);
461461

@@ -466,8 +466,8 @@ export class D3Utils {
466466
return false;
467467
}
468468
return (
469-
d.trainrunSection.getId() === trainrunSection.getId() &&
470-
d.trainrunSection.getSourceNodeId() === grayoutEdgeLinePinNode.getId()
469+
d.trainrunSections[0].getId() === trainrunSection.getId() &&
470+
d.trainrunSections[0].getSourceNodeId() === grayoutEdgeLinePinNode.getId()
471471
);
472472
})
473473
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, false);
@@ -477,8 +477,8 @@ export class D3Utils {
477477
return false;
478478
}
479479
return (
480-
d.trainrunSection.getId() === trainrunSection.getId() &&
481-
d.trainrunSection.getTargetNodeId() === grayoutEdgeLinePinNode.getId()
480+
d.trainrunSections[0].getId() === trainrunSection.getId() &&
481+
d.trainrunSections[0].getTargetNodeId() === grayoutEdgeLinePinNode.getId()
482482
);
483483
})
484484
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, false);

src/app/view/editor-main-view/data-views/trainrunSectionViewObject.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class TrainrunSectionViewObject {
66

77
constructor(
88
private editorView: EditorView,
9-
public trainrunSection: TrainrunSection,
9+
public trainrunSections: TrainrunSection[],
1010
isNonStopAtSource: boolean,
1111
isNonStopAtTarget: boolean,
1212
isMuted: boolean,
@@ -18,7 +18,7 @@ export class TrainrunSectionViewObject {
1818
) {
1919
this.key = TrainrunSectionViewObject.generateKey(
2020
editorView,
21-
trainrunSection,
21+
trainrunSections,
2222
isNonStopAtSource,
2323
isNonStopAtTarget,
2424
isMuted,
@@ -31,12 +31,12 @@ export class TrainrunSectionViewObject {
3131
}
3232

3333
getTrainrun() {
34-
return this.trainrunSection.getTrainrun();
34+
return this.trainrunSections[0].getTrainrun();
3535
}
3636

3737
static generateKey(
3838
editorView: EditorView,
39-
d: TrainrunSection,
39+
trainrunSections: TrainrunSection[],
4040
isNonStopAtSource: boolean,
4141
isNonStopAtTarget: boolean,
4242
isMuted: boolean,
@@ -46,6 +46,7 @@ export class TrainrunSectionViewObject {
4646
hiddenTagTrainrunName: boolean,
4747
hiddenTagDirectionArrows: boolean,
4848
): string {
49+
const d = trainrunSections[0];
4950
const cumulativeTravelTimeData = editorView.getCumulativeTravelTimeAndNodePath(d);
5051
const cumulativeTravelTime =
5152
cumulativeTravelTimeData[cumulativeTravelTimeData.length - 1].sumTravelTime;
@@ -166,6 +167,4 @@ export class TrainrunSectionViewObject {
166167

167168
return key;
168169
}
169-
170-
171170
}

0 commit comments

Comments
 (0)