src/Crud/templates/crud/index_inner.html.twig line 1

Open in your IDE?
  1. <script>
  2.     $(document).ready(function(){
  3.         {% block button_new %}
  4.             {% if entities|length>0 %}
  5.                 $('#{{ routeClassName }}').on('draw.dt', 
  6.                     function(){
  7.                         {% if newInIndex %}
  8.                             $("#{{ routeClassName }}_length").addClass("hide");
  9.                             if (!$("#{{ routeClassName }}_wrapper").hasClass("boton_nuevo"))
  10.                             {
  11.                                 $("#{{ routeClassName }}_wrapper").addClass("boton_nuevo")
  12.                                 $("#{{ routeClassName }}_wrapper").
  13.                                     children("div.row").
  14.                                     children("div:first")
  15.                                     {% block button_new_elements %}
  16.                                          {% set texto = routeClassName~'.singular' %}     
  17.                                         .append("<span id='{{routeClassName}}_botonNuevoDiv' class='forChanges'><a id='{{routeClassName}}_botonNuevoBoton' href='{{ path('crud_plain_new', { 'rol': rol, 'routeClassName': routeClassName} ) }}'><button class='btn btn-white btn-inverse btn-bold btn-round' title='{% trans from 'crud' %}botones.nuevo{% endtrans %}'><i class='fas fa-plus green'></i><span class='hidden-xs'>&nbsp;{% trans from 'crud' %}botones.nuevo{% endtrans %}</span></button></a></span>")
  18.                                     {% endblock button_new_elements %}
  19.                                     ;    
  20.                             }
  21.                         {% endif %}  
  22.                         {% block more_index_buttons %}
  23.                         {% endblock more_index_buttons %}
  24.                     });
  25.             {% endif %}  
  26.         {% endblock button_new %}      
  27.         {% block table_script %}
  28.             {% block table_index_jquery %}
  29.                 $('.ace-index').click(function(e){ 
  30.                     e.preventDefault(); 
  31.                 });
  32.                 $('#{{ routeClassName }}').DataTable({
  33.                     responsive: {details: {type: 'inline'}},
  34.                     //searching:true,
  35.                     {% if showPaginator %}
  36.                        paging: true,
  37.                        pageLength: 50,
  38.                     {% else %}
  39.                        paging: false,
  40.                     {% endif %}
  41.                     {% if search %}
  42.                        searching: true,
  43.                     {% else %}
  44.                        searching: false,
  45.                     {% endif %}
  46.                     {% if tableInfo %}
  47.                        info: true,
  48.                     {% else %}
  49.                        info: false,
  50.                     {% endif %}
  51.                     {% if scrollY %}
  52.                        scrollY: {{ scrollY }},
  53.                     {% endif %}
  54.                     "aoColumns": [
  55.                         {% if columnAction %}
  56.                             {"bSortable": false}
  57.                         {% endif %}
  58.                         {% block sortableColumns %} 
  59.                             {% for field in indexFields %}
  60.                                 {% if not columnAction and loop.index==1 %}
  61.                                     null
  62.                                 {% else %}    
  63.                                     , null
  64.                                 {% endif %}    
  65.                             {% endfor %}
  66.                         {% endblock sortableColumns %} 
  67.                     ],
  68.                     {% if app.request.locale=='es' %}            
  69.                         language: {url: "{{ asset('ace/js/dataTables/languages/spanish.json') }}"}
  70.                     {% else %}
  71.                         {% if app.request.locale=='fr' %}            
  72.                             language: {url: "{{ asset('ace/js/dataTables/languages/french.json') }}"}
  73.                         {% else %}
  74.                             language: {url: "{{ asset('ace/js/dataTables/languages/english.json') }}"}
  75.                         {% endif %}
  76.                     {% endif %}
  77.                 });
  78.                 var $overflow = '';
  79.                 var colorbox_params = {
  80.                         rel: 'colorbox',
  81.                         reposition:true,
  82.                         scalePhotos:true,
  83.                         scrolling:false,
  84.                         previous:'<i class="fas fa-arrow-left"></i>',
  85.                         next:'<i class="fas fa-arrow-right"></i>',
  86.                         close:'&times;',
  87.                         current:'{current} of {total}',
  88.                         maxWidth:'100%',
  89.                         maxHeight:'100%',
  90.                         onOpen:function(){
  91.                                 $overflow = document.body.style.overflow;
  92.                                 document.body.style.overflow = 'hidden';
  93.                         },
  94.                         onClosed:function(){
  95.                                 document.body.style.overflow = $overflow;
  96.                         },
  97.                         onComplete:function(){
  98.                                 $.colorbox.resize();
  99.                         }
  100.                 };
  101.                 $('.ace-thumbnails [data-rel="colorbox"]').colorbox(colorbox_params);
  102.                 $("#cboxLoadingGraphic").html("<i class='fas fa-spinner blue fa-spin'></i>");//let's add a custom loading icon
  103.                 $(document).one('ajaxloadstart.page', function(e) {
  104.                     $('#colorbox, #cboxOverlay').remove();
  105.                 });
  106.             {% endblock table_index_jquery %}
  107.         {% endblock table_script %}
  108.     });
  109.     {% block table_index_functions %}
  110.     {% endblock table_index_functions %}
  111.     
  112. </script>
  113. {% block jquery %}
  114.     <script type="text/javascript">
  115.         $(function()
  116.         {
  117.             $(".del_item").click(function(e){
  118.                 if (!confirm("{{ 'delete.confirm' | trans({}, 'crud') }}")){
  119.                     e.preventDefault();
  120.                 }
  121.             });
  122.             $('.chosen-select').chosen({allow_single_deselect:true}); 
  123.         });
  124.     </script>    
  125. {% endblock jquery %}
  126. {% block principal_heading %}
  127. {% endblock %}
  128. {% block filter %}
  129.     {% if showFilter %}
  130.         {% include '@crud\\Common\\filter.html.twig' %}
  131.     {% endif %}
  132. {% endblock filter %}
  133. {% block results %}
  134.     <div class="widget-box transparent">
  135.         {% block secondary_heading %}
  136.             <div class="widget-header widget-header-flat">
  137.                 <h4 id="header-index" class="widget-title lighter">
  138.                     {% block icon_secondary_heading %}
  139.                         <i class="fas fa-list-ol blue"></i>
  140.                     {% endblock icon_secondary_heading %}
  141.                     {% set texto = routeClassName~'.plural' %}     
  142.                     {{ texto | trans({}, 'crud') }} 
  143.                     {#% if filterActive %}&nbsp;(<i class="fas fa-filter blue"></i>&nbsp;{{ 'index.filtrado' | trans({}, 'crud')  }}){% endif %#}
  144.                     {% block more_secondary_heading %}
  145.                     {% endblock more_secondary_heading %}
  146.                 </h4>
  147.             </div>
  148.         {% endblock secondary_heading %}
  149.         <div class="widget-body" style="display: block;">
  150.             <div class="widget-main no-padding">
  151.                 {% block table %}
  152.                     {% block index_no_elements %}
  153.                         {% if entities|length==0 %}
  154.                             {% block show_no_results %}
  155.                                 <div class="alert alert-info">
  156.                                     <strong>
  157.                                         <i class="fas fa-info-circle bigger-150"></i>
  158.                                         {% if showFilter %}
  159.                                             {% trans from 'crud' %}index.info.no_elements.filtro{% endtrans %}
  160.                                         {% else %}    
  161.                                             {% trans from 'crud' %}index.info.no_elements.nofiltro{% endtrans %}
  162.                                         {% endif %}    
  163.                                     </strong>
  164.                                     <br>
  165.                                 </div>
  166.                             {% endblock show_no_results %}
  167.                             {% if newInIndex %}
  168.                                 <br>
  169.                                 <div id="{{ routeClassName }}_botonNuevoDiv" class="forChanges">
  170.                                     {% block button_new_no_elements %}
  171.                                         <a id="{{routeClassName}}_botonNuevoBoton"
  172.                                             {% block button_new_no_elements_href %}
  173.                                                 href="{{ path('crud_plain_new', {'rol' : rol, 'routeClassName': routeClassName} ) }}"
  174.                                             {% endblock button_new_no_elements_href %}
  175.                                             {% block button_new_no_elements_onclick %}
  176.                                             {% endblock button_new_no_elements_onclick %}>
  177.                                             {% set texto = routeClassName~'.singular' %}     
  178.                                             <button class='btn btn-white btn-inverse btn-bold btn-round' title="{% trans from 'crud' %}botones.nuevo{% endtrans %}&nbsp;{{ texto | trans({}, 'crud')|lower }}">
  179.                                                 <i class="fas fa-plus green"></i>
  180.                                                 <span class="hidden-xs">
  181.                                                     {% trans from 'crud' %}botones.nuevo{% endtrans %}
  182.                                                 </span>
  183.                                             </button>
  184.                                         </a>
  185.                                     {% endblock button_new_no_elements %}
  186.                                 </div>
  187.                             {% endif %} 
  188.                             {% block more_noelements_buttons %}
  189.                             {% endblock more_noelements_buttons %}
  190.                         {% endif %}    
  191.                     {% endblock index_no_elements %}
  192.                     {% block info %}  
  193.                         <div class='row'>        
  194.                             <div class='{% block colindex %}col-xs-12{% endblock colindex %}'>        
  195.                                 {% block main_column_info %}
  196.                                 {% endblock main_column_info %}
  197.                                 {% block index %}
  198.                                     {% if entities|length>0 %}
  199.                                         <table id="{{ routeClassName }}" class="table table-striped table-bordered table-hover" width="100%">
  200.                                             <thead>
  201.                                                 <tr>
  202.                                                     {% block action_header_data %} 
  203.                                                         {% if columnAction %}
  204.                                                             <th id="noExl" style="width: max-content" class="crud_th">{#% trans from 'crud' %}index.acciones.table_header{% endtrans %#}</th>
  205.                                                         {% endif %}
  206.                                                     {% endblock action_header_data %}    
  207.                                                     {% block index_th %}
  208.                                                         {% for field in indexFields %} 
  209.                                                             <th class="crud_th">{{ field['label'] }}</th>
  210.                                                         {% endfor %}   
  211.                                                     {% endblock index_th %}
  212.                                                 </tr>
  213.                                             </thead>
  214.                                             <tbody>
  215.                                                 {% for entity in entities %}
  216.                                                     <tr id="tr_{{ entity.id }}" entityId='{{ entity.id }}' {% block tr_attr %}{% endblock tr_attr %}>
  217.                                                         {% block action_column_data %} 
  218.                                                             {% if columnAction %}
  219.                                                                 <td id="noExl" class="crud_td" {% block styleCellAction %}{% endblock %}>
  220.                                                                     <div id="{{ routeClassName }}_{{entity.id}}" class="pull-left action-buttons forChanges">
  221.                                                                         <nobr>  
  222.                                                                             {% block index_actions %}
  223.                                                                                 {% if showInIndex %}
  224.                                                                                     {% block show_action %}    
  225.                                                                                         <a class="action_show" href="{{ path('crud_plain_show', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName }) }}" itemid="{{ entity.id }}">
  226.                                                                                             <i class="{{ buttons['view'] }} bigger-150" title="{% trans from 'crud' %}index.acciones.show_alt{% endtrans %}"></i>
  227.                                                                                         </a>
  228.                                                                                     {% endblock show_action %}    
  229.                                                                                 {% endif %}        
  230.                                                                                 {% if editInIndex %}
  231.                                                                                     {% if not entity.getSistema() %}
  232.                                                                                         {% block edit_action %}    
  233.                                                                                             <a class="action_edit" href="{{ path('crud_plain_edit', { 'id': entity.id, 'rol': rol, 'routeClassName': routeClassName }) }}" itemid="{{ entity.id }}">
  234.                                                                                                 <i class="{{ buttons['edit'] }} bigger-150" title="{% trans from 'crud' %}index.acciones.edit_alt{% endtrans %}"></i>
  235.                                                                                             </a>
  236.                                                                                         {% endblock edit_action %}    
  237.                                                                                     {% endif %}        
  238.                                                                                 {% endif %}        
  239.                                                                                 {% if deleteInIndex %}
  240.                                                                                     {% if not entity.getSistema() %}
  241.                                                                                         {% block delete_action %}    
  242.                                                                                             <a class="del_item" href="{{ path('crud_plain_delete', { 'id': entity.id, 'rol': rol, 'routeClassName': routeClassName }) }}" itemid="{{ entity.id }}">
  243.                                                                                                 <i class="{{ buttons['delete'] }} bigger-150" title="{% trans from 'crud' %}index.acciones.delete_alt{% endtrans %}"></i>
  244.                                                                                                 <!--img src="{{ asset(buttons['delete']) }}" title="{% trans from 'crud' %}index.acciones.delete_alt{% endtrans %}"-->
  245.                                                                                             </a>
  246.                                                                                         {% endblock delete_action %}    
  247.                                                                                     {% endif %}        
  248.                                                                                 {% endif %}        
  249.                                                                             {% endblock %}
  250.                                                                         </nobr>
  251.                                                                     </div>                                          
  252.                                                                 </td>
  253.                                                             {% endif %}
  254.                                                         {% endblock action_column_data %}    
  255.                                                         {% block index_data %}
  256.                                                             {% for field in indexFields %}
  257.                                                                 <td  class="crud_td {{ field['nombre'] }}" {% block styleCellData %}{% endblock %}>
  258.                                                                     {% block cellData %}
  259.                                                                         {% if field['type'] is defined and isSubString(field['type'],'attach') and entity.getFieldValue(field['nombre']) %}
  260.                                                                             <a href="{{ absolute_url(entity.getFieldValue(field['nombre']).getUrl()) }}" target="_blank">{{ entity.getFieldValue(field['nombre']).getFileName() }}</a>
  261.                                                                         {% else %}
  262.                                                                         {% if field['type'] is defined and isSubString(field['type'],'image') and entity.getFieldValue(field['nombre']) %}
  263.                                                                             <img width="{{ imageWidth }}" src="{{ absolute_url(entity.getFieldValue(field['nombre']).getUrl()) }}">
  264.                                                                         {% else %}
  265.                                                                             {% if field['type'] is defined and field['type']=='datetime' and entity.getFieldValue(field['nombre']) %}
  266.                                                                                 {{ entity.getFieldValue(field['nombre'])|date('Y/m/d H:i') }}
  267.                                                                             {% else %}
  268.                                                                                 {%if field['type'] is defined and (field['type']=='fecha' or field['type']=='date') and entity.getFieldValue(field['nombre'])%}
  269.                                                                                     {{ entity.getFieldValue(field['nombre'])|date('Y/m/d') }}
  270.                                                                                 {% else%}
  271.                                                                                     {%if field['type'] is defined and (field['type']=='hora' or field['type']=='time') and entity.getFieldValue(field['nombre'])%}
  272.                                                                                         {{ entity.getFieldValue(field['nombre'])|date('H:i') }}
  273.                                                                                     {% else%}
  274.                                                                                         {% if field['type'] is defined and field['type']=='boolean' and booleans[entity.getFieldValue(field['nombre'])] is defined %}
  275.                                                                                             {#<i class="{{ booleans[entity.getFieldValue(field['nombre'])] }}"></i>#}
  276.                                                                                             <span class="hide">{{ entity.getFieldValue(field['nombre']) }}</span>
  277.                                                                                             <div style="text-align: center">
  278.                                                                                                 <label class="block">
  279.                                                                                                     <input class="ace ace-switch ace-switch-5 ace-index" type="checkbox" style="width: 100%" {% if entity.getFieldValue(field['nombre']) %}checked="{{ entity.getFieldValue(field['nombre']) }}"{% endif %}>
  280.                                                                                                     <span class="lbl" data-lbl="&nbsp;{{ 'choice_value.yes' | trans({}, 'crud') | upper}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ 'choice_value.no'  | trans({}, 'crud') | upper}}"></span>
  281.                                                                                                 </label>
  282.                                                                                             </div>
  283.                                                                                         {% else %}
  284.                                                                                             {% autoescape %}{{ entity.getFieldValue(field['nombre']) | raw }}{% endautoescape %}
  285.                                                                                             {% endif %}
  286.                                                                                         {% endif %}
  287.                                                                                     {% endif %}
  288.                                                                                 {% endif %}
  289.                                                                             {% endif %}
  290.                                                                         {% endif %}
  291.                                                                     {% endblock %}
  292.                                                                 </td>       
  293.                                                             {% endfor %}   
  294.                                                         {% endblock %}
  295.                                                     </tr>
  296.                                                 {% endfor %}
  297.                                             </tbody>
  298.                                         </table>
  299.                                     {% endif %}
  300.                                 {% endblock index %}
  301.                             </div>   {# end column #}
  302.                             {% block other_columns %}
  303.                             {% endblock other_columns %}
  304.                         </div>    {# end row #}    
  305.                     {% endblock info %}
  306.                 {% endblock table %}
  307.             </div>                   
  308.         </div>                   
  309.     </div>
  310. {% endblock results %}
  311.