Bug 343635: Enabling classifications should add a tree view of classifications and products when entering a new bug - Patch by Frédéric Buclin <LpSolit@gmail.com> r=bkor a=justdave
git-svn-id: svn://10.0.0.236/trunk@217184 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
1deb867b0e
commit
ba1bec1581
@ -72,21 +72,36 @@ if ($product_name eq '') {
|
||||
my $classification = Bugzilla->params->{'useclassification'} ?
|
||||
scalar($cgi->param('classification')) : '__all';
|
||||
|
||||
unless ($classification) {
|
||||
my $class;
|
||||
# Get all classifications with at least one enterable product.
|
||||
foreach my $product (@enterable_products) {
|
||||
$class->{$product->classification_id} ||=
|
||||
new Bugzilla::Classification($product->classification_id);
|
||||
}
|
||||
my @classifications = sort {$a->sortkey <=> $b->sortkey
|
||||
|| lc($a->name) cmp lc($b->name)}
|
||||
(values %$class);
|
||||
# Unless a real classification name is given, we sort products
|
||||
# by classification.
|
||||
my @classifications;
|
||||
|
||||
unless ($classification && $classification ne '__all') {
|
||||
if (Bugzilla->params->{'useclassification'}) {
|
||||
my $class;
|
||||
# Get all classifications with at least one enterable product.
|
||||
foreach my $product (@enterable_products) {
|
||||
$class->{$product->classification_id}->{'object'} ||=
|
||||
new Bugzilla::Classification($product->classification_id);
|
||||
# Nice way to group products per classification, without querying
|
||||
# the DB again.
|
||||
push(@{$class->{$product->classification_id}->{'products'}}, $product);
|
||||
}
|
||||
@classifications = sort {$a->{'object'}->sortkey <=> $b->{'object'}->sortkey
|
||||
|| lc($a->{'object'}->name) cmp lc($b->{'object'}->name)}
|
||||
(values %$class);
|
||||
}
|
||||
else {
|
||||
@classifications = ({object => undef, products => \@enterable_products});
|
||||
}
|
||||
}
|
||||
|
||||
unless ($classification) {
|
||||
# We know there is at least one classification available,
|
||||
# else we would have stopped earlier.
|
||||
if (scalar(@classifications) > 1) {
|
||||
$vars->{'classifications'} = \@classifications;
|
||||
# We only need classification objects.
|
||||
$vars->{'classifications'} = [map {$_->{'object'}} @classifications];
|
||||
|
||||
$vars->{'target'} = "enter_bug.cgi";
|
||||
$vars->{'format'} = $cgi->param('format');
|
||||
@ -98,7 +113,7 @@ if ($product_name eq '') {
|
||||
exit;
|
||||
}
|
||||
# If we come here, then there is only one classification available.
|
||||
$classification = $classifications[0]->name;
|
||||
$classification = $classifications[0]->{'object'}->name;
|
||||
}
|
||||
|
||||
# Keep only enterable products which are in the specified classification.
|
||||
@ -108,6 +123,7 @@ if ($product_name eq '') {
|
||||
if ($class) {
|
||||
@enterable_products
|
||||
= grep {$_->classification_id == $class->id} @enterable_products;
|
||||
@classifications = ({object => $class, products => \@enterable_products});
|
||||
}
|
||||
else {
|
||||
@enterable_products = ();
|
||||
@ -118,7 +134,7 @@ if ($product_name eq '') {
|
||||
ThrowUserError('no_products');
|
||||
}
|
||||
elsif (scalar(@enterable_products) > 1) {
|
||||
$vars->{'products'} = \@enterable_products;
|
||||
$vars->{'classifications'} = \@classifications;
|
||||
$vars->{'target'} = "enter_bug.cgi";
|
||||
$vars->{'format'} = $cgi->param('format');
|
||||
$vars->{'cloned_bug_id'} = $cgi->param('cloned_bug_id');
|
||||
|
||||
@ -41,7 +41,10 @@
|
||||
</th>
|
||||
|
||||
<td valign="top"> Show all products</td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="2"> </th>
|
||||
</tr>
|
||||
[% END %]
|
||||
|
||||
[% FOREACH class = classifications %]
|
||||
|
||||
@ -20,8 +20,9 @@
|
||||
#%]
|
||||
|
||||
[%# INTERFACE:
|
||||
# products: array of product objects. The list of products
|
||||
# the user can enter bugs into.
|
||||
# classifications: array of hashes, with an 'object' key representing a
|
||||
# classification object and 'products' the list of
|
||||
# product objects the user can enter bugs into.
|
||||
# target: the script that displays this template.
|
||||
# cloned_bug_id: ID of the bug being cloned.
|
||||
# format: the desired format to display the target.
|
||||
@ -42,16 +43,29 @@
|
||||
|
||||
<table>
|
||||
|
||||
[% FOREACH p = products %]
|
||||
<tr>
|
||||
<th align="right" valign="top">
|
||||
<a href="[% target %]?product=[% p.name FILTER url_quote -%]
|
||||
[%- IF cloned_bug_id %]&cloned_bug_id=[% cloned_bug_id FILTER url_quote %][% END -%]
|
||||
[%- IF format %]&format=[% format FILTER url_quote %][% END %]">
|
||||
[% p.name FILTER html %]</a>:
|
||||
</th>
|
||||
[% FOREACH c = classifications %]
|
||||
[% IF c.object %]
|
||||
<tr>
|
||||
<th colspan="2" align="left">[% c.object.name FILTER html %]:
|
||||
[%+ c.object.description FILTER html_light %]</th>
|
||||
</tr>
|
||||
[% END %]
|
||||
|
||||
<td valign="top">[% p.description FILTER html_light %]</td>
|
||||
[% FOREACH p = c.products %]
|
||||
<tr>
|
||||
<th align="right" valign="top">
|
||||
<a href="[% target %]?product=[% p.name FILTER url_quote -%]
|
||||
[%- IF cloned_bug_id %]&cloned_bug_id=[% cloned_bug_id FILTER url_quote %][% END -%]
|
||||
[%- IF format %]&format=[% format FILTER url_quote %][% END %]">
|
||||
[% p.name FILTER html FILTER no_break %]</a>:
|
||||
</th>
|
||||
|
||||
<td valign="top">[% p.description FILTER html_light %]</td>
|
||||
</tr>
|
||||
[% END %]
|
||||
|
||||
<tr>
|
||||
<th colspan="2"> </th>
|
||||
</tr>
|
||||
[% END %]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user