Explorar o código

Add batch blocks.

Romain Geissler %!s(int64=13) %!d(string=hai) anos
pai
achega
f80d03ba43
Modificáronse 1 ficheiros con 29 adicións e 23 borrados
  1. 29 23
      Resources/views/CRUD/base_list.html.twig

+ 29 - 23
Resources/views/CRUD/base_list.html.twig

@@ -132,31 +132,37 @@ file that was distributed with this source code.
             </table>
 
             {% if batchactions|length > 0%}
-                <script type="text/javascript">
-                    jQuery(document).ready(function($){
-                       $('#list_batch_checkbox').click(function(){
-                           $(this).closest('table').find("td input[type='checkbox']").attr('checked', $(this).is(':checked')).parent().parent().toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'));
-                       });
-                       $("td.sonata-ba-list-field-batch input[type='checkbox']").change(function(){
-                           $(this).parent().parent().toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'));
-                       });
-                    });
-                </script>
-
-                <div class="actions sonata-ba-list-actions">
-                    <select name="action">
-                        {% for action, options in batchactions %}
-                            <option value="{{ action }}">{{ options.label }}</option>
-                        {% endfor %}
-                    </select>
+                {% block batch %}
+                    <script type="text/javascript">
+                        {% block batch_javascript %}
+                            jQuery(document).ready(function($){
+                               $('#list_batch_checkbox').click(function(){
+                                   $(this).closest('table').find("td input[type='checkbox']").attr('checked', $(this).is(':checked')).parent().parent().toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'));
+                               });
+                               $("td.sonata-ba-list-field-batch input[type='checkbox']").change(function(){
+                                   $(this).parent().parent().toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'));
+                               });
+                            });
+                        {% endblock %}
+                    </script>
+
+                    <div class="actions sonata-ba-list-actions">
+                        {% block batch_actions %}
+                            <select name="action">
+                                {% for action, options in batchactions %}
+                                    <option value="{{ action }}">{{ options.label }}</option>
+                                {% endfor %}
+                            </select>
 
-                    <label>
-                        <input type="checkbox" name="all_elements"/>
-                        {% trans from 'SonataAdminBundle' %}all_elements{% endtrans %}
-                    </label>
+                            <label>
+                                <input type="checkbox" name="all_elements"/>
+                                {% trans from 'SonataAdminBundle' %}all_elements{% endtrans %}
+                            </label>
 
-                    <input type="submit" class="btn primary" value="{% trans from 'SonataAdminBundle' %}btn_batch{% endtrans %}" />
-                </div>
+                            <input type="submit" class="btn primary" value="{% trans from 'SonataAdminBundle' %}btn_batch{% endtrans %}" />
+                        {% endblock %}
+                    </div>
+                {% endblock %}
             {% endif %}
         </form>
     {% else %}