1 package Reaction::UI::ViewPort::GridView::Role::Pager;
5 use aliased 'Reaction::InterfaceModel::Collection';
9 has paged_collection => (isa => Collection, is => 'rw', lazy_build => 1);
11 has pager => (isa => 'Data::Page', is => 'rw', lazy_build => 1);
12 has page => (isa => 'Int', is => 'rw', lazy_build => 1, trigger_adopt('page'));
13 has per_page => (isa => 'Int', is => 'rw', lazy_build => 1, trigger_adopt('page'));
15 implements build_page => as { 1 };
16 implements build_per_page => as { 10 };
18 implements build_pager => as { shift->paged_collection->pager };
20 implements adopt_page => as {
22 $self->clear_paged_collection;
26 around accept_events => sub { ('page', shift->(@_)); };
28 implements build_paged_collection => sub {
30 my $collection = $self->current_collection;
31 return $collection->where(undef, {rows => $self->per_page})->page($self->page);