summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/DBInfoscreen.pm5
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm29
2 files changed, 27 insertions, 7 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm
index 836f94e..8687cb8 100644
--- a/lib/DBInfoscreen.pm
+++ b/lib/DBInfoscreen.pm
@@ -312,8 +312,9 @@ sub startup {
$r->get('/_ajax_mapinfo/:tripid/:lineno')->to('map#ajax_route');
$r->get('/map/:tripid/:lineno')->to('map#route');
$r->get('/intersection/:trips')->to('map#intersection');
- $r->get('/z/:train/*station')->to('stationboard#station_train_details');
- $r->get('/z/:train')->to('stationboard#train_details');
+ $r->get( '/z/:train/*station' => 'train_at_station' )
+ ->to('stationboard#station_train_details');
+ $r->get( '/z/:train' => 'train' )->to('stationboard#train_details');
$r->get('/map')->to('map#search_form');
$r->get('/_trainsearch')->to('map#search');
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,