refactored page actions to event subscriber (#2420)

This commit is contained in:
Kevin Papst
2021-03-15 14:18:44 +01:00
committed by GitHub
parent 9a2fd9ba91
commit e1c9af795c
117 changed files with 2403 additions and 815 deletions

View File

@@ -1,30 +1,7 @@
{% macro users(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {'search': {'class': 'search-toggle visible-xs-inline'}} %}
{% if view == 'index' %}
{% set actions = actions|merge({'visibility': '#modal_user_admin'}) %}
{% else %}
{% set actions = actions|merge({'back': path('admin_user')}) %}
{% endif %}
{% set actions = actions|merge({'download': {'url': path('user_export'), 'class': 'toolbar-action'}}) %}
{% if is_granted('create_user') %}
{% set actions = actions|merge({'create': {'url': path('admin_user_create')}}) %}
{% endif %}
{% if view == 'index' %}
{% set actions = actions|merge({'help': {'url': 'users.html'|docu_link, 'target': '_blank'}}) %}
{% elseif view == 'permissions' %}
{% set actions = actions|merge({'help': {'url': 'permissions.html'|docu_link, 'target': '_blank'}}) %}
{% endif %}
{% set actions = actions|merge({'help': {'url': 'users.html'|docu_link, 'target': '_blank'}}) %}
{% set event = trigger('actions.users', {'actions': actions, 'view': view}) %}
{{ widgets.page_actions(event.payload.actions) }}
{% set event = actions(app.user, 'users', view) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}
{% macro user_permissions(view) %}
@@ -35,7 +12,7 @@
{% macro user(user, view, options) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'user', {'view': view, 'user': user}) %}
{% set event = actions(app.user, 'user', view, {'user': user}) %}
{% if view == 'index' %}
{{ widgets.table_actions(event.actions) }}
{% else %}