Skip to content

Commit 9705915

Browse files
committed
feat(traffic-side): add traffic side configuration in editor properties
Implement complete interface for railway traffic conventions: - Add TrafficSide methods to DataService and UiInteractionService - Add editor properties panel with left/right selection - Add translations for all labels and tooltips Allows users to configure left-hand vs right-hand traffic conventions according to regional railway standards. Signed-off-by: Uriel-Sautron <uriel.sautron@gmail.com>
1 parent a5355f0 commit 9705915

File tree

7 files changed

+84
-3
lines changed

7 files changed

+84
-3
lines changed

src/app/services/data/data.service.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Direction,
66
TrainrunFrequency,
77
TrainrunTimeCategory,
8+
TrafficSide,
89
} from "../../data-structures/business.data.structures";
910
import {NetzgrafikDefault} from "../../sample-netzgrafik/netzgrafik.default";
1011
import {NodeService} from "./node.service";
@@ -185,6 +186,7 @@ export class DataService implements OnDestroy {
185186
const metadata = this.netzgrafikDtoStore.netzgrafikDto.metadata;
186187
metadata.netzgrafikColors = this.netzgrafikColoringService.getDtos();
187188
metadata.orderingAlgorithm = this.nodeService.getCurrentOrderingAlgorithm();
189+
metadata.trafficSide = this.netzgrafikDtoStore.netzgrafikDto.metadata.trafficSide || "leftHand";
188190

189191
return {
190192
nodes: this.nodeService.getDtos(),
@@ -249,6 +251,14 @@ export class DataService implements OnDestroy {
249251
return this.netzgrafikDtoStore.netzgrafikDto.metadata.trainrunTimeCategories;
250252
}
251253

254+
getTrafficSide(): TrafficSide {
255+
return this.netzgrafikDtoStore.netzgrafikDto.metadata.trafficSide || "leftHand";
256+
}
257+
258+
setTrafficSideType(trafficSideType: TrafficSide) {
259+
this.netzgrafikDtoStore.netzgrafikDto.metadata.trafficSide = trafficSideType;
260+
}
261+
252262
getDirections(): Direction[] {
253263
return Object.values(Direction);
254264
}

src/app/services/ui/ui.interaction.service.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import {Trainrun} from "../../models/trainrun.model";
3030
import {LoadPerlenketteService} from "../../perlenkette/service/load-perlenkette.service";
3131
import {TravelTimeCreationEstimatorType} from "../../view/themes/editor-trainrun-traveltime-creator-type";
3232
import {OrderingAlgorithm} from "../../data-structures/technical.data.structures";
33+
import {TrafficSide} from "src/app/data-structures/business.data.structures";
34+
import {DataService} from "../data/data.service";
3335

3436
export interface ViewboxProperties {
3537
currentViewBox: string;
@@ -105,6 +107,7 @@ export class UiInteractionService implements OnDestroy {
105107
private activeTheme: ThemeBase = null;
106108
private activeStreckengrafikRenderingType: StreckengrafikRenderingType = null;
107109
private activeTravelTimeCreationEstimatorType: TravelTimeCreationEstimatorType = null;
110+
private activeTrafficSideType: TrafficSide;
108111
private editorMode: EditorMode = EditorMode.NetzgrafikEditing;
109112
private isMultiSelectedNodesCorridor = false;
110113

@@ -122,6 +125,7 @@ export class UiInteractionService implements OnDestroy {
122125
private trainrunService: TrainrunService,
123126
private netzgrafikColoringService: NetzgrafikColoringService,
124127
private loadPerlenketteService: LoadPerlenketteService,
128+
private dataService: DataService,
125129
) {
126130
this.activeTheme = null;
127131
this.loadActiveTheme();
@@ -295,6 +299,14 @@ export class UiInteractionService implements OnDestroy {
295299
this.saveUserSettingToLocalStorage();
296300
}
297301

302+
getActiveTrafficSideType(): TrafficSide {
303+
return this.activeTrafficSideType || this.dataService.getTrafficSide();
304+
}
305+
306+
setActiveTrafficSideType(activeTrafficSideType: TrafficSide) {
307+
this.activeTrafficSideType = activeTrafficSideType;
308+
}
309+
298310
getActiveOrderingAlgorithm(): OrderingAlgorithm {
299311
return this.nodeService.getCurrentOrderingAlgorithm();
300312
}

src/app/view/editor-properties-view-component/editor-properties-view.component.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,29 @@ <h2 class="SummaryTitle">{{ "app.view.editor-properties-view-component.settings"
135135
</sbb-radio-group>
136136
</sbb-expansion-panel>
137137

138+
<sbb-expansion-panel [expanded]="true">
139+
<sbb-expansion-panel-header>{{
140+
"app.view.editor-properties-view-component.trafficSide" | translate
141+
}}</sbb-expansion-panel-header>
142+
<sbb-label>{{
143+
"app.view.editor-properties-view-component.trafficSide" | translate
144+
}}</sbb-label>
145+
<br />
146+
<sbb-radio-group
147+
[(ngModel)]="activeTrafficSideType"
148+
class="sbb-radio-group-vertical"
149+
>
150+
<sbb-radio-button
151+
*ngFor="let option of trafficSideTypeOptions"
152+
[value]="option.trafficSide"
153+
[title]="option.title"
154+
(change)="onUpdateTrafficSideType($event)"
155+
>
156+
{{ option.name }}
157+
</sbb-radio-button>
158+
</sbb-radio-group>
159+
</sbb-expansion-panel>
160+
138161
<sbb-expansion-panel [expanded]="true">
139162
<sbb-expansion-panel-header>{{
140163
"app.view.editor-properties-view-component.graphicTimetable" | translate

src/app/view/editor-properties-view-component/editor-properties-view.component.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {ThemeBase} from "../themes/theme-base";
66
import {ThemeRegistration} from "../themes/theme-registration";
77
import {StreckengrafikRenderingType} from "../themes/streckengrafik-rendering-type";
88
import {TravelTimeCreationEstimatorType} from "../themes/editor-trainrun-traveltime-creator-type";
9+
import {TrafficSide} from "src/app/data-structures/business.data.structures";
910

1011
@Component({
1112
selector: "sbb-editor-properties-view-component",
@@ -84,6 +85,20 @@ export class EditorPropertiesViewComponent {
8485
];
8586
activeTravelTimeCreationEstimatorType: TravelTimeCreationEstimatorType = null;
8687

88+
trafficSideTypeOptions = [
89+
{
90+
name: $localize`:@@app.left:Left`,
91+
title: $localize`:@@app.view.editor-properties-view-component.leftTrafficSideTooltip:Trains are operated according to left-hand running conventions.`,
92+
trafficSide: "leftHand" as TrafficSide,
93+
},
94+
{
95+
name: $localize`:@@app.right:Right`,
96+
title: $localize`:@@app.view.editor-properties-view-component.rightTrafficSideTooltip:Trains are operated according to right-hand running conventions.`,
97+
trafficSide: "rightHand" as TrafficSide,
98+
},
99+
];
100+
activeTrafficSideType: TrafficSide = null;
101+
87102
activeDarkBackgroundColor = EditorPropertiesViewComponent.DEFAULT_DARK_BACKGROUNDCOLOR;
88103
activeBackgroundColor = EditorPropertiesViewComponent.DEFAULT_BACKGROUNDCOLOR;
89104

@@ -97,6 +112,7 @@ export class EditorPropertiesViewComponent {
97112
this.uiInteractionService.getActiveStreckengrafikRenderingType();
98113
this.activeTravelTimeCreationEstimatorType =
99114
this.uiInteractionService.getActiveTravelTimeCreationEstimatorType();
115+
this.activeTrafficSideType = this.uiInteractionService.getActiveTrafficSideType();
100116
if (activeTheme.isDark) {
101117
this.activeDarkBackgroundColor = this.getHexColor(activeTheme.backgroundColor);
102118
} else {
@@ -124,6 +140,11 @@ export class EditorPropertiesViewComponent {
124140
this.uiInteractionService.setActiveTravelTimeCreationEstimatorType(event.value);
125141
}
126142

143+
onUpdateTrafficSideType(event: SbbRadioChange) {
144+
this.uiInteractionService.setActiveTrafficSideType(event.value);
145+
this.activeTrafficSideType = this.uiInteractionService.getActiveTrafficSideType();
146+
}
147+
127148
colorPicked(value) {
128149
this.onUpdateColorTheme(
129150
new SbbRadioChange(null, this.uiInteractionService.getActiveTheme().themeRegistration),

src/assets/i18n/de.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"logger": {
2020
"title": "Titel"
2121
},
22+
"left": "Links",
23+
"right": "Rechts",
2224
"models": {
2325
"node": {
2426
"shortNameDefault": "NEW",
@@ -446,7 +448,10 @@
446448
"fixed": "Konstant 1min.",
447449
"fixedTooltip": "Übernimmt die Fahrzeit mit konstant 1min (Default).",
448450
"retrieveFromEdge": "Abschnittsfahrzeit",
449-
"retrieveFromEdgeTooltip": "Übernimmt die max. Fahrzeit auf dem selben Abschnitt aller Züge gleicher Kategorie, sonst max. Fahrzeit aller Züge, sonst 1 Min."
451+
"retrieveFromEdgeTooltip": "Übernimmt die max. Fahrzeit auf dem selben Abschnitt aller Züge gleicher Kategorie, sonst max. Fahrzeit aller Züge, sonst 1 Min.",
452+
"trafficSide": "Verkehrsseite",
453+
"leftTrafficSideTooltip": "Die Züge verkehren nach den Regeln für Linksverkehr.",
454+
"rightTrafficSideTooltip": "Die Züge verkehren nach den Regeln für Rechtsverkehr."
450455
},
451456
"editor-side-view": {
452457
"editor-node-detail-view": {

src/assets/i18n/en.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"logger": {
2020
"title": "Title"
2121
},
22+
"left": "Left",
23+
"right": "Right",
2224
"models": {
2325
"node": {
2426
"shortNameDefault": "NEW",
@@ -451,7 +453,10 @@
451453
"fixed": "Constant 1min",
452454
"fixedTooltip": "Adopts the travel time with a constant 1min (default).",
453455
"retrieveFromEdge": "Section travel time",
454-
"retrieveFromEdgeTooltip": "Takes over the max. travel time on the same section of all trains of the same category, otherwise max. travel time of all trains, otherwise 1 min."
456+
"retrieveFromEdgeTooltip": "Takes over the max. travel time on the same section of all trains of the same category, otherwise max. travel time of all trains, otherwise 1 min.",
457+
"trafficSide": "Traffic side",
458+
"leftTrafficSideTooltip": "Trains are operated according to left-hand running conventions.",
459+
"rightTrafficSideTooltip": "Trains are operated according to right-hand running conventions."
455460
},
456461
"editor-side-view": {
457462
"editor-node-detail-view": {

src/assets/i18n/fr.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"logger": {
2020
"title": "Titre"
2121
},
22+
"left": "Gauche",
23+
"right": "Droite",
2224
"models": {
2325
"node": {
2426
"shortNameDefault": "NEW",
@@ -451,7 +453,10 @@
451453
"fixed": "Constante 1min",
452454
"fixedTooltip": "Adopte le temps de parcours avec une constante de 1min (par défaut).",
453455
"retrieveFromEdge": "Temps de parcours de la section",
454-
"retrieveFromEdgeTooltip": "Reprend le temps de parcours maximal sur le même tronçon de tous les trains de la même catégorie, sinon le temps de parcours maximal de tous les trains, sinon 1 min."
456+
"retrieveFromEdgeTooltip": "Reprend le temps de parcours maximal sur le même tronçon de tous les trains de la même catégorie, sinon le temps de parcours maximal de tous les trains, sinon 1 min.",
457+
"trafficSide": "Sens de circulation",
458+
"leftTrafficSideTooltip": "Les trains sont exploités selon les conventions de circulation à gauche.",
459+
"rightTrafficSideTooltip": "Les trains sont exploités selon les conventions de circulation à droite."
455460
},
456461
"editor-side-view": {
457462
"editor-node-detail-view": {

0 commit comments

Comments
 (0)