diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-07-07 13:13:29 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-07-07 13:18:00 +0100 |
commit | 5405b213903785e0c215efcf9c7125bddbd14731 (patch) | |
tree | 5ae9fb6f4630e49487b09f34c1a6a91e675eebb0 | |
parent | d597f5012f2db5408eb0a913a789bbe2de4d923a (diff) |
Better sort admin user table.
Sort the table when showing search results, and show users
without name at the bottom, rather than at the top.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/Users.pm | 23 |
2 files changed, 10 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d05be748..e36b2017d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Admin improvements: - Display user name/email for contributed as reports. #2990 - Interface for enabling anonymous reports for certain categories. #2989 + - Better sort admin user table. - Development improvements: - `#geolocate_link` is now easier to re-style. #3006 - Links inside `#front-main` can be customised using `$primary_link_*` Sass variables. #3007 diff --git a/perllib/FixMyStreet/App/Controller/Admin/Users.pm b/perllib/FixMyStreet/App/Controller/Admin/Users.pm index 5bb91341d..c73f1429b 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Users.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Users.pm @@ -47,8 +47,8 @@ sub index :Path : Args(0) { my $search = $c->get_param('search'); my $role = $c->get_param('role'); + my $users = $c->cobrand->users; if ($search || $role) { - my $users = $c->cobrand->users; my $isearch; if ($search) { $search = $self->trim($search); @@ -78,25 +78,20 @@ sub index :Path : Args(0) { join => 'user_roles', }); } - - my @users = $users->all; - $c->stash->{users} = [ @users ]; - if ($search) { - $c->forward('/admin/add_flags', [ { email => { ilike => $isearch } } ]); - } - } else { $c->forward('/auth/get_csrf_token'); $c->forward('/admin/fetch_all_bodies'); $c->cobrand->call_hook('admin_user_edit_extra_data'); # Admin users by default - my $users = $c->cobrand->users->search( - { from_body => { '!=', undef } }, - { order_by => 'name' } - ); - my @users = $users->all; - $c->stash->{users} = \@users; + $users = $users->search({ from_body => { '!=', undef } }); + } + + $users = $users->search(undef, { order_by => [ \"name = ''", 'name' ] }); + my @users = $users->all; + $c->stash->{users} = \@users; + if ($search) { + $c->forward('/admin/add_flags', [ { email => { ilike => "%$search%" } } ]); } my $rs; |