From 63be194996849202878c4a87e4c68a25d1976d3e Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Fri, 7 Nov 2008 17:34:39 +0000 Subject: Bug 308253: Ability to add select (enum) fields to a bug whose list of values depends on the value of another field Patch By Max Kanat-Alexander r=bbaetz, a=mkanat --- template/en/default/bug/create/create.html.tmpl | 11 ++++---- template/en/default/bug/field-events.js.tmpl | 36 +++++++++++++++++++++++++ template/en/default/bug/field.html.tmpl | 32 ++++++++++++++-------- template/en/default/bug/knob.html.tmpl | 12 ++------- 4 files changed, 64 insertions(+), 27 deletions(-) create mode 100644 template/en/default/bug/field-events.js.tmpl (limited to 'template/en/default/bug') diff --git a/template/en/default/bug/create/create.html.tmpl b/template/en/default/bug/create/create.html.tmpl index 0b941cc35..089292603 100644 --- a/template/en/default/bug/create/create.html.tmpl +++ b/template/en/default/bug/create/create.html.tmpl @@ -642,13 +642,12 @@ function handleWantsAttachment(wants_attachment) { [% IF sel.name == "bug_status" %] - [% FOREACH controlled = select_fields.bug_status.controls_visibility_of %] - - [% END %] [% END %] [% END %] diff --git a/template/en/default/bug/field-events.js.tmpl b/template/en/default/bug/field-events.js.tmpl new file mode 100644 index 000000000..7cdf64687 --- /dev/null +++ b/template/en/default/bug/field-events.js.tmpl @@ -0,0 +1,36 @@ +[%# The contents of this file are subject to the Mozilla Public + # License Version 1.1 (the "License"); you may not use this file + # except in compliance with the License. You may obtain a copy of + # the License at http://www.mozilla.org/MPL/ + # + # Software distributed under the License is distributed on an "AS + # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + # implied. See the License for the specific language governing + # rights and limitations under the License. + # + # The Original Code is the Bugzilla Bug Tracking System. + # + # The Initial Developer of the Original Code is the San Jose State + # University Foundation. Portions created by the Initial Developer + # are Copyright (C) 2008 the Initial Developer. All Rights Reserved. + # + # Contributor(s): Max Kanat-Alexander + #%] + +[%# INTERFACE: + # field: a Bugzilla::Field object + #%] + +[% FOREACH controlled_field = field.controls_visibility_of %] + showFieldWhen('[% controlled_field.name FILTER js %]', + '[% field.name FILTER js %]', + '[% controlled_field.visibility_value.name FILTER js %]'); +[% END %] +[% FOREACH legal_value = field.legal_values %] + [% FOREACH controlled_value = legal_value.controlled_values %] + showValueWhen('[% controlled_value.field.name FILTER js %]', + '[% controlled_value.name FILTER js %]', + '[% field.name FILTER js %]', + '[% legal_value.name FILTER js %]'); + [% END %] +[% END %] diff --git a/template/en/default/bug/field.html.tmpl b/template/en/default/bug/field.html.tmpl index 9b93a9ff2..d29aaa305 100644 --- a/template/en/default/bug/field.html.tmpl +++ b/template/en/default/bug/field.html.tmpl @@ -126,10 +126,20 @@ [% END %] [% FOREACH legal_value = field.legal_values %] + [% SET control_value = legal_value.visibility_value %] + [% SET control_field = field.value_field %] + [%# We always show selected values, even if they should be + # hidden %] + [% IF value.contains(legal_value.name).size %] + selected="selected" + [% ELSIF control_field && control_value + && !bug.${control_field.name}.contains(control_value.name) + %] + class="bz_hidden_option" disabled="disabled" + [% END %]> + [%- legal_value.name FILTER html -%] + [% END %] [%# When you pass an empty multi-select in the web interface, @@ -142,19 +152,19 @@ [% IF field.type == constants.FIELD_TYPE_MULTI_SELECT %] [% END %] + + + [% CASE constants.FIELD_TYPE_TEXTAREA %] [% INCLUDE global/textarea.html.tmpl id = field.name name = field.name minrows = 4 maxrows = 8 cols = 60 defaultcontent = value %] [% END %] - - [% FOREACH controlled_field = field.controls_visibility_of %] - - [% END %] [% ELSIF field.type == constants.FIELD_TYPE_TEXTAREA %]
[% value FILTER wrap_comment(60) FILTER html %]
diff --git a/template/en/default/bug/knob.html.tmpl b/template/en/default/bug/knob.html.tmpl index 038e6cbb3..be94559aa 100644 --- a/template/en/default/bug/knob.html.tmpl +++ b/template/en/default/bug/knob.html.tmpl @@ -122,16 +122,8 @@ ['[% "is_duplicate" IF bug.dup_id %]', '[% bug.bug_status FILTER js %]'] ); - [% FOREACH controlled = select_fields.bug_status.controls_visibility_of %] - showFieldWhen('[% controlled.name FILTER js %]', - 'bug_status', - '[% controlled.visibility_value.name FILTER js %]'); - [% END %] - [% FOREACH controlled = select_fields.resolution.controls_visibility_of %] - showFieldWhen('[% controlled.name FILTER js %]', - 'resolution', - '[% controlled.visibility_value.name FILTER js %]'); - [% END %] + [% INCLUDE "bug/field-events.js.tmpl" field = select_fields.bug_status %] + [% INCLUDE "bug/field-events.js.tmpl" field = select_fields.resolution %] [%# Common actions %] -- cgit v1.2.3-24-g4f1b