diff options
author | Zarino Zappia <mail@zarino.co.uk> | 2016-09-30 16:34:00 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-10-13 19:22:11 +0100 |
commit | a5ef113e2cc3105da41cf5449b505db6fa336c59 (patch) | |
tree | c60d906c0b5dd6fc974a35f8e921ae728dab080c /perllib/FixMyStreet/App/Controller/Around.pm | |
parent | 3872c39f5426165c3abfe397d15dd2a63f731e26 (diff) |
Allow multiple selections in report list filter.
This lets people filter by multiple categories or states. It uses our
jQuery multi-select plugin to turn the <select multiple>s into little
overlay lists of checkboxes. HTML5 history is also supported.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Around.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index ec84ca09a..1f45f8029 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -181,7 +181,7 @@ sub display_location : Private { my ( $on_map_all, $on_map, $nearby, $distance ) = FixMyStreet::Map::map_features( $c, latitude => $latitude, longitude => $longitude, - interval => $interval, category => $c->stash->{filter_category}, + interval => $interval, categories => $c->stash->{filter_category}, states => $c->stash->{filter_problem_states} ); # copy the found reports to the stash @@ -258,13 +258,11 @@ sub check_and_stash_category : Private { )->all; my @categories = map { $_->category } @contacts; $c->stash->{filter_categories} = \@categories; - - - my $category = $c->get_param('filter_category'); my %categories_mapped = map { $_ => 1 } @categories; - if ( defined $category && $categories_mapped{$category} ) { - $c->stash->{filter_category} = $category; - } + + my $categories = [ $c->get_param_list('filter_category', 1) ]; + my @valid_categories = grep { $_ && $categories_mapped{$_} } @$categories; + $c->stash->{filter_category} = \@valid_categories; } =head2 /ajax @@ -303,7 +301,7 @@ sub ajax : Path('/ajax') { my ( $on_map_all, $on_map_list, $nearby, $dist ) = FixMyStreet::Map::map_features($c, bbox => $bbox, interval => $interval, - category => $c->get_param('filter_category'), + categories => [ $c->get_param_list('filter_category', 1) ], states => $c->stash->{filter_problem_states} ); # create a list of all the pins |