From 8c1cdef6abdd4dabc768760f182067402da09145 Mon Sep 17 00:00:00 2001 From: Simon Green Date: Fri, 3 Jan 2014 08:11:04 +1000 Subject: Bug 940010 - When entering a new bug, if there's only one active version or component, automatically select it r=LpSolit, a=sgreen --- enter_bug.cgi | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'enter_bug.cgi') diff --git a/enter_bug.cgi b/enter_bug.cgi index a609a2b9a..1769b464c 100755 --- a/enter_bug.cgi +++ b/enter_bug.cgi @@ -149,9 +149,16 @@ if ($cloned_bug_id) { $cloned_bug_id = $cloned_bug->id; } -if (scalar(@{$product->components}) == 1) { - # Only one component; just pick it. - $cgi->param('component', $product->components->[0]->name); +# If there is only one active component, choose it +my @active = grep { $_->is_active } @{$product->components}; +if (scalar(@active) == 1) { + $cgi->param('component', $active[0]->name); +} + +# If there is only one active version, choose it +@active = grep { $_->is_active } @{$product->versions}; +if (scalar(@active) == 1) { + $cgi->param('version', $active[0]->name); } my %default; -- cgit v1.2.3-24-g4f1b