-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathbase_list.html.twig
392 lines (351 loc) · 26.6 KB
/
base_list.html.twig
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
38
39
40
41
42
43
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
{#
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 base_template %}
{%- block actions -%}
{% include '@SonataAdmin/CRUD/action_buttons.html.twig' %}
{%- endblock -%}
{%- block tab_menu -%}
{{ knp_menu_render(admin.sidemenu(action), {
'currentClass': 'active',
'template': get_global_template('tab_menu_template')
}, 'twig') }}
{%- endblock -%}
{% block title %}
{{ admin.isChild and admin.parent.subject ? 'title_edit'|trans({'%name%': admin.parent.toString(admin.parent.subject)|u.truncate(15, '...') }, 'SonataAdminBundle') : '' }}
{% endblock %}
{% block navbar_title %}
{{ admin.isChild and admin.parent.subject ? 'title_edit'|trans({'%name%': admin.parent.toString(admin.parent.subject)|u.truncate(100, '...') }, 'SonataAdminBundle') : '' }}
{% endblock %}
{# Define the variable out of the block to prevent error if someone is overriding the list_table and not the list_footer #}
{% set datagrid_has_results = admin.datagrid.results|length > 0 %}
{% block list_table %}
<div class="col-xs-12 col-md-12">
{% set batchactions = admin.batchactions %}
{% if admin.hasRoute('batch') and batchactions|length %}
<form action="{{ admin.generateUrl('batch', {'filter': admin.filterParameters}) }}" method="POST" >
<input type="hidden" name="_sonata_csrf_token" value="{{ csrf_token }}">
{% endif %}
{# Add a margin if no pager to prevent dropdown cropping on window #}
<div class="box box-primary"{% if admin.datagrid.pager.lastPage == 1 %} style="margin-bottom: 100px;"{% endif %}>
<div class="box-body{% if datagrid_has_results %} table-responsive no-padding{% endif %}">
{{ sonata_block_render_event('sonata.admin.list.table.top', { 'admin': admin }) }}
{% block list_header %}{% endblock %}
{% if datagrid_has_results %}
{% block table %}
<table class="table table-bordered table-striped table-hover sonata-ba-list">
{% block table_header %}
<thead>
<tr class="sonata-ba-list-field-header">
{% for field_description in admin.list.getElements() %}
{% if admin.hasRoute('batch') and field_description.name == constant('Sonata\\AdminBundle\\Datagrid\\ListMapper::NAME_BATCH') and batchactions|length > 0 %}
<th class="sonata-ba-list-field-header sonata-ba-list-field-header-batch">
<input type="checkbox" id="list_batch_checkbox">
</th>
{% elseif field_description.name == constant('Sonata\\AdminBundle\\Datagrid\\ListMapper::NAME_SELECT') %}
<th class="sonata-ba-list-field-header sonata-ba-list-field-header-select"></th>
{% elseif field_description.name == constant('Sonata\\AdminBundle\\Datagrid\\ListMapper::NAME_ACTIONS') and app.request.isXmlHttpRequest %}
{# NEXT_MAJOR: Remove this case in version 5 and recommend using the option `ajax_hidden` instead. #}
{# Action buttons disabled in ajax view! #}
{% elseif field_description.getOption('ajax_hidden') == true and app.request.isXmlHttpRequest %}
{# Disable fields with 'ajax_hidden' option set to true #}
{% else %}
{% set sortable = false %}
{% if field_description.option('sortable', false) %}
{% set sortable = true %}
{% set sort_parameters = admin.datagrid.sortparameters(field_description) %}
{% set current = admin.datagrid.values[constant('Sonata\\AdminBundle\\Datagrid\\DatagridInterface::SORT_BY')] is defined
and (admin.datagrid.values[constant('Sonata\\AdminBundle\\Datagrid\\DatagridInterface::SORT_BY')] == field_description
or admin.datagrid.values[constant('Sonata\\AdminBundle\\Datagrid\\DatagridInterface::SORT_BY')].name == sort_parameters.filter[constant('Sonata\\AdminBundle\\Datagrid\\DatagridInterface::SORT_BY')]) %}
{% set sort_active_class = current ? 'sonata-ba-list-field-order-active' : '' %}
{% set sort_by = current ? admin.datagrid.values[constant('Sonata\\AdminBundle\\Datagrid\\DatagridInterface::SORT_ORDER')] : field_description.option(constant('Sonata\\AdminBundle\\Datagrid\\DatagridInterface::SORT_ORDER'), sort_parameters.filter[constant('Sonata\\AdminBundle\\Datagrid\\DatagridInterface::SORT_ORDER')]) %}
{% endif %}
{% apply spaceless %}
<th class="sonata-ba-list-field-header-{{ field_description.type }}{% if sortable %} sonata-ba-list-field-header-order-{{ sort_by|lower }} {{ sort_active_class }}{% endif %}{% if field_description.option('header_class') %} {{ field_description.option('header_class') }}{% endif %}"{% if field_description.option('header_style') %} style="{{ field_description.option('header_style') }}"{% endif %}>
{% if sortable %}
<a href="{{ admin.generateUrl(action|default('list'), sort_parameters|merge({_list_mode: admin.getListMode()})) }}">
{% endif %}
{% if field_description.getOption('label_icon') %}
<span class="sonata-ba-list-field-header-label-icon">
{{ field_description.getOption('label_icon')|parse_icon }}
</span>
{% endif %}
{% if field_description.label is not same as(false) %}
{% if field_description.translationDomain is same as(false) %}
{{ field_description.label }}
{% else %}
{{ field_description.label|trans({}, field_description.translationDomain) }}
{% endif %}
{% endif %}
{% if sortable %}</a>{% endif %}
</th>
{% endapply %}
{% endif %}
{% endfor %}
</tr>
</thead>
{% endblock %}
{% block table_body %}
<tbody>
{% include get_admin_template('outer_list_rows_' ~ admin.getListMode(), admin.code) %}
</tbody>
{% endblock %}
{% block table_footer %}
{% endblock %}
</table>
{% endblock %}
{% else %}
{% block no_result_content %}
<div class="info-box">
<span class="info-box-icon bg-aqua"><i class="fas fa-arrow-circle-right" aria-hidden="true"></i></span>
<div class="info-box-content">
<span class="info-box-text">{{ 'no_result'|trans({}, 'SonataAdminBundle') }}</span>
<div class="progress">
<div class="progress-bar" style="width: 0%"></div>
</div>
<div class="progress-description">
<ul class="list-unstyled">
{%- if admin.datagrid.pager.countResults() > 0 -%}
<li>
<a href="{{ admin.generateUrl(action|default('list'), admin.datagrid.getPaginationParameters(1)) }}">
{{- 'go_to_the_first_page'|trans({}, 'SonataAdminBundle') -}}
</a>
</li>
{%- elseif not app.request.xmlHttpRequest -%}
{%- include get_admin_template('button_create', admin.code) -%}
{%- endif -%}
</ul>
</div>
</div><!-- /.info-box-content -->
</div>
{% endblock %}
{% endif %}
{{ sonata_block_render_event('sonata.admin.list.table.bottom', { 'admin': admin }) }}
</div>
{% block list_footer %}
{% if datagrid_has_results %}
<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') }}
({{ admin.datagrid.pager.countResults() }})
</label>
<select name="action" style="width: auto; height: auto" class="form-control">
{% for action, options in batchactions %}
<option value="{{ action }}">
{% if options.translation_domain is defined and options.translation_domain is same as(false) %}
{{ options.label }}
{% else %}
{{ options.label|trans({}, options.translation_domain ?? admin.translationDomain) }}
{% endif %}
</option>
{% endfor %}
</select>
{% endblock %}
<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.hasAccess('export') and export_formats|length %}
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fas fa-share-square" aria-hidden="true"></i>
{{ "label_export_download"|trans({}, "SonataAdminBundle") }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{% for format in export_formats %}
<li>
<a href="{{ admin.generateUrl('export', admin.datagrid.paginationparameters(0) + {'format' : format}) }}">
<i class="fas 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 %}
-
{% endif %}
{% endif %}
{% 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 %}
</div>
{% if admin.hasRoute('batch') and batchactions|length %}
</form>
{% endif %}
</div>
{% endblock %}
{% block list_filters_actions %}
{# NEXT_MAJOR: Remove |default(filter.option('show_filter')) #}
{% set displayableFilters = admin.datagrid.filters|filter(filter => filter.showFilter|default(filter.option('show_filter')) is not same as (false)) %}
{%- if displayableFilters|length %}
<ul class="nav navbar-nav navbar-right" id="filter-list-{{ admin.uniqid() }}" {{ stimulus_controller('sonata-filter-list', {}, { 'active': 'active' }, { 'sonata-filter': '#filter-container-' ~ admin.uniqid() }) }}>
<li class="dropdown sonata-actions">
<a href="#" class="dropdown-toggle sonata-ba-action" data-toggle="dropdown">
<i class="fas fa-filter" aria-hidden="true"></i>
{{ 'link_filters'|trans({}, 'SonataAdminBundle') }}
<span class="badge" {{ stimulus_target('sonata-filter-list', 'counter') }}></span>
<b class="caret"></b>
</a>
<ul class="dropdown-menu dropdown-menu-scrollable" role="menu">
{% for filter in displayableFilters %}
{# NEXT_MAJOR: Remove |default(filter.option('show_filter')) #}
{% set filterDisplayed = filter.isActive() or filter.showFilter|default(filter.option('show_filter')) is same as (true) %}
<li>
<a href="#" class="sonata-toggle-filter sonata-ba-action{% if filterDisplayed %} active{% endif %}" data-filter="filter-{{ admin.uniqid }}-{{ filter.name }}" {{ stimulus_target('sonata-filter-list', 'field') }} {{ stimulus_action('sonata-filter-list', 'toggle', 'click') }}>
<i class="far"></i>
{% if filter.label is not same as(false) %}
{% if filter.translationDomain is same as(false) %}
{{ filter.label }}
{% elseif filter.labelTranslationParameters is defined %}
{{ filter.label|trans(filter.labelTranslationParameters, filter.translationDomain ?? admin.translationDomain) }}
{% else %} {# NEXT_MAJOR: remove the else part and change elseif to else #}
{{ filter.label|trans(filter.option('label_translation_parameters', {}), filter.translationDomain ?? admin.translationDomain) }}
{% endif %}
{% endif %}
</a>
</li>
{% endfor %}
</ul>
</li>
</ul>
{% endif -%}
{% endblock %}
{% block list_filters %}
{% if admin.datagrid.filters %}
{% form_theme form get_admin_template('filter', admin.code) %}
<div class="col-xs-12 col-md-12 sonata-filters-box"
id="filter-container-{{ admin.uniqid() }}" {{ stimulus_controller('sonata-filter', { 'defaultValues': admin.defaultFilterParameters|json_encode }, {}, { 'sonata-filter-list': '#filter-list-' ~ admin.uniqid() }) }} {% if not admin.datagrid.hasDisplayableFilters %}hidden{% endif %}>
<div class="box box-primary" >
<div class="box-body">
<form
class="sonata-filter-form form-horizontal {{ admin.isChild and 1 == admin.datagrid.filters|length ? 'hide' : '' }}"
action="{{ admin.generateUrl(action|default('list')) }}"
method="GET"
role="form"
{{ stimulus_target('sonata-filter', 'form') }}
{{ stimulus_action('sonata-filter', 'prepareSubmit', 'submit') }}>
{{ form_errors(form) }}
<div class="row">
<div class="col-sm-9">
{% set withAdvancedFilter = false %}
{% for filter in admin.datagrid.filters %}
{# NEXT_MAJOR: Remove |default(filter.option('show_filter')) #}
{% set filterDisplayed = filter.isActive() or filter.showFilter|default(filter.option('show_filter')) is same as (true) %}
{% set filterCanBeDisplayed = filter.option('show_filter') is not same as(false) %}
<div class="form-group {% block sonata_list_filter_group_class %}{% endblock %}" id="filter-{{ admin.uniqid }}-{{ filter.name }}" {{ stimulus_target('sonata-filter', 'group') }} {% if not filterDisplayed %}hidden{% endif %}>
{% if filter.label is not same as(false) %}
<label for="{{ form[filter.formName].children['value'].vars.id }}" class="col-sm-3 control-label">
{% if filter.translationDomain is same as(false) %}
{{ filter.label }}
{% else %}
{{ filter.label|trans(filter.option('label_translation_parameters', {}), filter.translationDomain ?? admin.translationDomain) }}
{% endif %}
</label>
{% endif %}
{% set attr = form[filter.formName].children['type'].vars.attr|default({}) %}
<div class="col-sm-4 advanced-filter" {{ stimulus_target('sonata-filter', 'advanced') }} {% if not field_value(form[filter.formName].children['type']) %}hidden{% endif %}>
{{ form_widget(form[filter.formName].children['type'], {'attr': attr}) }}
</div>
<div class="col-sm-4">
{{ form_widget(form[filter.formName].children['value']) }}
</div>
{% if filterCanBeDisplayed %}
<div class="col-sm-1">
<label class="control-label">
<a href="#" class="sonata-ba-action" {{ stimulus_action('sonata-filter', 'hideFilter', 'click', { 'id': 'filter-' ~ admin.uniqid ~ '-' ~ filter.name }) }}>
<i class="fas fa-minus-circle" aria-hidden="true"></i>
</a>
</label>
</div>
{% endif %}
</div>
{# NEXT_MAJOR: Remove |default(filter.option('advanced_filter')) #}
{% if filter.withAdvancedFilter|default(filter.option('advanced_filter')) %}
{% set withAdvancedFilter = true %}
{% endif %}
{% endfor %}
</div>
<div class="col-sm-3 text-center">
<input type="hidden" name="filter[{{ constant('Sonata\\AdminBundle\\Datagrid\\DatagridInterface::PAGE') }}]" id="filter__page" value="1">
{% set foo = form[constant('Sonata\\AdminBundle\\Datagrid\\DatagridInterface::PAGE')].setRendered() %}
{{ form_rest(form) }}
<div class="form-group">
<button type="submit" class="btn btn-primary" {{ stimulus_target('sonata-filter', 'submitter') }}>
<i class="fas fa-filter" aria-hidden="true"></i> {{ 'btn_filter'|trans({}, 'SonataAdminBundle') }}
</button>
<a class="btn btn-default" href="{{ admin.generateUrl(action|default('list'), {filters: 'reset'}) }}">
{{ 'link_reset_filter'|trans({}, 'SonataAdminBundle') }}
</a>
</div>
{% if withAdvancedFilter %}
<div class="form-group">
<a href="#" {{ stimulus_action('sonata-filter', 'toggleAdvanced', 'click') }}>
<i class="fas fa-cogs" aria-hidden="true"></i>
{{ 'btn_advanced_filters'|trans({}, 'SonataAdminBundle') }}
</a>
</div>
{% endif %}
</div>
</div>
{% for paramKey, paramValue in admin.persistentParameters %}
<input type="hidden" name="{{ paramKey }}" value="{{ paramValue }}">
{% endfor %}
</form>
</div>
</div>
</div>
{% endif %}
{% endblock %}