diff options
author | Simon Green <sgreen@redhat.com> | 2014-08-10 17:42:10 +1000 |
---|---|---|
committer | Simon Green <sgreen@redhat.com> | 2014-08-10 17:42:10 +1000 |
commit | f4b9806c5ab5e63383269ef328643145ade66004 (patch) | |
tree | 3bc3f7918a1aa5c80387c69846de5e34b241fba7 /Bugzilla | |
parent | a6cb5aa278082c88958cfac19fc39b1cfc3306b0 (diff) | |
download | bugs-f4b9806c5ab5e63383269ef328643145ade66004.tar bugs-f4b9806c5ab5e63383269ef328643145ade66004.tar.gz bugs-f4b9806c5ab5e63383269ef328643145ade66004.tar.bz2 bugs-f4b9806c5ab5e63383269ef328643145ade66004.tar.xz bugs-f4b9806c5ab5e63383269ef328643145ade66004.zip |
Bug 897915 - Field lists not sorted alphabetically
r=dkl, a=sgreen
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Template.pm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index b36249b2f..52ccee593 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -611,6 +611,21 @@ $Template::Stash::LIST_OPS->{ clone } = return [@$list]; }; +# Allow us to sort the list of fields correctly +$Template::Stash::LIST_OPS->{ sort_by_field_name } = + sub { + sub field_name { + if ($_[0] eq 'noop') { + # Sort --- first + return ''; + } + # Otherwise sort by field_desc or description + return $_[1]{$_[0]} || $_[0]; + } + my ($list, $field_desc) = @_; + return [ sort { lc field_name($a, $field_desc) cmp lc field_name($b, $field_desc) } @$list ]; + }; + # Allow us to still get the scalar if we use the list operation ".0" on it, # as we often do for defaults in query.cgi and other places. $Template::Stash::SCALAR_OPS->{ 0 } = |