Skip to content

Commit

Permalink
Merge pull request sonata-project#1829 from sylvaindeloux/SONATA-192
Browse files Browse the repository at this point in the history
Added parameter to limit pager links
  • Loading branch information
rande committed Dec 4, 2013
2 parents ac21332 + 3660371 commit 939f836
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function getConfigTreeBuilder()
->booleanNode('html5_validate')->defaultValue(true)->end()
->booleanNode('confirm_exit')->defaultValue(true)->end()
->booleanNode('use_select2')->defaultValue(true)->end()
->integerNode('pager_links')->defaultValue(null)->end()
->end()
->end()
->arrayNode('dashboard')
Expand Down
1 change: 1 addition & 0 deletions Resources/doc/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Full Configuration Options
options:
html5_validate: false # does not use html5 validation
confirm_exit: false # disable confirmation when quitting with unsaved changes
pager_links: 5 # pager max links to display
# set to true to persist filter settings per admin module in the user's session
persist_filters: false
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/Pager/base_links.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ file that was distributed with this source code.
{% endif %}

{# Set the number of pages to display in the pager #}
{% for page in admin.datagrid.pager.getLinks() %}
{% for page in admin.datagrid.pager.getLinks(admin_pool.getOption('pager_links')) %}
{% if page == admin.datagrid.pager.page %}
<li class="active"><a href="{{ admin.generateUrl('list', admin.modelmanager.paginationparameters(admin.datagrid, page)) }}">{{ page }}</a></li>
{% else %}
Expand Down
3 changes: 2 additions & 1 deletion Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function testOptions()
$config = $processor->processConfiguration(new Configuration(), array());

$this->assertTrue($config['options']['html5_validate']);
$this->assertNull($config['options']['pager_links']);
$this->assertTrue($config['options']['confirm_exit']);
}

Expand All @@ -38,4 +39,4 @@ public function testOptionsWithInvalidFormat()
)
)));
}
}
}

0 comments on commit 939f836

Please sign in to comment.