diff options
Diffstat (limited to 'rt/share/html/Search/Elements/SelectGroupBy')
-rw-r--r-- | rt/share/html/Search/Elements/SelectGroupBy | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/rt/share/html/Search/Elements/SelectGroupBy b/rt/share/html/Search/Elements/SelectGroupBy index 8daab6daa..99f0f47eb 100644 --- a/rt/share/html/Search/Elements/SelectGroupBy +++ b/rt/share/html/Search/Elements/SelectGroupBy @@ -49,11 +49,29 @@ $Name => 'GroupBy' $Default => 'Status' $Query => '' +$ShowEmpty => 0 </%args> -<select id="<% $Name %>" name="<% $Name %>"> -% while (@options) { -% my ($text, $value) = (shift @options, shift @options); -<option value="<% $value %>" <% $value eq $Default ? 'selected="selected"' : '' |n%>><% $text %></option> +<select name="<% $Name %>" class="cascade-by-optgroup"> +% if ( $ShowEmpty ) { +<option value=""> </option> +% } +<%perl> +my $in_optgroup = ""; +while ( my ($label, $value) = splice @options, 0, 2 ) { + my ($optgroup, $text) = @$label; + if ($in_optgroup ne $optgroup) { + $m->out("</optgroup>\n") if $in_optgroup; + + my $name = $m->interp->apply_escapes(loc($optgroup), 'h'); + $m->out(qq[<optgroup label="$name">\n]); + + $in_optgroup = $optgroup; + } +</%perl> +<option value="<% $value %>" <% $value eq ($Default||'') ? 'selected="selected"' : '' |n %>><% loc($text) %></option> +% } +% if ($in_optgroup) { + </optgroup> % } </select> <%init> |