unstable switchover before template renaming. added searchpath for widgets trying...
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / GridView / Role / Order.pm
CommitLineData
e22de101 1package Reaction::UI::ViewPort::GridView::Role::Order;
2
3use Reaction::Role;
4
5role Order, which {
6
7 has order_by => (isa => 'Str', is => 'rw', trigger_adopt('order_by'));
8 has order_by_desc => (isa => 'Int', is => 'rw', trigger_adopt('order_by'), lazy_build => 1);
9
10 around build_current_collection => sub {
11 my $orig = shift;
12 my ($self) = @_;
13 my $collection = $orig->(@_);
14 my %attrs;
15
16 #XXX DBICism that needs to be fixed
17 if ($self->has_order_by) {
18 $attrs{order_by} = $self->order_by;
19 $attrs{order_by} .= ' DESC' if ($self->order_by_desc);
20 }
21
22 return $collection->where(undef, \%attrs);
23 };
24
25 around accept_events => sub { ('order_by', 'order_by_desc', shift->(@_)); };
26
27};
28
291;