summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-02-08 14:41:01 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2025-02-08 14:41:01 +0100
commitf7cbdd5e9de6ab5004c0983ff1fe2a61a28ae499 (patch)
treecb612c809f30af5e96b3b166d6107197a5e77a5a /lib/DBInfoscreen
parent442b0e8db87cda064af2111e8283ad5d87555e0e (diff)
EFA: show candidates on ambiguous input
Diffstat (limited to 'lib/DBInfoscreen')
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm32
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 1bdb00c..4b63924 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -50,12 +50,22 @@ sub handle_no_results {
my $errstr = $data->{errstr};
if ($efa) {
- $self->render(
- 'landingpage',
- error => ( $errstr // "Keine Abfahrten an '$station'" ),
- hide_opts => 0,
- status => $data->{status} // 404,
- );
+ if ( $errstr =~ m{ambiguous} and $efa->name_candidates ) {
+ $self->render(
+ 'landingpage',
+ stationlist => [ $efa->name_candidates ],
+ hide_opts => 0,
+ status => $data->{status} // 300,
+ );
+ }
+ else {
+ $self->render(
+ 'landingpage',
+ error => ( $errstr // "Keine Abfahrten an '$station'" ),
+ hide_opts => 0,
+ status => $data->{status} // 404,
+ );
+ }
return;
}
elsif ($hafas) {
@@ -579,13 +589,14 @@ sub handle_request {
}
)->catch(
sub {
- my ($err) = @_;
+ my ( $err, $status ) = @_;
if ( $template eq 'json' ) {
$self->handle_no_results_json(
$station,
{
errstr => $err,
- status => ( $err =~ m{Ambiguous|LOCATION} ? 300 : 500 ),
+ status =>
+ ( $err =~ m{[Aa]mbiguous|LOCATION} ? 300 : 500 ),
},
$api_version
);
@@ -595,9 +606,10 @@ sub handle_request {
$station,
{
errstr => $err,
- status => ( $err =~ m{Ambiguous|LOCATION} ? 300 : 500 ),
+ status => ( $err =~ m{[Aa]mbiguous|LOCATION} ? 300 : 500 ),
},
- $hafas, $efa
+ $hafas,
+ $efa ? $status : undef
);
return;
}