Commit 3331c1ba authored by David Lawrence's avatar David Lawrence

Bug 1161070: api searches should honour the same fields in its "order" parameter as the web UI

r=dylan,a=simon
parent 300331b4
...@@ -716,7 +716,25 @@ sub search { ...@@ -716,7 +716,25 @@ sub search {
ThrowUserError('buglist_parameters_required'); ThrowUserError('buglist_parameters_required');
} }
$options{order} = [ split(/\s*,\s*/, delete $match_params->{order}) ] if $match_params->{order}; # Allow the use of order shortcuts similar to web UI
if ($match_params->{order}) {
# Convert the value of the "order" form field into a list of columns
# by which to sort the results.
my %order_types = (
"Bug Number" => [ "bug_id" ],
"Importance" => [ "priority", "bug_severity" ],
"Assignee" => [ "assigned_to", "bug_status", "priority", "bug_id" ],
"Last Changed" => [ "changeddate", "bug_status", "priority",
"assigned_to", "bug_id" ],
);
if ($order_types{$match_params->{order}}) {
$options{order} = $order_types{$match_params->{order}};
}
else {
$options{order} = [ split(/\s*,\s*/, $match_params->{order}) ];
}
}
$options{params} = $match_params; $options{params} = $match_params;
my $search = new Bugzilla::Search(%options); my $search = new Bugzilla::Search(%options);
......
...@@ -575,7 +575,25 @@ sub search { ...@@ -575,7 +575,25 @@ sub search {
ThrowUserError('buglist_parameters_required'); ThrowUserError('buglist_parameters_required');
} }
$options{order} = [ split(/\s*,\s*/, delete $match_params->{order}) ] if $match_params->{order}; # Allow the use of order shortcuts similar to web UI
if ($match_params->{order}) {
# Convert the value of the "order" form field into a list of columns
# by which to sort the results.
my %order_types = (
"Bug Number" => [ "bug_id" ],
"Importance" => [ "priority", "bug_severity" ],
"Assignee" => [ "assigned_to", "bug_status", "priority", "bug_id" ],
"Last Changed" => [ "changeddate", "bug_status", "priority",
"assigned_to", "bug_id" ],
);
if ($order_types{$match_params->{order}}) {
$options{order} = $order_types{$match_params->{order}};
}
else {
$options{order} = [ split(/\s*,\s*/, $match_params->{order}) ];
}
}
$options{params} = $match_params; $options{params} = $match_params;
my $search = new Bugzilla::Search(%options); my $search = new Bugzilla::Search(%options);
......
...@@ -645,29 +645,18 @@ my @order_columns; ...@@ -645,29 +645,18 @@ my @order_columns;
if ($order) { if ($order) {
# Convert the value of the "order" form field into a list of columns # Convert the value of the "order" form field into a list of columns
# by which to sort the results. # by which to sort the results.
ORDER: for ($order) { my %order_types = (
/^Bug Number$/ && do { "Bug Number" => [ "bug_id" ],
@order_columns = ("bug_id"); "Importance" => [ "priority", "bug_severity" ],
last ORDER; "Assignee" => [ "assigned_to", "bug_status", "priority", "bug_id" ],
}; "Last Changed" => [ "changeddate", "bug_status", "priority",
/^Importance$/ && do { "assigned_to", "bug_id" ],
@order_columns = ("priority", "bug_severity"); );
last ORDER; if ($order_types{$order}) {
}; @order_columns = @{ $order_types{$order} };
/^Assignee$/ && do { }
@order_columns = ("assigned_to", "bug_status", "priority", else {
"bug_id"); @order_columns = split(/\s*,\s*/, $order);
last ORDER;
};
/^Last Changed$/ && do {
@order_columns = ("changeddate", "bug_status", "priority",
"assigned_to", "bug_id");
last ORDER;
};
do {
# A custom list of columns. Bugzilla::Search will validate items.
@order_columns = split(/\s*,\s*/, $order);
};
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment