Commit e394756f authored by ghendricks%novell.com's avatar ghendricks%novell.com

Bug 456743 - Add the ability to disable field values (mark them as inactive)

patch by ghendricks@novell.com r=LpSolit, a=LpSolit
parent f304db03
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
# Contributor(s): Dan Mosedale <dmose@mozilla.org> # Contributor(s): Dan Mosedale <dmose@mozilla.org>
# Frédéric Buclin <LpSolit@gmail.com> # Frédéric Buclin <LpSolit@gmail.com>
# Myk Melez <myk@mozilla.org> # Myk Melez <myk@mozilla.org>
# Greg Hendricks <ghendricks@novell.com>
=head1 NAME =head1 NAME
...@@ -1033,8 +1034,14 @@ sub check_field { ...@@ -1033,8 +1034,14 @@ sub check_field {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
# If $legalsRef is undefined, we use the default valid values. # If $legalsRef is undefined, we use the default valid values.
# Valid values for this check are all possible values.
# Using get_legal_values would only return active values, but since
# some bugs may have inactive values set, we want to check them too.
unless (defined $legalsRef) { unless (defined $legalsRef) {
$legalsRef = get_legal_field_values($name); $legalsRef = Bugzilla::Field->new({name => $name})->legal_values;
my @values = map($_->name, @$legalsRef);
$legalsRef = \@values;
} }
if (!defined($value) if (!defined($value)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
# The Original Code is the Bugzilla Bug Tracking System. # The Original Code is the Bugzilla Bug Tracking System.
# #
# Contributor(s): Max Kanat-Alexander <mkanat@bugzilla.org> # Contributor(s): Max Kanat-Alexander <mkanat@bugzilla.org>
# Greg Hendricks <ghendricks@novell.com>
use strict; use strict;
...@@ -40,12 +41,14 @@ use constant DB_COLUMNS => qw( ...@@ -40,12 +41,14 @@ use constant DB_COLUMNS => qw(
id id
value value
sortkey sortkey
isactive
visibility_value_id visibility_value_id
); );
use constant UPDATE_COLUMNS => qw( use constant UPDATE_COLUMNS => qw(
value value
sortkey sortkey
isactive
visibility_value_id visibility_value_id
); );
...@@ -58,6 +61,7 @@ use constant VALIDATORS => { ...@@ -58,6 +61,7 @@ use constant VALIDATORS => {
value => \&_check_value, value => \&_check_value,
sortkey => \&_check_sortkey, sortkey => \&_check_sortkey,
visibility_value_id => \&_check_visibility_value_id, visibility_value_id => \&_check_visibility_value_id,
isactive => \&Bugzilla::Object::check_boolean,
}; };
use constant CLASS_MAP => { use constant CLASS_MAP => {
...@@ -211,6 +215,7 @@ sub _check_if_controller { ...@@ -211,6 +215,7 @@ sub _check_if_controller {
# Accessors # # Accessors #
############# #############
sub is_active { return $_[0]->{'isactive'}; }
sub sortkey { return $_[0]->{'sortkey'}; } sub sortkey { return $_[0]->{'sortkey'}; }
sub bug_count { sub bug_count {
...@@ -301,6 +306,7 @@ sub controlled_values { ...@@ -301,6 +306,7 @@ sub controlled_values {
# Mutators # # Mutators #
############ ############
sub set_is_active { $_[0]->set('isactive', $_[1]); }
sub set_name { $_[0]->set('value', $_[1]); } sub set_name { $_[0]->set('value', $_[1]); }
sub set_sortkey { $_[0]->set('sortkey', $_[1]); } sub set_sortkey { $_[0]->set('sortkey', $_[1]); }
sub set_visibility_value { sub set_visibility_value {
......
...@@ -188,6 +188,9 @@ if ($action eq 'update') { ...@@ -188,6 +188,9 @@ if ($action eq 'update') {
$value->set_name($cgi->param('value_new')); $value->set_name($cgi->param('value_new'));
$value->set_sortkey($cgi->param('sortkey')); $value->set_sortkey($cgi->param('sortkey'));
$value->set_visibility_value($cgi->param('visibility_value_id')); $value->set_visibility_value($cgi->param('visibility_value_id'));
if (!($value->is_static || $value->is_default)) {
$value->set_is_active($cgi->param('is_active'));
}
$vars->{'changes'} = $value->update(); $vars->{'changes'} = $value->update();
delete_token($token); delete_token($token);
$vars->{'message'} = 'field_value_updated'; $vars->{'message'} = 'field_value_updated';
......
...@@ -232,11 +232,6 @@ if (Bugzilla->params->{'usetargetmilestone'}) { ...@@ -232,11 +232,6 @@ if (Bugzilla->params->{'usetargetmilestone'}) {
$vars->{'have_keywords'} = Bugzilla::Keyword::keyword_count(); $vars->{'have_keywords'} = Bugzilla::Keyword::keyword_count();
my $legal_resolutions = get_legal_field_values('resolution');
push(@$legal_resolutions, "---"); # Oy, what a hack.
# Another hack - this array contains "" for some reason. See bug 106589.
$vars->{'resolution'} = [grep ($_, @$legal_resolutions)];
my @chfields; my @chfields;
push @chfields, "[Bug creation]"; push @chfields, "[Bug creation]";
...@@ -262,11 +257,12 @@ if (Bugzilla->user->in_group(Bugzilla->params->{'timetrackinggroup'})) { ...@@ -262,11 +257,12 @@ if (Bugzilla->user->in_group(Bugzilla->params->{'timetrackinggroup'})) {
} }
@chfields = (sort(@chfields)); @chfields = (sort(@chfields));
$vars->{'chfield'} = \@chfields; $vars->{'chfield'} = \@chfields;
$vars->{'bug_status'} = get_legal_field_values('bug_status'); $vars->{'bug_status'} = Bugzilla::Field->new({name => 'bug_status'})->legal_values;
$vars->{'rep_platform'} = get_legal_field_values('rep_platform'); $vars->{'rep_platform'} = Bugzilla::Field->new({name => 'rep_platform'})->legal_values;
$vars->{'op_sys'} = get_legal_field_values('op_sys'); $vars->{'op_sys'} = Bugzilla::Field->new({name => 'op_sys'})->legal_values;
$vars->{'priority'} = get_legal_field_values('priority'); $vars->{'priority'} = Bugzilla::Field->new({name => 'priority'})->legal_values;
$vars->{'bug_severity'} = get_legal_field_values('bug_severity'); $vars->{'bug_severity'} = Bugzilla::Field->new({name => 'bug_severity'})->legal_values;
$vars->{'resolution'} = Bugzilla::Field->new({name => 'resolution'})->legal_values;
# Boolean charts # Boolean charts
my @fields = Bugzilla->get_fields({ obsolete => 0 }); my @fields = Bugzilla->get_fields({ obsolete => 0 });
......
...@@ -81,8 +81,19 @@ ...@@ -81,8 +81,19 @@
</td> </td>
</tr> </tr>
[% END %] [% END %]
<tr>
<th align="right"><label for="is_active">Enabled for [% terms.bugs %]:</label></th>
<td><input id="is_active" name="is_active" type="checkbox" value="1"
[%+ 'checked="checked"' IF value.is_active %]
[%+ 'disabled="disabled"' IF value.is_default OR value.is_static %]>
[% IF value.is_default %]
This value is selected as default in the parameters for this field. It cannot be disabled.
[% ELSIF value.is_static %]
This value is non-deletable and cannot be disabled.
[% END %]
</td>
</tr>
</table> </table>
<input type="hidden" name="value" value="[% value.name FILTER html %]"> <input type="hidden" name="value" value="[% value.name FILTER html %]">
<input type="hidden" name="action" value="update"> <input type="hidden" name="action" value="update">
<input type="hidden" name="field" value="[% field.name FILTER html %]"> <input type="hidden" name="field" value="[% field.name FILTER html %]">
......
...@@ -51,6 +51,11 @@ ...@@ -51,6 +51,11 @@
heading => "Sortkey" heading => "Sortkey"
}, },
{ {
name => "isactive"
heading => "Enabled for $terms.bugs"
yesno_field => 1
},
{
name => "action" name => "action"
heading => "Action" heading => "Action"
content => "Delete" content => "Delete"
......
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
selected="selected" selected="selected"
[% ELSIF (control_field && control_value [% ELSIF (control_field && control_value
&& !bug.${control_field.name}.contains(control_value.name)) && !bug.${control_field.name}.contains(control_value.name))
|| (field.name == "product" && !legal_value.is_active) || !legal_value.is_active
%] %]
class="bz_hidden_option" disabled="disabled" class="bz_hidden_option" disabled="disabled"
[% END %]> [% END %]>
......
...@@ -611,15 +611,17 @@ function doOnSelectProduct(selectmode) { ...@@ -611,15 +611,17 @@ function doOnSelectProduct(selectmode) {
<td align="left"> <td align="left">
<select name="[% sel.name %]" id="[% sel.name %]" <select name="[% sel.name %]" id="[% sel.name %]"
multiple="multiple" size="[% sel.size %]"> multiple="multiple" size="[% sel.size %]">
[% FOREACH name = ${sel.name} %] [% FOREACH value = ${sel.name} %]
<option value="[% name FILTER html %]" [%# This only applies for Resolution really %]
[% " selected" IF lsearch(default.${sel.name}, name) != -1 %]> <option value="[% value.name OR '---' FILTER html %]"
[% " selected" IF lsearch(default.${sel.name}, value.name) != -1 %]>
[% IF sel.name == "bug_status" %] [% IF sel.name == "bug_status" %]
[% get_status(name) FILTER html %] [% get_status(value.name) FILTER html %]
[% ELSIF sel.name == "resolution" %] [% ELSIF sel.name == "resolution" %]
[% get_resolution(name) FILTER html %] [%# Again, resolution has that odd empty value. Replace it with '---' %]
[% get_resolution(value.name) OR '---' FILTER html %]
[% ELSE %] [% ELSE %]
[% name FILTER html %] [% value.name FILTER html %]
[% END %] [% END %]
</option> </option>
[% END %] [% END %]
......
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