Document the newly added pagination template variable. Update the tests to look for it and test it

This commit is contained in:
Colin Kuskie 2008-11-24 02:23:48 +00:00
parent 9110697a3a
commit 2a40ab2e6c
3 changed files with 27 additions and 15 deletions

View file

@ -34,15 +34,15 @@ our $HELP = {
{ 'name' => 'pagination.pageCount.isMultiple' },
{ 'name' => 'pagination.pageList', },
{ 'name' => 'pagination.pageLoop',
'variables' => [ { 'name' => 'pagination.url' }, { 'name' => 'pagination.text' }, { 'name' => 'pagination.range' } ]
'variables' => [ { 'name' => 'pagination.url' }, { 'name' => 'pagination.text' }, { 'name' => 'pagination.range' }, { 'name' => 'pagination.activePage' }, ]
},
{ 'name' => 'pagination.pageList.upTo20' },
{ 'name' => 'pagination.pageLoop.upTo20',
'variables' => [ { 'name' => 'pagination.url' }, { 'name' => 'pagination.text' }, { 'name' => 'pagination.range' } ]
'variables' => [ { 'name' => 'pagination.url' }, { 'name' => 'pagination.text' }, { 'name' => 'pagination.range' }, { 'name' => 'pagination.activePage' }, ]
},
{ 'name' => 'pagination.pageList.upTo10' },
{ 'name' => 'pagination.pageLoop.upTo10',
'variables' => [ { 'name' => 'pagination.url' }, { 'name' => 'pagination.text' }, { 'name' => 'pagination.range' } ]
'variables' => [ { 'name' => 'pagination.url' }, { 'name' => 'pagination.text' }, { 'name' => 'pagination.range' }, { 'name' => 'pagination.activePage' }, ]
}
],
fields => [],

View file

@ -2112,6 +2112,11 @@ This group could then be named "Employees in HMO 1", and would allow you to rest
lastUpdated => 1220541683,
},
'pagination.activePage' => {
message => q|A boolean which will be true if the this page in the pageLoop is the currently viewed page.|,
lastUpdated => 1227493265,
},
'pagination.pageList.upTo20' => {
message => q|A list of links to the 20 nearest in the paginator relative to the current page. So if you're on page 60, you'll see links for 50-70.|,
lastUpdated => 1149182026,

View file

@ -48,18 +48,22 @@ cmp_bag([25..49], $p->getPageData(2), 'page 2 data correct');
cmp_bag([ ], $p->getPageData(5), 'page 5 data correct');
# Test getPageLinks
cmp_deeply(
[
map { +{
my $expectedPages;
$expectedPages = [ map { +{
'pagination.text' => ( $_ + 1 ),
'pagination.range' => ( 25 * $_ + 1 ) . "-" . ( $_ * 25 + 25 <= $endingRowNum + 1 ? $_ * 25 + 25 : $endingRowNum + 1 ), # First row number - Last row number
'pagination.url' => ( $_ != 0 ? $url . '?pn=' . ( $_ + 1 ) : '' ), # Current page has no URL
} } (0..$NumberOfPages-1)
],
} } (0..$NumberOfPages-1) ];
$expectedPages->[0]->{'pagination.activePage'} = 'true';
cmp_deeply(
($p->getPageLinks)[0],
$expectedPages,
'page links correct',
);
$startingRowNum = 0;
$endingRowNum = 100;
@paginatingData = ($startingRowNum..$endingRowNum);
@ -83,16 +87,19 @@ is('100', $p->getPage(5), '(101) page 5 stringification okay');
is($p->getPageNumber, 1, 'Default page number is 1'); ##Additional page numbers are specified at instantiation
# Test getPageLinks
cmp_deeply(
($p->getPageLinks)[0],
[
map { +{
$expectedPages = [ map { +{
'pagination.text' => ( $_ + 1 ),
'pagination.range' => ( 25 * $_ + 1 ) . "-" . ( $_ * 25 + 25 <= $endingRowNum + 1 ? $_ * 25 + 25 : $endingRowNum + 1 ), # First row number - Last row number
'pagination.url' => ( $_ != 0 ? $url . '?pn=' . ( $_ + 1 ) : '' ), # Current page has no URL
} } (0..$NumberOfPages-1)
],
} } (0..$NumberOfPages-1) ];
$expectedPages->[0]->{'pagination.activePage'} = 'true';
# Test getPageLinks
cmp_deeply(
($p->getPageLinks)[0],
$expectedPages,
'page links correct',
);