aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Users.pm23
-rw-r--r--perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm24
3 files changed, 31 insertions, 18 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d851c5b0d..c237355d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,9 +23,11 @@
- Fix photo orientation in modern browsers.
- Improve compatibility with G Suite OpenID Connect authentication. #3032
- Fix duplicate asset message after dismissing duplicate suggestions.
+ - Improve moderation diff display in a few small ways. #3105
- 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;
diff --git a/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm b/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm
index 6d14e6a9f..dd76a52c0 100644
--- a/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm
+++ b/perllib/FixMyStreet/DB/Result/ModerationOriginalData.pm
@@ -156,6 +156,20 @@ sub compare_photo {
return FixMyStreet::Template::SafeString->new($s);
}
+# This is a list of extra keys that could be set on a report after a moderation
+# has occurred. This can confuse the display of the last moderation entry, as
+# the comparison with the problem's extra will be wrong.
+my @keys_to_ignore = (
+ 'sent_to', # SendReport::Email adds this arrayref when sent
+ 'closed_updates', # Marked to close a report to updates
+ 'closure_alert_sent_at', # Set by alert sending if update closes a report
+ # Can be set/changed by an Open311 update
+ 'external_status_code', 'customer_reference',
+ # Can be set by inspectors
+ 'traffic_information', 'detailed_information', 'duplicates', 'duplicate_of', 'order',
+);
+my %keys_to_ignore = map { $_ => 1 } @keys_to_ignore;
+
sub compare_extra {
my ($self, $other) = @_;
@@ -163,18 +177,20 @@ sub compare_extra {
my $new = $other->get_extra_metadata;
my $both = { %$old, %$new };
- my @all_keys = grep { $_ ne 'sent_to' } sort keys %$both;
+ my @all_keys = grep { !$keys_to_ignore{$_} } sort keys %$both;
my @s;
foreach (@all_keys) {
+ $old->{$_} = join(', ', @{$old->{$_}}) if ref $old->{$_} eq 'ARRAY';
+ $new->{$_} = join(', ', @{$new->{$_}}) if ref $new->{$_} eq 'ARRAY';
if ($old->{$_} && $new->{$_}) {
push @s, string_diff("$_ = $old->{$_}", "$_ = $new->{$_}");
} elsif ($new->{$_}) {
push @s, string_diff("", "$_ = $new->{$_}");
- } else {
+ } elsif ($old->{$_}) {
push @s, string_diff("$_ = $old->{$_}", "");
}
}
- return join ', ', grep { $_ } @s;
+ return join '; ', grep { $_ } @s;
}
sub extra_diff {
@@ -193,7 +209,7 @@ sub string_diff {
$new = FixMyStreet::Template::html_filter($new);
if ($options{single}) {
- return unless $old;
+ return '' unless $old;
$old = [ $old ];
$new = [ $new ];
}