Commit a224d895 authored by terry%netscape.com's avatar terry%netscape.com

Patch by David Gardiner <david.gardiner@unisa.edu.au> (with further

hacks by me): Added javascript magic to adjust component/version lists when products get selected.
parent 5066e675
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# Netscape Communications Corporation. All Rights Reserved. # Netscape Communications Corporation. All Rights Reserved.
# #
# Contributor(s): Terry Weissman <terry@mozilla.org> # Contributor(s): Terry Weissman <terry@mozilla.org>
# David Gardiner <david.gardiner@unisa.edu.au>
use diagnostics; use diagnostics;
use strict; use strict;
...@@ -37,6 +38,8 @@ use vars @::legal_resolution, ...@@ -37,6 +38,8 @@ use vars @::legal_resolution,
@::legal_versions, @::legal_versions,
@::legal_severity, @::legal_severity,
@::legal_target_milestone, @::legal_target_milestone,
%::versions,
%::components,
%::FORM; %::FORM;
...@@ -181,6 +184,127 @@ my $emailinput1 = GenerateEmailInput(1); ...@@ -181,6 +184,127 @@ my $emailinput1 = GenerateEmailInput(1);
my $emailinput2 = GenerateEmailInput(2); my $emailinput2 = GenerateEmailInput(2);
# javascript
my $jscript = << 'ENDSCRIPT';
<script language="Javascript1.1">
<!--
var cpts = new Array();
var vers = new Array();
ENDSCRIPT
my $p;
my $v;
my $c;
my $i = 0;
my $j = 0;
foreach $c (@::legal_components) {
$jscript .= "cpts['$c'] = [];\n";
}
foreach $v (@::legal_versions) {
$jscript .= "vers['$v'] = [];\n";
}
for $p (@::legal_product) {
foreach $c (@{$::components{$p}}) {
$jscript .= "cpts['$c'].push('$p');\n";
}
foreach $v (@{$::versions{$p}}) {
$jscript .= "vers['$v'].push('$p');\n";
}
}
$i = 0;
$jscript .= "
// Only display versions/components valid for selected product(s)
function selectProduct(f) {
var cnt = 0;
var i;
var j;
for (i=0 ; i<f.product.length ; i++) {
if (f.product[i].selected) {
cnt++;
}
}
var doall = (cnt == f.product.length || cnt == 0);
var csel = new Array();
for (i=0 ; i<f.component.length ; i++) {
if (f.component[i].selected) {
csel[f.component[i].value] = 1;
}
}
f.component.options.length = 0;
for (c in cpts) {
var doit = doall;
for (i=0 ; !doit && i<f.product.length ; i++) {
if (f.product[i].selected) {
var p = f.product[i].value;
for (j in cpts[c]) {
var p2 = cpts[c][j];
if (p2 == p) {
doit = true;
break;
}
}
}
}
if (doit) {
var l = f.component.length;
f.component[l] = new Option(c, c);
if (csel[c] != undefined) {
f.component[l].selected = true;
}
}
}
var vsel = new Array();
for (i=0 ; i<f.version.length ; i++) {
if (f.version[i].selected) {
vsel[f.version[i].value] = 1;
}
}
f.version.options.length = 0;
for (v in vers) {
var doit = doall;
for (i=0 ; !doit && i<f.product.length ; i++) {
if (f.product[i].selected) {
var p = f.product[i].value;
for (j in vers[v]) {
var p2 = vers[v][j];
if (p2 == p) {
doit = true;
break;
}
}
}
}
if (doit) {
var l = f.version.length;
f.version[l] = new Option(v, v);
if (vsel[v] != undefined) {
f.version[l].selected = true;
}
}
}
}
// -->
</script>\n";
# Muck the "legal product" list so that the default one is always first (and # Muck the "legal product" list so that the default one is always first (and
...@@ -198,6 +322,8 @@ PutHeader("Bugzilla Query Page", "Query Page"); ...@@ -198,6 +322,8 @@ PutHeader("Bugzilla Query Page", "Query Page");
push @::legal_resolution, "---"; # Oy, what a hack. push @::legal_resolution, "---"; # Oy, what a hack.
push @::legal_target_milestone, "---"; # Oy, what a hack. push @::legal_target_milestone, "---"; # Oy, what a hack.
print $jscript;
print " print "
<FORM NAME=queryForm METHOD=GET ACTION=\"buglist.cgi\"> <FORM NAME=queryForm METHOD=GET ACTION=\"buglist.cgi\">
...@@ -271,7 +397,7 @@ print " ...@@ -271,7 +397,7 @@ print "
<tr> <tr>
<td align=left valign=top> <td align=left valign=top>
<SELECT NAME=\"product\" MULTIPLE SIZE=5> <SELECT NAME=\"product\" MULTIPLE SIZE=5 onChange=\"selectProduct(this.form);\">
@{[make_options(\@::legal_product, $default{'product'}, $type{'product'})]} @{[make_options(\@::legal_product, $default{'product'}, $type{'product'})]}
</SELECT> </SELECT>
</td> </td>
......
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