Mailing List Archive

rt branch, 4.4/sort-external-cf-values, created. rt-4.4.4-45-gcea23cb97
The branch, 4.4/sort-external-cf-values has been created
at cea23cb97465440a1f5e33c40f676f8a32a4ab2a (commit)

- Log -----------------------------------------------------------------
commit cea23cb97465440a1f5e33c40f676f8a32a4ab2a
Author: Blaine Motsinger <blaine@bestpractical.com>
Date: Mon Jun 3 20:09:21 2019 -0500

Add sort for external custom field values

This commit adds sorting for external custom field values using both
the name and sortorder values.

diff --git a/lib/RT/CustomFieldValues/External.pm b/lib/RT/CustomFieldValues/External.pm
index ad0bdcb4e..7dc972147 100644
--- a/lib/RT/CustomFieldValues/External.pm
+++ b/lib/RT/CustomFieldValues/External.pm
@@ -191,7 +191,8 @@ sub _DoSearch {
my $i = 0;

my $check = $self->__BuildAggregatorsCheck;
- foreach( @{ $self->ExternalValues } ) {
+
+ foreach( $self->_SortValues( @{ $self->ExternalValues } ) ) {
my $value = $self->NewItem;
$value->LoadFromHash( { %defaults, %$_ } );
next if $check && !$check->( $self, $value );
@@ -202,6 +203,16 @@ sub _DoSearch {
return $self->_RecordCount;
}

+sub _SortValues {
+ my $self = shift;
+ my @items = @_;
+
+ no warnings 'uninitialized';
+
+ return sort { $a->{sortorder} <=> $b->{sortorder} || lc($a->{name}) cmp lc($b->{name}) }
+ @items;
+}
+
sub _DoCount {
my $self = shift;


-----------------------------------------------------------------------
_______________________________________________
rt-commit mailing list
rt-commit@lists.bestpractical.com
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit