Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

menu.html.twig 4.0KB

4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {% macro render_menu_item(item, translation_domain, active) %}
  2. {% if item.type == 'divider' %}
  3. {{ item.label|trans(domain = translation_domain) }}
  4. {% else %}
  5. {% set menu_params = { menuIndex: item.menu_index, submenuIndex: item.submenu_index } %}
  6. {% set path =
  7. item.type == 'link' ? item.url :
  8. item.type == 'route' ? path(item.route, item.params) :
  9. item.type == 'entity' ? path('easyadmin', { entity: item.entity, action: 'list' }|merge(menu_params)|merge(item.params)) :
  10. item.type == 'empty' ? '#' : '' %}
  11. {# if the URL generated for the route belongs to the backend, regenerate
  12. the URL to include the menu_params to display the selected menu item
  13. (this is checked comparing the beginning of the route URL with the backend homepage URL)
  14. #}
  15. {% if item.type == 'route' and (path starts with path('easyadmin')) %}
  16. {% set path = path(item.route, menu_params|merge(item.params)) %}
  17. {% endif %}
  18. <a href="{{ path }}"
  19. class="nav-link {{ item.css_class|default('') }} {{ active ? 'active' }}"
  20. {% if item.target|default(false) %}target="{{ item.target }}"{% endif %}
  21. {% if item.rel|default(false) %}rel="{{ item.rel }}"{% endif %}>
  22. {% if item.icon is not empty %}<i class="fa fa-fw {{ item.icon }}"></i>{% endif %}
  23. <p>{{ item.label|trans(domain = translation_domain) }}
  24. {% if item.children|default([]) is not empty %}<i class="right fas fa-angle-left"></i>{% endif %}
  25. {% if item.params.count_menu_item is defined and count_menu_items(item.params.count_menu_item) > 0 %}<span class="badge badge-{{ item.params.alert is defined ? 'danger' : 'info' }} right">{{ count_menu_items(item.params.count_menu_item) }}</span>{% endif %}
  26. </p>
  27. </a>
  28. {% endif %}
  29. {% endmacro %}
  30. {% import _self as helper %}
  31. {% block main_menu_before %}{% endblock %}
  32. {% set _translation_domain = (_entity_config.translation_domain)|default(easyadmin_config('translation_domain'))|default('messages') %}
  33. <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
  34. {% set _menu_items = easyadmin_config('design.menu') %}
  35. {% block main_menu %}
  36. {% for item in _menu_items %}
  37. {% block menu_item %}
  38. {% set is_selected_menu = app.request.query.get('menuIndex')|default(-1) == item.menu_index %}
  39. {% set is_selected_submenu = is_selected_menu and app.request.query.get('submenuIndex')|default(-1) != -1 %}
  40. {% if easyadmin_is_granted(item.permission) %}
  41. <li class="{{ item.type == 'divider' ? 'nav-header' : 'nav-item' }} {{ item.children is not empty ? 'treeview' }} {{ is_selected_menu ? 'menu-open' }}">
  42. {{ helper.render_menu_item(item, _translation_domain, is_selected_menu) }}
  43. {% if item.children|default([]) is not empty %}
  44. <ul class="nav nav-treeview">
  45. {% for subitem in item.children %}
  46. {% block menu_subitem %}
  47. {% if easyadmin_is_granted(subitem.permission) %}
  48. <li class="nav-item ">
  49. {{ helper.render_menu_item(subitem, _translation_domain, is_selected_menu and app.request.query.get('submenuIndex')|default(-1) == subitem.submenu_index ? true) }}
  50. </li>
  51. {% endif %}
  52. {% endblock menu_subitem %}
  53. {% endfor %}
  54. </ul>
  55. {% endif %}
  56. </li>
  57. {% endif %}
  58. {% endblock menu_item %}
  59. {% endfor %}
  60. {% endblock main_menu %}
  61. </ul>
  62. {% block main_menu_after %}{% endblock %}