templates/menu/ntl-list.html.twig line 1

  1. {% extends 'knp_menu.html.twig' %}
  2. {%- block list %}
  3.     {% if item.hasChildren and options.depth is not same as(0) and item.displayChildren %}
  4.         {% import 'knp_menu.html.twig' as knp_menu %}        
  5.         <ntl-list  {{ knp_menu.attributes(listAttributes) }} role="menu">
  6.             {{ block('children') }}
  7.         </ntl-list>                
  8.     {% endif %}
  9. {% endblock -%}
  10. {%- block item %}
  11.     {% if item.displayed %}
  12.     {# building the class of the item #}
  13.         {%- set classes = item.attribute('class') is not empty ? [item.attribute('class'),"nav-item"] : ["nav-item"] %}
  14.         {%- if matcher.isCurrent(item) %}
  15.             {%- set classes = classes|merge([options.currentClass]) %}
  16.         {%- elseif matcher.isAncestor(item, options.matchingDepth) %}
  17.             {%- set classes = classes|merge([options.ancestorClass]) %}
  18.         {%- endif %}
  19.         {%- if item.actsLikeFirst %}
  20.             {%- set classes = classes|merge([options.firstClass]) %}
  21.         {%- endif %}
  22.         {%- if item.actsLikeLast %}
  23.             {%- set classes = classes|merge([options.lastClass]) %}
  24.         {%- endif %}
  25.         {% if options.itemClass is defined %}
  26.             {%- set classes = classes|merge([options.itemClass]) %}
  27.         {% endif %}
  28.         {# Mark item as "leaf" (no children) or as "branch" (has children that are displayed) #}
  29.         {% if item.hasChildren and options.depth is not same as(0) %}
  30.             {% if options.branch_class is not empty and item.displayChildren %}
  31.                 {%- set classes = classes|merge([options.branch_class]) %}
  32.             {% endif %}
  33.         {% elseif options.leaf_class is not empty %}
  34.             {%- set classes = classes|merge([options.leaf_class]) %}
  35.         {%- endif %}
  36.         {%- set attributes = item.attributes %}
  37.         {%- if classes is not empty %}
  38.             {%- set attributes = attributes|merge({'class': classes|join(' ')}) %}
  39.         {%- endif %}
  40.         
  41.         {% set menuExpanded = true %}
  42.         {% if "expanded" in item.extras|keys and not item.extras["expanded"] %}
  43.             {% set menuExpanded = false %}
  44.         {% endif %}
  45.         
  46.         {% if item.children|length == 0 %}
  47.             {% if "show-in-modal" in attributes|keys %}        
  48.                 <ntl-list-item {% if "icon" in item.extras|keys and item.extras["icon"] %}graphic="icon"{% endif %} {% for attrname,attrval in attributes %} {{attrname}} = "{{attrval}}" {% endfor %}  role="menuitem" >                                
  49.                     {% if item.uri is defined and item.uri %}                                        
  50.                         <ntl-fetcher trigger-on="click" show-in-modal url="{{item.uri}}"></ntl-fetcher>                                    
  51.                     {% endif %}
  52.                     {{ block('menuItemContent') }}                
  53.                 </ntl-list-item>   
  54.             {% else %}
  55.                 <ntl-list-item role="menuitem" {% if "icon" in item.extras|keys and item.extras["icon"] %}graphic="icon"{% endif %} {% for attrname,attrval in attributes %} {{attrname}} = "{{attrval}}" {% endfor %} {% if item.uri is defined and item.uri %}href="{{item.uri}}"{% endif %}>                                            
  56.                     {{ block('menuItemContent') }}      
  57.                 </ntl-list-item>
  58.             {% endif %}        
  59.         {% else %}
  60.             {%- set childrenClasses = item.childrenAttribute('class') is not empty ? [item.childrenAttribute('class')] : [] %}
  61.             {%- set childrenClasses = childrenClasses|merge(['list-group level_' ~ item.level]) %}
  62.             {% if menuExpanded == false %}
  63.                 {% set state = "collapsed" %}
  64.             {% else %}
  65.                 {% set state = "expanded" %}
  66.             {% endif %}
  67.             {%- set listAttributes = item.childrenAttributes|merge({'class': childrenClasses|join(' '), 'state' : state })  %}
  68.     
  69.             <ntl-list-item {% if "icon" in item.extras|keys and item.extras["icon"] %}graphic="avatar"{% endif %} class="group-item" role="menu-item">
  70.                 <span class="caption">{{ block('menuItemContent') }}</span>
  71.                 {{ block('list') }}
  72.             </ntl-list-item>
  73.         
  74.         {% endif %}
  75.     {% endif %}
  76. {% endblock -%}
  77. {%- block menuItemContent %}
  78.     {% if "icon" in item.extras|keys and item.extras["icon"] %}        
  79.         <ntl-icon class="icon" slot="graphic">{{ item.extras["icon"] }}</ntl-icon>            
  80.     {% endif %}     
  81.     {% if "hint" in item.extras|keys and item.extras["hint"] %}        
  82.         <span slot="meta">
  83.             <ntl-icon>help</ntl-icon>
  84.             <ntl-tooltip label="{{item.extras["hint"]}}"></ntl-tooltip>
  85.         </span>
  86.     {% endif %}     
  87.     <span class="title">                
  88.         {{ block('label') }}
  89.     </span>
  90. {% endblock -%}