aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm16
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm16
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm46
-rw-r--r--perllib/FixMyStreet/Map.pm12
4 files changed, 29 insertions, 61 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index c4040af95..5bfe1ada2 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -165,19 +165,7 @@ sub display_location : Private {
$c->stash->{all_pins} = $all_pins;
my $interval = $all_pins ? undef : $c->cobrand->on_map_default_max_pin_age;
- my $states;
- $c->stash->{filter_status} = $c->cobrand->on_map_default_status;
- my $status = $c->req->param('status') || $c->cobrand->on_map_default_status;
- if ( $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';
- }
+ $c->forward( '/reports/stash_report_filter_status' );
# Check the category to filter by, if any, is valid
$c->forward('check_and_stash_category');
@@ -185,7 +173,7 @@ sub display_location : Private {
# get the map features
my ( $on_map_all, $on_map, $around_map, $distance ) =
FixMyStreet::Map::map_features( $c, $latitude, $longitude,
- $interval, $c->stash->{filter_category}, $states );
+ $interval, $c->stash->{filter_category}, $c->stash->{filter_problem_states} );
# copy the found reports to the stash
$c->stash->{on_map} = $on_map;
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index 0bcee7ac6..b3d341a68 100644
--- a/perllib/FixMyStreet/App/Controller/My.pm
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -28,24 +28,12 @@ sub my : Path : Args(0) {
my $p_page = $c->req->params->{p} || 1;
my $u_page = $c->req->params->{u} || 1;
- my $states;
- $c->stash->{filter_status} = $c->cobrand->on_map_default_status;
- my $status = $c->req->param('status') || $c->cobrand->on_map_default_status;
- if ( $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';
- }
+ $c->forward( '/reports/stash_report_filter_status' );
my $pins = [];
my $problems = {};
-
+ my $states = $c->stash->{filter_problem_states};
my $params = {
state => [ keys %$states ],
};
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index e5f9d9507..5a044c9af 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -109,6 +109,7 @@ sub ward : Path : Args(2) {
$c->forward( 'ward_check', [ $ward ] )
if $ward;
$c->forward( 'check_canonical_url', [ $body ] );
+ $c->forward( 'stash_report_filter_status' );
$c->forward( 'load_and_group_problems' );
my $body_short = $c->cobrand->short_name( $c->stash->{body} );
@@ -120,16 +121,6 @@ sub ward : Path : Args(2) {
$c->stash->{stats} = $c->cobrand->get_report_stats();
- $c->stash->{filter_status} = $c->cobrand->on_map_default_status;
- my $status = $c->req->param('status') || $c->cobrand->on_map_default_status;
- if ( $status eq 'all' ) {
- $c->stash->{filter_status} = 'all';
- } elsif ( $status eq 'open' ) {
- $c->stash->{filter_status} = 'open';
- } elsif ( $status eq 'fixed' ) {
- $c->stash->{filter_status} = 'fixed';
- }
-
my @categories = $c->stash->{body}->contacts->search( undef, {
columns => [ 'category' ],
distinct => 1,
@@ -393,22 +384,11 @@ sub load_and_group_problems : Private {
my ( $self, $c ) = @_;
my $page = $c->req->params->{p} || 1;
+ # NB: If 't' is specified, it will override 'status'.
my $type = $c->req->params->{t} || 'all';
my $category = $c->req->params->{c} || $c->req->params->{filter_category} || '';
- # Unlike the 't' query param, 'status' isn't affected by
- # the age of a report, so treat the filtering separately.
- # If 't' is specified, it will override 'status'.
- my $states;
- my $status = $c->req->param('status') || $c->cobrand->on_map_default_status;
- if ( $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();
- }
-
+ my $states = $c->stash->{filter_problem_states};
my $where = {
non_public => 0,
state => [ keys %$states ]
@@ -517,6 +497,26 @@ sub redirect_body : Private {
$c->res->redirect( $c->uri_for($url, $c->req->params ) );
}
+sub stash_report_filter_status : Private {
+ my ( $self, $c ) = @_;
+
+ my $status = $c->req->param('status') || $c->cobrand->on_map_default_status;
+ if ( $status eq 'all' ) {
+ $c->stash->{filter_status} = 'all';
+ $c->stash->{filter_problem_states} = FixMyStreet::DB::Result::Problem->visible_states();
+ } elsif ( $status eq 'open' ) {
+ $c->stash->{filter_status} = 'open';
+ $c->stash->{filter_problem_states} = FixMyStreet::DB::Result::Problem->open_states();
+ } elsif ( $status eq 'fixed' ) {
+ $c->stash->{filter_status} = 'fixed';
+ $c->stash->{filter_problem_states} = FixMyStreet::DB::Result::Problem->fixed_states();
+ } else {
+ $c->stash->{filter_status} = $c->cobrand->on_map_default_status;
+ }
+
+ return 1;
+}
+
sub add_row {
my ( $c, $problem, $body, $problems, $pins ) = @_;
push @{$problems->{$body}}, $problem;
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm
index 704b19bee..0fa23d081 100644
--- a/perllib/FixMyStreet/Map.pm
+++ b/perllib/FixMyStreet/Map.pm
@@ -119,16 +119,8 @@ sub map_pins {
my ( $min_lon, $min_lat, $max_lon, $max_lat ) = split /,/, $bbox;
my $category = $c->req->param('filter_category');
- # Filter reports by status, if present in query params
- my $states;
- my $status = $c->req->param('status') || $c->cobrand->on_map_default_status;
- if ( $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();
- }
+ $c->forward( '/reports/stash_report_filter_status' );
+ my $states = $c->stash->{filter_problem_states};
my ( $around_map, $around_map_list, $nearby, $dist ) =
FixMyStreet::Map::map_features_bounds( $c, $min_lon, $min_lat, $max_lon, $max_lat, $interval, $category, $states );