Commit 8816b8cb authored by myk%mozilla.org's avatar myk%mozilla.org

Fix for bug 171505: shows disabled flags in the UI

r=bbaetz a=justdave
parent c39803cc
...@@ -555,12 +555,11 @@ sub edit ...@@ -555,12 +555,11 @@ sub edit
SendSQL("SELECT product_id, component_id FROM bugs WHERE bug_id = $bugid"); SendSQL("SELECT product_id, component_id FROM bugs WHERE bug_id = $bugid");
my ($product_id, $component_id) = FetchSQLData(); my ($product_id, $component_id) = FetchSQLData();
my $flag_types = Bugzilla::FlagType::match({ 'target_type' => 'attachment' , my $flag_types = Bugzilla::FlagType::match({ 'target_type' => 'attachment' ,
'product_id' => $product_id , 'product_id' => $product_id ,
'component_id' => $component_id , 'component_id' => $component_id });
'is_active' => 1});
foreach my $flag_type (@$flag_types) { foreach my $flag_type (@$flag_types) {
$flag_type->{'flags'} = Bugzilla::Flag::match({ 'type_id' => $flag_type->{'id'}, $flag_type->{'flags'} = Bugzilla::Flag::match({ 'type_id' => $flag_type->{'id'},
'attach_id' => $::FORM{'id'} }); 'attach_id' => $::FORM{'id'} });
} }
$vars->{'flag_types'} = $flag_types; $vars->{'flag_types'} = $flag_types;
......
...@@ -209,8 +209,7 @@ sub show_bug { ...@@ -209,8 +209,7 @@ sub show_bug {
my $flag_types = my $flag_types =
Bugzilla::FlagType::match({ 'target_type' => 'bug', Bugzilla::FlagType::match({ 'target_type' => 'bug',
'product_id' => $bug{'product_id'}, 'product_id' => $bug{'product_id'},
'component_id' => $bug{'component_id'}, 'component_id' => $bug{'component_id'});
'is_active' => 1 });
foreach my $flag_type (@$flag_types) { foreach my $flag_type (@$flag_types) {
$flag_type->{'flags'} = $flag_type->{'flags'} =
Bugzilla::Flag::match({ 'bug_id' => $id , Bugzilla::Flag::match({ 'bug_id' => $id ,
...@@ -219,13 +218,21 @@ sub show_bug { ...@@ -219,13 +218,21 @@ sub show_bug {
} }
$vars->{'flag_types'} = $flag_types; $vars->{'flag_types'} = $flag_types;
# The number of types of flags that can be set on attachments # The number of types of flags that can be set on attachments to this bug
# to this bug. If none, flags won't be shown in the list of attachments. # and the number of flags on those attachments. One of these counts must be
$vars->{'num_attachment_flag_types'} = # greater than zero in order for the "flags" column to appear in the table
Bugzilla::FlagType::count({ 'target_type' => 'a', # of attachments.
'product_id' => $bug{'product_id'}, my $num_attachment_flag_types =
'component_id' => $bug{'component_id'}, Bugzilla::FlagType::count({ 'target_type' => 'attachment',
'is_active' => 1 }); 'product_id' => $bug{'product_id'},
'component_id' => $bug{'component_id'},
'is_active' => 1 });
my $num_attachment_flags =
Bugzilla::Flag::count({ 'target_type' => 'attachment',
'bug_id' => $id });
$vars->{'show_attachment_flags'}
= $num_attachment_flag_types || $num_attachment_flags;
# Dependencies # Dependencies
my @list; my @list;
......
...@@ -19,16 +19,13 @@ ...@@ -19,16 +19,13 @@
# Contributor(s): Myk Melez <myk@mozilla.org> # Contributor(s): Myk Melez <myk@mozilla.org>
#%] #%]
[%# Whether or not to include flags. %]
[% display_flags = num_attachment_flag_types > 0 %]
<br> <br>
<table cellspacing="0" cellpadding="4" border="1"> <table cellspacing="0" cellpadding="4" border="1">
<tr> <tr>
<th bgcolor="#cccccc" align="left">Attachment</th> <th bgcolor="#cccccc" align="left">Attachment</th>
<th bgcolor="#cccccc" align="left">Type</th> <th bgcolor="#cccccc" align="left">Type</th>
<th bgcolor="#cccccc" align="left">Created</th> <th bgcolor="#cccccc" align="left">Created</th>
[% IF display_flags %] [% IF show_attachment_flags %]
<th bgcolor="#cccccc" align="left">Flags</th> <th bgcolor="#cccccc" align="left">Flags</th>
[% END %] [% END %]
<th bgcolor="#cccccc" align="left">Actions</th> <th bgcolor="#cccccc" align="left">Actions</th>
...@@ -55,7 +52,7 @@ ...@@ -55,7 +52,7 @@
<td valign="top">[% attachment.date %]</td> <td valign="top">[% attachment.date %]</td>
[% IF display_flags %] [% IF show_attachment_flags %]
<td valign="top"> <td valign="top">
[% IF attachment.flags.size == 0 %] [% IF attachment.flags.size == 0 %]
<i>none</i> <i>none</i>
...@@ -85,7 +82,7 @@ ...@@ -85,7 +82,7 @@
[% END %] [% END %]
<tr> <tr>
<td colspan="[% display_flags ? 4 : 3 %]"> <td colspan="[% show_attachment_flags ? 4 : 3 %]">
<a href="attachment.cgi?bugid=[% bugid %]&amp;action=enter">Create a New Attachment</a> (proposed patch, testcase, etc.) <a href="attachment.cgi?bugid=[% bugid %]&amp;action=enter">Create a New Attachment</a> (proposed patch, testcase, etc.)
</td> </td>
<td colspan="1"> <td colspan="1">
......
...@@ -33,9 +33,13 @@ ...@@ -33,9 +33,13 @@
<td> <td>
<select name="flag-[% flag.id %]"> <select name="flag-[% flag.id %]">
<option value="X"></option> <option value="X"></option>
<option value="+" [% "selected" IF flag.status == "+" %]>+</option> [% IF flag.is_active %]
<option value="-" [% "selected" IF flag.status == "-" %]>-</option> <option value="+" [% "selected" IF flag.status == "+" %]>+</option>
<option value="?" [% "selected" IF flag.status == "?" %]>?</option> <option value="-" [% "selected" IF flag.status == "-" %]>-</option>
<option value="?" [% "selected" IF flag.status == "?" %]>?</option>
[% ELSE %]
<option value="[% flag.status %]" selected>[% flag.status %]</option>
[% END %]
</select> </select>
</td> </td>
<td> <td>
......
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