summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'lib/DBInfoscreen/Controller')
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm29
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 59b7748..5c282bd 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -814,12 +814,12 @@ sub render_train {
= $self->app->train_details_db->{ $departure->{train_no} };
my @cycle_from;
my @cycle_to;
- for my $cycle ( values %{ $departure->{composition}->{cycle} // {} } ) {
- push( @cycle_from, @{ $cycle->{from} // [] } );
- push( @cycle_to, @{ $cycle->{to} // [] } );
+ for my $pred ( @{ $departure->{composition}{predecessors} // [] } ) {
+ push( @cycle_from, $pred->[1] );
+ }
+ for my $succ ( @{ $departure->{composition}{successors} // [] } ) {
+ push( @cycle_to, $succ->[1] );
}
- @cycle_from = sort { $a <=> $b } uniq @cycle_from;
- @cycle_to = sort { $a <=> $b } uniq @cycle_to;
$departure->{cycle_from}
= [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_from ];
$departure->{cycle_to}
@@ -1059,6 +1059,25 @@ sub train_details {
$res->{details} = [@him_details];
}
+ if ( $self->param('detailed') ) {
+ $res->{composition}
+ = $self->app->train_details_db->{ $res->{train_no} };
+ my @cycle_from;
+ my @cycle_to;
+ for my $pred ( @{ $res->{composition}{predecessors} // [] } ) {
+ push( @cycle_from, $pred->[1] );
+ }
+ for my $succ ( @{ $res->{composition}{successors} // [] } ) {
+ push( @cycle_to, $succ->[1] );
+ }
+ $res->{cycle_from}
+ = [ map { [ $_, $self->app->train_details_db->{$_} ] }
+ @cycle_from ];
+ $res->{cycle_to}
+ = [ map { [ $_, $self->app->train_details_db->{$_} ] }
+ @cycle_to ];
+ }
+
$self->render(
$self->param('ajax') ? '_train_details' : 'train_details',
departure => $res,