Explorar el Código

Merge branch 'master' into migrate_to_core_inline_validation

Thomas Rabaix hace 10 años
padre
commit
2f9c6ff70e
Se han modificado 2 ficheros con 84 adiciones y 82 borrados
  1. 2 2
      Admin/Admin.php
  2. 82 80
      Resources/views/CRUD/base_list.html.twig

+ 2 - 2
Admin/Admin.php

@@ -26,8 +26,8 @@ use Sonata\AdminBundle\Datagrid\ListMapper;
 use Sonata\AdminBundle\Datagrid\DatagridMapper;
 use Sonata\AdminBundle\Show\ShowMapper;
 
-use Sonata\CoreBundle\Validator\ErrorElement;
-use Sonata\CoreBundle\Validator\Constraints\InlineConstraint;
+use Sonata\AdminBundle\Validator\ErrorElement;
+use Sonata\AdminBundle\Validator\Constraints\InlineConstraint;
 
 use Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface;
 use Sonata\AdminBundle\Builder\FormContractorInterface;

+ 82 - 80
Resources/views/CRUD/base_list.html.twig

@@ -92,93 +92,95 @@ file that was distributed with this source code.
                         {{ sonata_block_render_event('sonata.admin.list.table.bottom', { 'admin': admin }) }}
                     </div>
                     {% block list_footer %}
