]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 377956: Tabular and graphical reports should support single-select custom fields...
authorlpsolit%gmail.com <>
Sat, 3 Jan 2009 01:08:27 +0000 (01:08 +0000)
committerlpsolit%gmail.com <>
Sat, 3 Jan 2009 01:08:27 +0000 (01:08 +0000)
query.cgi
report.cgi
template/en/default/search/search-report-select.html.tmpl

index 5998c31abb3fa01d76ebe649c3f0879ca08d07f3..f41310bb73d09a6da1962ab1e827467b983298b8 100755 (executable)
--- a/query.cgi
+++ b/query.cgi
@@ -116,7 +116,7 @@ sub PrefillForm {
     my $foundone = 0;
 
     # Nothing must be undef, otherwise the template complains.
-    foreach my $name ("bug_status", "resolution", "assigned_to",
+    my @list = ("bug_status", "resolution", "assigned_to",
                       "rep_platform", "priority", "bug_severity",
                       "classification", "product", "reporter", "op_sys",
                       "component", "version", "chfield", "chfieldfrom",
@@ -133,8 +133,13 @@ sub PrefillForm {
                       "x_axis_field", "y_axis_field", "z_axis_field",
                       "chart_format", "cumulate", "x_labels_vertical",
                       "category", "subcategory", "name", "newcategory",
-                      "newsubcategory", "public", "frequency") 
-    {
+                      "newsubcategory", "public", "frequency");
+    # These fields can also have default values (when used in reports).
+    my @custom_select_fields =
+      grep { $_->type == FIELD_TYPE_SINGLE_SELECT } Bugzilla->active_custom_fields;
+    push(@list, map { $_->name } @custom_select_fields);
+
+    foreach my $name (@list) {
         $default{$name} = [];
     }
  
@@ -343,6 +348,13 @@ if (($cgi->param('query_format') || $cgi->param('format') || "")
     $vars->{'category'} = Bugzilla::Chart::getVisibleSeries();
 }
 
+if ($cgi->param('format') && $cgi->param('format') =~ /^report-(table|graph)$/) {
+    # Get legal custom fields for tabular and graphical reports.
+    my @custom_fields_for_reports =
+      grep { $_->type == FIELD_TYPE_SINGLE_SELECT } Bugzilla->active_custom_fields;
+    $vars->{'custom_fields'} = \@custom_fields_for_reports;
+}
+
 $vars->{'known_name'} = $cgi->param('known_name');
 
 
index 61670417cab798bf6b38d91193d0ab382005647e..c84ed6208ed0842bdd87cbfaba3f789ccd6e5f34 100755 (executable)
@@ -119,6 +119,15 @@ $columns{'op_sys'}           = "bugs.op_sys";
 $columns{'votes'}            = "bugs.votes";
 $columns{'keywords'}         = "bugs.keywords";
 $columns{'target_milestone'} = "bugs.target_milestone";
+# Single-select fields are also accepted as valid column names.
+my @single_select_fields =
+  grep { $_->type == FIELD_TYPE_SINGLE_SELECT } Bugzilla->active_custom_fields;
+
+foreach my $custom_field (@single_select_fields) {
+    my $field_name = $custom_field->name;
+    $columns{$field_name} = "bugs.$field_name";
+}
+
 # One which means "nothing". Any number would do, really. It just gets SELECTed
 # so that we always select 3 items in the query.
 $columns{''}                 = "42217354";
index e893bf6a7ecffb2ddf0e2c9fd3ad81361c0666e6..de647871634d4d641e641f6208169628afa3c681 100644 (file)
         [% " selected" IF default.$name.0 == field %]>
         [% field_descs.$field || field FILTER html %]</option>
     [% END %]
+
+    [%# Single-select fields are also valid column names. %]
+    [% FOREACH field = custom_fields %]
+      <option value="[% field.name FILTER html %]"
+        [% " selected" IF default.$name.0 == field.name %]>
+        [% field.description FILTER html %]</option>
+    [% END %]
   </select>
 [% END %]