summaryrefslogtreecommitdiff
path: root/rt/share/html/Search/Elements/SelectGroupBy
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-07-09 22:18:55 -0700
committerIvan Kohler <ivan@freeside.biz>2015-07-09 22:18:55 -0700
commit1c538bfabc2cd31f27067505f0c3d1a46cba6ef0 (patch)
tree96922ad4459eda1e649327fd391d60c58d454c53 /rt/share/html/Search/Elements/SelectGroupBy
parent4f5619288413a185e9933088d9dd8c5afbc55dfa (diff)
RT 4.2.11, ticket#13852
Diffstat (limited to 'rt/share/html/Search/Elements/SelectGroupBy')
-rw-r--r--rt/share/html/Search/Elements/SelectGroupBy26
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="">&nbsp;</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>