Skip to content

Commit

Permalink
Merge pull request sonata-project#1402 from EmmanuelVella/choose
Browse files Browse the repository at this point in the history
Add row selector for sonata_type_model_list
  • Loading branch information
rande committed Jun 12, 2013
2 parents 789de28 + 51fb3d1 commit 4af7d58
Show file tree
Hide file tree
Showing 28 changed files with 138 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,19 @@ protected function buildList()
foreach ($this->getExtensions() as $extension) {
$extension->configureListFields($mapper);
}

if ($this->hasRequest() && $this->getRequest()->isXmlHttpRequest()) {
$fieldDescription = $this->getModelManager()->getNewFieldDescriptionInstance($this->getClass(), 'select', array(
'label' => false,
'code' => '_select',
'sortable' => false,
));

$fieldDescription->setAdmin($this);
$fieldDescription->setTemplate($this->getTemplate('select'));

$mapper->add($fieldDescription, 'select');
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public function fixTemplates(ContainerBuilder $container, Definition $definition
'list_block' => 'SonataAdminBundle:Block:block_admin_list.html.twig',
'delete' => 'SonataAdminBundle:CRUD:delete.html.twig',
'batch' => 'SonataAdminBundle:CRUD:list__batch.html.twig',
'select' => 'SonataAdminBundle:CRUD:list__select.html.twig',
'batch_confirmation' => 'SonataAdminBundle:CRUD:batch_confirmation.html.twig',
'inner_list_row' => 'SonataAdminBundle:CRUD:list_inner_row.html.twig',
'base_list_field' => 'SonataAdminBundle:CRUD:base_list_field.html.twig',
Expand Down
11 changes: 11 additions & 0 deletions Resources/public/css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ body.sonata-bc {
float: right
}

.sonata-bc .sonata-ba-list tr:hover td.sonata-ba-list-field.sonata-ba-list-field-select a {
visibility: visible;
}

.sonata-bc td.sonata-ba-list-field.sonata-ba-list-field-select {
text-align: center;
}
.sonata-bc td.sonata-ba-list-field.sonata-ba-list-field-select a {
visibility: hidden;
}

.sonata-bc div.sonata-ba-modal-edit-one-to-one td.sonata-ba-list-field-batch,
.sonata-bc div.sonata-ba-modal-edit-one-to-one div.sonata-ba-list-actions,
.sonata-bc div.sonata-ba-modal-edit-one-to-one th.sonata-ba-list-field-header-batch {
Expand Down
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.bg.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>На страница</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.ca.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Per pàgina</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.cs.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Zobrazit nejvíce</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.de.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Einträge pro Seite</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Per page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>Select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.es.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Por página</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.eu.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>label_per_page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.fa.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>در هر صفحه</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.fr.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Par page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>Sélectionner</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.hr.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>label_per_page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.hu.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>label_per_page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.it.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>label_per_page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.ja.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>1ページの件数</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.lb.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>label_per_page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.nl.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Aantal per pagina</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.pl.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Na stronie</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.pt.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>label_per_page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.pt_BR.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>label_per_page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.ru.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Записей на страницу</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.sk.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Zobraziť najviac</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.sl.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>label_per_page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.uk.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>Записів на сторінку</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 4 additions & 0 deletions Resources/translations/SonataAdminBundle.zh_CN.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@
<source>label_per_page</source>
<target>label_per_page</target>
</trans-unit>
<trans-unit id="list_select">
<source>list_select</source>
<target>list_select</target>
</trans-unit>
</body>
</file>
</xliff>
2 changes: 2 additions & 0 deletions Resources/views/CRUD/base_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ file that was distributed with this source code.
<th class="sonata-ba-list-field-header sonata-ba-list-field-header-batch">
<input type="checkbox" id="list_batch_checkbox" />
</th>
{% elseif field_description.getOption('code') == '_select' %}
<th class="sonata-ba-list-field-header sonata-ba-list-field-header-select"></th>
{% elseif field_description.name == '_action' and app.request.isXmlHttpRequest %}
{# Action buttons disabled in ajax view! #}
{% else %}
Expand Down
19 changes: 19 additions & 0 deletions Resources/views/CRUD/list__select.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}

{% extends admin.getTemplate('base_list_field') %}

{% block field %}
<a class="btn" href="#">
<i class="icon-arrow-right"></i>
{{ 'list_select'|trans({}, 'SonataAdminBundle') }}
</a>
{% endblock %}

0 comments on commit 4af7d58

Please sign in to comment.