From 20dfdcf2bb218180ff8bdd788a91a31bc2bb17ab Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Fri, 24 Oct 2008 23:15:01 +0000 Subject: [PATCH] Bug 458436: Allow standard global select fields to control visibility of custom fields Patch By Max Kanat-Alexander r=bbaetz, a=mkanat git-svn-id: svn://10.0.0.236/trunk@254758 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bugzilla/Field.pm | 14 ++++++ mozilla/webtools/bugzilla/editvalues.cgi | 3 +- .../default/admin/custom_fields/cf-js.js.tmpl | 3 +- .../admin/custom_fields/create.html.tmpl | 3 +- .../admin/custom_fields/edit.html.tmpl | 4 +- .../en/default/bug/create/create.html.tmpl | 48 ++++++++++++++----- .../template/en/default/bug/edit.html.tmpl | 31 +++++++++--- .../template/en/default/bug/field.html.tmpl | 30 ++++++++---- .../template/en/default/bug/knob.html.tmpl | 11 +++++ 9 files changed, 111 insertions(+), 36 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bugzilla/Field.pm b/mozilla/webtools/bugzilla/Bugzilla/Field.pm index ffe39b38e6b..a5e380a1166 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Field.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Field.pm @@ -208,6 +208,20 @@ use constant DEFAULT_FIELDS => ( {name => "owner_idle_time", desc => "Time Since Assignee Touched"}, ); +################ +# Constructors # +################ + +# Override match to add is_select. +sub match { + my $self = shift; + my ($params) = @_; + if (delete $params->{is_select}) { + $params->{type} = [FIELD_TYPE_SINGLE_SELECT, FIELD_TYPE_MULTI_SELECT]; + } + return $self->SUPER::match(@_); +} + ############## # Validators # ############## diff --git a/mozilla/webtools/bugzilla/editvalues.cgi b/mozilla/webtools/bugzilla/editvalues.cgi index b5a1fc119db..33824528461 100755 --- a/mozilla/webtools/bugzilla/editvalues.cgi +++ b/mozilla/webtools/bugzilla/editvalues.cgi @@ -75,8 +75,7 @@ my $token = $cgi->param('token'); # field = '' -> Show nice list of fields # if (!$cgi->param('field')) { - my @field_list = Bugzilla->get_fields( - {type => [FIELD_TYPE_SINGLE_SELECT, FIELD_TYPE_MULTI_SELECT]}); + my @field_list = Bugzilla->get_fields({ is_select => 1 }); $vars->{'fields'} = \@field_list; $template->process("admin/fieldvalues/select-field.html.tmpl", $vars) diff --git a/mozilla/webtools/bugzilla/template/en/default/admin/custom_fields/cf-js.js.tmpl b/mozilla/webtools/bugzilla/template/en/default/admin/custom_fields/cf-js.js.tmpl index 863f14dca33..bf72ff99828 100644 --- a/mozilla/webtools/bugzilla/template/en/default/admin/custom_fields/cf-js.js.tmpl +++ b/mozilla/webtools/bugzilla/template/en/default/admin/custom_fields/cf-js.js.tmpl @@ -24,8 +24,7 @@ function toggleCheckbox(this_checkbox, other_checkbox_id) { } var select_values = new Array(); -[% FOREACH sel_field = Bugzilla.active_custom_fields %] - [% NEXT IF !sel_field.is_select %] +[% FOREACH sel_field = Bugzilla.get_fields({ is_select => 1 }) %] select_values[[% sel_field.id FILTER js %]] = [ [% FOREACH legal_value = sel_field.legal_values %] [[% legal_value.id FILTER js %], '[% legal_value.name FILTER html %]'], diff --git a/mozilla/webtools/bugzilla/template/en/default/admin/custom_fields/create.html.tmpl b/mozilla/webtools/bugzilla/template/en/default/admin/custom_fields/create.html.tmpl index da10c7bcbf8..17bd5bfdc86 100644 --- a/mozilla/webtools/bugzilla/template/en/default/admin/custom_fields/create.html.tmpl +++ b/mozilla/webtools/bugzilla/template/en/default/admin/custom_fields/create.html.tmpl @@ -99,8 +99,7 @@ - [% FOREACH sel_field = Bugzilla.active_custom_fields %] - [% NEXT IF !sel_field.is_select || sel_field.id == field.id %] + [% FOREACH sel_field = Bugzilla.get_fields({ is_select => 1 }) %] + [% NEXT IF sel_field.id == field.id %]