Use html_select() instead of select-menu.html.tmpl
parent
d8c8ea112d
commit
55e38839aa
|
@ -401,7 +401,7 @@ sub _get_clusions
|
|||
$product_name ||= "__Any__";
|
||||
$component_id ||= 0;
|
||||
$component_name ||= "__Any__";
|
||||
$clusions{"$product_name:$component_name"} = "$product_id:$component_id";
|
||||
$clusions{"$product_id:$component_id"} = "$product_name:$component_name";
|
||||
}
|
||||
return \%clusions;
|
||||
}
|
||||
|
|
|
@ -916,13 +916,12 @@ sub create
|
|||
Bugzilla => Bugzilla::Template::Plugin::Bugzilla->new,
|
||||
|
||||
# HTML <select>
|
||||
# html_select(name, { <attr> => <value> }, <selected value>, (
|
||||
# html_select(name, <selected value>, <values>, [<value names>], [<attr_hash>])
|
||||
# <values> may be one of:
|
||||
# [ { id => <option value>, name => <option text> }, ... ]
|
||||
# OR
|
||||
# { <option value> => <option text>, ... } # will be sorted on text
|
||||
# OR
|
||||
# [ <option value>, ... ], { <option value> => <option text>, ... }
|
||||
# ))
|
||||
# [ <option value>, ... ]
|
||||
# in the last case, <value names> may be { <option value> => <option text>, ... }
|
||||
html_select => sub
|
||||
{
|
||||
my ($name, $selected, $values, $valuenames, $attrs) = @_;
|
||||
|
@ -949,7 +948,7 @@ sub create
|
|||
{
|
||||
$html .= '<option value="'.html_quote($_).'"';
|
||||
$html .= ' selected="selected"' if $selected->{$_};
|
||||
$html .= '>'.html_quote($valuenames->{$_}).'</option>';
|
||||
$html .= '>'.html_quote($valuenames && $valuenames->{$_} || $_).'</option>';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -213,7 +213,7 @@ sub edit
|
|||
else
|
||||
{
|
||||
my %inclusions;
|
||||
$inclusions{"__Any__:__Any__"} = "0:0";
|
||||
$inclusions{"0:0"} = "__Any__:__Any__";
|
||||
$vars->{type} = {
|
||||
target_type => $target_type,
|
||||
inclusions => \%inclusions,
|
||||
|
@ -232,8 +232,8 @@ sub processCategoryChange
|
|||
{
|
||||
my ($categoryAction, $token) = @_;
|
||||
|
||||
my @inclusions = $ARGS->{inclusions};
|
||||
my @exclusions = $ARGS->{exclusions};
|
||||
my @inclusions = list $ARGS->{inclusions};
|
||||
my @exclusions = list $ARGS->{exclusions};
|
||||
if ($categoryAction eq 'include')
|
||||
{
|
||||
my ($product, $component) = get_prod_comp();
|
||||
|
@ -258,7 +258,7 @@ sub processCategoryChange
|
|||
}
|
||||
|
||||
# Convert the array @clusions('prod_ID:comp_ID') back to a hash of
|
||||
# the form %clusions{'prod_name:comp_name'} = 'prod_ID:comp_ID'
|
||||
# the form %clusions{'prod_ID:comp_ID'} = 'prod_name:comp_name'
|
||||
my %inclusions = clusion_array_to_hash(\@inclusions);
|
||||
my %exclusions = clusion_array_to_hash(\@exclusions);
|
||||
|
||||
|
@ -289,7 +289,7 @@ sub processCategoryChange
|
|||
}
|
||||
|
||||
# Convert the array @clusions('prod_ID:comp_ID') back to a hash of
|
||||
# the form %clusions{'prod_name:comp_name'} = 'prod_ID:comp_ID'
|
||||
# the form %clusions{'prod_ID:comp_ID'} = 'prod_name:comp_name'
|
||||
sub clusion_array_to_hash
|
||||
{
|
||||
my $array = shift;
|
||||
|
@ -312,7 +312,7 @@ sub clusion_array_to_hash
|
|||
$components{$component_id} ||= new Bugzilla::Component($component_id);
|
||||
$component_name = $components{$component_id}->name if $components{$component_id};
|
||||
}
|
||||
$hash{"$product_name:$component_name"} = $ids;
|
||||
$hash{$ids} = "$product_name:$component_name";
|
||||
}
|
||||
return %hash;
|
||||
}
|
||||
|
|
|
@ -55,11 +55,11 @@
|
|||
<input type="hidden" name="id" value="[% type.id %]">
|
||||
<input type="hidden" name="token" value="[% token FILTER html %]">
|
||||
<input type="hidden" name="target_type" value="[% type.target_type %]">
|
||||
[% FOREACH category = type.inclusions %]
|
||||
<input type="hidden" name="inclusions" value="[% category.value FILTER html %]">
|
||||
[% FOREACH category = type.inclusions.keys %]
|
||||
<input type="hidden" name="inclusions" value="[% category FILTER html %]">
|
||||
[% END %]
|
||||
[% FOREACH category = type.exclusions %]
|
||||
<input type="hidden" name="exclusions" value="[% category.value FILTER html %]">
|
||||
[% FOREACH category = type.exclusions.keys %]
|
||||
<input type="hidden" name="exclusions" value="[% category FILTER html %]">
|
||||
[% END %]
|
||||
|
||||
[%# Add a hidden button at the top of the form so that the user pressing "return"
|
||||
|
@ -121,12 +121,12 @@
|
|||
</td>
|
||||
<td style="vertical-align: top;">
|
||||
<b>Inclusions:</b><br>
|
||||
[% PROCESS "global/select-menu.html.tmpl" name="inclusion_to_remove" multiple="1" size="7" options=type.inclusions %]<br>
|
||||
[% html_select('inclusion_to_remove', '', type.inclusions, '', { multiple => '1', size => '7' }) %]
|
||||
<input type="submit" name="categoryAction-removeInclusion" value="Remove Inclusion">
|
||||
</td>
|
||||
<td style="vertical-align: top;">
|
||||
<b>Exclusions:</b><br>
|
||||
[% PROCESS "global/select-menu.html.tmpl" name="exclusion_to_remove" multiple="1" size="7" options=type.exclusions %]<br>
|
||||
[% html_select('exclusion_to_remove', '', type.exclusions, '', { multiple => '1', size => '7' }) %]
|
||||
<input type="submit" name="categoryAction-removeExclusion" value="Remove Exclusion">
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -25,13 +25,7 @@
|
|||
[% FOR f = incorrect_fields %]
|
||||
<td>
|
||||
<b>[% f.field.description | html %]:</b><br />
|
||||
[% PROCESS "global/select-menu.html.tmpl"
|
||||
name = f.field.name
|
||||
options = f.options
|
||||
default = f.options.0
|
||||
size = 10
|
||||
multiple = f.field.type == constants.FIELD_TYPE_MULTI_SELECT
|
||||
%]
|
||||
[% html_select(f.field.name, f.options.0, f.options, '', { size => 10, multiple => (f.field.type == constants.FIELD_TYPE_MULTI_SELECT) }) %]
|
||||
</td>
|
||||
[% END %]
|
||||
</tr>
|
||||
|
|
|
@ -207,11 +207,6 @@
|
|||
'series.frequency * 2',
|
||||
],
|
||||
|
||||
'global/select-menu.html.tmpl' => [
|
||||
'options',
|
||||
'size',
|
||||
],
|
||||
|
||||
'global/tabs.html.tmpl' => [
|
||||
'content',
|
||||
],
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
[%# 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 Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Myk Melez <myk@mozilla.org>
|
||||
#%]
|
||||
|
||||
[%# INTERFACE:
|
||||
# name: string; the name of the menu.
|
||||
#
|
||||
# multiple: boolean; whether or not the menu is multi-select
|
||||
#
|
||||
# size: integer; the number of items to display at once
|
||||
#
|
||||
# options: array or hash; the items with which to populate the array.
|
||||
# If a hash is passed, the hash keys become the names displayed
|
||||
# to the user while the hash values become the value of the item.
|
||||
#
|
||||
# default: string; the item selected in the menu by default.
|
||||
#
|
||||
# onchange: code; JavaScript to be run when the user changes the value
|
||||
# selected in the menu.
|
||||
#%]
|
||||
|
||||
[%# Get the scalar representation of the options reference,
|
||||
# which looks like "ARRAY(0xA352BA3F)" or "HASH(0xA352BA3F)",
|
||||
# so we can figure out whether it is a reference to an array
|
||||
# or a hash.
|
||||
#%]
|
||||
[% options_type = BLOCK %][% options %][% END %]
|
||||
|
||||
<select name="[% name FILTER html %]"
|
||||
[% IF onchange %]onchange="[% onchange FILTER html %]"[% END %]
|
||||
[% IF multiple %] multiple [% END %]
|
||||
[% IF size %] size="[% size %]" [% END %]>
|
||||
[% IF options_type.search("ARRAY") %]
|
||||
[% FOREACH value = options %]
|
||||
<option value="[% value FILTER html %]"
|
||||
[% " selected" IF value == default %]>
|
||||
[% value FILTER html %]
|
||||
</option>
|
||||
[% END %]
|
||||
[% ELSIF options_type.search("HASH") %]
|
||||
[% FOREACH option = options %]
|
||||
<option value="[% option.value FILTER html %]"
|
||||
[% " selected" IF option.value == default %]>
|
||||
[% option.key FILTER html %]
|
||||
</option>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</select>
|
|
@ -91,10 +91,7 @@ to some group are shown by default.
|
|||
</td>
|
||||
<th align="right">Flag:</th>
|
||||
<td>
|
||||
[% PROCESS "global/select-menu.html.tmpl"
|
||||
name="type"
|
||||
options=types
|
||||
default=selected_type %]
|
||||
[% html_select('type', selected_type, types) %]
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
@ -115,19 +112,16 @@ to some group are shown by default.
|
|||
<th align="right">Group By:</th>
|
||||
<td>
|
||||
[% groups = {
|
||||
"Requester" => 'requester' ,
|
||||
"Requestee" => 'requestee',
|
||||
"Flag" => 'type' ,
|
||||
"Product/Component" => 'category'
|
||||
'requester' => "Requester",
|
||||
'requestee' => "Requestee",
|
||||
'type' => "Flag",
|
||||
'category' => "Product/Component",
|
||||
} %]
|
||||
[% PROCESS "global/select-menu.html.tmpl" name="group" options=groups default=selected_group %]
|
||||
[% html_select('group', selected_group, groups) %]
|
||||
</td>
|
||||
<th align="right">Status:</th>
|
||||
<td>
|
||||
[% PROCESS "global/select-menu.html.tmpl"
|
||||
name="status"
|
||||
options=["all", "?", "+-", "+", "-"]
|
||||
default=selected_status %]
|
||||
[% html_select('status', selected_status, ["all", "?", "+-", "+", "-"]) %]
|
||||
</td>
|
||||
<td><input type="submit" id="filter" value="Filter" /></td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue