]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 539894: Use <optgroup/> to group products into classifications in the product...
authorrojanu <aliustek@gmail.com>
Wed, 2 Apr 2014 08:35:08 +0000 (16:35 +0800)
committerByron Jones <glob@mozilla.com>
Wed, 2 Apr 2014 08:35:08 +0000 (16:35 +0800)
r=glob, a=justdave

reports.cgi
template/en/default/admin/flag-type/edit.html.tmpl
template/en/default/admin/flag-type/list.html.tmpl
template/en/default/bug/edit.html.tmpl
template/en/default/global/product-select.html.tmpl [new file with mode: 0644]
template/en/default/list/edit-multiple.html.tmpl
template/en/default/reports/duplicates.html.tmpl
template/en/default/reports/old-charts.html.tmpl
template/en/default/request/queue.html.tmpl
template/en/default/search/search-specific.html.tmpl

index 618feb8c88b2829efda27ab3ed70429afbecd96a..1f1791e4228a740d22cf5ee747b2a72fe8faaf2f 100755 (executable)
@@ -59,13 +59,7 @@ if (! defined($product_id)) {
         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->{'products'} = \@myproducts;
 
     print $cgi->header();
 }
index 4ee4a999ca14cfb97d29a8374530913bc1c7fb45..5f45b6b768590a4b083a1dc57caddff3643936ad 100644 (file)
           <tr>
             <th class="top left">
               Product/Component:<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 %]
index 3783cade839a7f85fb2ebb6866c13bc744be9788..25b2e3390c00ffea5c1ab0561b41ca6f7174a190 100644 (file)
 <form id="flagtype_form" name="flagtype_form" action="editflagtypes.cgi" method="get">
   <div class="inline">
     <label for="product">Product:</label>
-    <select id="product" 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="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
+    %]
   </div>
 
   <div class="inline">
index 61fa2c1ec61cc62a4deeca26a1f080ec40bd6821..ae33146a7ba0b051f059df4de9e31c3d7b96e0e9 100644 (file)
     [%#  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'
+         value = bug.product
+        %]
+      <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 (file)
index 0000000..8e43c9d
--- /dev/null
@@ -0,0 +1,80 @@
+[%# 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 %]
index 2282d69f4c1983658619af862612fbfb0f0ef214..5adc47a59b09bcbc0d030603c6130d02962771bd 100644 (file)
 
     <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>
index 67d1f233e8a8bc15b15441964a8ecef557fde1bf..0d47aae75b0d6c53e915f0f9a6bb78eebe17681a 100644 (file)
     <tr>
       <td>Restrict to products:</td>
       <td>
-        <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>
 
index b3ebe386db687416c159b20437bf524edacbb5df..acebca74d33b0c0172dc9a75c60724b289963b5e 100644 (file)
@@ -7,7 +7,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.
   #%]
         <tr>
           <th>Product:</th>
           <td>
-            <select id="product_id" name="product_id">
-              [% FOREACH product = products %]
-                <option value="[% product.id FILTER html %]">[% product.name || '-All-' FILTER html %]</option>
-              [% END %]
-            </select>
+            [% INCLUDE "global/product-select.html.tmpl"
+              id   => "product_id"
+              name => "product_id"
+              valueattribute => "id"
+              add  => "-All-"
+            %]
           </td>
         </tr>
         <tr>
index 07dec7315ce14f6ff2567811cf5bdcc0f997fe22..b2b76ba0bb3017dc6a9a007b53b41e72b9e0d927 100644 (file)
@@ -67,28 +67,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>
index 4d1b4c7ef992c5b5f61390ea2b726ed99affb983..e5d59abfb2ed89c18f37b62d2de58b67684a32a6 100644 (file)
@@ -60,30 +60,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>