Bug 458436: Allow standard global select fields to control visibility of custom fields
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=bbaetz, a=mkanat git-svn-id: svn://10.0.0.236/trunk@254758 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
d72aba3e03
commit
20dfdcf2bb
@ -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 #
|
||||
##############
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 %]'],
|
||||
|
||||
@ -99,8 +99,7 @@
|
||||
<select name="visibility_field_id" id="visibility_field_id"
|
||||
onchange="onChangeVisibilityField()">
|
||||
<option></option>
|
||||
[% FOREACH sel_field = Bugzilla.active_custom_fields %]
|
||||
[% NEXT IF !sel_field.is_select %]
|
||||
[% 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 %])
|
||||
|
||||
@ -84,8 +84,8 @@
|
||||
<select name="visibility_field_id" id="visibility_field_id"
|
||||
onchange="onChangeVisibilityField()">
|
||||
<option></option>
|
||||
[% 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 %]
|
||||
<option value="[% sel_field.id FILTER html %]"
|
||||
[% ' selected="selected"'
|
||||
IF sel_field.id == field.visibility_field.id %]>
|
||||
|
||||
@ -162,6 +162,14 @@ function handleWantsAttachment(wants_attachment) {
|
||||
-->
|
||||
</script>
|
||||
|
||||
[% USE Bugzilla %]
|
||||
[% SET select_fields = {} %]
|
||||
[% FOREACH field = Bugzilla.get_fields(
|
||||
{ type => constants.FIELD_TYPE_SINGLE_SELECT, custom => 0 })
|
||||
%]
|
||||
[% select_fields.${field.name} = field %]
|
||||
[% END %]
|
||||
|
||||
<form name="Create" id="Create" method="post" action="post_bug.cgi"
|
||||
enctype="multipart/form-data">
|
||||
<input type="hidden" name="product" value="[% product.name FILTER html %]">
|
||||
@ -235,18 +243,21 @@ function handleWantsAttachment(wants_attachment) {
|
||||
</select>
|
||||
</td>
|
||||
|
||||
[% sel = { description => 'Severity', name => 'bug_severity' } %]
|
||||
[% INCLUDE select %]
|
||||
[% INCLUDE bug/field.html.tmpl
|
||||
bug = default, field = select_fields.bug_severity, editable = 1,
|
||||
value = default.bug_severity %]
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
[% sel = { description => 'Platform', name => 'rep_platform' } %]
|
||||
[% INCLUDE select %]
|
||||
[% INCLUDE bug/field.html.tmpl
|
||||
bug = default, field = select_fields.rep_platform, editable = 1,
|
||||
value = default.rep_platform %]
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
[% sel = { description => 'OS', name => 'op_sys' } %]
|
||||
[% INCLUDE select %]
|
||||
[% INCLUDE bug/field.html.tmpl
|
||||
bug = default, field = select_fields.op_sys, editable = 1,
|
||||
value = default.op_sys %]
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@ -260,12 +271,11 @@ function handleWantsAttachment(wants_attachment) {
|
||||
[% END %]
|
||||
|
||||
[% IF Param('letsubmitterchoosepriority') %]
|
||||
[% sel = { description => 'Priority', name => 'priority' } %]
|
||||
[% INCLUDE select %]
|
||||
[% INCLUDE bug/field.html.tmpl
|
||||
bug = default, field = select_fields.priority, editable = 1,
|
||||
value = default.priority %]
|
||||
[% ELSE %]
|
||||
<td colspan="2">
|
||||
<input type="hidden" name="priority" value="[% default.priority FILTER html %]">
|
||||
</td>
|
||||
<td colspan="2"> </td>
|
||||
[% END %]
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -437,7 +447,9 @@ function handleWantsAttachment(wants_attachment) {
|
||||
[% NEXT UNLESS field.enter_bug %]
|
||||
[% SET value = ${field.name}.defined ? ${field.name} : "" %]
|
||||
<tr>
|
||||
[% PROCESS bug/field.html.tmpl editable=1 value_span=3 %]
|
||||
[% INCLUDE bug/field.html.tmpl
|
||||
bug = default, field = field, value = value, editable = 1,
|
||||
value_span = 3 %]
|
||||
</tr>
|
||||
[% END %]
|
||||
|
||||
@ -617,7 +629,7 @@ function handleWantsAttachment(wants_attachment) {
|
||||
[% END %]
|
||||
|
||||
<td>
|
||||
<select name="[% sel.name %]">
|
||||
<select name="[% sel.name %]" id="[% sel.name %]">
|
||||
[%- FOREACH x = ${sel.name} %]
|
||||
<option value="[% x FILTER html %]"
|
||||
[% " selected=\"selected\"" IF x == default.${sel.name} %]>
|
||||
@ -628,5 +640,15 @@ function handleWantsAttachment(wants_attachment) {
|
||||
[% END %]</option>
|
||||
[% END %]
|
||||
</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>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</td>
|
||||
[% END %]
|
||||
|
||||
@ -30,6 +30,14 @@
|
||||
|
||||
[% PROCESS bug/time.html.tmpl %]
|
||||
|
||||
[% USE Bugzilla %]
|
||||
[% SET select_fields = {} %]
|
||||
[% FOREACH field = Bugzilla.get_fields(
|
||||
{ type => constants.FIELD_TYPE_SINGLE_SELECT, custom => 0 })
|
||||
%]
|
||||
[% select_fields.${field.name} = field %]
|
||||
[% END %]
|
||||
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
|
||||
@ -390,9 +398,15 @@
|
||||
<td class="field_label">
|
||||
<label for="rep_platform" accesskey="h"><b>Platform</b></label>:
|
||||
</td>
|
||||
<td>
|
||||
[% PROCESS select selname => "rep_platform" no_td=> 1 %]
|
||||
[%+ PROCESS select selname => "op_sys" no_td=> 1 %]
|
||||
<td class="field_value">
|
||||
[% INCLUDE bug/field.html.tmpl
|
||||
bug = bug, field = select_fields.rep_platform,
|
||||
no_tds = 1, value = bug.rep_platform
|
||||
editable = bug.check_can_change_field('rep_platform', 0, 1) %]
|
||||
[%+ INCLUDE bug/field.html.tmpl
|
||||
bug = bug, field = select_fields.op_sys,
|
||||
no_tds = 1, value = bug.op_sys
|
||||
editable = bug.check_can_change_field('op_sys', 0, 1) %]
|
||||
<script type="text/javascript">
|
||||
assignToDefaultOnChange(['product', 'component']);
|
||||
</script>
|
||||
@ -433,8 +447,14 @@
|
||||
<b><a href="page.cgi?id=fields.html#importance"><u>I</u>mportance</a></b></label>:
|
||||
</td>
|
||||
<td>
|
||||
[% PROCESS select selname => "priority" no_td=>1 %]
|
||||
[% PROCESS select selname = "bug_severity" no_td=>1 %]
|
||||
[% INCLUDE bug/field.html.tmpl
|
||||
bug = bug, field = select_fields.priority,
|
||||
no_tds = 1, value = bug.priority
|
||||
editable = bug.check_can_change_field('priority', 0, 1) %]
|
||||
[%+ INCLUDE bug/field.html.tmpl
|
||||
bug = bug, field = select_fields.bug_severity,
|
||||
no_tds = 1, value = bug.bug_severity
|
||||
editable = bug.check_can_change_field('bug_severity', 0, 1) %]
|
||||
[% IF bug.use_votes %]
|
||||
<span id="votes_container">
|
||||
[% IF bug.votes %]
|
||||
@ -915,7 +935,6 @@
|
||||
[% BLOCK section_customfields %]
|
||||
[%# *** Custom Fields *** %]
|
||||
|
||||
[% USE Bugzilla %]
|
||||
[% FOREACH field = Bugzilla.active_custom_fields %]
|
||||
<tr>
|
||||
[% PROCESS bug/field.html.tmpl value=bug.${field.name}
|
||||
|
||||
@ -28,6 +28,8 @@
|
||||
# allow_dont_change: display the --do_not_change-- option for select fields.
|
||||
# value_span: A colspan for the table cell containing
|
||||
# the field value.
|
||||
# no_tds: boolean; if true, don't display the label <th> or the
|
||||
# wrapping <td> for the field.
|
||||
# bug (optional): The current Bugzilla::Bug being displayed, or a hash
|
||||
# with default field values being displayed on a page.
|
||||
#%]
|
||||
@ -41,18 +43,28 @@
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
<th class="field_label [% ' bz_hidden_field' IF hidden %]"
|
||||
id="field_label_[% field.name FILTER html %]">
|
||||
[% IF editable %]
|
||||
<label for="[% field.name FILTER html %]">
|
||||
[% END %]
|
||||
[% field_descs.${field.name} FILTER html %]:
|
||||
[% '</label>' IF editable %]
|
||||
</th>
|
||||
[% IF NOT no_tds %]
|
||||
<th class="field_label [% ' bz_hidden_field' IF hidden %]"
|
||||
id="field_label_[% field.name FILTER html %]">
|
||||
[% IF editable %]
|
||||
<label for="[% field.name FILTER html %]">
|
||||
[% END %]
|
||||
[% IF !field.custom %]
|
||||
<a href="page.cgi?id=fields.html#[% field.name FILTER url_quote %]">
|
||||
[% END -%]
|
||||
[% field_descs.${field.name} FILTER html %]:
|
||||
[%- IF !field.custom %]
|
||||
</a>
|
||||
[% END %]
|
||||
[% '</label>' IF editable %]
|
||||
</th>
|
||||
[% END %]
|
||||
|
||||
[% IF NOT no_tds %]
|
||||
<td class="field_value [% ' bz_hidden_field' IF hidden %]"
|
||||
id="field_container_[% field.name FILTER html %]"
|
||||
[% " colspan=\"$value_span\"" FILTER none IF value_span %]>
|
||||
[% END %]
|
||||
[% IF editable %]
|
||||
[% SWITCH field.type %]
|
||||
[% CASE constants.FIELD_TYPE_FREETEXT %]
|
||||
@ -153,4 +165,4 @@
|
||||
[% ELSE %]
|
||||
[% value.join(', ') FILTER html %]
|
||||
[% END %]
|
||||
</td>
|
||||
[% '</td>' IF NOT no_tds %]
|
||||
|
||||
@ -120,6 +120,17 @@
|
||||
YAHOO.util.Event.addListener( window, 'load', showHideStatusItems,
|
||||
['[% "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 %]
|
||||
</script>
|
||||
|
||||
[%# Common actions %]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user