mark cancelled stops in checkin view
This commit is contained in:
parent
3582ba317b
commit
6d45533c14
3 changed files with 67 additions and 6 deletions
|
@ -399,7 +399,7 @@ sub startup {
|
||||||
sched_departure => $train->sched_departure,
|
sched_departure => $train->sched_departure,
|
||||||
real_departure => $train->departure,
|
real_departure => $train->departure,
|
||||||
route => $json->encode(
|
route => $json->encode(
|
||||||
[ map { [$_] } $train->route ]
|
[ $self->route_diff($train) ]
|
||||||
),
|
),
|
||||||
messages => $json->encode(
|
messages => $json->encode(
|
||||||
[
|
[
|
||||||
|
@ -636,7 +636,7 @@ sub startup {
|
||||||
real_arrival => $train->arrival,
|
real_arrival => $train->arrival,
|
||||||
cancelled => $train->arrival_is_cancelled ? 1 : 0,
|
cancelled => $train->arrival_is_cancelled ? 1 : 0,
|
||||||
route =>
|
route =>
|
||||||
$json->encode( [ map { [$_] } $train->route ] ),
|
$json->encode( [ $self->route_diff($train) ] ),
|
||||||
messages => $json->encode(
|
messages => $json->encode(
|
||||||
[
|
[
|
||||||
map { [ $_->[0]->epoch, $_->[1] ] }
|
map { [ $_->[0]->epoch, $_->[1] ] }
|
||||||
|
@ -1574,6 +1574,55 @@ sub startup {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$self->helper(
|
||||||
|
'route_diff' => sub {
|
||||||
|
my ( $self, $train ) = @_;
|
||||||
|
my @json_route;
|
||||||
|
my @route = $train->route;
|
||||||
|
my @sched_route = $train->sched_route;
|
||||||
|
|
||||||
|
say "real is " . join( " - ", @route );
|
||||||
|
say "sched is " . join( " - ", @sched_route );
|
||||||
|
|
||||||
|
my $route_idx = 0;
|
||||||
|
my $sched_idx = 0;
|
||||||
|
|
||||||
|
while ( $route_idx <= $#route and $sched_idx <= $#sched_route ) {
|
||||||
|
if ( $route[$route_idx] eq $sched_route[$sched_idx] ) {
|
||||||
|
push( @json_route, [ $route[$route_idx], {}, undef ] );
|
||||||
|
$route_idx++;
|
||||||
|
$sched_idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
# this branch is inefficient, but won't be taken frequently
|
||||||
|
elsif ( not( grep { $_ eq $route[$route_idx] } @sched_route ) )
|
||||||
|
{
|
||||||
|
push( @json_route,
|
||||||
|
[ $route[$route_idx], {}, 'additional' ],
|
||||||
|
);
|
||||||
|
$route_idx++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
push( @json_route,
|
||||||
|
[ $sched_route[$sched_idx], {}, 'cancelled' ],
|
||||||
|
);
|
||||||
|
$sched_idx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while ( $route_idx <= $#route ) {
|
||||||
|
push( @json_route, [ $route[$route_idx], {}, 'additional' ], );
|
||||||
|
$route_idx++;
|
||||||
|
}
|
||||||
|
while ( $sched_idx <= $#sched_route ) {
|
||||||
|
push( @json_route,
|
||||||
|
[ $sched_route[$sched_idx], {}, 'cancelled' ],
|
||||||
|
);
|
||||||
|
$sched_idx++;
|
||||||
|
}
|
||||||
|
return @json_route;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$self->helper(
|
$self->helper(
|
||||||
'get_dbdb_station_p' => sub {
|
'get_dbdb_station_p' => sub {
|
||||||
my ( $self, $ds100 ) = @_;
|
my ( $self, $ds100 ) = @_;
|
||||||
|
|
|
@ -56,7 +56,7 @@ sub run {
|
||||||
dep_platform => $train->platform,
|
dep_platform => $train->platform,
|
||||||
real_departure => $train->departure,
|
real_departure => $train->departure,
|
||||||
route =>
|
route =>
|
||||||
$json->encode( [ map { [$_] } $train->route ] ),
|
$json->encode( [ $self->app->route_diff($train) ] ),
|
||||||
messages => $json->encode(
|
messages => $json->encode(
|
||||||
[
|
[
|
||||||
map { [ $_->[0]->epoch, $_->[1] ] }
|
map { [ $_->[0]->epoch, $_->[1] ] }
|
||||||
|
@ -103,7 +103,7 @@ sub run {
|
||||||
sched_arrival => $train->sched_arrival,
|
sched_arrival => $train->sched_arrival,
|
||||||
real_arrival => $train->arrival,
|
real_arrival => $train->arrival,
|
||||||
route =>
|
route =>
|
||||||
$json->encode( [ map { [$_] } $train->route ] ),
|
$json->encode( [ $self->app->route_diff($train) ] ),
|
||||||
messages => $json->encode(
|
messages => $json->encode(
|
||||||
[
|
[
|
||||||
map { [ $_->[0]->epoch, $_->[1] ] }
|
map { [ $_->[0]->epoch, $_->[1] ] }
|
||||||
|
|
|
@ -200,9 +200,15 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
% for my $station (@{$journey->{route_after}}) {
|
% for my $station (@{$journey->{route_after}}) {
|
||||||
<tr><td><a class="action-checkout" data-station="<%= $station->[0] %>"><%= $station->[0] %>
|
<tr><td><a class="action-checkout" data-station="<%= $station->[0] %>"><%= $station->[0] %>
|
||||||
% if ($station->[1]{rt_arr}) {
|
% if ($station->[2] and $station->[2] eq 'cancelled') {
|
||||||
|
<span style="float: right;">entfällt</span>
|
||||||
|
% }
|
||||||
|
% elsif ($station->[1]{rt_arr}) {
|
||||||
<span style="float: right;"><%= $station->[1]{rt_arr}->strftime('%H:%M') %></span>
|
<span style="float: right;"><%= $station->[1]{rt_arr}->strftime('%H:%M') %></span>
|
||||||
% }
|
% }
|
||||||
|
% elsif ($station->[2] and $station->[2] eq 'additional') {
|
||||||
|
<span style="float: right;">Zusatzhalt</span>
|
||||||
|
% }
|
||||||
</a></td></tr>
|
</a></td></tr>
|
||||||
% }
|
% }
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -247,9 +253,15 @@
|
||||||
% for my $station (@{$journey->{route_after}}) {
|
% for my $station (@{$journey->{route_after}}) {
|
||||||
% my $is_dest = ($journey->{arr_name} and $station->[0] eq $journey->{arr_name});
|
% my $is_dest = ($journey->{arr_name} and $station->[0] eq $journey->{arr_name});
|
||||||
<tr><td><a style="<%= $is_dest? 'font-weight: bold;' : '' %>" class="action-checkout" data-station="<%= $station->[0] %>"><%= $station->[0] %>
|
<tr><td><a style="<%= $is_dest? 'font-weight: bold;' : '' %>" class="action-checkout" data-station="<%= $station->[0] %>"><%= $station->[0] %>
|
||||||
% if ($station->[1]{rt_arr}) {
|
% if ($station->[2] and $station->[2] eq 'cancelled') {
|
||||||
|
<span style="float: right;">entfällt</span>
|
||||||
|
% }
|
||||||
|
% elsif ($station->[1]{rt_arr}) {
|
||||||
<span style="float: right;"><%= $station->[1]{rt_arr}->strftime('%H:%M') %></span>
|
<span style="float: right;"><%= $station->[1]{rt_arr}->strftime('%H:%M') %></span>
|
||||||
% }
|
% }
|
||||||
|
% elsif ($station->[2] and $station->[2] eq 'additional') {
|
||||||
|
<span style="float: right;">Zusatzhalt</span>
|
||||||
|
% }
|
||||||
</a></td></tr>
|
</a></td></tr>
|
||||||
% }
|
% }
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in a new issue