unstable switchover before template renaming. added searchpath for widgets trying...
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / GridView / Role / Pager.pm
CommitLineData
e22de101 1package Reaction::UI::ViewPort::GridView::Role::Pager;
2
3use Reaction::Role;
4
5use aliased 'Reaction::InterfaceModel::Collection';
6
7role Pager, which {
8
9 has paged_collection => (isa => Collection, is => 'rw', lazy_build => 1);
10
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'));
14
15 implements build_page => as { 1 };
16 implements build_per_page => as { 10 };
17
18 implements build_pager => as { shift->paged_collection->pager };
19
20 implements adopt_page => as {
21 my ($self) = @_;
22 $self->clear_paged_collection;
23 $self->clear_pager;
24 };
25
26 around accept_events => sub { ('page', shift->(@_)); };
27
28 implements build_paged_collection => sub {
29 my ($self) = @_;
30 my $collection = $self->current_collection;
31 return $collection->where(undef, {rows => $self->per_page})->page($self->page);
32 };
33
34};
35
361;