diff options
| -rw-r--r-- | lib/DBInfoscreen.pm | 5 | ||||
| -rw-r--r-- | lib/DBInfoscreen/Controller/Stationboard.pm | 29 | ||||
| -rw-r--r-- | templates/_train_details.html.ep | 16 | 
3 files changed, 38 insertions, 12 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, diff --git a/templates/_train_details.html.ep b/templates/_train_details.html.ep index 21f11a3..3e07cf8 100644 --- a/templates/_train_details.html.ep +++ b/templates/_train_details.html.ep @@ -320,10 +320,6 @@          </ul>        </div>  %   } -%   if ($departure->{has_cycle}) { -      <div class="db-attr"><a href="https://lib.finalrewind.org/dbdb/db_umlauf/<%= $departure->{train_no} %>.svg">Umlaufplan</a> -        (ggf. fehlerhaft)</div> -%   }  %   if ($details->{attributes}) {  %     if (@{$details->{attributes}} > 1) {          <div class="db-attr"> @@ -352,7 +348,12 @@  %           my ($train_no, $train) = @{$t};  %           my $tt = $train->{type} // $train->{rawType} // 'Zug';  %           $tt =~ s{ .*|[0-9]}{}; +%           if ($tt ne 'Zug') { +            <li><a href="<%= url_for('train', train => "$tt $train_no")->query({detailed => param('detailed'), past => param('past'), rt => param('rt')}) %>"><%= $tt %> <%= $train_no %></a> +%           } +%           else {              <li><%= $tt %> <%= $train_no %> +%           }  %             if ($train->{route}{start} and $train->{route}{end}) {                  <%= $train->{route}{start} %> → <%= $train->{route}{end} %>  %             } @@ -361,7 +362,7 @@          </ul>  %     }  %   } -%   elsif ($details and not $departure->{departure}) { +%   if ($details and not $departure->{departure}) {  %     if (my $e = $details->{route}{postEnd}) {          Zug wird voraussichtlich in <%= $e %> abgestellt.<br/><br/>  %     } @@ -372,7 +373,12 @@  %           my ($train_no, $train) = @{$t};  %           my $tt = $train->{type} // $train->{rawType} // 'Zug';  %           $tt =~ s{ .*|[0-9]}{}; +%           if ($tt ne 'Zug') { +            <li><a href="<%= url_for('train', train => "$tt $train_no")->query({detailed => param('detailed'), past => param('past'), rt => param('rt')}) %>"><%= $tt %> <%= $train_no %></a> +%           } +%           else {              <li><%= $tt %> <%= $train_no %> +%           }  %             if ($train->{route}{start} and $train->{route}{end}) {                  <%= $train->{route}{start} %> → <%= $train->{route}{end} %>  %             } | 
