1 package Reaction::UI::ViewPort::GridView::Role::Order;
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);
10 before order_by => sub {
12 my ($self, $val) = @_;
13 confess "invalid column name for order_by"
14 unless grep { $val eq $_ } $self->collection
21 implements _build_order_by_desc => as { 0 };
23 implements adopt_order_by => as {
24 shift->clear_current_collection;
27 around _build_current_collection => sub {
30 my $collection = $orig->(@_);
33 #XXX DBICism that needs to be fixed
34 if ($self->has_order_by) {
35 $attrs{order_by} = $self->order_by;
36 $attrs{order_by} .= ' DESC' if ($self->order_by_desc);
39 return $collection->where(undef, \%attrs);
42 around accept_events => sub { ('order_by', 'order_by_desc', shift->(@_)); };