diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2022-04-02 18:14:21 +0200 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2022-04-02 18:14:21 +0200 | 
| commit | 5ff9e5c7a1ee9725724e0d2abd7592166f9f49e0 (patch) | |
| tree | ba4b7454e952ca141717617aba0e86e1bd799f46 | |
| parent | 5dfbdd864433a01271e8025842b20608146e5152 (diff) | |
history map: allow filtering by train type
| -rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 14 | ||||
| -rw-r--r-- | templates/history_map.html.ep | 6 | 
2 files changed, 20 insertions, 0 deletions
| diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 7a036a7..d6253ac 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -787,6 +787,14 @@ sub commute {  	);  } +sub has_str_in_list { +	my ( $str, @strs ) = @_; +	if ( List::Util::any { $str eq $_ } @strs ) { +		return 1; +	} +	return; +} +  sub map_history {  	my ($self) = @_; @@ -799,6 +807,7 @@ sub map_history {  	my $route_type    = $self->param('route_type');  	my $filter_from   = $self->param('filter_after');  	my $filter_until  = $self->param('filter_before'); +	my $filter_type   = $self->param('filter_type');  	my $with_polyline = $route_type eq 'beeline' ? 0 : 1;  	my $parser = DateTime::Format::Strptime->new( @@ -831,6 +840,11 @@ sub map_history {  		before        => $filter_until,  	); +	if ($filter_type) { +		my @filter = split( qr{, *}, $filter_type ); +		@journeys = grep { has_str_in_list( $_->{type}, @filter ) } @journeys; +	} +  	if ( not @journeys ) {  		$self->render(  			template            => 'history_map', diff --git a/templates/history_map.html.ep b/templates/history_map.html.ep index 0976ab4..ff2b243 100644 --- a/templates/history_map.html.ep +++ b/templates/history_map.html.ep @@ -70,6 +70,12 @@  		</div>  	</div>  	<div class="row"> +		<div class="input-field col s12"> +			%= text_field 'filter_type', id => 'filter_type' +			<label for="filter_tpye">Zugtypen</label> +		</div> +	</div> +	<div class="row">  		<div class="col s12 center-align">  			<button class="btn wave-effect waves-light" type="submit">  				Anzeigen | 
