From e394756f42902de5eade4f6738127c25fa2bcef7 Mon Sep 17 00:00:00 2001 From: "ghendricks%novell.com" <> Date: Fri, 17 Jul 2009 22:40:09 +0000 Subject: Bug 456743 - Add the ability to disable field values (mark them as inactive) patch by ghendricks@novell.com r=LpSolit, a=LpSolit --- Bugzilla/Field.pm | 9 ++++++++- Bugzilla/Field/Choice.pm | 12 +++++++++--- editvalues.cgi | 3 +++ query.cgi | 16 ++++++---------- template/en/default/admin/fieldvalues/edit.html.tmpl | 13 ++++++++++++- template/en/default/admin/fieldvalues/list.html.tmpl | 5 +++++ template/en/default/bug/field.html.tmpl | 2 +- template/en/default/search/form.html.tmpl | 14 ++++++++------ 8 files changed, 52 insertions(+), 22 deletions(-) diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 1cc89239e..a71afef35 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -15,6 +15,7 @@ # Contributor(s): Dan Mosedale # Frédéric Buclin # Myk Melez +# Greg Hendricks =head1 NAME @@ -1033,8 +1034,14 @@ sub check_field { my $dbh = Bugzilla->dbh; # 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) { - $legalsRef = get_legal_field_values($name); + $legalsRef = Bugzilla::Field->new({name => $name})->legal_values; + my @values = map($_->name, @$legalsRef); + $legalsRef = \@values; + } if (!defined($value) diff --git a/Bugzilla/Field/Choice.pm b/Bugzilla/Field/Choice.pm index f23b0c46d..ce1020d6b 100644 --- a/Bugzilla/Field/Choice.pm +++ b/Bugzilla/Field/Choice.pm @@ -17,6 +17,7 @@ # The Original Code is the Bugzilla Bug Tracking System. # # Contributor(s): Max Kanat-Alexander +# Greg Hendricks use strict; @@ -40,12 +41,14 @@ use constant DB_COLUMNS => qw( id value sortkey + isactive visibility_value_id ); use constant UPDATE_COLUMNS => qw( value sortkey + isactive visibility_value_id ); @@ -58,6 +61,7 @@ use constant VALIDATORS => { value => \&_check_value, sortkey => \&_check_sortkey, visibility_value_id => \&_check_visibility_value_id, + isactive => \&Bugzilla::Object::check_boolean, }; use constant CLASS_MAP => { @@ -211,7 +215,8 @@ sub _check_if_controller { # Accessors # ############# -sub sortkey { return $_[0]->{'sortkey'}; } +sub is_active { return $_[0]->{'isactive'}; } +sub sortkey { return $_[0]->{'sortkey'}; } sub bug_count { my $self = shift; @@ -301,8 +306,9 @@ sub controlled_values { # Mutators # ############ -sub set_name { $_[0]->set('value', $_[1]); } -sub set_sortkey { $_[0]->set('sortkey', $_[1]); } +sub set_is_active { $_[0]->set('isactive', $_[1]); } +sub set_name { $_[0]->set('value', $_[1]); } +sub set_sortkey { $_[0]->set('sortkey', $_[1]); } sub set_visibility_value { my ($self, $value) = @_; $self->set('visibility_value_id', $value); diff --git a/editvalues.cgi b/editvalues.cgi index 3c553c8d1..477bf8696 100755 --- a/editvalues.cgi +++ b/editvalues.cgi @@ -188,6 +188,9 @@ if ($action eq 'update') { $value->set_name($cgi->param('value_new')); $value->set_sortkey($cgi->param('sortkey')); $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(); delete_token($token); $vars->{'message'} = 'field_value_updated'; diff --git a/query.cgi b/query.cgi index eed492114..577410681 100755 --- a/query.cgi +++ b/query.cgi @@ -232,11 +232,6 @@ if (Bugzilla->params->{'usetargetmilestone'}) { $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; push @chfields, "[Bug creation]"; @@ -262,11 +257,12 @@ if (Bugzilla->user->in_group(Bugzilla->params->{'timetrackinggroup'})) { } @chfields = (sort(@chfields)); $vars->{'chfield'} = \@chfields; -$vars->{'bug_status'} = get_legal_field_values('bug_status'); -$vars->{'rep_platform'} = get_legal_field_values('rep_platform'); -$vars->{'op_sys'} = get_legal_field_values('op_sys'); -$vars->{'priority'} = get_legal_field_values('priority'); -$vars->{'bug_severity'} = get_legal_field_values('bug_severity'); +$vars->{'bug_status'} = Bugzilla::Field->new({name => 'bug_status'})->legal_values; +$vars->{'rep_platform'} = Bugzilla::Field->new({name => 'rep_platform'})->legal_values; +$vars->{'op_sys'} = Bugzilla::Field->new({name => 'op_sys'})->legal_values; +$vars->{'priority'} = Bugzilla::Field->new({name => 'priority'})->legal_values; +$vars->{'bug_severity'} = Bugzilla::Field->new({name => 'bug_severity'})->legal_values; +$vars->{'resolution'} = Bugzilla::Field->new({name => 'resolution'})->legal_values; # Boolean charts my @fields = Bugzilla->get_fields({ obsolete => 0 }); diff --git a/template/en/default/admin/fieldvalues/edit.html.tmpl b/template/en/default/admin/fieldvalues/edit.html.tmpl index b01415577..5650ee87b 100644 --- a/template/en/default/admin/fieldvalues/edit.html.tmpl +++ b/template/en/default/admin/fieldvalues/edit.html.tmpl @@ -81,8 +81,19 @@ [% END %] + + + + [% 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 %] + + - diff --git a/template/en/default/admin/fieldvalues/list.html.tmpl b/template/en/default/admin/fieldvalues/list.html.tmpl index fdc22d912..3f750ebca 100644 --- a/template/en/default/admin/fieldvalues/list.html.tmpl +++ b/template/en/default/admin/fieldvalues/list.html.tmpl @@ -50,6 +50,11 @@ name => "sortkey" heading => "Sortkey" }, + { + name => "isactive" + heading => "Enabled for $terms.bugs" + yesno_field => 1 + }, { name => "action" heading => "Action" diff --git a/template/en/default/bug/field.html.tmpl b/template/en/default/bug/field.html.tmpl index 21a73a805..039910f1d 100644 --- a/template/en/default/bug/field.html.tmpl +++ b/template/en/default/bug/field.html.tmpl @@ -142,7 +142,7 @@ selected="selected" [% ELSIF (control_field && control_value && !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" [% END %]> diff --git a/template/en/default/search/form.html.tmpl b/template/en/default/search/form.html.tmpl index 46df426c1..078ff8c6b 100644 --- a/template/en/default/search/form.html.tmpl +++ b/template/en/default/search/form.html.tmpl @@ -611,15 +611,17 @@ function doOnSelectProduct(selectmode) {