From 2a55a8f7c6b5a8d3b8619b5014389d9ad2c99937 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 31 Oct 2022 16:37:32 +0100 Subject: train details: show operator and additional HIM messages --- lib/DBInfoscreen/Controller/Stationboard.pm | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'lib/DBInfoscreen/Controller') diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index 735cbe7..c2a5f80 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -676,7 +676,8 @@ sub render_train { sub { my ( $route_ts, $journey ) = @_; - $departure->{trip_id} = $journey->id; + $departure->{trip_id} = $journey->id; + $departure->{operator} = $journey->operator; if ( my $load = $route_ts->{$station_name}{load} ) { if ( %{$load} ) { @@ -755,8 +756,14 @@ sub render_train { } my @him_messages; + my @him_details; for my $message ( $journey->messages ) { - if ( not $message->code ) { + if ( $message->code ) { + push( @him_details, + [ $message->short // q{}, { text => $message->text } ] + ); + } + else { push( @him_messages, [ $message->short // q{}, { text => $message->text } ] ); @@ -775,6 +782,7 @@ sub render_train { $m->[0] =~ s{(?!<)->}{ → }; } unshift( @{ $departure->{moreinfo} }, @him_messages ); + unshift( @{ $departure->{details} }, @him_details ); } )->catch( sub { @@ -1010,6 +1018,7 @@ sub train_details { $res->{origin} = $journey->route_start; $res->{destination} = $journey->route_end; + $res->{operator} = $journey->operator; $res->{route_post_diff} = [ map { { name => $_->{name} } } $journey->route ]; @@ -1020,8 +1029,14 @@ sub train_details { } my @him_messages; + my @him_details; for my $message ( $journey->messages ) { - if ( not $message->code ) { + if ( $message->code ) { + push( @him_details, + [ $message->short // q{}, { text => $message->text } ] + ); + } + else { push( @him_messages, [ $message->short // q{}, { text => $message->text } ] ); @@ -1041,6 +1056,9 @@ sub train_details { if (@him_messages) { $res->{moreinfo} = [@him_messages]; } + if (@him_details) { + $res->{details} = [@him_details]; + } $self->render( $self->param('ajax') ? '_train_details' : 'train_details', -- cgit v1.2.3