base_list.twig.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. {#
  2. This file is part of the Sonata package.
  3. (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  4. For the full copyright and license information, please view the LICENSE
  5. file that was distributed with this source code.
  6. #}
  7. {% extends base_template %}
  8. {% block title %}{% trans 'title_list' from 'BaseApplicationBundle'%}{% endblock %}
  9. {% block actions %}
  10. <div class="sonata-actions">
  11. <ul>
  12. <li class="sonata-action-element"><a href="{{ admin.generateUrl('create') }}">{% trans "link_action_create" from "BaseApplicationBundle" %}</a></li>
  13. </ul>
  14. </div>
  15. {% endblock %}
  16. {% block list_table %}
  17. <form action="{{ admin.generateUrl('batch') }}" method="POST" >
  18. <table>
  19. {% block table_header %}
  20. <tr>
  21. {% for field_description in list.elements %}
  22. {% if field_description.getOption('code') == '_batch' %}
  23. <th class="sonata-ba-list-field-header sonata-ba-list-field-header-batch"><input type="checkbox" id="list_batch_checkbox" /></th>
  24. {% else %}
  25. <th class="sonata-ba-list-field-header sonata-ba-list-field-header-{{ field_description.type}}">{{ field_description.name }}</th>
  26. {% endif %}
  27. {% endfor %}
  28. </tr>
  29. {% endblock %}
  30. {% block table_body %}{% endblock %}
  31. {% block table_footer %}
  32. {% if datagrid.pager.haveToPaginate() %}
  33. <tr>
  34. <td colspan="{{ list.elements|length }}" class="pager">
  35. <ul>
  36. {% if datagrid.pager.page != datagrid.pager.previouspage %}
  37. <li><a href="{{ admin.generateUrl('list', datagrid.values|merge({'page': datagrid.pager.previouspage})) }}">{% trans 'link_previous_pager' from 'BaseApplicationBundle' %}</a></li>
  38. {% endif %}
  39. {# Set the number of pages to display in the pager #}
  40. {% for page in datagrid.pager.getLinks(5) %}
  41. {% if page == datagrid.pager.page %}
  42. <li>{{ page }}</li>
  43. {% else %}
  44. <li><a href="{{ admin.generateUrl('list', datagrid.values|merge({'page': page})) }}">{{ page }}</a></li>
  45. {% endif %}
  46. {% endfor %}
  47. {% if datagrid.pager.page != datagrid.pager.nextpage %}
  48. <li><a href="{{ admin.generateUrl('list', datagrid.values|merge({'page': datagrid.pager.nextpage})) }}">{% trans 'link_next_pager' from 'BaseApplicationBundle' %}</a></li>
  49. {% endif %}
  50. </ul>
  51. </td>
  52. </tr>
  53. {% endif %}
  54. {% endblock %}
  55. </table>
  56. <script type="text/javascript">
  57. jQuery(document).ready(function($){
  58. $('#list_batch_checkbox').click(function(){
  59. $(this).closest('table').find("td input[type='checkbox']").attr('checked', $(this).is(':checked'));
  60. });
  61. });
  62. </script>
  63. <div class="sonata-ba-list-actions">
  64. <select name="action" >
  65. {% for action, label in admin.batchactions %}
  66. <option value="{{ action }}">{{ label }}</option>
  67. {% endfor %}
  68. </select>
  69. <input type="submit" value="{% trans 'btn_batch' from 'BaseApplicationBundle' %}" />
  70. </div>
  71. </form>
  72. {% endblock %}
  73. {% block list_filters %}
  74. <form action="{{ admin.generateUrl('list') }}" method="GET">
  75. {% for filter in datagrid.filters %}
  76. <div>
  77. {{ filter|render_filter_element }}</td>
  78. </div>
  79. {% endfor %}
  80. <input type="submit" value="{% trans 'btn_filter' from 'BaseApplicationBundle' %}" />
  81. <a href="{{ admin.generateUrl('list') }}">{% trans 'link_reset_filter' from 'BaseApplicationBundle' %}</a>
  82. </form>
  83. {% endblock %}