refactor backend details into sub-template

This commit is contained in:
Birte Kristina Friesel 2024-08-24 07:42:20 +02:00
parent 520e645600
commit 087536862b
No known key found for this signature in database
GPG key ID: B63118F7196EA660
2 changed files with 27 additions and 50 deletions

View file

@ -0,0 +1,25 @@
<div class="row">
<div class="col s8 m6 l6 right-align">
%= $backend->{longname}
% if ($backend->{id} == $user->{backend_id}) {
(aktuell ausgewählt)
% }
% if ($backend->{has_area}) {
<br/>
<a href="https://dbf.finalrewind.org/coverage/HAFAS/<%= $backend->{name} %>"><%= join(q{, }, @{$backend->{regions} // []}) || '[Karte]' %></a>
% }
% elsif ($backend->{regions}) {
<br/>
%= join(q{, }, @{$backend->{regions} // []})
% }
% if ($backend->{homepage}) {
<br/>
<a href="<%= $backend->{homepage} %>"><%= $backend->{homepage} =~ s{ ^ http s? :// (?: www[.] )? (.*?) (?: / )? $ }{$1}xr %></a>
% }
</div>
<div class="col s4 m6 l6 left-align">
<button class="btn waves-effect waves-light <%= $backend->{id} == $user->{backend_id} ? 'disabled' : q{} %>" style="min-width: 6em;" type="submit" name="backend" value="<%= $backend->{id} %>">
<%= $backend->{name} %>
</button>
</div>
</div>

View file

@ -21,31 +21,7 @@
</div> </div>
</div> </div>
% for my $backend (@{ stash('suggestions') // [] }) { % for my $backend (@{ stash('suggestions') // [] }) {
<div class="row"> %= include '_backend_line', user => $user, backend => $backend
<div class="col s8 m6 l6 right-align">
%= $backend->{longname}
% if ($backend->{id} == $user->{backend_id}) {
(aktuell ausgewählt)
% }
% if ($backend->{has_area}) {
<br/>
<a href="https://dbf.finalrewind.org/coverage/HAFAS/<%= $backend->{name} %>"><%= join(q{, }, @{$backend->{regions} // []}) || '[Karte]' %></a>
% }
% elsif ($backend->{regions}) {
<br/>
%= join(q{, }, @{$backend->{regions} // []})
% }
% if ($backend->{homepage}) {
<br/>
<a href="<%= $backend->{homepage} %>"><%= $backend->{homepage} =~ s{ ^ http s? :// (?: www[.] )? (.*?) (?: / )? $ }{$1}xr %></a>
% }
</div>
<div class="col s4 m6 l6 left-align">
<button class="btn waves-effect waves-light <%= $backend->{id} == $user->{backend_id} ? 'disabled' : q{} %>" style="min-width: 6em;" type="submit" name="backend" value="<%= $backend->{id} %>">
<%= $backend->{name} %>
</button>
</div>
</div>
% } % }
% } % }
<div class="row"> <div class="row">
@ -54,30 +30,6 @@
</div> </div>
</div> </div>
% for my $backend (@{ stash('backends') // [] }) { % for my $backend (@{ stash('backends') // [] }) {
<div class="row"> %= include '_backend_line', user => $user, backend => $backend
<div class="col s8 m6 l6 right-align">
%= $backend->{longname}
% if ($backend->{id} == $user->{backend_id}) {
(aktuell ausgewählt)
% }
% if ($backend->{has_area}) {
<br/>
<a href="https://dbf.finalrewind.org/coverage/HAFAS/<%= $backend->{name} %>"><%= join(q{, }, @{$backend->{regions} // []}) || '[Karte]' %></a>
% }
% elsif ($backend->{regions}) {
<br/>
%= join(q{, }, @{$backend->{regions} // []})
% }
% if ($backend->{homepage}) {
<br/>
<a href="<%= $backend->{homepage} %>"><%= $backend->{homepage} =~ s{ ^ http s? :// (?: www[.] )? (.*?) (?: / )? $ }{$1}xr %></a>
% }
</div>
<div class="col s4 m6 l6 left-align">
<button class="btn waves-effect waves-light <%= $backend->{id} == $user->{backend_id} ? 'disabled' : q{} %>" style="min-width: 6em;" type="submit" name="backend" value="<%= $backend->{id} %>">
<%= $backend->{name} %>
</button>
</div>
</div>
% } % }
%= end %= end