add_block.html.twig 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. {% block user_block %}
  2. {% set items_per_column = admin_pool.getOption('dropdown_number_groups_per_colums') %}
  3. {% set groups = [] %}
  4. {% for group in admin_pool.dashboardgroups %}
  5. {% set display_group = false %}
  6. {% for admin in group.items if display_group == false %}
  7. {% if admin.hasRoute('create') and admin.isGranted('CREATE') %}
  8. {% set display_group = true %}
  9. {% set groups = [group]|merge(groups) %}
  10. {% endif %}
  11. {% endfor %}
  12. {% endfor %}
  13. {% set column_count = (groups|length / items_per_column)|round(0, 'ceil') %}
  14. <div class="dropdown-menu multi-column dropdown-add"
  15. {% if column_count > 1 %}style="width: {{ column_count*140 }}px;"{% endif %}
  16. >
  17. {% for group in groups|reverse %}
  18. {% set display = (group.roles is empty or is_granted('ROLE_SONATA_ADMIN') ) %}
  19. {% for role in group.roles if not display %}
  20. {% set display = is_granted(role) %}
  21. {% endfor %}
  22. {% if display %}
  23. {% if loop.first or loop.index0 % items_per_column == 0 %}
  24. {% if loop.first %}
  25. <div class="container-fluid">
  26. <div class="row">
  27. {% else %}
  28. </ul>
  29. {% endif %}
  30. <ul class="dropdown-menu{% if column_count > 1 %} col-md-{{ (12/column_count)|round }}{% endif %}">
  31. {% endif %}
  32. {% if loop.index0 % items_per_column != 0 %}
  33. <li role="presentation" class="divider"></li>
  34. {% endif %}
  35. <li role="presentation" class="dropdown-header">{{ group.label|trans({}, group.label_catalogue) }}</li>
  36. {% for admin in group.items %}
  37. {% if admin.hasRoute('create') and admin.isGranted('CREATE') %}
  38. <li role="presentation">
  39. <a role="menuitem" tabindex="-1" href="{{ admin.generateUrl('create')}}">{{ admin.label|trans({}, admin.translationdomain) }}</a>
  40. </li>
  41. {% endif %}
  42. {% endfor %}
  43. {% if loop.last %}
  44. </ul>
  45. </div>
  46. </div>
  47. {% endif %}
  48. {% endif %}
  49. {% endfor %}
  50. </div>
  51. {% endblock %}