From: myk%mozilla.org <> Date: Tue, 14 Dec 2004 10:29:57 +0000 (+0000) Subject: Fix for bug 241814: properly trim component fields according to product selection... X-Git-Tag: bugzilla-2.18~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30edaeb2d1d2e8722d9fecfb97db606bbf947bc7;p=thirdparty%2Fbugzilla.git Fix for bug 241814: properly trim component fields according to product selection in the request queue, flag type editing, and anywhere else that uses the same code; r=vladd, a=justdave --- diff --git a/productmenu.js b/productmenu.js index d917d325c0..e633ab3279 100644 --- a/productmenu.js +++ b/productmenu.js @@ -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; } diff --git a/request.cgi b/request.cgi index cffad983fa..55629e20e8 100755 --- a/request.cgi +++ b/request.cgi @@ -264,7 +264,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; diff --git a/template/en/default/admin/flag-type/edit.html.tmpl b/template/en/default/admin/flag-type/edit.html.tmpl index 1faaaf3b87..9e683cd992 100644 --- a/template/en/default/admin/flag-type/edit.html.tmpl +++ b/template/en/default/admin/flag-type/edit.html.tmpl @@ -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? @@ -33,10 +33,6 @@ [% END %] [% END %] -[% header_html = BLOCK %] - -[% 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"] %]