diff options
author | Dave Arter <davea@mysociety.org> | 2015-03-20 17:49:40 +0000 |
---|---|---|
committer | Steven Day <steve@mysociety.org> | 2015-06-29 12:43:01 +0100 |
commit | a76bd2ab4910aedd589b12ee857091d11b9db30b (patch) | |
tree | 057e444c2892e467101d7904c48bf87b1bc926f2 | |
parent | badc0954505c93c12a8ecf4932245958425d15ec (diff) |
Use a consistent method of filtering by category on /around and /ajax
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 13 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map.pm | 6 |
2 files changed, 17 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index f25b149e6..9d86975c6 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -164,7 +164,20 @@ sub display_location : Private { my $all_pins = $c->req->param('all_pins') ? 1 : undef; $c->stash->{all_pins} = $all_pins; my $interval = $all_pins ? undef : $c->cobrand->on_map_default_max_pin_age; + my $states = $c->cobrand->on_map_default_states; + $c->stash->{filter_status} = $c->cobrand->on_map_default_status; + my $status = $c->req->param('status'); + if ( !defined $states || $status eq 'all' ) { + $states = FixMyStreet::DB::Result::Problem->visible_states(); + $c->stash->{filter_status} = 'all'; + } elsif ( $status eq 'open' ) { + $states = FixMyStreet::DB::Result::Problem->open_states(); + $c->stash->{filter_status} = 'open'; + } elsif ( $status eq 'fixed' ) { + $states = FixMyStreet::DB::Result::Problem->fixed_states(); + $c->stash->{filter_status} = 'fixed'; + } # Check the category to filter by, if any, is valid $c->forward('check_and_stash_category'); diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm index 2606fd9a4..7db4a7e3d 100644 --- a/perllib/FixMyStreet/Map.pm +++ b/perllib/FixMyStreet/Map.pm @@ -120,9 +120,11 @@ sub map_pins { my $category = $c->req->param('category'); # Filter reports by status, if present in query params + my $states = $c->cobrand->on_map_default_states; my $status = $c->req->param('status') || ''; - my $states; - if ( $status eq 'open' ) { + if ( !defined $states || $status eq 'all' ) { + $states = FixMyStreet::DB::Result::Problem->visible_states(); + } elsif ( $status eq 'open' ) { $states = FixMyStreet::DB::Result::Problem->open_states(); } elsif ( $status eq 'fixed' ) { $states = FixMyStreet::DB::Result::Problem->fixed_states(); |