backend selection: add coverage regions and links to coverage map

This commit is contained in:
Birte Kristina Friesel 2024-08-21 19:39:30 +02:00
parent 4c7b3117cd
commit 1a185897e2
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA
2 changed files with 46 additions and 3 deletions

View file

@ -1005,6 +1005,36 @@ sub backend_form {
my @backends = $self->stations->get_backends; my @backends = $self->stations->get_backends;
my %place_map = (
AT => 'Österreich',
CH => 'Schweiz',
'CH-BE' => 'Kanton Bern',
'CH-GE' => 'Kanton Genf',
'CH-LU' => 'Kanton Luzern',
'CH-ZH' => 'Kanton Zürich',
DE => 'Deutschland',
'DE-BB' => 'Brandenburg',
'DE-BW' => 'Baden-Württemberg',
'DE-BE' => 'Berlin',
'DE-BY' => 'Bayern',
'DE-HB' => 'Bremen',
'DE-HE' => 'Hessen',
'DE-MV' => 'Mecklenburg-Vorpommern',
'DE-NI' => 'Niedersachsen',
'DE-NW' => 'Nordrhein-Westfalen',
'DE-RP' => 'Rheinland-Pfalz',
'DE-SH' => 'Schleswig-Holstein',
'DE-ST' => 'Sachsen-Anhalt',
'DE-TH' => 'Thüringen',
DK => 'Dänemark',
'GB-NIR' => 'Nordirland',
LI => 'Liechtenstein',
LU => 'Luxembourg',
IE => 'Irland',
'US-CA' => 'California',
'US-TX' => 'Texas',
);
for my $backend (@backends) { for my $backend (@backends) {
my $type = 'UNKNOWN'; my $type = 'UNKNOWN';
if ( $backend->{iris} ) { if ( $backend->{iris} ) {
@ -1018,6 +1048,9 @@ sub backend_form {
$type = 'HAFAS'; $type = 'HAFAS';
$backend->{longname} = $s->{name}; $backend->{longname} = $s->{name};
$backend->{homepage} = $s->{homepage}; $backend->{homepage} = $s->{homepage};
$backend->{regions} = [ map { $place_map{$_} // $_ }
@{ $s->{coverage}{regions} // [] } ];
$backend->{has_area} = $s->{coverage}{area} ? 1 : 0;
} }
else { else {
$type = undef; $type = undef;

View file

@ -17,12 +17,22 @@
% for my $backend (@{ stash('backends') // [] }) { % for my $backend (@{ stash('backends') // [] }) {
<div class="row"> <div class="row">
<div class="col s8 m6 l6 right-align"> <div class="col s8 m6 l6 right-align">
% if ($backend->{longname}) { %= $backend->{longname}
<a href="<%= $backend->{homepage} %>"><%= $backend->{longname} %></a>
% }
% if ($backend->{id} == $user->{backend_id}) { % if ($backend->{id} == $user->{backend_id}) {
(aktuell ausgewählt) (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>
<div class="col s4 m6 l6 left-align"> <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} %>"> <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} %>">