Fix a bug in the paginator where in 10/20 page links the number
of pages becomes less than 10/20. Add lots of Paginator tests to check this.
This commit is contained in:
parent
a8979545ef
commit
91ecdda498
3 changed files with 145 additions and 7 deletions
|
|
@ -504,6 +504,10 @@ sub getPageLinks {
|
|||
my $start = ($minPage > 0) ? $minPage : 1;
|
||||
my $maxPage = $start + $limit - 1;
|
||||
my $end = ($maxPage < $self->getPageNumber) ? $self->getPageNumber : $maxPage;
|
||||
if ($maxPage > $self->getNumberOfPages) {
|
||||
$end = $self->getNumberOfPages;
|
||||
$start = $self->getNumberOfPages - $limit + 1;
|
||||
}
|
||||
my @temp;
|
||||
foreach my $page (@pages) {
|
||||
if ($i <= $end && $i >= $start) {
|
||||
|
|
@ -754,5 +758,24 @@ sub setAlphabeticalKey {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setPageNumber ( pageNumber )
|
||||
|
||||
Sets the page number. This is really a convenience method for testing.
|
||||
Returns the page number that was set.
|
||||
|
||||
=head3 pageNumber
|
||||
|
||||
Sets the pageNumber. Setting the pageNumber outside of the set of
|
||||
pages would cause the Paginator to behave poorly.
|
||||
|
||||
=cut
|
||||
|
||||
sub setPageNumber {
|
||||
my $self = shift;
|
||||
$self->{_pn} = shift;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue