diff options
author | Steven Day <steve@mysociety.org> | 2015-06-23 16:14:27 +0100 |
---|---|---|
committer | Steven Day <steve@mysociety.org> | 2015-06-29 12:43:01 +0100 |
commit | badc0954505c93c12a8ecf4932245958425d15ec (patch) | |
tree | 00c3b2c8b26d6e248070c4a84399d5426e514749 /perllib | |
parent | 5313adb5005a91648a98525d73b6a37b661f4b22 (diff) |
Combine all My Reports into a single list, allow filtering
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/My.pm | 18 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 8 |
2 files changed, 25 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm index bbef1f8d8..8e55b4371 100644 --- a/perllib/FixMyStreet/App/Controller/My.pm +++ b/perllib/FixMyStreet/App/Controller/My.pm @@ -28,11 +28,26 @@ sub my : Path : Args(0) { my $p_page = $c->req->params->{p} || 1; my $u_page = $c->req->params->{u} || 1; + 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'; + } + my $pins = []; my $problems = {}; + my $params = { - state => [ FixMyStreet::DB::Result::Problem->visible_states() ], + state => [ keys %$states ], }; $params = { %{ $c->cobrand->problems_clause }, @@ -55,6 +70,7 @@ sub my : Path : Args(0) { }; my $state = $problem->is_fixed ? 'fixed' : $problem->is_closed ? 'closed' : 'confirmed'; push @{ $problems->{$state} }, $problem; + push @{ $problems->{all} }, $problem; } $c->stash->{problems_pager} = $rs->pager; $c->stash->{problems} = $problems; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 590288050..27cbd2de8 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -375,6 +375,14 @@ Return undef to show all visible reports. sub on_map_default_states { return undef; } +=head2 on_map_default_status + +Return the default ?status= query parameter to use for filter on map page. + +=cut + +sub on_map_default_status { return 'all'; } + =head2 allow_photo_upload Return a boolean indicating whether the cobrand allows photo uploads |