-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalising the overhaul of the actions
- Loading branch information
1 parent
1a7901a
commit 3c054a3
Showing
13 changed files
with
375 additions
and
291 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
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
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,53 @@ | ||
{% set params = action.path.params %} | ||
{% if view.data.resource and action.setResource is defined%} | ||
{% do action.setResource(view.data.resource) %} | ||
{% endif %} | ||
|
||
{% set id = app.request.attributes.get('id') %} | ||
{% if id %} | ||
{% set params = action.path.params|merge({id: id}) %} | ||
{% endif %} | ||
|
||
{% if action.modal %} | ||
{% include action.modal with {action: action, id: 'modal_' ~ action.id, params: params} %} | ||
{% endif %} | ||
|
||
{% set disabled = action.disabled or not | ||
((action.path.role is null or is_granted(action.path.role, view.data.resource)) | ||
and (action.role is null or is_granted(action.role, view.data.resource))) | ||
%} | ||
|
||
{% if not (disabled and crudit_hide_if_disabled(action)) %} | ||
{% block actions_item %} | ||
<span class="btn-wrapper" title="{{ action.title|trans(domain=view.config.translation_domain) }}"> | ||
<a | ||
class=" | ||
{{ action.cssClass ?? 'btn btn-sm btn-primary mt-2 ms-1 mt-md-0' }} | ||
{% if disabled %} disabled{% endif %} | ||
" | ||
{% if action.modal %} | ||
data-bs-toggle="modal" | ||
data-bs-target="#modal_{{ action.id }}" | ||
{% elseif action.confirmModal %} | ||
data-bs-toggle="modal" | ||
data-bs-target="#modal-confirm" | ||
data-confirm-link="{{ path(action.path.route, params) }}" | ||
data-confirm-text="{{ ('modal.confirm.' ~ action.label)|trans }}" | ||
{% elseif not action.disabled %} | ||
href="{{ action.url ?? path(action.path.route, params) }}" | ||
{% endif %} | ||
|
||
{% if action.target is defined and action.target %} | ||
target="{{ action.target }}" | ||
{% endif %} | ||
> | ||
{% if action.icon %} | ||
<i class="{{ action.icon.cssClass }}"></i> | ||
{% endif %} | ||
{% if not action.hideLabel %} | ||
{{ action.label|trans(domain=view.config.translation_domain) }} | ||
{% endif %} | ||
</a> | ||
</span> | ||
{% endblock %} | ||
{% endif %} |
128 changes: 76 additions & 52 deletions
128
src/Resources/views/brick/links/actions/_dropdown_actions.html.twig
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,58 +1,82 @@ | ||
<div class="dropdown"> | ||
<button | ||
id="dropdown-actions-{{ action.label|replace({'.': '-'}) }}" | ||
class="btn btn-primary dropdown-toggle py-1" | ||
data-bs-toggle="dropdown" | ||
> | ||
{{ dropdown_action.label|trans(domain=view.config.translation_domain) }} | ||
</button> | ||
<ul | ||
class="dropdown-menu dropdown-menu-end" | ||
aria-labelledby="#dropdown-actions-{{ dropdown_action.label|replace({'.': '-'}) }}" | ||
> | ||
{% for group_name, group in dropdown_action.actions %} | ||
{% if crudit_is_dropdown_group_name(group_name) %} | ||
<li><h6 class="dropdown-header">{{ group_name|trans(domain=view.config.translation_domain) }}</h6></li> | ||
{% elseif loop.index0 != 0 and not crudit_is_dropdown_group_name(group_name) %} | ||
<li><hr class="dropdown-divider"></li> | ||
{% endif %} | ||
{% set disabled = | ||
dropdown_action.disabled | ||
or not(dropdown_action.role is null or is_granted(dropdown_action.role, view.data.resource)) | ||
%} | ||
|
||
{% for action in group %} | ||
{% set params = action.path.params %} | ||
{% if view.data.resource and action.setResource is defined%} | ||
{% do action.setResource(view.data.resource) %} | ||
{% if not (disabled and crudit_hide_if_disabled(dropdown_action)) %} | ||
<div class="dropdown"> | ||
{% block dropdown_actions_button %} | ||
<button | ||
{# Replace . & _ in label to have only - #} | ||
id="dropdown-actions-{{ action.label|replace({'.': '-', '_': '-'}) }}" | ||
class=" | ||
{{ dropdown_action.cssClass ?? 'btn btn-sm btn-primary dropdown-toggle mt-2 ms-1 mt-md-0' }} | ||
{% if disabled %} disabled{% endif %} | ||
" | ||
data-bs-toggle="dropdown" | ||
> | ||
{% if dropdown_action.icon %} | ||
<i class="{{ dropdown_action.icon.cssClass }}"></i> | ||
{% endif %} | ||
{{ dropdown_action.label|trans(domain=view.config.translation_domain) }} | ||
</button> | ||
{% endblock %} | ||
{% block dropdown_actions_menu %} | ||
<ul | ||
class="dropdown-menu dropdown-menu-end" | ||
aria-labelledby="#dropdown-actions-{{ dropdown_action.label|replace({'.': '-'}) }}" | ||
> | ||
{% for group_name, group in dropdown_action.actions %} | ||
{% if crudit_is_dropdown_group_name(group_name) %} | ||
<li><h6 class="dropdown-header">{{ group_name|trans(domain=view.config.translation_domain) }}</h6></li> | ||
{% elseif loop.index0 != 0 and not crudit_is_dropdown_group_name(group_name) %} | ||
<li><hr class="dropdown-divider"></li> | ||
{% endif %} | ||
|
||
{% set id = app.request.attributes.get('id') %} | ||
{% if id %} | ||
{% set params = action.path.params|merge({id: id}) %} | ||
{% endif %} | ||
{% for action in group %} | ||
{% set params = action.path.params %} | ||
{% if view.data.resource and action.setResource is defined%} | ||
{% do action.setResource(view.data.resource) %} | ||
{% endif %} | ||
|
||
{% if action.modal %} | ||
{% include action.modal with {action: action, id: 'modal_' ~ action.id, params: params} %} | ||
{% endif %} | ||
{% set id = app.request.attributes.get('id') %} | ||
{% if id %} | ||
{% set params = action.path.params|merge({id: id}) %} | ||
{% endif %} | ||
|
||
{% set disabled = action.disabled or not | ||
((action.path.role is null or is_granted(action.path.role, view.data.resource)) | ||
and (action.role is null or is_granted(action.role, view.data.resource))) | ||
%} | ||
{% if action.modal %} | ||
{% include action.modal with {action: action, id: 'modal_' ~ action.id, params: params} %} | ||
{% endif %} | ||
|
||
{% if not (disabled and crudit_hide_if_disabled(action)) %} | ||
<li> | ||
<a | ||
class="{{ action.cssClass ?? 'dropdown-item' }} {% if disabled %}disabled{% endif %}" | ||
{% if action.modal %} | ||
data-bs-toggle="modal" data-bs-target="#modal_{{ action.id }}" | ||
{% elseif not action.disabled %} | ||
href="{{ action.url ?? path(action.path.route, params) }}" | ||
{% endif %} | ||
> | ||
{% if action.icon %}<i class="{{ action.icon.cssClass }}"></i>{% endif %} | ||
{% if not action.hideLabel %}{{ action.label|trans(domain=view.config.translation_domain) }}{% endif %} | ||
</a> | ||
</li> | ||
{% endif %} | ||
{% endfor %} | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
{% set disabled = action.disabled or not | ||
((action.path.role is null or is_granted(action.path.role, view.data.resource)) | ||
and (action.role is null or is_granted(action.role, view.data.resource))) | ||
%} | ||
|
||
{% if not (disabled and crudit_hide_if_disabled(action)) %} | ||
{% block dropdown_actions_item %} | ||
<li> | ||
<a | ||
class="{{ action.cssClass ?? 'dropdown-item' }} {% if disabled %}disabled{% endif %}" | ||
{% if action.modal %} | ||
data-bs-toggle="modal" data-bs-target="#modal_{{ action.id }}" | ||
{% elseif not action.disabled %} | ||
href="{{ action.url ?? path(action.path.route, params) }}" | ||
{% endif %} | ||
> | ||
{% if action.icon %} | ||
<i class="{{ action.icon.cssClass }}"></i> | ||
{% endif %} | ||
{% if not action.hideLabel %} | ||
{{ action.label|trans(domain=view.config.translation_domain) }} | ||
{% endif %} | ||
</a> | ||
</li> | ||
{% endblock %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endfor %} | ||
</ul> | ||
{% endblock %} | ||
</div> | ||
{% endif %} |
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
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
Oops, something went wrong.