[Bps-public-commit] rt-extension-assets branch, master, updated. 1.02rc1-2-g3cc0bfe
Alex Vandiver
alexmv at bestpractical.com
Mon Nov 3 12:13:00 EST 2014
The branch, master has been updated
via 3cc0bfe57cc007fbcd1a3c9ce49f32211e820643 (commit)
via 2d7c175b51759d8af346c7667d95f0372d0ee0ee (commit)
from 5c377658e8b3c43ab6409266837571225e5359a4 (commit)
Summary of changes:
lib/RT/Assets.pm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit 2d7c175b51759d8af346c7667d95f0372d0ee0ee
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Oct 29 14:13:01 2014 -0400
Fix sorting by asset custom fields
Assets rely on the core _OrderByCF function to implement the relevant
joins and ORDER BY clauses; _OrderByCF was refactored for this purpose.
Unfortunately, bestpractical/rt at 63ca3d85 (in 4.2.0 and later) changed
the method to take three arguments, not two. An undefined CF was thus
passed into the ordering function, leading to nonsensical joins,
sometimes empty results, and apparently-random row ordering.
Update the calling convention to pass the three arguments that the core
method expects.
diff --git a/lib/RT/Assets.pm b/lib/RT/Assets.pm
index 52f39fa..504ad47 100644
--- a/lib/RT/Assets.pm
+++ b/lib/RT/Assets.pm
@@ -210,7 +210,7 @@ sub OrderByCols {
my @res = ();
for my $row (@_) {
if ( blessed($row->{FIELD}) and $row->{FIELD}->isa("RT::CustomField") ) {
- push @res, $self->_OrderByCF( $row, $row->{FIELD} );
+ push @res, $self->_OrderByCF( $row, $row->{FIELD}->id, $row->{FIELD} );
} else {
push @res, $row;
}
commit 3cc0bfe57cc007fbcd1a3c9ce49f32211e820643
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Oct 30 17:00:49 2014 -0400
Allow sorting by role groups
diff --git a/lib/RT/Assets.pm b/lib/RT/Assets.pm
index 504ad47..5081ac8 100644
--- a/lib/RT/Assets.pm
+++ b/lib/RT/Assets.pm
@@ -208,12 +208,28 @@ sub SimpleSearch {
sub OrderByCols {
my $self = shift;
my @res = ();
+
+ my $class = $self->_RoleGroupClass;
+
for my $row (@_) {
if ( blessed($row->{FIELD}) and $row->{FIELD}->isa("RT::CustomField") ) {
push @res, $self->_OrderByCF( $row, $row->{FIELD}->id, $row->{FIELD} );
+ } elsif ($row->{FIELD} =~ /^(\w+)(?:\.(\w+))?$/) {
+ my ($role, $subkey) = ($1, $2);
+ if ($class->HasRole($role)) {
+ $self->{_order_by_role}{ $role }
+ ||= ( $self->_WatcherJoin( Name => $role, Class => $class) )[2];
+ push @res, {
+ %$row,
+ ALIAS => $self->{_order_by_role}{ $role },
+ FIELD => $subkey || 'EmailAddress',
+ };
+ } else {
+ push @res, $row;
+ }
} else {
push @res, $row;
- }
+ }
}
return $self->SUPER::OrderByCols( @res );
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list