From 45dc2e4e2abc8da3f7fdc795ce0863c3664280ce Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Thu, 8 Aug 2024 21:13:39 +0200 Subject: Switch to new carriage formation API --- templates/_checked_in.html.ep | 59 +++++++++++++++++++++++++++---------------- templates/_wagons.html.ep | 12 ++++++--- 2 files changed, 46 insertions(+), 25 deletions(-) (limited to 'templates') diff --git a/templates/_checked_in.html.ep b/templates/_checked_in.html.ep index 5ee233e..672c0d1 100644 --- a/templates/_checked_in.html.ep +++ b/templates/_checked_in.html.ep @@ -68,33 +68,48 @@ % } % if (my $wr = $journey->{wagonorder}) {
- % my @wagons = $wr->wagons; - % my $direction = $wr->direction == 100 ? '→' : '←'; - % if ($journey->{dep_direction}) { - % $direction = $journey->{dep_direction} eq 'l' ? '◀' : '▶'; - % if (($journey->{dep_direction} eq 'l' ? 0 : 100) != $wr->direction) { - % @wagons = reverse @wagons; + + % my $direction = $wr->direction == 100 ? '→' : '←'; + % if ($journey->{dep_direction}) { + % $direction = $journey->{dep_direction} eq 'l' ? '◀' : '▶'; % } - % } - - %= $direction - % my $gi; - % for my $wagon (@wagons) { - % if (not ($wagon->is_locomotive or $wagon->is_powercar)) { - % if (defined $gi and $gi != $wagon->group_index) { + %= $direction + % my $had_entry = 0; + % for my $group ($wr->groups) { + % if ($had_entry) { + % $had_entry = 0; • % } - % if ($wagon->is_closed) { - X - % } - % else { - %= $wagon->number || ($wagon->type =~ m{AB} ? '½' : $wagon->type =~ m{A} ? '1.' : $wagon->type =~ m{B} ? '2.' : $wagon->type ) + % for my $wagon ($group->carriages) { + % if (not ($wagon->is_locomotive or $wagon->is_powercar)) { + % $had_entry = 1; + % if ($wagon->is_closed) { + X + % } + % elsif ( $wagon->number) { + %= $wagon->number + % } + % else { + % if ( $wagon->has_first_class ) { + % if ( $wagon->has_second_class ) { + ½ + % } + % else { + 1. + % } + % } + % elsif ( $wagon->has_second_class ) { + 2. + % } + % else { + %= $wagon->type; + % } + % } + % } % } % } - % $gi = $wagon->group_index; - % } - %= $direction - + %= $direction + % }
diff --git a/templates/_wagons.html.ep b/templates/_wagons.html.ep index 106709e..b4af3bc 100644 --- a/templates/_wagons.html.ep +++ b/templates/_wagons.html.ep @@ -4,10 +4,16 @@ % if ($wagon_number and my $group_name = app->ice_name->{$wagon_number}) { „<%= $group_name %>“ % } - als <%= $journey->{type} %> <%= $wagongroup->{no} %> - von <%= $wagongroup->{from} %> nach <%= $wagongroup->{to} %>
+ als <%= $wagongroup->{type} // $journey->{type} %> <%= $wagongroup->{no} %> + % if ($wagongroup->{from}) { + von <%= $wagongroup->{from} %> + % } + % if ($wagongroup->{to}) { + nach <%= $wagongroup->{to} %> + % } +
% for my $wagon (@{$wagongroup->{wagons}}) { - % if (length($wagon->{id}) == 12) { + % if (length($wagon->{id}) == 12 or length($wagon->{id}) == 14) { <%= substr($wagon->{id}, 0, 2) %><%= substr($wagon->{id}, 2, 2) %><%= substr($wagon->{id}, 4, 1) %><%= substr($wagon->{id}, 5, 3) %><%= substr($wagon->{id}, 8, 3) %><%= substr($wagon->{id}, 11) %> % } % elsif ($wagon->{id}) { -- cgit v1.2.3