summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2014-04-07 16:42:08 +0200
committerDavid Lawrence <dkl@mozilla.com>2014-04-07 16:42:08 +0200
commitf3f8239ff36c892c0437fc8054a68e07d7ca0020 (patch)
tree3eb1e9f4ddde3f0e434927bfe285fb5ede1f8659
parent818b908a18de4862f060c64ad12f779ac8480f01 (diff)
downloadbugzilla-f3f8239ff36c892c0437fc8054a68e07d7ca0020.tar.gz
bugzilla-f3f8239ff36c892c0437fc8054a68e07d7ca0020.tar.xz
Bug 990982 - backport bug 539894 to bmo (Use <optgroup/> to group products into classifications in the product drop-down on show_bug.cgi)
r=glob
-rw-r--r--extensions/ProductDashboard/template/en/default/pages/productdashboard.html.tmpl14
-rwxr-xr-xreports.cgi6
-rw-r--r--template/en/default/admin/flag-type/edit.html.tmpl13
-rw-r--r--template/en/default/admin/flag-type/list.html.tmpl15
-rw-r--r--template/en/default/bug/edit.html.tmpl18
-rw-r--r--template/en/default/global/product-select.html.tmpl85
-rw-r--r--template/en/default/list/edit-multiple.html.tmpl8
-rw-r--r--template/en/default/reports/duplicates.html.tmpl12
-rw-r--r--template/en/default/reports/old-charts.html.tmpl11
-rw-r--r--template/en/default/request/queue.html.tmpl28
-rw-r--r--template/en/default/search/search-instant.html.tmpl28
-rw-r--r--template/en/default/search/search-specific.html.tmpl29
12 files changed, 147 insertions, 120 deletions
diff --git a/extensions/ProductDashboard/template/en/default/pages/productdashboard.html.tmpl b/extensions/ProductDashboard/template/en/default/pages/productdashboard.html.tmpl
index 82de063aa..c0c5dc6b2 100644
--- a/extensions/ProductDashboard/template/en/default/pages/productdashboard.html.tmpl
+++ b/extensions/ProductDashboard/template/en/default/pages/productdashboard.html.tmpl
@@ -139,16 +139,10 @@
[% END %]
<strong>Choose product:</strong>
- <select name="product">
- [% FOREACH c = classifications %]
- <optgroup label="[% c.name FILTER html %]">
- [% FOREACH p = c.products %]
- <option value="[% p.name FILTER html %]"
- [% IF p.name == product.name %]selected="selected"[% END %]>
- [% p.name FILTER html %]</option>
- [% END %]</optgroup>
- [% END %]
- </select>
+ [% INCLUDE "global/product-select.html.tmpl"
+ id => "product"
+ name => "product"
+ %]
<select name="bug_status" id="bug_status">
[% statuses = [ { name = 'open', label = "Open $terms.Bugs" },
{ name = 'closed', label = "Closed $terms.Bugs" },
diff --git a/reports.cgi b/reports.cgi
index 01bbb50c7..edc7eb55b 100755
--- a/reports.cgi
+++ b/reports.cgi
@@ -77,13 +77,7 @@ if (!$product_name) {
push(@datasets, $datasets);
}
- # We only want those products that the user has permissions for.
- my @myproducts = ('-All-');
- # Extract product names from objects and add them to the list.
- push( @myproducts, map { $_->name } @{$user->get_selectable_products} );
-
$vars->{'datasets'} = \@datasets;
- $vars->{'products'} = \@myproducts;
print $cgi->header();
}
diff --git a/template/en/default/admin/flag-type/edit.html.tmpl b/template/en/default/admin/flag-type/edit.html.tmpl
index 69dc05bd3..9043db96d 100644
--- a/template/en/default/admin/flag-type/edit.html.tmpl
+++ b/template/en/default/admin/flag-type/edit.html.tmpl
@@ -108,12 +108,13 @@
<tr>
<td style="vertical-align: top;">
<b>Product/Component:</b><br>
- <select name="product" onchange="selectProduct(this, this.form.component, null, null, '__Any__');">
- <option value="">__Any__</option>
- [% FOREACH prod = products %]
- <option value="[% prod.name FILTER html %]">[% prod.name FILTER html %]</option>
- [% END %]
- </select><br>
+ [% INCLUDE "global/product-select.html.tmpl"
+ id => "product"
+ name => "product"
+ add => "__Any__"
+ onchange => "selectProduct(this, this.form.component, null, null, '__Any__');"
+ products => products
+ %]<br>
<select name="component">
<option value="">__Any__</option>
[% FOREACH comp = components %]
diff --git a/template/en/default/admin/flag-type/list.html.tmpl b/template/en/default/admin/flag-type/list.html.tmpl
index 220db8900..3d1be7bfb 100644
--- a/template/en/default/admin/flag-type/list.html.tmpl
+++ b/template/en/default/admin/flag-type/list.html.tmpl
@@ -61,14 +61,13 @@
<tr>
<th><label for="product">Product:</label></th>
<td>
- <select name="product" onchange="selectProduct(this, this.form.component, null, null, '__Any__');">
- <option value="">__Any__</option>
- [% FOREACH prod = products %]
- <option value="[% prod.name FILTER html %]"
- [% " selected" IF selected_product == prod.name %]>
- [% prod.name FILTER html %]</option>
- [% END %]
- </select>
+ [% INCLUDE "global/product-select.html.tmpl"
+ id => "product"
+ name => "product"
+ add => "__Any__"
+ onchange => "selectProduct(this, this.form.component, null, null, '__Any__');"
+ products => products
+ %]
</td>
<th><label for="component">Component:</label></th>
<td>
diff --git a/template/en/default/bug/edit.html.tmpl b/template/en/default/bug/edit.html.tmpl
index fe6b27bc7..5ea34cc59 100644
--- a/template/en/default/bug/edit.html.tmpl
+++ b/template/en/default/bug/edit.html.tmpl
@@ -303,11 +303,19 @@
[%# PRODUCT #%]
[%#############%]
<tr>
- [% INCLUDE bug/field.html.tmpl
- bug = bug, field = bug_fields.product,
- override_legal_values = bug.choices.product
- desc_url = 'describecomponents.cgi', value = bug.product
- editable = bug.check_can_change_field('product', 0, 1) %]
+ [% PROCESS "bug/field-label.html.tmpl"
+ field = bug_fields.product
+ desc_url = 'describecomponents.cgi'
+ %]
+ <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>
[%# Classification is here so that it can be used in value controllers
diff --git a/template/en/default/global/product-select.html.tmpl b/template/en/default/global/product-select.html.tmpl
new file mode 100644
index 000000000..fb07b7cd4
--- /dev/null
+++ b/template/en/default/global/product-select.html.tmpl
@@ -0,0 +1,85 @@
+[%# 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 %]
+ [% class_products = [] %]
+ [% FOREACH p = user.get_selectable_products(c.id) %]
+ [% NEXT IF (products && !product_ids.exists(p.id)) %]
+ [% class_products.push(p) %]
+ [% END %]
+ [% NEXT UNLESS class_products.size > 0 %]
+ <optgroup label="[% c.name FILTER html %]">
+ [% FOREACH p = class_products %]
+ <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 %]
diff --git a/template/en/default/list/edit-multiple.html.tmpl b/template/en/default/list/edit-multiple.html.tmpl
index 6a3269dff..d560a9d57 100644
--- a/template/en/default/list/edit-multiple.html.tmpl
+++ b/template/en/default/list/edit-multiple.html.tmpl
@@ -61,9 +61,11 @@
<th><label for="product">Product:</label></th>
<td>
- [% PROCESS selectmenu menuname = "product"
- menuitems = products
- property = "name" %]
+ [% INCLUDE "global/product-select.html.tmpl"
+ id => "product"
+ name => "product"
+ dontchange => dontchange
+ %]
</td>
<th><label for="version">Version:</label></th>
diff --git a/template/en/default/reports/duplicates.html.tmpl b/template/en/default/reports/duplicates.html.tmpl
index ff1c271fe..d17e1a094 100644
--- a/template/en/default/reports/duplicates.html.tmpl
+++ b/template/en/default/reports/duplicates.html.tmpl
@@ -82,13 +82,11 @@
</td>
<td rowspan="4" valign="top">Restrict to products:</td>
<td rowspan="4" valign="top">
- <select name="product" size="5" multiple="multiple">
- [% FOREACH p = user.get_selectable_products %]
- <option name="[% p.name FILTER html %]"
- [% ' selected="selected"' IF product.contains(p.name) %]
- >[% p.name FILTER html %]</option>
- [% END %]
- </select>
+ [% INCLUDE "global/product-select.html.tmpl"
+ id => "product"
+ name => "product"
+ multiple => 5
+ %]
</td>
</tr>
diff --git a/template/en/default/reports/old-charts.html.tmpl b/template/en/default/reports/old-charts.html.tmpl
index 4bdc0cffa..2f50b31c6 100644
--- a/template/en/default/reports/old-charts.html.tmpl
+++ b/template/en/default/reports/old-charts.html.tmpl
@@ -14,7 +14,6 @@
#%]
[%# INTERFACE:
- # products: an array of product names the user is allowed to view.
# datasets: an array of hashes with available statuses and resolutions.
# url_image: URL of the generated graph.
#%]
@@ -37,11 +36,11 @@
<tr>
<th>Product:</th>
<td align="center">
- <select id="product" name="product">
- [% FOREACH product = products %]
- <option value="[% product FILTER html %]">[% product FILTER html %]</option>
- [% END %]
- </select>
+ [% INCLUDE "global/product-select.html.tmpl"
+ id => "product"
+ name => "product"
+ add => "-All-"
+ %]
</td>
</tr>
<tr>
diff --git a/template/en/default/request/queue.html.tmpl b/template/en/default/request/queue.html.tmpl
index 261db0438..9ba8cbc45 100644
--- a/template/en/default/request/queue.html.tmpl
+++ b/template/en/default/request/queue.html.tmpl
@@ -81,28 +81,12 @@ to some group are shown by default.
</td>
<th>Product:</th>
<td>
- <select name="product" onchange="selectProduct(this, this.form.component, null, null, 'Any');">
- <option value="">Any</option>
- [% IF Param('useclassification') %]
- [% FOREACH c = user.get_selectable_classifications %]
- <optgroup label="[% c.name FILTER html %]">
- [% 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>
+ [% INCLUDE "global/product-select.html.tmpl"
+ id => "product"
+ name => "product"
+ add => "Any"
+ onchange => "selectProduct(this, this.form.component, null, null, 'Any');"
+ %]
</td>
<th>Flag:</th>
<td>
diff --git a/template/en/default/search/search-instant.html.tmpl b/template/en/default/search/search-instant.html.tmpl
index 5d75d1996..94cb619d0 100644
--- a/template/en/default/search/search-instant.html.tmpl
+++ b/template/en/default/search/search-instant.html.tmpl
@@ -41,29 +41,11 @@ YAHOO.bugzilla.instantSearch.setLabels( {
<b><label for="product">Product:</label></b>
</td>
<td>
- <select name="product" id="product">
- [% IF Param('useclassification') %]
- [% FOREACH c = classification %]
- <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 lsearch(default.product, p.name) != -1 %]>
- [% p.name FILTER html %]
- </option>
- [% END %]
- [% END %]
- </optgroup>
- [% END %]
- [% ELSE %]
- [% FOREACH p = product %]
- <option value="[% p.name FILTER html %]"
- [% " selected" IF lsearch(default.product, p.name) != -1 %]>
- [% p.name FILTER html %]
- </option>
- [% END %]
- [% END %]
- </select>
+ [% INCLUDE "global/product-select.html.tmpl"
+ id => "product"
+ name => "product"
+ value => default.product.0
+ %]
</td>
</tr>
<tr>
diff --git a/template/en/default/search/search-specific.html.tmpl b/template/en/default/search/search-specific.html.tmpl
index 7e5de2c4a..ea522a877 100644
--- a/template/en/default/search/search-specific.html.tmpl
+++ b/template/en/default/search/search-specific.html.tmpl
@@ -67,30 +67,11 @@ for "crash secure SSL flash".
<label for="product">[% field_descs.product FILTER html %]:</label>
</th>
<td>
- <select name="product" id="product">
- <option value="">All</option>
- [% IF Param('useclassification') %]
- [% FOREACH c = classification %]
- <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>
+ [% INCLUDE "global/product-select.html.tmpl"
+ id => "product"
+ name => "product"
+ add => "All"
+ %]
</td>
</tr>
<tr>