Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 343a358

Browse files
committed
feature EasyCorp#1090 List: Changed the _global_actions var to a block (Pierstoval)
This PR was merged into the master branch. Discussion ---------- List: Changed the _global_actions var to a block Actually this var was quite problematic to one of my backends, and I clearly don't understand why it wasn't transformed to a block earlier... @javiereguiluz any idea about why it was a variable instead of a block? By the way, if you want to simplify your code review, I just copy/pasted the `set` tag and replaced it with a `block` tag (and added some tag names in the `endblock` tags to simplify template readability). Plus, it adds much more override flexibility because one now can override all blocks AND this block, so one could absolutely refactor the whole list view just with this new block. What do you think? Commits ------- 1617254 List: Changed the _global_actions var to a block
2 parents 9fb2e9f + 1617254 commit 343a358

1 file changed

Lines changed: 42 additions & 44 deletions

File tree

Resources/views/default/list.html.twig

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -33,48 +33,6 @@
3333
{% endspaceless %}
3434
{% endset %}
3535

36-
{% set _global_actions %}
37-
{% if easyadmin_action_is_enabled_for_list_view('search', _entity_config.name) %}
38-
{% set _action = easyadmin_get_action_for_list_view('search', _entity_config.name) %}
39-
40-
{% block search_action %}
41-
<div class="form-action {{ _action.css_class|default('') }}">
42-
<form method="get" action="{{ path('easyadmin') }}">
43-
{% block search_form %}
44-
<input type="hidden" name="action" value="search">
45-
<input type="hidden" name="entity" value="{{ _request_parameters.entity }}">
46-
<input type="hidden" name="sortField" value="{{ _request_parameters.sortField }}">
47-
<input type="hidden" name="sortDirection" value="{{ _request_parameters.sortDirection }}">
48-
<input type="hidden" name="menuIndex" value="{{ _request_parameters.menuIndex }}">
49-
<input type="hidden" name="submenuIndex" value="{{ _request_parameters.submenuIndex }}">
50-
<div class="input-group">
51-
<input class="form-control" type="search" name="query" value="{{ app.request.get('query')|default('') }}">
52-
<span class="input-group-btn">
53-
<button class="btn" type="submit">
54-
<i class="fa fa-search"></i>
55-
<span class="hidden-xs hidden-sm">{{ _action.label|default('action.search')|trans(_trans_parameters) }}</span>
56-
</button>
57-
</span>
58-
</div>
59-
{% endblock %}
60-
</form>
61-
</div>
62-
{% endblock search_action %}
63-
{% endif %}
64-
65-
{% if easyadmin_action_is_enabled_for_list_view('new', _entity_config.name) %}
66-
{% set _action = easyadmin_get_action_for_list_view('new', _entity_config.name) %}
67-
{% block new_action %}
68-
<div class="button-action">
69-
<a class="{{ _action.css_class|default('') }}" href="{{ path('easyadmin', _request_parameters|merge({ action: _action.name })) }}">
70-
{% if _action.icon %}<i class="fa fa-{{ _action.icon }}"></i>{% endif %}
71-
{{ _action.label is defined and not _action.label is empty ? _action.label|trans(_trans_parameters) }}
72-
</a>
73-
</div>
74-
{% endblock new_action %}
75-
{% endif %}
76-
{% endset %}
77-
7836
{% block page_title %}{{ _content_title|striptags }}{% endblock %}
7937

8038
{% block content_header %}
@@ -85,11 +43,51 @@
8543

8644
<div class="col-sm-7">
8745
<div class="global-actions">
88-
{{ _global_actions }}
46+
{% block global_actions %}
47+
{% if easyadmin_action_is_enabled_for_list_view('search', _entity_config.name) %}
48+
{% set _action = easyadmin_get_action_for_list_view('search', _entity_config.name) %}
49+
50+
{% block search_action %}
51+
<div class="form-action {{ _action.css_class|default('') }}">
52+
<form method="get" action="{{ path('easyadmin') }}">
53+
{% block search_form %}
54+
<input type="hidden" name="action" value="search">
55+
<input type="hidden" name="entity" value="{{ _request_parameters.entity }}">
56+
<input type="hidden" name="sortField" value="{{ _request_parameters.sortField }}">
57+
<input type="hidden" name="sortDirection" value="{{ _request_parameters.sortDirection }}">
58+
<input type="hidden" name="menuIndex" value="{{ _request_parameters.menuIndex }}">
59+
<input type="hidden" name="submenuIndex" value="{{ _request_parameters.submenuIndex }}">
60+
<div class="input-group">
61+
<input class="form-control" type="search" name="query" value="{{ app.request.get('query')|default('') }}">
62+
<span class="input-group-btn">
63+
<button class="btn" type="submit">
64+
<i class="fa fa-search"></i>
65+
<span class="hidden-xs hidden-sm">{{ _action.label|default('action.search')|trans(_trans_parameters) }}</span>
66+
</button>
67+
</span>
68+
</div>
69+
{% endblock %}
70+
</form>
71+
</div>
72+
{% endblock search_action %}
73+
{% endif %}
74+
75+
{% if easyadmin_action_is_enabled_for_list_view('new', _entity_config.name) %}
76+
{% set _action = easyadmin_get_action_for_list_view('new', _entity_config.name) %}
77+
{% block new_action %}
78+
<div class="button-action">
79+
<a class="{{ _action.css_class|default('') }}" href="{{ path('easyadmin', _request_parameters|merge({ action: _action.name })) }}">
80+
{% if _action.icon %}<i class="fa fa-{{ _action.icon }}"></i>{% endif %}
81+
{{ _action.label is defined and not _action.label is empty ? _action.label|trans(_trans_parameters) }}
82+
</a>
83+
</div>
84+
{% endblock new_action %}
85+
{% endif %}
86+
{% endblock global_actions %}
8987
</div>
9088
</div>
9189
</div>
92-
{% endblock %}
90+
{% endblock content_header %}
9391

9492
{% block main %}
9593
{% set _list_item_actions = easyadmin_get_actions_for_list_item(_entity_config.name) %}

0 commit comments

Comments
 (0)