list.html.twig 10.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
{% extends '@SonataAdmin/CRUD/base_list.html.twig' %}

{% block list_header %}
    {% if admin.datagrid.results|length > 0 %}
        <div class="box-footer">
            <div class="form-inline clearfix">
                {% if not app.request.isXmlHttpRequest %}
                    {# NEXT_MAJOR : remove this assignment #}
                    {% set export_formats = export_formats|default(admin.exportFormats) %}

                    <div class="pull-left">
                        {% if admin.hasRoute('export') and admin.hasAccess('export') and export_formats|length %}
                            <div class="btn-group">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                    <i class="fa fa-share-square-o" aria-hidden="true"></i>
                                    {{ "label_export_download"|trans({}, "SonataAdminBundle") }}
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    {% for format in export_formats %}
                                    <li>
                                        {# NEXT_MAJOR: Remove completely next "<a>" element and uncomment the other one #}
                                        <a href="{{ admin.generateUrl('export', sonata_pagination_parameters(admin, 0) + {'format' : format}) }}">
                                            <i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
                                            {{ ("export_format_" ~ format)|trans({}, 'SonataAdminBundle') }}
                                        </a>
                                        {#
                                        <a href="{{ admin.generateUrl('export', admin.datagrid.paginationparameters(0) + {'format' : format}) }}">
                                            <i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
                                            {{ ("export_format_" ~ format)|trans({}, 'SonataAdminBundle') }}
                                        </a>
                                        #}
                                    </li>
                                    {% endfor %}
                                </ul>
                            </div>
                    </div>
38 39 40 41 42 43
                    {% if admin.total is defined and admin.total > 0 %}
                        <div class="pull-left" style="margin: 5px 5px;">
                            <label for="{{ admin.uniqid }}_sum_of_orders" class="control-label">{{ admin.totalLabel is defined ? admin.totalLabel : (('Total'|trans))}} : </label>
                            <label class="control-label">{{ admin.total }}</label>
                        </div>
                    {% endif %}
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
{# 
                            {% if block('pager_results') is not empty %}
                                &nbsp;-&nbsp;
                            {% endif %} #}
                        {% endif %}

                    <div class="pull-right">
                        {% include get_admin_template('pager_results', admin.code) %}
                    </div>
                {% endif %}
            </div>
        </div>
    {% endif %}
{% endblock %}


{% block list_footer %}
    {% 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 ($) {
                                            // Toggle individual checkboxes when the batch checkbox is changed
                                            $('#list_batch_checkbox').on('ifChanged change', function () {
                                                var checkboxes = $(this)
                                                    .closest('table')
                                                    .find('td.sonata-ba-list-field-batch input[type="checkbox"], div.sonata-ba-list-field-batch input[type="checkbox"]')
                                                ;

                                                if (Admin.get_config('USE_ICHECK')) {
                                                    checkboxes.iCheck($(this).is(':checked') ? 'check' : 'uncheck');
                                                } else {
                                                    checkboxes.prop('checked', this.checked);
                                                }
                                            });

                                            // Add a CSS class to rows when they are selected
                                            $('td.sonata-ba-list-field-batch input[type="checkbox"], div.sonata-ba-list-field-batch input[type="checkbox"]')
                                                .on('ifChanged change', 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') }}
                                    {# NEXT_MAJOR: remove the attribute check and just use .countResults() #}
                                    ({{ attribute(admin.datagrid.pager, 'countResults') is defined ? admin.datagrid.pager.countResults() : admin.datagrid.pager.getNbResults() }})
                                </label>

                                <select name="action" style="width: auto; height: auto" class="form-control">
                                    {% for action, options in batchactions %}
                                        <option value="{{ action }}">{{ options.label|trans({}, options.translation_domain|default(admin.translationDomain)) }}</option>
                                    {% endfor %}
                                </select>
                            {% endblock %}

                                <input type="submit" class="btn btn-small btn-primary" value="{{ 'btn_batch'|trans({}, 'SonataAdminBundle') }}">
                            {% endblock %}
                        {% endif %}
                    </div>


                    {# NEXT_MAJOR : remove this assignment #}
                    {% set export_formats = export_formats|default(admin.exportFormats) %}

                    <div class="pull-left ml-2">
                        {% if admin.hasRoute('export') and admin.hasAccess('export') and export_formats|length %}
                            <div class="btn-group">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                    <i class="fa fa-share-square-o" aria-hidden="true"></i>
                                    {{ "label_export_download"|trans({}, "SonataAdminBundle") }}
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu">
                                    {% for format in export_formats %}
                                    <li>
                                        {# NEXT_MAJOR: Remove completely next "<a>" element and uncomment the other one #}
                                        <a href="{{ admin.generateUrl('export', sonata_pagination_parameters(admin, 0) + {'format' : format}) }}">
                                            <i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
                                            {{ ("export_format_" ~ format)|trans({}, 'SonataAdminBundle') }}
                                        </a>
                                        {#
                                        <a href="{{ admin.generateUrl('export', admin.datagrid.paginationparameters(0) + {'format' : format}) }}">
                                            <i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
                                            {{ ("export_format_" ~ format)|trans({}, 'SonataAdminBundle') }}
                                        </a>
                                        #}
                                    </li>
                                    {% endfor %}
                                </ul>
                            </div>
                            {# {% if block('pager_results') is not empty %}
                                &nbsp;-&nbsp;
                            {% endif %} #}
                        {% endif %}
                    </div>
                    <div class="pull-right">
                        {% block pager_results %}
                            {% include get_admin_template('pager_results', admin.code) %}
                        {% endblock %}
                    </div>
                {% endif %}
            </div>

            {% block pager_links %}
                {% if admin.datagrid.pager.haveToPaginate() %}
                    <hr/>
                    {% include get_admin_template('pager_links', admin.code) %}
                {% endif %}
            {% endblock %}
        </div>
    {% endif %}
{% endblock %}