]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 471771: editflagtypes.cgi should display the number of flags per type - Patch...
authorlpsolit%gmail.com <>
Thu, 1 Jan 2009 19:04:52 +0000 (19:04 +0000)
committerlpsolit%gmail.com <>
Thu, 1 Jan 2009 19:04:52 +0000 (19:04 +0000)
editflagtypes.cgi
template/en/default/admin/flag-type/list.html.tmpl

index 4117c91e8b91a9953880755b42d44233d67301a5..d77c6b8a3cd3f3a771acdb96d4ffe7ab8ae82045 100755 (executable)
@@ -100,6 +100,7 @@ sub list {
     my $component = validateComponent($product, scalar $cgi->param('component'));
     my $product_id = $product ? $product->id : 0;
     my $component_id = $component ? $component->id : 0;
+    my $show_flag_counts = (defined $cgi->param('show_flag_counts')) ? 1 : 0;
 
     # Define the variables and functions that will be passed to the UI template.
     $vars->{'selected_product'} = $cgi->param('product');
@@ -140,6 +141,20 @@ sub list {
                                          'group' => scalar $cgi->param('group')});
     }
 
+    if ($show_flag_counts) {
+        my %bug_lists;
+        my %map = ('+' => 'granted', '-' => 'denied', '?' => 'pending');
+
+        foreach my $flagtype (@$bug_flagtypes, @$attach_flagtypes) {
+            $bug_lists{$flagtype->id} = {};
+            my $flags = Bugzilla::Flag->match({type_id => $flagtype->id});
+            # Build lists of bugs, triaged by flag status.
+            map { push(@{$bug_lists{$flagtype->id}->{$map{$_->status}}}, $_->bug_id) } @$flags;
+        }
+        $vars->{'bug_lists'} = \%bug_lists;
+        $vars->{'show_flag_counts'} = 1;
+    }
+
     $vars->{'bug_types'} = $bug_flagtypes;
     $vars->{'attachment_types'} = $attach_flagtypes;
 
index d4bba945a289a8f8f4866db0c31584e89d76bea1..497d3b3d5f46cf1345a8f13695e9f8312b24abb3 100644 (file)
@@ -16,6 +16,7 @@
   # Rights Reserved.
   #
   # Contributor(s): Myk Melez <myk@mozilla.org>
+  #                 Frédéric Buclin <LpSolit@gmail.com>
   #%]
 
 [% PROCESS global/variables.none.tmpl %]
           [% END %]
         </select>
       </td>
+      <td>
+        <input type="checkbox" id="show_flag_counts" name="show_flag_counts" value="1"
+               [%+ 'checked="checked"' IF show_flag_counts %]>
+        <label for="show_flag_counts">Show flag counts</label>
+      </td>
       <td><input type="submit" id="submit" value="Filter"></td>
     </tr>
   </table>
       <th>Properties</th>
       <th>Grant group</th>
       <th>Request group</th>
+      [% IF show_flag_counts %]
+        <th>Flags</th>
+        [%# Note to translators: translate the strings in quotes only. %]
+        [% state_desc = {granted = 'granted' denied = 'denied' pending = 'pending'} %]
+      [% END %]
       <th>Actions</th>
     </tr>
 
         </td>
         <td>[% IF type.grant_group %][% type.grant_group.name FILTER html %][% END %]</td>
         <td>[% IF type.request_group %][% type.request_group.name FILTER html %][% END %]</td>
+        [% IF show_flag_counts %]
+          <td>
+            [% FOREACH state = ['granted', 'pending', 'denied'] %]
+              [% bug_list = bug_lists.${type.id}.$state || [] %]
+              [% IF bug_list.size %]
+                <a href="buglist.cgi?bug_id=[% bug_list.unique.nsort.join(",") FILTER html %]">
+                  [% bug_list.size FILTER html %] [%+ state_desc.$state FILTER html %]
+                </a>
+                <br>
+              [% ELSE %]
+                0 [% state_desc.$state FILTER html %]<br>
+              [% END %]
+            [% END %]
+          </td>
+        [% END %]
         <td>
           <a href="editflagtypes.cgi?action=copy&amp;id=[% type.id %]">Copy</a>
           | <a href="editflagtypes.cgi?action=confirmdelete&amp;id=[% type.id %]">Delete</a>