diff options
author | mkanat%bugzilla.org <> | 2008-11-07 18:34:39 +0100 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2008-11-07 18:34:39 +0100 |
commit | 63be194996849202878c4a87e4c68a25d1976d3e (patch) | |
tree | 657fbe1458ce256015a832251219669070886e1e /template | |
parent | ebd2e3a29a893e1ea26899bac53296fc6422f47c (diff) | |
download | bugzilla-63be194996849202878c4a87e4c68a25d1976d3e.tar.gz bugzilla-63be194996849202878c4a87e4c68a25d1976d3e.tar.xz |
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 <mkanat@bugzilla.org> r=bbaetz, a=mkanat
Diffstat (limited to 'template')
-rw-r--r-- | template/en/default/admin/custom_fields/cf-js.js.tmpl | 12 | ||||
-rw-r--r-- | template/en/default/admin/custom_fields/create.html.tmpl | 24 | ||||
-rw-r--r-- | template/en/default/admin/custom_fields/edit.html.tmpl | 24 | ||||
-rw-r--r-- | template/en/default/admin/fieldvalues/confirm-delete.html.tmpl | 17 | ||||
-rw-r--r-- | template/en/default/admin/fieldvalues/create.html.tmpl | 21 | ||||
-rw-r--r-- | template/en/default/admin/fieldvalues/edit.html.tmpl | 27 | ||||
-rw-r--r-- | template/en/default/bug/create/create.html.tmpl | 11 | ||||
-rw-r--r-- | template/en/default/bug/field-events.js.tmpl | 36 | ||||
-rw-r--r-- | template/en/default/bug/field.html.tmpl | 32 | ||||
-rw-r--r-- | template/en/default/bug/knob.html.tmpl | 12 | ||||
-rw-r--r-- | template/en/default/global/messages.html.tmpl | 11 | ||||
-rw-r--r-- | template/en/default/global/user-error.html.tmpl | 24 |
12 files changed, 217 insertions, 34 deletions
diff --git a/template/en/default/admin/custom_fields/cf-js.js.tmpl b/template/en/default/admin/custom_fields/cf-js.js.tmpl index bf72ff998..6c5bbf626 100644 --- a/template/en/default/admin/custom_fields/cf-js.js.tmpl +++ b/template/en/default/admin/custom_fields/cf-js.js.tmpl @@ -32,6 +32,18 @@ var select_values = new Array(); ]; [% END %] +function onChangeType(type_field) { + var value_field = document.getElementById('value_field_id'); + if (type_field.value == [% constants.FIELD_TYPE_SINGLE_SELECT %] + || type_field.value == [% constants.FIELD_TYPE_MULTI_SELECT %]) + { + value_field.disabled = false; + } + else { + value_field.disabled = true; + } +} + function onChangeVisibilityField() { var vis_field = document.getElementById('visibility_field_id'); var vis_value = document.getElementById('visibility_value_id'); diff --git a/template/en/default/admin/custom_fields/create.html.tmpl b/template/en/default/admin/custom_fields/create.html.tmpl index 17bd5bfdc..a2db4708b 100644 --- a/template/en/default/admin/custom_fields/create.html.tmpl +++ b/template/en/default/admin/custom_fields/create.html.tmpl @@ -75,7 +75,7 @@ <tr> <th align="right"><label for="type">Type:</label></th> <td> - <select id="type" name="type"> + <select id="type" name="type" onchange="onChangeType(this)"> [% FOREACH type = field_types.keys %] [% NEXT IF type == constants.FIELD_TYPE_UNKNOWN %] <option value="[% type FILTER html %]">[% field_types.$type FILTER html %]</option> @@ -112,6 +112,28 @@ </select> </td> </tr> + + <tr> + <td colspan="2"> </td> + <th> + <label for="value_field_id"> + Field that controls the values<br> + that appear in this field: + </label> + </th> + + <td> + <select disabled="disabled" name="value_field_id" id="value_field_id"> + <option></option> + [% FOREACH sel_field = Bugzilla.get_fields({ is_select => 1 }) %] + <option value="[% sel_field.id FILTER html %]"> + [% sel_field.description FILTER html %] + ([% sel_field.name FILTER html %]) + </option> + [% END %] + </select> + </td> + </tr> </table> <p> <input type="hidden" name="action" value="new"> diff --git a/template/en/default/admin/custom_fields/edit.html.tmpl b/template/en/default/admin/custom_fields/edit.html.tmpl index 3d7355a77..b6a8ae9bd 100644 --- a/template/en/default/admin/custom_fields/edit.html.tmpl +++ b/template/en/default/admin/custom_fields/edit.html.tmpl @@ -109,10 +109,32 @@ [% IF field.is_select %] <tr> <th> </th> - <td colspan="3"> + <td> <a href="editvalues.cgi?field=[% field.name FILTER url_quote %]">Edit legal values for this field</a>. </td> + + <th> + <label for="value_field_id"> + Field that controls the values<br> + that appear in this field: + </label> + </th> + + <td> + <select name="value_field_id" id="value_field_id"> + <option></option> + [% FOREACH sel_field = Bugzilla.get_fields({ is_select => 1 }) %] + [% NEXT IF sel_field.id == field.id %] + <option value="[% sel_field.id FILTER html %]" + [% ' selected="selected"' + IF sel_field.id == field.value_field.id %]> + [% sel_field.description FILTER html %] + ([% sel_field.name FILTER html %]) + </option> + [% END %] + </select> + </td> </tr> [% END %] </table> diff --git a/template/en/default/admin/fieldvalues/confirm-delete.html.tmpl b/template/en/default/admin/fieldvalues/confirm-delete.html.tmpl index 2389fb6ae..b215edf04 100644 --- a/template/en/default/admin/fieldvalues/confirm-delete.html.tmpl +++ b/template/en/default/admin/fieldvalues/confirm-delete.html.tmpl @@ -62,7 +62,8 @@ <h2>Confirmation</h2> [% IF value.is_default || value.bug_count || (value_count == 1) - || value.controls_visibility_of_fields.size + || value.controls_visibility_of_fields.size + || value.controlled_values.size %] <p>Sorry, but the '[% value.name FILTER html %]' value cannot be deleted @@ -121,6 +122,20 @@ [% END %] </li> [% END %] + + [% IF value.controlled_values.size %] + <li>This value controls the visibility of the following values in + other fields:<br> + [% FOREACH controlled = value.controlled_values %] + <a href="editvalues.cgi?action=edit&field= + [%- controlled.field.name FILTER url_quote %]&value= + [%- controlled.name FILTER url_quote %]"> + [% controlled.field.description FILTER html %] + ([% controlled.field.name FILTER html %]): + [%+ controlled.name FILTER html %]</a><br> + [% END %] + </li> + [% END %] </ul> [% ELSE %] diff --git a/template/en/default/admin/fieldvalues/create.html.tmpl b/template/en/default/admin/fieldvalues/create.html.tmpl index bd6c427e6..f1eec1a5a 100644 --- a/template/en/default/admin/fieldvalues/create.html.tmpl +++ b/template/en/default/admin/fieldvalues/create.html.tmpl @@ -62,6 +62,27 @@ </td> </tr> [% END %] + [% IF field.value_field %] + <tr> + <th align="right"> + <label for="visibility_value_id">Only appears when + [%+ field.value_field.description FILTER html %] is set to: + </label> + </th> + <td> + <select name="visibility_value_id" id="visibility_value_id"> + <option></option> + [% FOREACH field_value = field.value_field.legal_values %] + [% NEXT IF field_value.name == '' %] + <option value="[% field_value.id FILTER none %]"> + [%- field_value.name FILTER html -%] + </option> + [% END %] + </select> + <small>(Leave unset to have this value always appear.)</small> + </td> + </tr> + [% END %] </table> <input type="submit" id="create" value="Add"> <input type="hidden" name="action" value="new"> diff --git a/template/en/default/admin/fieldvalues/edit.html.tmpl b/template/en/default/admin/fieldvalues/edit.html.tmpl index f12383866..b01415577 100644 --- a/template/en/default/admin/fieldvalues/edit.html.tmpl +++ b/template/en/default/admin/fieldvalues/edit.html.tmpl @@ -32,7 +32,9 @@ <table border="0" cellpadding="4" cellspacing="0"> <tr> - <th valign="top"><label for="value_new">Field Value:</label></th> + <th valign="top" align="right"> + <label for="value_new">Field Value:</label> + </th> <td> [% IF value.is_static %] <input type="hidden" name="value_new" id="value_new" @@ -56,6 +58,29 @@ <td>[% IF value.is_open %]Open[% ELSE %]Closed[% END %]</td> </tr> [% END %] + [% IF field.value_field %] + <tr> + <th align="right"> + <label for="visibility_value_id">Only appears when + [%+ field.value_field.description FILTER html %] is set to: + </label> + </th> + <td> + <select name="visibility_value_id" id="visibility_value_id"> + <option></option> + [% FOREACH field_value = field.value_field.legal_values %] + [% NEXT IF field_value.name == '' %] + <option value="[% field_value.id FILTER none %]" + [% ' selected="selected"' + IF field_value.id == value.visibility_value.id %]> + [%- field_value.name FILTER html -%] + </option> + [% END %] + </select> + <small>(Leave unset to have this value always appear.)</small> + </td> + </tr> + [% END %] </table> <input type="hidden" name="value" value="[% value.name FILTER html %]"> 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) { </select> [% IF sel.name == "bug_status" %] - [% FOREACH controlled = select_fields.bug_status.controls_visibility_of %] - <script type="text/javascript"> - showFieldWhen('[% controlled.name FILTER js %]', - 'bug_status', - '[% controlled.visibility_value.name FILTER js %]'); + <script type="text/javascript"> + <!-- + [%+ INCLUDE "bug/field-events.js.tmpl" + field = select_fields.bug_status %] + //--> </script> - [% END %] [% END %] </td> [% 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 <mkanat@bugzilla.org> + #%] + +[%# 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 @@ </option> [% END %] [% FOREACH legal_value = field.legal_values %] + [% SET control_value = legal_value.visibility_value %] + [% SET control_field = field.value_field %] <option value="[% legal_value.name FILTER html %]" - [%- " selected=\"selected\"" - IF value.contains(legal_value.name).size %]> - [%- legal_value.name FILTER html %]</option> + [%# 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 -%] + </option> [% END %] </select> [%# When you pass an empty multi-select in the web interface, @@ -142,19 +152,19 @@ [% IF field.type == constants.FIELD_TYPE_MULTI_SELECT %] <input type="hidden" name="defined_[% field.name FILTER html %]"> [% END %] + + <script type="text/javascript"> + <!-- + initHidingOptionsForIE('[% field.name FILTER js %]'); + [%+ INCLUDE "bug/field-events.js.tmpl" field = field %] + //--> + </script> + [% 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 %] - <script type="text/javascript"> - showFieldWhen('[% controlled_field.name FILTER js %]', - '[% field.name FILTER js %]', - '[% controlled_field.visibility_value.name FILTER js %]'); - </script> - [% END %] [% ELSIF field.type == constants.FIELD_TYPE_TEXTAREA %] <div class="uneditable_textarea">[% value FILTER wrap_comment(60) FILTER html %]</div> 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 %] </script> [%# Common actions %] diff --git a/template/en/default/global/messages.html.tmpl b/template/en/default/global/messages.html.tmpl index d7de4fbc7..1a9c7220a 100644 --- a/template/en/default/global/messages.html.tmpl +++ b/template/en/default/global/messages.html.tmpl @@ -332,6 +332,17 @@ <li>Sortkey updated to <em>[% changes.sortkey.1 FILTER html %]</em>.</li> [% END %] + [% IF changes.visibility_value_id %] + [% IF value.visibility_value.defined %] + <li>It only appears when + [%+ value.field.value_field.description FILTER html %] is set to + '[%+ value.visibility_value.name FILTER html %]'.</li> + [% ELSE %] + <li>It now always appears, no matter what + [%+ value.field.value_field.description FILTER html %] is set to. + </li> + [% END %] + [% END %] </ul> [% ELSE %] No changes made to the field value <em>[% value_old FILTER html %]</em>. diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 0936847f5..0b10b7396 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -412,7 +412,7 @@ [% ELSIF error == "field_control_must_be_select" %] [% title = "Invalid Field Type Selected" %] Only drop-down and multi-select fields can be used to control - the visibility of other fields. [% field.description FILTER html %] + the visibility/values of other fields. [% field.description FILTER html %] is not the right type of field. [% ELSIF error == "field_invalid_name" %] @@ -433,6 +433,11 @@ [% title = "Missing Name for Field" %] You must enter a name for this field. + [% ELSIF error == "field_value_control_select_only" %] + [% title = "Invalid Value Control Field" %] + Only Drop-Down or Multi-Select fields can have a field that + controls their values. + [% ELSIF error == "fieldname_invalid" %] [% title = "Specified Field Does Not Exist" %] The field '[% field.name FILTER html %]' does not exist or @@ -446,8 +451,21 @@ [% ELSIF error == "fieldvalue_is_controller" %] [% title = "Value Controls Other Fields" %] You cannot delete the '[% value.name FILTER html %]' value for this - field because it controls the visibility of the following other fields: - [%+ fields.join(', ') FILTER html %]. + field because + [% IF fields.size %] + it controls the visibility of the following fields: + [%+ fields.join(', ') FILTER html %]. + [% END %] + [% ' and ' IF fields.size AND vals.size %] + [% IF vals.size %] + it controls the visibility of the following field values: + <ul> + [% FOREACH val = vals %] + <li>[% val.field.name FILTER html %]: + '[% val.name FILTER html %]'</li> + [% END %] + </ul> + [% END %] [% ELSIF error == "fieldvalue_is_default" %] [% title = "Specified Field Value Is Default" %] |