aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm19
-rw-r--r--templates/web/default/my/my.html38
-rw-r--r--web/css/core.css1
-rw-r--r--web/css/core.scss1
4 files changed, 48 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index 74f7a6d52..b1359ae03 100644
--- a/perllib/FixMyStreet/App/Controller/My.pm
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -28,9 +28,15 @@ sub my : Path : Args(0) {
# Even though front end doesn't yet have it, have it on this page, it's better!
FixMyStreet::Map::set_map_class( 'FMS' );
+ my $p_page = $c->req->params->{p} || 1;
+ my $u_page = $c->req->params->{u} || 1;
+
my $pins = [];
my $problems = {};
- foreach my $problem ( $c->user->problems ) {
+ my $rs = $c->user->problems->search( undef,
+ { rows => 50 } )->page( $p_page );
+
+ while ( my $problem = $rs->next ) {
push @$pins, {
latitude => $problem->latitude,
longitude => $problem->longitude,
@@ -40,12 +46,15 @@ sub my : Path : Args(0) {
};
push @{ $problems->{$problem->state} }, $problem;
}
-
+ $c->stash->{problems_pager} = $rs->pager;
$c->stash->{problems} = $problems;
- my @updates = $c->user->comments->search( {
- state => 'confirmed',
- } )->all;
+
+ $rs = $c->user->comments->search(
+ { state => 'confirmed' },
+ { rows => 50 } )->page( $u_page );
+ my @updates = $rs->all;
$c->stash->{updates} = \@updates;
+ $c->stash->{updates_pager} = $rs->pager;
FixMyStreet::Map::display_map(
$c,
diff --git a/templates/web/default/my/my.html b/templates/web/default/my/my.html
index 08b6a6693..e7f4ca72d 100644
--- a/templates/web/default/my/my.html
+++ b/templates/web/default/my/my.html
@@ -1,9 +1,9 @@
[%
- PROCESS "maps/${map.type}.html" IF c.user.problems;
+ PROCESS "maps/${map.type}.html" IF problems.size;
INCLUDE 'header.html', title = loc('Your Reports')
%]
-[% IF c.user.problems %]
+[% IF problems.size %]
[% map_html %]
</div>
<div id="side">
@@ -13,6 +13,8 @@
<h1>[% loc('Your Reports') %]</h1>
+[% INCLUDE pagination, pager = problems_pager %]
+
[% FOREACH p = problems.confirmed %]
[% IF loop.first %]<h2>[% loc('Open reports') %]</h2>[% END %]
[% INCLUDE problem %]
@@ -31,7 +33,12 @@
END %]
[% FOREACH u IN updates %]
- [% IF loop.first %]<h2>[% loc('Your updates') %]</h2><ul>[% END %]
+ [% IF loop.first %]
+ <h2>[% loc('Your updates') %]</h2>
+ [% INCLUDE pagination, pager = updates_pager %]
+ <ul>
+ [% END %]
+
<li>&ldquo;[% u.text | html %]&rdquo;
&ndash; <a href="[% c.uri_for( '/report', u.problem_id ) %]#update_[% u.id %]">[% u.problem.title | html %]</a>.
<em class="council_sent_info">
@@ -48,10 +55,10 @@ END %]
[% BLOCK problem %]
[% "<ul>" IF loop.first %]
- <li><a href="[% c.uri_for( '/report', p.id ) %]">[% p.title | html %]</a>.
- <em class="council_sent_info">
+ <li><a href="[% c.uri_for( '/report', p.id ) %]">[% p.title | html %]</a>
+ <em class="council_sent_info"> &ndash;
[% IF p.whensent %]
- [% tprintf( loc("Reported %s to %s"), prettify_epoch( p.confirmed_local.epoch, 'date' ), p.body(c) ) %]
+ [% tprintf( loc("Reported %s, to %s"), prettify_epoch( p.confirmed_local.epoch, 'date' ), p.body(c) ) %]
[% ELSE %]
[% tprintf( loc("Reported %s"), prettify_epoch( p.confirmed_local.epoch, 'date' ) ) %]
[% END %]
@@ -61,3 +68,22 @@ END %]
[% "</ul>" IF loop.last %]
[% END %]
+[% BLOCK pagination %]
+ [% IF pager.last_page > 1 %]
+ <p>
+ [% IF pager.previous_page %]
+ <a href="[% c.req.uri_with({'p_page' => pager.previous_page}) %]">&larr; Previous</a>
+ [% ELSE %]
+ &larr; Previous
+ [% END %]
+ |
+ [% pager.first %] to [% pager.last %] of [% pager.total_entries %]
+ |
+ [% IF pager.next_page %]
+ <a href="[% c.req.uri_with({'p_page' => pager.next_page}) %]">Next &rarr;</a>
+ [% ELSE %]
+ Next &rarr;
+ [% END %]
+ </p>
+ [% END %]
+[% END %]
diff --git a/web/css/core.css b/web/css/core.css
index a67c54f17..85c16a9ae 100644
--- a/web/css/core.css
+++ b/web/css/core.css
@@ -176,6 +176,7 @@
}
#mysociety p#copyright {
float: right;
+ text-align: right;
margin: 0 0 1em 0;
font-size: 78%;
}
diff --git a/web/css/core.scss b/web/css/core.scss
index 74e62f481..5e24b5702 100644
--- a/web/css/core.scss
+++ b/web/css/core.scss
@@ -226,6 +226,7 @@ $map_width: 500px;
p#copyright {
float: right;
+ text-align: right;
margin: 0 0 1em 0;
font-size: 78%;
}