vendor/sonata-project/admin-bundle/src/Resources/views/Core/add_block.html.twig line 1

  1. {% set items_per_column = sonata_config.getOption('dropdown_number_groups_per_colums') %}
  2. {% set groups = get_sonata_dashboard_groups_with_creatable_admins() %}
  3. {% set column_count = (groups|length / items_per_column)|round(0, 'ceil') %}
  4. {% if groups|length > 0 %}
  5. <div class="dropdown-menu multi-column dropdown-add"
  6.     {% if column_count > 1 %}style="width: {{ column_count*140 }}px;"{% endif %}
  7. >
  8.     {% for group in groups|reverse %}
  9.         {% set display = group.roles is empty or is_granted(sonata_config.getOption('role_admin')) or group.roles|filter(role => is_granted(role))|length > 0 %}
  10.         {% if loop.first %}
  11.             {% set render_first_element = true %}
  12.         {% endif %}
  13.         {% if display %}
  14.             {% if render_first_element or loop.index0 % items_per_column == 0 %}
  15.                 {% if render_first_element %}
  16.                     <div class="container-fluid">
  17.                         <div class="row">
  18.                     {% set render_first_element = false %}
  19.                 {% else %}
  20.                     </ul>
  21.                 {% endif %}
  22.                 <ul class="dropdown-menu{% if column_count > 1 %} col-md-{{ (12/column_count)|round }}{% endif %}">
  23.             {% endif %}
  24.             {% if loop.index0 % items_per_column != 0 %}
  25.                 <li role="presentation" class="divider"></li>
  26.             {% endif %}
  27.             <li role="presentation" class="dropdown-header">
  28.                 {{ group.icon|parse_icon }}
  29.                 {# NEXT_MAJOR: Remove the default null #}
  30.                 {% if group.translation_domain|default(null) is same as(false) %}
  31.                     {{ group.label }}
  32.                 {% else %}
  33.                     {# NEXT_MAJOR: Remove the fallback on group.label_catalogue #}
  34.                     {{ group.label|trans({}, group.translation_domain|default(group.label_catalogue)) }}
  35.                 {% endif %}
  36.             </li>
  37.             {% for admin in group.items %}
  38.                 {% if admin.hasRoute('create') and admin.hasAccess('create') %}
  39.                     {% if admin.subClasses is empty %}
  40.                         <li role="presentation">
  41.                             <a role="menuitem" tabindex="-1" href="{{ admin.generateUrl('create') }}">
  42.                                 {% if admin.label is not empty %}
  43.                                     {{ admin.label|trans({}, admin.translationdomain) }}
  44.                                 {% endif %}
  45.                             </a>
  46.                         </li>
  47.                     {% else %}
  48.                         {% for subclass in admin.subclasses|keys %}
  49.                             <li role="presentation">
  50.                                 <a role="menuitem" tabindex="-1" href="{{ admin.generateUrl('create', {'subclass': subclass}) }}">
  51.                                     {{ subclass|trans({}, admin.translationdomain) }}
  52.                                 </a>
  53.                             </li>
  54.                         {% endfor %}
  55.                     {% endif %}
  56.                 {% endif %}
  57.             {% endfor %}
  58.             {% if loop.last and not render_first_element %}
  59.                 </ul>
  60.                 </div>
  61.                 </div>
  62.             {% endif %}
  63.         {% endif %}
  64.     {% endfor %}
  65. </div>
  66. {% endif %}