diff options
author | lpsolit%gmail.com <> | 2006-12-19 17:32:03 +0100 |
---|---|---|
committer | lpsolit%gmail.com <> | 2006-12-19 17:32:03 +0100 |
commit | 4aad094aa406d102927a0665b021ad820c3e6164 (patch) | |
tree | a334b699bf1c6ccd1a7dc17c5f4d89dea1f0276a /enter_bug.cgi | |
parent | a32a16cafd772c918f2487423aa3317149bfff75 (diff) | |
download | bugzilla-4aad094aa406d102927a0665b021ad820c3e6164.tar.gz bugzilla-4aad094aa406d102927a0665b021ad820c3e6164.tar.xz |
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
Diffstat (limited to 'enter_bug.cgi')
-rwxr-xr-x | enter_bug.cgi | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/enter_bug.cgi b/enter_bug.cgi index 7f5a17e46..4496f010e 100755 --- a/enter_bug.cgi +++ b/enter_bug.cgi @@ -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); + # 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}); } - my @classifications = sort {$a->sortkey <=> $b->sortkey - || lc($a->name) cmp lc($b->name)} - (values %$class); + } + 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'); |