1 package Reaction::UI::ViewPort::Collection::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'));
15 has per_page_max => (isa => 'Int', is => 'rw', lazy_build => 1);
17 implements _build_page => as { 1 };
18 implements _build_per_page => as { 10 };
19 implements _build_per_page_max => as { 100 };
21 implements _build_pager => as { shift->current_collection->pager };
23 implements adopt_page => as {
25 #$self->clear_paged_collection;
28 $self->clear_current_collection;
31 around accept_events => sub { ('page','per_page', shift->(@_)); };
33 #implements build_paged_collection => as {
35 # my $collection = $self->current_collection;
36 # return $collection->where(undef, {rows => $self->per_page})->page($self->page);
39 around _build_current_collection => sub {
42 my $collection = $orig->(@_);
43 return $collection->where(undef, {rows => $self->per_page})->page($self->page);