-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
condition
parameter default true on sonata_helper.html.twig
-…
…> `crud_action` macro to add condition on action display
- Loading branch information
Louis Fortunier
committed
Aug 22, 2024
1 parent
d37f233
commit 56f75be
Showing
2 changed files
with
16 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
### Add | ||
- Add `condition` parameter default true on `sonata_helper.html.twig` -> `crud_action` macro to add condition on action display |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
{% trans_default_domain 'admin' %} | ||
|
||
{% macro crud_action(object, action, icon) %} | ||
{% set url = admin.generateObjectUrl(action, object) %} | ||
{% set label = ('action.' ~ action|u.snake)|trans %} | ||
{% if admin.isCurrentRoute('list') %} | ||
<a href="{{ url }}" class="btn btn-xs btn-default" title="{{ label }}"> | ||
<i class="{{ icon }}"></i> | ||
</a> | ||
{% else %} | ||
<li> | ||
<a class="sonata-action-element" href="{{ url }}"> | ||
<i class="{{ icon }}"></i> {{ label }} | ||
{% macro crud_action(object, action, icon, condition = true) %} | ||
{% if condition %} | ||
{% set url = admin.generateObjectUrl(action, object) %} | ||
{% set label = ('action.' ~ action|u.snake)|trans %} | ||
{% if admin.isCurrentRoute('list') %} | ||
<a href="{{ url }}" class="btn btn-xs btn-default" title="{{ label }}"> | ||
<i class="{{ icon }}"></i> | ||
</a> | ||
</li> | ||
{% else %} | ||
<li> | ||
<a class="sonata-action-element" href="{{ url }}"> | ||
<i class="{{ icon }}"></i> {{ label }} | ||
</a> | ||
</li> | ||
{% endif %} | ||
{% endif %} | ||
{% endmacro %} |