templates/includes/partials/_header_buttons.html.twig line 1

Open in your IDE?
  1. {% use "form_div_layout.html.twig"  %}
  2. {#
  3.     Archivo para generar la configuración de botones de cada página...
  4.     Ejemplo:
  5.         {% set header_buttons = [
  6.             {
  7.               * 'show'          : is_granted('ROLE_MEZCLAS_CREATE'),            //OBLIGATORIO - Condicion a seguir (true o false) 
  8.                 'title'         : {
  9.                     'text'  : ''                                                 //Texto de titulo de la página para el objeto visualizado
  10.                     'class' : ''
  11.                 }
  12.                 'tag'           : 'a',                                          //Elemento a crear [a, button], si no se especifica se utiliza 'a'
  13.                 'icon'          : 'far fa-plus-square',                         //Icono a utilizar
  14.                 'text_xs_pre'   : 'string',                                     //Texto visible en todos los tamaños antes del otro tamaño
  15.                 'text_sm_pre'   : 'string',                                     //Texto visible hasta el tamaño SM antes del otro tamaño
  16.                 'text_md_in'    : 'string',                                     //Texto visible hasta el tamaño MD 
  17.                 'text_sm_post'  : 'string',                                     //Texto visible hasta el tamaño SM despues del anterior
  18.                 'text_xs_post'  : 'string',                                     //Texto visible en todos los tamaños despues del anterior
  19.                 'attr'          : {                                             //Todos los atributos que queramos añadir al elemento...
  20.                     'class' : 'btn-danger',
  21.                     'href'  : path('mezcla_new')
  22.                 }
  23.             }
  24.         ] %}
  25. #}
  26. {% if header_buttons is defined and header_buttons is iterable %}
  27.     {% if app.session.get('back_button_route') %}
  28.         <a href="{{ path(app.session.get('back_button_route'), app.session.get('back_button_params') | default({}) | merge({'back_clear' : 1})) }}" role="button" class="btn btn-sm btn-secondary btn-with-addon text-nowrap me-1">
  29.             <span class="btn-addon">
  30.                 <i class="btn-addon-icon fas fa-undo-alt"></i>
  31.             </span>
  32.             {{ app.session.get('back_button_text') }}
  33.         </a>
  34.     {% endif %}
  35.     {% for but in header_buttons %}
  36.         {% set continue = true %}
  37.         {% if app.session.get('back_button_route') and (but.id is defined ? but.id == "returnListButton")   %}
  38.             {% set continue = false %}
  39.         {% endif %}
  40.         {% if (but.show | default(false)) and continue  %}
  41.             {% set attr = but.attr | default({}) | merge( { class: (but.attr.class|default('') ~ ' btn btn-sm text-nowrap me-1 ' ~ (but.icon is defined ? 'px-3 btn-with-addon' : '')) | trim} ) %}
  42.             <{{ but.tag | default('a') }} {{ block('attributes') }}>
  43.                 {% if but.icon is defined %}
  44.                     <span class="btn-addon">
  45.                         <i class="btn-addon-icon {{ but.icon }}"></i> 
  46.                     </span>
  47.                 {% endif %}
  48.                 {{ but.text_xs_pre | default('') }}
  49.                 <span class="d-none d-sm-inline">
  50.                     {{ but.text_sm_pre | default('') }}
  51.                     <span class="d-none d-md-inline">{{ but.text_md_in | default('') }}</span>
  52.                     <span class="d-none d-xl-inline">{{ but.text_xl_in | default('') }}</span>
  53.                     {{ but.text_sm_post | default('') }}
  54.                 </span>
  55.                 {{ but.text_xs_post | default('') }}
  56.             </{{ but.tag | default('a') }}>
  57.         {% endif %}
  58.     {% endfor %}
  59. {% endif %}
  60. {#{{ include(PATH_PARTIALS ~ '/_topbar_filtro.html.twig')}}#}