1 package Reaction::UI::ViewPort::GridView::Role::Pager;
5 use aliased 'Reaction::InterfaceModel::Collection';
7 # XX This needs to be consumed after Ordered
10 #has paged_collection => (isa => Collection, is => 'rw', lazy_build => 1);
12 has pager => (isa => 'Data::Page', is => 'rw', lazy_build => 1);
13 has page => (isa => 'Int', is => 'rw', lazy_build => 1, trigger_adopt('page'));
14 has per_page => (isa => 'Int', is => 'rw', lazy_build => 1, trigger_adopt('page'));
16 implements build_page => as { 1 };
17 implements build_per_page => as { 10 };
19 implements build_pager => as { shift->current_collection->pager };
21 implements adopt_page => as {
23 #$self->clear_paged_collection;
24 $self->clear_current_collection;
28 around accept_events => sub { ('page', shift->(@_)); };
30 #implements build_paged_collection => as {
32 # my $collection = $self->current_collection;
33 # return $collection->where(undef, {rows => $self->per_page})->page($self->page);
36 around build_current_collection => sub {
39 my $collection = $orig->(@_);
40 return $collection->where(undef, {rows => $self->per_page})->page($self->page);