Commit b4aecfef authored by rojanu's avatar rojanu Committed by Byron Jones

Bug 539894: Use <optgroup/> to group products into classifications in the…

Bug 539894: Use <optgroup/> to group products into classifications in the product drop-down on show_bug.cgi r=glob, a=justdave
parent b6027058
...@@ -59,13 +59,7 @@ if (! defined($product_id)) { ...@@ -59,13 +59,7 @@ if (! defined($product_id)) {
push(@datasets, $datasets); push(@datasets, $datasets);
} }
# Start our product list with an entry for all products, then add those
# products that the user has permissions for.
my @myproducts = ($product_all);
push( @myproducts, @{$user->get_selectable_products} );
$vars->{'datasets'} = \@datasets; $vars->{'datasets'} = \@datasets;
$vars->{'products'} = \@myproducts;
print $cgi->header(); print $cgi->header();
} }
......
...@@ -88,12 +88,13 @@ ...@@ -88,12 +88,13 @@
<tr> <tr>
<th class="top left"> <th class="top left">
Product/Component:<br> Product/Component:<br>
<select name="product" onchange="selectProduct(this, this.form.component, null, null, '__Any__');"> [% INCLUDE "global/product-select.html.tmpl"
<option value="">__Any__</option> id => "product"
[% FOREACH prod = products %] name => "product"
<option value="[% prod.name FILTER html %]">[% prod.name FILTER html %]</option> add => "__Any__"
[% END %] onchange => "selectProduct(this, this.form.component, null, null, '__Any__');"
</select><br> products => products
%]<br>
<select name="component"> <select name="component">
<option value="">__Any__</option> <option value="">__Any__</option>
[% FOREACH comp = components %] [% FOREACH comp = components %]
......
...@@ -39,15 +39,13 @@ ...@@ -39,15 +39,13 @@
<form id="flagtype_form" name="flagtype_form" action="editflagtypes.cgi" method="get"> <form id="flagtype_form" name="flagtype_form" action="editflagtypes.cgi" method="get">
<div class="inline"> <div class="inline">
<label for="product">Product:</label> <label for="product">Product:</label>
<select id="product" name="product" [% INCLUDE "global/product-select.html.tmpl"
onchange="selectProduct(this, this.form.component, null, null, '__Any__');"> id => "product"
<option value="">__Any__</option> name => "product"
[% FOREACH prod = products %] add => "__Any__"
<option value="[% prod.name FILTER html %]" onchange => "selectProduct(this, this.form.component, null, null, '__Any__');"
[%+ 'selected="selected"' IF selected_product == prod.name %]> products => products
[%- prod.name FILTER html %]</option> %]
[% END %]
</select>
</div> </div>
<div class="inline"> <div class="inline">
......
...@@ -241,11 +241,20 @@ ...@@ -241,11 +241,20 @@
[%# PRODUCT #%] [%# PRODUCT #%]
[%#############%] [%#############%]
<tr> <tr>
[% INCLUDE bug/field.html.tmpl [% PROCESS "bug/field-label.html.tmpl"
bug = bug, field = bug_fields.product, field = bug_fields.product
override_legal_values = bug.choices.product desc_url = 'describecomponents.cgi'
desc_url = 'describecomponents.cgi', value = bug.product value = bug.product
editable = bug.check_can_change_field('product', 0, 1) %] %]
<td class="field_value" id="field_container_product">
[% INCLUDE "global/product-select.html.tmpl"
id => "product"
name => "product"
value => bug.product
products => bug.choices.product
isselect => bug.check_can_change_field('product', 0, 1)
%]
</td>
</tr> </tr>
[%# Classification is here so that it can be used in value controllers [%# Classification is here so that it can be used in value controllers
......
[%# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
#%]
[%# INTERFACE:
# name: mandatory; field name
# id: optional; field id
# value: optional; default field value/selection
# classes: optional; an array of classes to be added
# onchange: optional; onchange attribute value
# disabled: optional; if true, the field is disabled
# accesskey: optional; accesskey attribute value
# add: optional; prepend menu option for value specified to start of select
# dontchange: optional; prepend menu option for "dontchange" to start of select
# multiple: optional; do multiselect box, value is size (height) of box
# title: optional; extra information to display as a tooltip
# products: optional; an array of custom product names
# isselect: optional; whether the product list should be displayed as a <select>
# or as just the plain text of its value.
# valueattribute: optional; the product attribute to be used for <option value="">,
# defaults to product name
#%]
[% IF !isselect.defined %]
[% isselect = 1 %]
[% END %]
[% DEFAULT valueattribute = "name" %]
[% IF isselect %]
<select name="[% name FILTER html %]"
[% IF id %] id="[% id FILTER html %]" [% END %]
[% IF classes %] class="[% classes.join(' ') FILTER html %]" [% END %]
[% IF onchange %] onchange="[% onchange FILTER html %]" [% END %]
[% IF disabled %] disabled="[% disabled FILTER html %]" [% END %]
[% IF accesskey %] accesskey="[% accesskey FILTER html %]" [% END %]
[% IF multiple %] multiple="multiple" size="[% multiple FILTER html %]" [% END %]
[% IF title %] title="[% title FILTER html %]" [% END %]
>
[% IF add %]
<option value="">[% add FILTER html %]</option>
[% END %]
[% IF dontchange %]
<option value="[% dontchange FILTER html %]">[% dontchange FILTER html %]</option>
[% END %]
[% IF Param('useclassification') %]
[% product_ids = {} %]
[% IF products %]
[% FOREACH p = products %]
[% key = p.id -%]
[% product_ids.$key = p.id -%]
[% END %]
[% END %]
[% FOREACH c = user.get_selectable_classifications %]
<optgroup label="[% c.name FILTER html %]">
[% FOREACH p = user.get_selectable_products(c.id) %]
[% NEXT IF (products && ! product_ids.exists(p.id)) %]
<option value="[% p.$valueattribute FILTER html %]"
[% " selected" IF (cgi.param(name) == p.name) || (value == p.name) %]>
[% p.name FILTER html %]
</option>
[% END %]
</optgroup>
[% END %]
[% ELSE %]
[% products = user.get_selectable_products UNLESS products %]
[% FOREACH p = products %]
<option value="[% p.$valueattribute FILTER html %]"
[% " selected" IF (cgi.param(name) == p.name) || (value == p.name) %]>
[% p.name FILTER html %]
</option>
[% END %]
[% END %]
</select>
[% ELSE %]
[% value.join(', ') FILTER html %]
[% END %]
...@@ -49,9 +49,11 @@ ...@@ -49,9 +49,11 @@
<th><label for="product">Product:</label></th> <th><label for="product">Product:</label></th>
<td> <td>
[% PROCESS selectmenu menuname = "product" [% INCLUDE "global/product-select.html.tmpl"
menuitems = products id => "product"
property = "name" %] name => "product"
dontchange => dontchange
%]
</td> </td>
<th><label for="version">Version:</label></th> <th><label for="version">Version:</label></th>
......
...@@ -51,13 +51,11 @@ ...@@ -51,13 +51,11 @@
<tr> <tr>
<td>Restrict to products:</td> <td>Restrict to products:</td>
<td> <td>
<select name="product" size="5" multiple="multiple"> [% INCLUDE "global/product-select.html.tmpl"
[% FOREACH p = user.get_selectable_products %] id => "product"
<option name="[% p.name FILTER html %]" name => "product"
[% ' selected="selected"' IF product.contains(p.name) %] multiple => 5
>[% p.name FILTER html %]</option> %]
[% END %]
</select>
</td> </td>
</tr> </tr>
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#%] #%]
[%# INTERFACE: [%# INTERFACE:
# products: an array of product names the user is allowed to view.
# datasets: an array of hashes with available statuses and resolutions. # datasets: an array of hashes with available statuses and resolutions.
# url_image: URL of the generated graph. # url_image: URL of the generated graph.
#%] #%]
...@@ -29,11 +28,12 @@ ...@@ -29,11 +28,12 @@
<tr> <tr>
<th>Product:</th> <th>Product:</th>
<td> <td>
<select id="product_id" name="product_id"> [% INCLUDE "global/product-select.html.tmpl"
[% FOREACH product = products %] id => "product_id"
<option value="[% product.id FILTER html %]">[% product.name || '-All-' FILTER html %]</option> name => "product_id"
[% END %] valueattribute => "id"
</select> add => "-All-"
%]
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -67,28 +67,12 @@ to some group are shown by default. ...@@ -67,28 +67,12 @@ to some group are shown by default.
</td> </td>
<th>Product:</th> <th>Product:</th>
<td> <td>
<select name="product" onchange="selectProduct(this, this.form.component, null, null, 'Any');"> [% INCLUDE "global/product-select.html.tmpl"
<option value="">Any</option> id => "product"
[% IF Param('useclassification') %] name => "product"
[% FOREACH c = user.get_selectable_classifications %] add => "Any"
<optgroup label="[% c.name FILTER html %]"> onchange => "selectProduct(this, this.form.component, null, null, 'Any');"
[% FOREACH p = user.get_selectable_products(c.id) %] %]
<option value="[% p.name FILTER html %]"
[% " selected" IF cgi.param('product') == p.name %]>
[% p.name FILTER html %]
</option>
[% END %]
</optgroup>
[% END %]
[% ELSE %]
[% FOREACH p = user.get_selectable_products %]
<option value="[% p.name FILTER html %]"
[% " selected" IF cgi.param('product') == p.name %]>
[% p.name FILTER html %]
</option>
[% END %]
[% END %]
</select>
</td> </td>
<th>Flag:</th> <th>Flag:</th>
<td> <td>
......
...@@ -60,30 +60,11 @@ for "crash secure SSL flash". ...@@ -60,30 +60,11 @@ for "crash secure SSL flash".
<label for="product">[% field_descs.product FILTER html %]:</label> <label for="product">[% field_descs.product FILTER html %]:</label>
</th> </th>
<td> <td>
<select name="product" id="product"> [% INCLUDE "global/product-select.html.tmpl"
<option value="">All</option> id => "product"
[% IF Param('useclassification') %] name => "product"
[% FOREACH c = classification %] add => "All"
<optgroup label="[% c.name FILTER html %]"> %]
[% FOREACH p = user.get_selectable_products(c.id) %]
[% IF p.components.size %]
<option value="[% p.name FILTER html %]"
[% " selected" IF default.product.contains(p.name) %]>
[% p.name FILTER html %]
</option>
[% END %]
[% END %]
</optgroup>
[% END %]
[% ELSE %]
[% FOREACH p = product %]
<option value="[% p.name FILTER html %]"
[% " selected" IF default.product.contains(p.name) %]>
[% p.name FILTER html %]
</option>
[% END %]
[% END %]
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
......
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