-                        <div class="box-footer">
-                            <div class="form-inline clearfix">
-                                {% if not app.request.isXmlHttpRequest %}
-                                    <div class="pull-left">
-                                        {% if admin.hasRoute('batch') and batchactions|length > 0  %}
-                                            {% block batch %}
-                                                <script>
-                                                    {% block batch_javascript %}
-                                                    jQuery(document).ready(function ($) {
-                                                        $('#list_batch_checkbox').on('ifChanged', function () {
-                                                            $(this)
-                                                                    .closest('table')
-                                                                    .find('td.sonata-ba-list-field-batch input[type="checkbox"], div.sonata-ba-list-field-batch input[type="checkbox"]')
-                                                                    .iCheck($(this).is(':checked') ? 'check' : 'uncheck')
+                        {% if admin.datagrid.results|length > 0 %}
+                            <div class="box-footer">
+                                <div class="form-inline clearfix">
+                                    {% if not app.request.isXmlHttpRequest %}
+                                        <div class="pull-left">
+                                            {% if admin.hasRoute('batch') and batchactions|length > 0  %}
+                                                {% block batch %}
+                                                    <script>
+                                                        {% block batch_javascript %}
+                                                        jQuery(document).ready(function ($) {
+                                                            $('#list_batch_checkbox').on('ifChanged', function () {
+                                                                $(this)
+                                                                        .closest('table')
+                                                                        .find('td.sonata-ba-list-field-batch input[type="checkbox"], div.sonata-ba-list-field-batch input[type="checkbox"]')
+                                                                        .iCheck($(this).is(':checked') ? 'check' : 'uncheck')
+                                                                ;
+                                                            });
+
+                                                            $('td.sonata-ba-list-field-batch input[type="checkbox"], div.sonata-ba-list-field-batch input[type="checkbox"]')
+                                                                    .on('ifChanged', function () {
+                                                                        $(this)
+                                                                                .closest('tr, div.sonata-ba-list-field-batch')
+                                                                                .toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'))
+                                                                        ;
+                                                                    })
+                                                                    .trigger('ifChanged')
                                                             ;
                                                         });
+                                                        {% endblock %}
+                                                    </script>
+
+                                                {% block batch_actions %}
+                                                    <label class="checkbox" for="{{ admin.uniqid }}_all_elements">
+                                                        <input type="checkbox" name="all_elements" id="{{ admin.uniqid }}_all_elements">
+                                                        {{ 'all_elements'|trans({}, 'SonataAdminBundle') }}
+                                                        ({{ admin.datagrid.pager.nbresults }})
+                                                    </label>
+
+                                                    <select name="action" style="width: auto; height: auto" class="form-control">
+                                                        {% for action, options in batchactions %}
+                                                            <option value="{{ action }}">{{ options.label }}</option>
+                                                        {% endfor %}
+                                                    </select>
+                                                {% endblock %}
 
-                                                        $('td.sonata-ba-list-field-batch input[type="checkbox"], div.sonata-ba-list-field-batch input[type="checkbox"]')
-                                                                .on('ifChanged', function () {
-                                                                    $(this)
-                                                                            .closest('tr, div.sonata-ba-list-field-batch')
-                                                                            .toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'))
-                                                                    ;
-                                                                })
-                                                                .trigger('ifChanged')
-                                                        ;
-                                                    });
-                                                    {% endblock %}
-                                                </script>
-
-                                            {% block batch_actions %}
-                                                <label class="checkbox" for="{{ admin.uniqid }}_all_elements">
-                                                    <input type="checkbox" name="all_elements" id="{{ admin.uniqid }}_all_elements">
-                                                    {{ 'all_elements'|trans({}, 'SonataAdminBundle') }}
-                                                    ({{ admin.datagrid.pager.nbresults }})
-                                                </label>
-
-                                                <select name="action" style="width: auto; height: auto" class="form-control">
-                                                    {% for action, options in batchactions %}
-                                                        <option value="{{ action }}">{{ options.label }}</option>
-                                                    {% endfor %}
-                                                </select>
-                                            {% endblock %}
-
-                                                <input type="submit" class="btn btn-small btn-primary" value="{{ 'btn_batch'|trans({}, 'SonataAdminBundle') }}">
-                                            {% endblock %}
-                                        {% endif %}
-                                    </div>
-
+                                                    <input type="submit" class="btn btn-small btn-primary" value="{{ 'btn_batch'|trans({}, 'SonataAdminBundle') }}">
+                                                {% endblock %}
+                                            {% endif %}
+                                        </div>
 
-                                    <div class="pull-right">
-                                        {% if admin.hasRoute('export') and admin.isGranted("EXPORT") and admin.getExportFormats()|length %}
-                                            <div class="btn-group">
-                                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
-                                                    <i class="glyphicon glyphicon-export"></i>
-                                                    {{ "label_export_download"|trans({}, "SonataAdminBundle") }}
-                                                    <span class="caret"></span>
-                                                </button>
-                                                <ul class="dropdown-menu">
-                                                    {% for format in admin.getExportFormats() %}
-                                                    <li>
-                                                        <a href="{{ admin.generateUrl('export', admin.modelmanager.paginationparameters(admin.datagrid, 0) + {'format' : format}) }}">
-                                                            <i class="glyphicon glyphicon-download"></i>
-                                                            {{ format|upper }}
-                                                        </a>
-                                                    <li>
-                                                        {% endfor %}
-                                                </ul>
-                                            </div>
 
-                                            &nbsp;-&nbsp;
-                                        {% endif %}
+                                        <div class="pull-right">
+                                            {% if admin.hasRoute('export') and admin.isGranted("EXPORT") and admin.getExportFormats()|length %}
+                                                <div class="btn-group">
+                                                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
+                                                        <i class="glyphicon glyphicon-export"></i>
+                                                        {{ "label_export_download"|trans({}, "SonataAdminBundle") }}
+                                                        <span class="caret"></span>
+                                                    </button>
+                                                    <ul class="dropdown-menu">
+                                                        {% for format in admin.getExportFormats() %}
+                                                        <li>
+                                                            <a href="{{ admin.generateUrl('export', admin.modelmanager.paginationparameters(admin.datagrid, 0) + {'format' : format}) }}">
+                                                                <i class="glyphicon glyphicon-download"></i>
+                                                                {{ format|upper }}
+                                                            </a>
+                                                        <li>
+                                                            {% endfor %}
+                                                    </ul>
+                                                </div>
+
+                                                &nbsp;-&nbsp;
+                                            {% endif %}
+
+                                            {% block pager_results %}
+                                                {% include admin.getTemplate('pager_results') %}
+                                            {% endblock %}
+                                        </div>
+                                    {% endif %}
+                                </div>
 
-                                        {% block pager_results %}
-                                            {% include admin.getTemplate('pager_results') %}
-                                        {% endblock %}
-                                    </div>
-                                {% endif %}
+                                {% block pager_links %}
+                                    {% if admin.datagrid.pager.haveToPaginate() %}
+                                        <hr/>
+                                        {% include admin.getTemplate('pager_links') %}
+                                    {% endif %}
+                                {% endblock %}
                             </div>
-
-                            {% block pager_links %}
-                                {% if admin.datagrid.pager.haveToPaginate() %}
-                                    <hr/>
-                                    {% include admin.getTemplate('pager_links') %}
-                                {% endif %}
-                            {% endblock %}
-                        </div>
+                        {% endif %}
                     {% endblock %}
                 </div>
         {% if admin.hasRoute('batch') %}