]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Fix for bug 241814: properly trim component fields according to product selection...
authormyk%mozilla.org <>
Tue, 14 Dec 2004 10:29:56 +0000 (10:29 +0000)
committermyk%mozilla.org <>
Tue, 14 Dec 2004 10:29:56 +0000 (10:29 +0000)
productmenu.js
request.cgi
template/en/default/admin/flag-type/edit.html.tmpl
template/en/default/request/queue.html.tmpl

index d917d325c089dac6f2728a96dc31ec2067d25ded..e633ab3279d844c62fac8428a9f126f27500a840 100644 (file)
@@ -203,19 +203,26 @@ function selectProduct( f , productfield, componentfield, blank ) {
     // - is_diff says if it's a full list or just a list of products that
     //   were added to the current selection.
     // - single indicates if a single item was selected
+    // - selectedIndex is the index of the first selected item
+    // - selectedValue is the value of the first selected item
     var sel = Array();
     var is_diff = 0;
     var single;
-
-    // if nothing selected, pick all
-    if ( f[productfield].selectedIndex == -1 ) {
-        for ( var i = 0 ; i < f[productfield].length ; i++ ) {
+    var selectedIndex = f[productfield].selectedIndex;
+    var selectedValue = f[productfield].options[selectedIndex].value;
+
+    // If nothing is selected, or the selected item is the "blank" value
+    // at the top of the list which represents all products on drop-down menus,
+    // then pick all products so we show all components.
+    if ( selectedIndex == -1 || !cpts[selectedValue])
+    {
+        for ( var i = blank ? 1 : 0 ; i < f[productfield].length ; i++ ) {
             sel[sel.length] = f[productfield].options[i].value;
         }
         single = 0;
     } else {
 
-        for ( i = 0 ; i < f[productfield].length ; i++ ) {
+        for ( i = blank ? 1 : 0 ; i < f[productfield].length ; i++ ) {
             if ( f[productfield].options[i].selected ) {
                 sel[sel.length] = f[productfield].options[i].value;
             }
index f872d1d286a8a48e84d6052341c7cb6d9801c9c4..b4b7e67661dbc0fa1a1910dc3bca06f2a554882b 100755 (executable)
@@ -266,7 +266,7 @@ sub queue {
     my $selectable = GetSelectableProductHash();
     $vars->{'products'} = $selectable->{legal_products};
     $vars->{'components'} = $selectable->{legal_components};
-    $vars->{'components_by_product'} = $selectable->{components};
+    $vars->{'components_by_product'} = $selectable->{components_by_product};
     
     $vars->{'excluded_columns'} = \@excluded_columns;
     $vars->{'group_field'} = $form_group;
index 253a310ac9528940420b21817d08906f235e5cb7..c735ac33d0cfbef1688cd533167097cb48a5e226 100644 (file)
@@ -21,7 +21,7 @@
 
 [% PROCESS global/variables.none.tmpl %]
 
-[%# The javascript and header_html blocks get used in header.html.tmpl. %]
+[%# The javascript block gets used in header.html.tmpl. %]
 [% javascript = BLOCK %]
   var usetms = 0; // do we have target milestone?
   var first_load = 1; // is this the first time we load the page?
   [% END %]
 [% END %]
 
-[% header_html = BLOCK %]
-  <script language="JavaScript" type="text/javascript" src="productmenu.js"></script>
-[% END %]
-
 [% IF type.target_type == "bug" %]
   [% title = BLOCK %]Create Flag Type for [% terms.Bugs %][% END %]
   [% typeLabelLowerPlural = BLOCK %][% terms.bugs %][% END %]
@@ -59,7 +55,8 @@
     table#form th { text-align: right; vertical-align: baseline; white-space: nowrap; }
     table#form td { text-align: left; vertical-align: baseline; }
   "
-  onload="selectProduct(forms[0], 'product', 'component', '__Any__');"
+  onload="selectProduct(document.forms[0], 'product', 'component', '__Any__');"
+  javascript_urls=["productmenu.js"]
 %]
 
 <form method="post" action="editflagtypes.cgi">
index 5a626b18307449cf6b4a81134331e1452b5d06df..fbfa94d25028b8a8a7e4b15ce16337d96c4d4875 100644 (file)
@@ -24,7 +24,7 @@
 [% USE Bugzilla %]
 [% cgi = Bugzilla.cgi %]
 
-[%# The javascript and header_html blocks get used in header.html.tmpl. %]
+[%# The javascript block gets used in header.html.tmpl. %]
 [% javascript = BLOCK %]
   var usetms = 0; // do we have target milestone?
   var first_load = 1; // is this the first time we load the page?
   [% END %]
 [% END %]
 
-[% header_html = BLOCK %]
-  <script language="JavaScript" type="text/javascript" src="productmenu.js"></script>
-[% END %]
-
 [% filter_form = BLOCK %]
 <form action="request.cgi" method="get">
   <input type="hidden" name="action" value="queue">
     table.requests th { text-align: left; }
     table#filter th { text-align: right; }
   "
+  onload="selectProduct(document.forms[0], 'product', 'component', 'Any');"
+  javascript_urls=["productmenu.js"]
 %]
 
 [% IF debug %]