diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 12 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 12 | ||||
-rw-r--r-- | templates/web/default/admin/report_blocks.html | 2 | ||||
-rw-r--r-- | templates/web/zurich/admin/index-dm.html | 2 | ||||
-rw-r--r-- | templates/web/zurich/admin/index-sdm.html | 8 | ||||
-rw-r--r-- | templates/web/zurich/admin/reports.html | 9 |
6 files changed, 28 insertions, 17 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 0f072b9a2..d25a23816 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -498,6 +498,12 @@ sub reports : Path('reports') { } } + my $order = $c->req->params->{o} || 'created'; + my $dir = defined $c->req->params->{d} ? $c->req->params->{d} : 1; + $c->stash->{order} = $order; + $c->stash->{dir} = $dir; + $order .= ' desc' if $dir; + if (my $search = $c->req->param('search')) { $c->stash->{searched} = $search; @@ -544,7 +550,7 @@ sub reports : Path('reports') { $query, { prefetch => 'user', - order_by => [\"(state='hidden')",'created'] + order_by => [ \"(state='hidden')", $order ] } ); @@ -587,7 +593,7 @@ sub reports : Path('reports') { { -select => [ 'me.*', qw/problem.bodies_str problem.state/ ], prefetch => [qw/user problem/], - order_by => [\"(me.state='hidden')",\"(problem.state='hidden')",'me.created'] + order_by => [ \"(me.state='hidden')", \"(problem.state='hidden')", "me.$order" ] } ); $c->stash->{updates} = [ $updates->all ]; @@ -600,7 +606,7 @@ sub reports : Path('reports') { my $page = $c->req->params->{p} || 1; my $problems = $c->cobrand->problems->search( $query, - { order_by => 'created desc' } + { order_by => $order } )->page( $page ); $c->stash->{problems} = [ $problems->all ]; $c->stash->{pager} = $problems->pager; diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index 8375e1809..104ba6bf5 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -229,18 +229,24 @@ sub admin { my $body = $c->stash->{body}; + my $order = $c->req->params->{o} || 'created'; + my $dir = defined $c->req->params->{d} ? $c->req->params->{d} : 1; + $c->stash->{order} = $order; + $c->stash->{dir} = $dir; + $order .= ' desc' if $dir; + # XXX No multiples or missing bodies $c->stash->{reports_new} = $c->cobrand->problems->search( { state => 'in progress', bodies_str => $body->id, }, { - order_by => 'created' + order_by => $order } ); $c->stash->{reports_unpublished} = $c->cobrand->problems->search( { state => 'planned', bodies_str => $body->parent->id, }, { - order_by => 'created desc' + order_by => $order } ); my $page = $c->req->params->{p} || 1; @@ -248,7 +254,7 @@ sub admin { state => 'fixed - council', bodies_str => $body->parent->id, }, { - order_by => 'created desc' + order_by => $order } )->page( $page ); $c->stash->{pager} = $c->stash->{reports_published}->pager; } diff --git a/templates/web/default/admin/report_blocks.html b/templates/web/default/admin/report_blocks.html index bb9f34cb9..0ceefa4ea 100644 --- a/templates/web/default/admin/report_blocks.html +++ b/templates/web/default/admin/report_blocks.html @@ -22,3 +22,5 @@ [% this_date.strftime('%d.%m.%Y') %] [% ELSE %][% no_time || ' ' %][% END %][% no_time = '' %] [%- END %] + +[% BLOCK sort_link %][% IF order == choice %][% c.uri_with( d => 1 - (c.req.params.d||0) ) %][% ELSE %][% c.uri_with( { o => choice } ) %][% END %][% END %] diff --git a/templates/web/zurich/admin/index-dm.html b/templates/web/zurich/admin/index-dm.html index 5b2141d36..4da29ffc7 100644 --- a/templates/web/zurich/admin/index-dm.html +++ b/templates/web/zurich/admin/index-dm.html @@ -15,8 +15,6 @@ [% INCLUDE 'admin/footer.html' %] -[% BLOCK sort_link %][% IF order == choice %][% c.uri_with( d => 1 - (c.req.params.d||0) ) %][% ELSE %][% c.uri_with( { o => choice } ) %][% END %][% END %] - [% BLOCK list %] <table cellspacing="0" cellpadding="2" border="1"> <tr> diff --git a/templates/web/zurich/admin/index-sdm.html b/templates/web/zurich/admin/index-sdm.html index 9fa1b7714..a25fcd296 100644 --- a/templates/web/zurich/admin/index-sdm.html +++ b/templates/web/zurich/admin/index-sdm.html @@ -18,10 +18,10 @@ <tr> <th>[% loc('ID') %]</th> <th>[% loc('Description') %]</th> - <th>[% loc('Category') %]</th> - <th>[% loc('Submitted') %]</th> - <th>[% loc('Updated') %]</th> - <th>[% loc('Status') %]</th> + <th><a href="[% INCLUDE sort_link choice = 'category' %]">[% loc('Category') %]</a></th> + <th><a href="[% INCLUDE sort_link choice = 'created' %]">[% loc('Submitted') %]</a></th> + <th><a href="[% INCLUDE sort_link choice = 'lastupdate' %]">[% loc('Updated') %]</a></th> + <th><a href="[% INCLUDE sort_link choice = 'state' %]">[% loc('Status') %]</a></th> [% IF NOT no_edit %] <th>*</th> [% END %] diff --git a/templates/web/zurich/admin/reports.html b/templates/web/zurich/admin/reports.html index 5122f7b5a..6ba18c9e7 100644 --- a/templates/web/zurich/admin/reports.html +++ b/templates/web/zurich/admin/reports.html @@ -5,16 +5,15 @@ <p><label for="search">[% loc('Search:') %]</label> <input type="text" name="search" size="30" id="search" value="[% searched | html %]"> </form> - [% IF problems.size %] <table cellspacing="0" cellpadding="2" border="1"> <tr> <th>[% loc('ID') %]</th> <th>[% loc('Description') %]</th> - <th>[% loc('Category') %]</th> - <th>[% loc('Submitted') %]</th> - <th>[% loc('Updated') %]</th> - <th>[% loc('Status') %]</th> + <th><a href="[% INCLUDE sort_link choice = 'category' %]">[% loc('Category') %]</a></th> + <th><a href="[% INCLUDE sort_link choice = 'created' %]">[% loc('Submitted') %]</a></th> + <th><a href="[% INCLUDE sort_link choice = 'lastupdate' %]">[% loc('Updated') %]</a></th> + <th><a href="[% INCLUDE sort_link choice = 'state' %]">[% loc('Status') %]</a></th> <th>*</th> </tr> [% INCLUDE 'admin/problem_row.html' %] |