From d72aba3e03044604d7cd00037ceaa791ec91c6dd Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Fri, 24 Oct 2008 23:13:51 +0000 Subject: [PATCH] Bug 459064: Set FIELD_TYPE_SINGLE_SELECT on standard global select fields Patch By Max Kanat-Alexander r=bbaetz, a=mkanat git-svn-id: svn://10.0.0.236/trunk@254757 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bugzilla/Field.pm | 27 +++++++++++++------ mozilla/webtools/bugzilla/Bugzilla/Search.pm | 23 ++++------------ .../bugzilla/Bugzilla/WebService/Bug.pm | 17 +++--------- mozilla/webtools/bugzilla/editvalues.cgi | 18 +++---------- 4 files changed, 30 insertions(+), 55 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla/Field.pm b/mozilla/webtools/bugzilla/Bugzilla/Field.pm index 7da8a8bba4d..ffe39b38e6b 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Field.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Field.pm @@ -125,6 +125,8 @@ use constant UPDATE_COLUMNS => qw( enter_bug visibility_field_id visibility_value_id + + type ); # How various field types translate into SQL data definitions. @@ -148,16 +150,22 @@ use constant DEFAULT_FIELDS => ( {name => 'classification', desc => 'Classification', in_new_bugmail => 1}, {name => 'product', desc => 'Product', in_new_bugmail => 1}, {name => 'version', desc => 'Version', in_new_bugmail => 1}, - {name => 'rep_platform', desc => 'Platform', in_new_bugmail => 1}, + {name => 'rep_platform', desc => 'Platform', in_new_bugmail => 1, + type => FIELD_TYPE_SINGLE_SELECT}, {name => 'bug_file_loc', desc => 'URL', in_new_bugmail => 1}, - {name => 'op_sys', desc => 'OS/Version', in_new_bugmail => 1}, - {name => 'bug_status', desc => 'Status', in_new_bugmail => 1}, + {name => 'op_sys', desc => 'OS/Version', in_new_bugmail => 1, + type => FIELD_TYPE_SINGLE_SELECT}, + {name => 'bug_status', desc => 'Status', in_new_bugmail => 1, + type => FIELD_TYPE_SINGLE_SELECT}, {name => 'status_whiteboard', desc => 'Status Whiteboard', in_new_bugmail => 1}, {name => 'keywords', desc => 'Keywords', in_new_bugmail => 1}, - {name => 'resolution', desc => 'Resolution'}, - {name => 'bug_severity', desc => 'Severity', in_new_bugmail => 1}, - {name => 'priority', desc => 'Priority', in_new_bugmail => 1}, + {name => 'resolution', desc => 'Resolution', + type => FIELD_TYPE_SINGLE_SELECT}, + {name => 'bug_severity', desc => 'Severity', in_new_bugmail => 1, + type => FIELD_TYPE_SINGLE_SELECT}, + {name => 'priority', desc => 'Priority', in_new_bugmail => 1, + type => FIELD_TYPE_SINGLE_SELECT}, {name => 'component', desc => 'Component', in_new_bugmail => 1}, {name => 'assigned_to', desc => 'AssignedTo', in_new_bugmail => 1}, {name => 'reporter', desc => 'ReportedBy', in_new_bugmail => 1}, @@ -551,6 +559,9 @@ sub set_visibility_value { delete $self->{visibility_value}; } +# This is only used internally by upgrade code in Bugzilla::Field. +sub _set_type { $_[0]->set('type', $_[1]); } + =pod =head2 Instance Method @@ -766,6 +777,7 @@ sub populate_field_definitions { if ($field) { $field->set_description($def->{desc}); $field->set_in_new_bugmail($def->{in_new_bugmail}); + $field->_set_type($def->{type}) if $def->{type}; $field->update(); } else { @@ -773,8 +785,7 @@ sub populate_field_definitions { $def->{mailhead} = $def->{in_new_bugmail}; delete $def->{in_new_bugmail}; } - $def->{description} = $def->{desc}; - delete $def->{desc}; + $def->{description} = delete $def->{desc}; Bugzilla::Field->create($def); } } diff --git a/mozilla/webtools/bugzilla/Bugzilla/Search.pm b/mozilla/webtools/bugzilla/Bugzilla/Search.pm index ac0099ea565..4b21b216b8e 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Search.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Search.pm @@ -53,12 +53,6 @@ use Date::Parse; # to, in order. use constant SPECIAL_ORDER => { 'bugs.target_milestone' => [ 'ms_order.sortkey','ms_order.value' ], - 'bugs.bug_status' => [ 'bug_status.sortkey','bug_status.value' ], - 'bugs.rep_platform' => [ 'rep_platform.sortkey','rep_platform.value' ], - 'bugs.priority' => [ 'priority.sortkey','priority.value' ], - 'bugs.op_sys' => [ 'op_sys.sortkey','op_sys.value' ], - 'bugs.resolution' => [ 'resolution.sortkey', 'resolution.value' ], - 'bugs.bug_severity' => [ 'bug_severity.sortkey','bug_severity.value' ] }; # When we add certain fields to the ORDER BY, we need to then add a @@ -66,12 +60,6 @@ use constant SPECIAL_ORDER => { # the join statements that need to be added. use constant SPECIAL_ORDER_JOIN => { 'bugs.target_milestone' => 'LEFT JOIN milestones AS ms_order ON ms_order.value = bugs.target_milestone AND ms_order.product_id = bugs.product_id', - 'bugs.bug_status' => 'LEFT JOIN bug_status ON bug_status.value = bugs.bug_status', - 'bugs.rep_platform' => 'LEFT JOIN rep_platform ON rep_platform.value = bugs.rep_platform', - 'bugs.priority' => 'LEFT JOIN priority ON priority.value = bugs.priority', - 'bugs.op_sys' => 'LEFT JOIN op_sys ON op_sys.value = bugs.op_sys', - 'bugs.resolution' => 'LEFT JOIN resolution ON resolution.value = bugs.resolution', - 'bugs.bug_severity' => 'LEFT JOIN bug_severity ON bug_severity.value = bugs.bug_severity' }; # Create a new Search @@ -117,8 +105,8 @@ sub init { my %special_order = %{SPECIAL_ORDER()}; my %special_order_join = %{SPECIAL_ORDER_JOIN()}; - my @select_fields = Bugzilla->get_fields({ type => FIELD_TYPE_SINGLE_SELECT, - obsolete => 0 }); + my @select_fields = + Bugzilla->get_fields({ type => FIELD_TYPE_SINGLE_SELECT }); my @multi_select_fields = Bugzilla->get_fields({ type => FIELD_TYPE_MULTI_SELECT, obsolete => 0 }); @@ -220,10 +208,9 @@ sub init { } } - my @legal_fields = ("product", "version", "rep_platform", "op_sys", - "bug_status", "resolution", "priority", "bug_severity", - "assigned_to", "reporter", "component", "classification", - "target_milestone", "bug_group"); + my @legal_fields = ("product", "version", "assigned_to", "reporter", + "component", "classification", "target_milestone", + "bug_group"); # Include custom select fields. push(@legal_fields, map { $_->name } @select_fields); diff --git a/mozilla/webtools/bugzilla/Bugzilla/WebService/Bug.pm b/mozilla/webtools/bugzilla/Bugzilla/WebService/Bug.pm index 8cfb6acdef4..b6411968c1b 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/WebService/Bug.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/WebService/Bug.pm @@ -45,15 +45,6 @@ use constant FIELD_MAP => { platform => 'rep_platform', }; -use constant GLOBAL_SELECT_FIELDS => qw( - bug_severity - bug_status - op_sys - priority - rep_platform - resolution -); - use constant PRODUCT_SPECIFIC_FIELDS => qw(version target_milestone component); ###################################################### @@ -192,13 +183,11 @@ sub legal_values { my ($self, $params) = @_; my $field = FIELD_MAP->{$params->{field}} || $params->{field}; - my @custom_select = Bugzilla->get_fields( - {custom => 1, type => [FIELD_TYPE_SINGLE_SELECT, FIELD_TYPE_MULTI_SELECT]}); - # We only want field names. - @custom_select = map {$_->name} @custom_select; + my @global_selects = Bugzilla->get_fields( + {type => [FIELD_TYPE_SINGLE_SELECT, FIELD_TYPE_MULTI_SELECT]}); my $values; - if (grep($_ eq $field, GLOBAL_SELECT_FIELDS, @custom_select)) { + if (grep($_->name eq $field, @global_selects)) { $values = get_legal_field_values($field); } elsif (grep($_ eq $field, PRODUCT_SPECIFIC_FIELDS)) { diff --git a/mozilla/webtools/bugzilla/editvalues.cgi b/mozilla/webtools/bugzilla/editvalues.cgi index 85d4c976155..b5a1fc119db 100755 --- a/mozilla/webtools/bugzilla/editvalues.cgi +++ b/mozilla/webtools/bugzilla/editvalues.cgi @@ -29,18 +29,6 @@ use Bugzilla::Token; use Bugzilla::Field; use Bugzilla::Field::Choice; -# List of different tables that contain the changeable field values -# (the old "enums.") Keep them in alphabetical order by their -# English name from field-descs.html.tmpl. -# Format: Array of valid field names. -my @valid_fields = ('op_sys', 'rep_platform', 'priority', 'bug_severity', - 'bug_status', 'resolution'); - -# Add custom select fields. -my @custom_fields = Bugzilla->get_fields( - {custom => 1, type => [FIELD_TYPE_SINGLE_SELECT, FIELD_TYPE_MULTI_SELECT]}); -push(@valid_fields, map { $_->name } @custom_fields); - ############### # Subroutines # ############### @@ -87,8 +75,8 @@ my $token = $cgi->param('token'); # field = '' -> Show nice list of fields # if (!$cgi->param('field')) { - # Convert @valid_fields into the format that select-field wants. - my @field_list = map({ name => $_ }, @valid_fields); + my @field_list = Bugzilla->get_fields( + {type => [FIELD_TYPE_SINGLE_SELECT, FIELD_TYPE_MULTI_SELECT]}); $vars->{'fields'} = \@field_list; $template->process("admin/fieldvalues/select-field.html.tmpl", $vars) @@ -98,7 +86,7 @@ if (!$cgi->param('field')) { # At this point, the field must be defined. my $field = Bugzilla::Field->check($cgi->param('field')); -if (!grep($_ eq $field->name, @valid_fields)) { +if (!$field->is_select) { ThrowUserError('fieldname_invalid', { field => $field }); } $vars->{'field'} = $field;