Skip to content

Commit

Permalink
Fixes issue with not being able to order dropdowns in extra questions
Browse files Browse the repository at this point in the history
Raised by Peterborough but an FMS issue as, when creating dropdowns for extra questions on categories, the 'key' input is ignored. This results in the user having no power over ordering the dropdown
list.

The interface leads the client to believe that they can influence the order.

This aligns the behaviour with the expectation.

mysociety/societyworks#2511
  • Loading branch information
MorayMySoc committed Aug 13, 2021
1 parent 8c28edc commit 0275a97
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- Only trigger one refresh going Back to list view. #3476
- Fix checked order of updates in dashboard export.
- Fix unable to edit user with verified landline #3295
- Fix key/value in dropdowns so the key int orders the dropdown list #2511
- Admin improvements:
- Enable per-category hint customisation.
- Move ban/unban buttons to user edit admin page.
Expand Down
5 changes: 2 additions & 3 deletions perllib/FixMyStreet/App/Controller/Admin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,8 @@ sub fetch_body_areas : Private {

sub update_extra_fields : Private {
my ($self, $c, $object) = @_;

my @indices = grep { /^metadata\[\d+\]\.code/ } keys %{ $c->req->params };
@indices = sort map { /(\d+)/ } @indices;

my @extra_fields;
foreach my $i (@indices) {
my $meta = {};
Expand All @@ -532,7 +530,7 @@ sub update_extra_fields : Private {
$meta->{values} = [];
my $re = qr{^metadata\[$i\]\.values\[\d+\]\.key};
my @vindices = grep { /$re/ } keys %{ $c->req->params };
@vindices = sort map { /values\[(\d+)\]/ } @vindices;
@vindices = map { /values\[(\d+)\]/ } @vindices;
foreach my $j (@vindices) {
my $name = $c->get_param("metadata[$i].values[$j].name");
my $key = $c->get_param("metadata[$i].values[$j].key");
Expand All @@ -544,6 +542,7 @@ sub update_extra_fields : Private {
$disable ? (disable => 1, disable_message => $disable_message) : (),
}) if $name;
}
@{$meta->{values}} = sort { $a->{key} <=> $b->{key} } @{$meta->{values}};
}
} elsif ($behaviour eq 'notice') {
$meta->{variable} = 'false';
Expand Down

0 comments on commit 0275a97

Please sign in to comment.