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 | |
parent | 5313adb5005a91648a98525d73b6a37b661f4b22 (diff) |
Combine all My Reports into a single list, allow filtering
-rw-r--r-- | perllib/FixMyStreet/App/Controller/My.pm | 18 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 8 | ||||
-rw-r--r-- | templates/web/fixmystreet/my/_problem-list.html | 27 | ||||
-rw-r--r-- | templates/web/fixmystreet/my/my.html | 22 |
4 files changed, 53 insertions, 22 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 diff --git a/templates/web/fixmystreet/my/_problem-list.html b/templates/web/fixmystreet/my/_problem-list.html new file mode 100644 index 000000000..1a891de80 --- /dev/null +++ b/templates/web/fixmystreet/my/_problem-list.html @@ -0,0 +1,27 @@ +[% FOREACH p = problems.confirmed %] + [% IF loop.first %]<h2>[% loc('Open reports') %]</h2>[% END %] + [% INCLUDE problem %] +[% END %] + +[% FOREACH p = problems.fixed %] + [% IF loop.first %]<h2>[% loc('Fixed reports') %]</h2>[% END %] + [% INCLUDE problem %] +[% END %] + +[% FOREACH p = problems.closed %] + [% IF loop.first %]<h2>[% loc('Closed reports') %]</h2>[% END %] + [% INCLUDE problem %] +[% END %] + +[%# FOREACH p = problems.unconfirmed; + IF loop.first; + '<h2>' _ loc('Unconfirmed reports') _ '</h2>'; + END; + INCLUDE problem; +END %] + +[% BLOCK problem %] + [% "<ul class='issue-list-a full-width'>" IF loop.first %] + [% INCLUDE 'report/_item.html', problem = p, no_fixed =1 %] + [% "</ul>" IF loop.last %] +[% END %] diff --git a/templates/web/fixmystreet/my/my.html b/templates/web/fixmystreet/my/my.html index eaf521494..9c857aab9 100644 --- a/templates/web/fixmystreet/my/my.html +++ b/templates/web/fixmystreet/my/my.html @@ -34,27 +34,7 @@ param = 'p' %] -[% FOREACH p = problems.confirmed %] - [% IF loop.first %]<h2>[% loc('Open reports') %]</h2>[% END %] - [% INCLUDE problem %] -[% END %] - -[% FOREACH p = problems.fixed %] - [% IF loop.first %]<h2>[% loc('Fixed reports') %]</h2>[% END %] - [% INCLUDE problem %] -[% END %] - -[% FOREACH p = problems.closed %] - [% IF loop.first %]<h2>[% loc('Closed reports') %]</h2>[% END %] - [% INCLUDE problem %] -[% END %] - -[%# FOREACH p = problems.unconfirmed; - IF loop.first; - '<h2>' _ loc('Unconfirmed reports') _ '</h2>'; - END; - INCLUDE problem; -END %] +[% INCLUDE 'my/_problem-list.html' %] [% FOREACH u IN updates %] [% IF loop.first %] |