Unverified Commit 8a9ba074 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

move coach sequence preview generation from template into Controller

parent fa0624eb
Loading
Loading
Loading
Loading
+34 −3
Original line number Diff line number Diff line
@@ -749,8 +749,38 @@ sub render_train {
						from_json => $wr_json );
					$departure->{wr}      = $wr;
					$departure->{wr_text} = join( q{ • },
						map { $_->{short} }
						grep { $_->{short} } $wr->train_descriptions );
						map { $_->desc_short }
						grep { $_->desc_short } $wr->groups );
					my $first = 0;
					for my $group ( $wr->groups ) {
						for my $wagon ( $group->wagons ) {
							if (
								not(   $wagon->is_locomotive
									or $wagon->is_powercar )
							  )
							{
								if ($first) {
									push( @{ $departure->{wr_preview} }, '' );
									$first = 0;
								}
								my $entry;
								if ( $wagon->is_closed ) {
									$entry = 'X';
								}
								else {
									$entry = $wagon->number
									  || (
										  $wagon->type =~ m{AB} ? '½'
										: $wagon->type =~ m{A}  ? '1.'
										: $wagon->type =~ m{B}  ? '2.'
										:                         $wagon->type
									  );
								}
								push( @{ $departure->{wr_preview} }, $entry );
							}
						}
						$first = 1;
					}
				};
				$departure->{wr_text} ||= 'Wagen';
				return;
@@ -827,6 +857,7 @@ sub render_train {

			if ($direction) {
				$departure->{direction}     = $direction;
				$departure->{direction_num} = $direction eq 'l' ? 0 : 100;
			}
			elsif ( $platform_info->{direction} ) {
				$departure->{direction} = 'a' . $platform_info->{direction};
+6 −19
Original line number Diff line number Diff line
@@ -118,30 +118,17 @@
    </div> <!-- dataline -->
%   if (my $wr = $departure->{wr}) {
      <div class="wagonorder-preview">
%     my @wagons = $wr->wagons;
%     my $direction = defined $wr->direction ? $wr->direction == 100 ? '→' : '←' : q{};
%     if ($departure->{direction}) {
%       $direction = $departure->{direction} eq 'l' ? '◀' : '▶';
%       if (($departure->{direction} eq 'l' ? 0 : 100) != $wr->direction) {
%         @wagons = reverse @wagons;
%       }
%     }
      <a href="/_wr/<%= $departure->{train_no} %>/<%= $departure->{wr_link} %>?e=<%= $departure->{direction} // '' %>">
      %= $direction
%     my $gi;
%     for my $wagon (@wagons) {
%       if (not ($wagon->is_locomotive or $wagon->is_powercar)) {
%         if (defined $gi and $gi != $wagon->group_index) {

%         }
%         if ($wagon->is_closed) {
            X
      % if (defined $departure->{direction_num} and $departure->{direction_num} != $wr->direction) {
        %= join(q{ }, reverse @{$departure->{wr_preview} // []})
      % }
      % else {
%=          $wagon->number || ($wagon->type =~ m{AB} ? '½' : $wagon->type =~ m{A} ? '1.' : $wagon->type =~ m{B} ? '2.' : $wagon->type )
%         }
%       }
%       $gi = $wagon->group_index;
        %= join(q{ }, @{$departure->{wr_preview} // []})
      % }
      %= $direction
      </a>