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

Open in your IDE?
  1. {% extends "@crud\\crud\\index_inner.html.twig" %}
  2. {% block button_new_no_elements_href %}
  3.     {% if idParent is defined %}
  4.         href="{{ path('crud_plain_new', { 'rol': rol, 'routeClassName': routeClassName, 'idParent': idParent} ) }}"
  5.     {% else %}
  6.         {{ parent() }}
  7.     {% endif %}
  8. {% endblock button_new_no_elements_href %}
  9. {% block button_new_no_elements_onclick %}
  10.     {% set texto = routeClassName~'.singular' %}
  11.     onclick='javascript:creaNuevo("{{ routeClassName }}", "{{ texto | trans({}, 'crud') }}", {{ widthModalForm }}, {{ heightModalForm }}); return false;'
  12. {% endblock button_new_no_elements_onclick %}
  13. {% block button_new_elements %}
  14.     {% set texto = routeClassName~'.singular' %}
  15.     {% set onClick = "javascript:creaNuevo('"~routeClassName~"', '"~  texto | trans({}, 'crud') ~"',"~ widthModalForm ~","~ heightModalForm ~"); return false;" %}
  16.     {% if idParent is defined %}
  17.         .append("<span id='{{routeClassName}}_botonNuevoDiv' class='forChanges'><a id='{{routeClassName}}_botonNuevoBoton' onclick='{{ onClick }}' href='{{ path('crud_plain_new', { 'rol': rol, 'routeClassName': routeClassName, 'idParent': idParent} ) }}'><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'>{% trans from 'crud' %}botones.nuevo{% endtrans %}</span></button></a></span>")
  18.     {% else %}
  19.         .append("<span id='{{routeClassName}}_botonNuevoDiv' class='forChanges'><a id='{{routeClassName}}_botonNuevoBoton' onclick='{{ onClick }}' 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'>{% trans from 'crud' %}botones.nuevo{% endtrans %}</span></button></a></span>")
  20.     {% endif %}
  21. {% endblock button_new_elements %}
  22.         
  23. {% block results %}
  24.     {{ parent() }}
  25.     <div id='dialog_{{ routeClassName }}'></div>
  26.     <div id='dialog_show_{{ routeClassName }}'></div>
  27.     
  28.     {% set filter = [] %}
  29.     {% if filterData is defined %}
  30.         {% set filter = filterData %}
  31.     {% endif %}
  32.     {% set parent = '' %}
  33.     {% if idParent is defined %}
  34.         {% set parent = idParent %}
  35.     {% endif %}
  36.     {% autoescape %}
  37.         {% set urlReload = path('crud_index', {'rol': rol, 'routeClassName': routeClassName, 'filterData': filter, 'idParent' : parent, 'view': index_view} ) %}
  38.         <input type='hidden' id='urlReload' value='{{ urlReload }}'>
  39.     {% endautoescape %}
  40. {% endblock %}
  41.         
  42. {% block show_action %}
  43.     {% set href = path('crud_plain_show', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName }) %}
  44.     {% set texto=routeClassName~'.singular' %}
  45.     <a href="" itemid="{{ entity.id }}" onclick="javascript:showModal('{{ routeClassName }}','{{ href }}', '{{ texto | trans({}, 'crud') }}'); return false;">
  46.         <i class="{{ buttons['view'] }}" title="{% trans from 'crud' %}index.acciones.show_alt{% endtrans %}"></i>
  47.     </a>
  48. {% endblock show_action %}    
  49. {% block edit_action %}
  50.     {% if idParent is defined %}
  51.         {% set href=path('crud_plain_edit', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName, 'idParent': idParent }) %}
  52.     {% else %}
  53.         {% set href=path('crud_plain_edit', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName }) %}
  54.     {% endif %}
  55.     {% set texto=routeClassName~'.singular' %}
  56.     <a href="" itemid="{{ entity.id }}" onclick="javascript:editModal('{{ routeClassName }}','{{ href }}', '{{ texto | trans({}, 'crud') }}', {{ widthModalForm }}, {{ heightModalForm }}); return false;">
  57.         <i class="{{ buttons['edit'] }}" title="{% trans from 'crud' %}index.acciones.edit_alt{% endtrans %}"></i>
  58.     </a>
  59. {% endblock edit_action %}    
  60. {% block delete_action %}
  61.     {% if idParent is defined %}
  62.         {% set href=path('crud_plain_delete', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName, 'idParent': idParent }) %}
  63.     {% else %}
  64.         {% set href=path('crud_plain_delete', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName }) %}
  65.     {% endif %}
  66.     <a class="del_modal_{{ routeClassName }}" href="{{ href }}" itemid="{{ entity.id }}">
  67.         <i class="{{ buttons['delete'] }}" title="{% trans from 'crud' %}index.acciones.delete_alt{% endtrans %}"></i>
  68.     </a>
  69. {% endblock delete_action %}  
  70.         
  71. {% block table_index_jquery %}
  72.     {{ parent() }}
  73.     {% if heightModalForm is not defined %}
  74.         {% set heightModalForm = 770 %}
  75.     {% endif %}
  76.     {% if widthModalForm is not defined %}
  77.         {% set widthModalForm = 1000 %}
  78.     {% endif %}
  79.     $("#dialog_{{ routeClassName }}").dialog({
  80.         autoOpen: false,
  81.         width: {{ widthModalForm }},
  82.         height: {{ heightModalForm }},
  83.         modal: true,
  84.         resizable: false,
  85.         title_html: true,
  86.         title: "<div id='texto' class='widget-header widget-header-small'><h4 class='smaller red'><i class='fas fa-shopping-cart'></i>&nbsp;</h4></div>",
  87.         {% block dialog_events %}{% endblock dialog_events %}
  88.         buttons: {
  89.             {% block dialog_buttons %}
  90.                 {% block dialog_buttons_save %}
  91.                     "{{ 'botones.grabar' | trans({}, 'crud') | upper }}": function() {
  92.                         if (validaDatos{{ routeClassName }}())
  93.                         {
  94.                            // var form = $('#crud_form_{{ routeClassName }}');
  95.                             var form = $('#dialog_{{ routeClassName }}').children('form');
  96.                         if ($(form).find('.wrong_email').length>0)
  97.                         {
  98.                             alert('Correo electrónico incorrecto');
  99.                             return false;
  100.                         }
  101.                             $( "#dialog_{{ routeClassName }}" ).parent().mask("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Actualizando...");
  102.                             $(form).ajaxSubmit({
  103.                                 type: form.attr('method'),
  104.                                 url: form.attr('action'),
  105.                                 dataType: 'json',
  106.                                 data: { _xml_http_request: true },
  107.                                 success: function(data) {
  108.                                     if (data.ok)
  109.                                     {
  110.                                         $( "#dialog_{{ routeClassName }}" ).dialog( "close" );
  111.                                         $( "#dialog_{{ routeClassName }}" ).parent().unmask();
  112.                                         {% set filter = [] %}
  113.                                         {% if filterData is defined %}
  114.                                             {% set filter = filterData %}
  115.                                         {% endif %}
  116.                                         {% set parent = '' %}
  117.                                         {% if idParent is defined %}
  118.                                             {% set parent = idParent %}
  119.                                         {% endif %}
  120.                                         var url="{% autoescape %}{{ path('crud_index', {'rol': rol, 'routeClassName': routeClassName, 'filterData': filter, 'idParent' : parent, 'view': index_view} ) }}{% endautoescape %}";
  121.                                         reloadContenedor('{{ routeClassName }}',url);
  122.                                     }
  123.                                     else
  124.                                     {
  125.                                         showError(bootbox,data.error);
  126.                                         $( "#dialog_{{ routeClassName }}" ).parent().unmask();
  127.                                     }
  128.                                 }
  129.                             })
  130.                         }
  131.                     },
  132.                     "{{ 'botones.grabar_y_crear' | trans({}, 'crud') | upper }}": function() {
  133.                         if (validaDatos{{ routeClassName }}())
  134.                         {
  135.                             var form = $('#crud_form_{{ routeClassName }}');
  136.                         if ($(form).find('.wrong_email').length>0)
  137.                         {
  138.                             alert('Correo electrónico incorrecto');
  139.                             return false;
  140.                         }
  141.                             $( "#dialog_{{ routeClassName }}" ).parent().mask("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Actualizando...");
  142.                             $(form).ajaxSubmit({
  143.                                 type: form.attr('method'),
  144.                                 url: form.attr('action'),
  145.                                 dataType: 'json',
  146.                                 data: { _xml_http_request: true },
  147.                                 success: function(data) {
  148.                                     if (data.ok)
  149.                                     {
  150.                                         {% set filter = [] %}
  151.                                         {% if filterData is defined %}
  152.                                             {% set filter = filterData %}
  153.                                         {% endif %}
  154.                                         {% set parent = '' %}
  155.                                         {% if idParent is defined %}
  156.                                             {% set parent = idParent %}
  157.                                         {% endif %}
  158.                                         var url="{% autoescape %}{{ path('crud_index', {'rol': rol, 'routeClassName': routeClassName, 'filterData': filter, 'idParent' : parent, 'view': index_view} ) }}{% endautoescape %}";
  159.                                         reloadContenedor('{{ routeClassName }}',url);
  160.                                         var urlForm=$("#{{ routeClassName }}_botonNuevoBoton").attr("href");
  161.                                         $('#dialog_{{ routeClassName }}').load(urlForm, function(){
  162.                                             $('#dialog_{{ routeClassName }}').parent().unmask();
  163.                                         });
  164.                                     }
  165.                                     else
  166.                                     {
  167.                                         showError(bootbox,data.error);
  168.                                         $( "#dialog_{{ routeClassName }}" ).parent().unmask();
  169.                                     }
  170.                                 }
  171.                             })
  172.                         }
  173.                     },
  174.                 {% endblock dialog_buttons_save %}
  175.                 {% block dialog_buttons_cancel %}
  176.                     "{{ 'botones.cancelar' | trans({}, 'crud') | upper }}": function() {
  177.                         $( "#dialog_{{ routeClassName }}" ).dialog( "close" );
  178.                     }
  179.                 {% endblock dialog_buttons_cancel %}
  180.           {% endblock dialog_buttons %}
  181.         }
  182.     });
  183.     {% if heightModalShow is not defined %}
  184.         {% set heightModalShow = heightModalForm %}
  185.     {% endif %}
  186.     {% if widthModalShow is not defined %}
  187.         {% set widthModalShow = widthModalForm %}
  188.     {% endif %}
  189.     $("#dialog_show_{{ routeClassName }}").dialog({
  190.         autoOpen: false,
  191.         height: {{ heightModalShow }},
  192.         width: {{ widthModalShow }},
  193.         modal: true,
  194.         resizable: false,
  195.         title_html: true,
  196.         title: "<div id='texto' class='widget-header widget-header-small'><h4 class='smaller red'><i class='fas fa-shopping-cart'></i>&nbsp;</h4></div>",
  197.         buttons: {
  198.                     "{{ 'botones.cerrar' | trans({}, 'crud') | upper }}": function() {
  199.                         $( "#dialog_show_{{ routeClassName }}" ).dialog( "close" );
  200.                     }
  201.         }
  202.     });
  203.     $(".del_modal_{{ routeClassName }}").click(function(e){
  204.         e.preventDefault();
  205.         if (confirm("{{ 'delete.confirm' | trans({}, 'crud') }}"))
  206.         {
  207.             $('#contenedor_{{ routeClassName }}').mask("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Actualizando...");
  208.             $.ajax({
  209.                 type: "GET",
  210.                 url: $(this).attr("href"),
  211.                 dataType: 'json',
  212.                 data: { _xml_http_request: true },
  213.                 success: function(html){
  214.                     if (html.ok)
  215.                     {
  216.                         {% if filterData is defined %}
  217.                             var url="{{ path('crud_index', {'rol': rol, 'routeClassName': routeClassName, 'filterData': filterData, 'view': index_view} ) }}";
  218.                         {% else %}
  219.                             var url="{{ path('crud_index', {'rol': rol, 'routeClassName': routeClassName, 'view': index_view} ) }}";
  220.                         {% endif %}
  221.                         reloadContenedor('{{ routeClassName }}',url);
  222.                     }
  223.                     else
  224.                     {
  225.                         $('#contenedor_{{ routeClassName }}').unmask();
  226.                         showError(bootbox, html.error);
  227.                     }
  228.                 }
  229.             });
  230.         }
  231.     });
  232. {% endblock table_index_jquery %}
  233.         
  234. {% block table_index_functions %}
  235.     {{ parent() }}
  236.     function validaDatos{{ routeClassName }}()
  237.     {
  238.         {% block valida_datos %}
  239.             return true;
  240.         {% endblock valida_datos %}
  241.     }
  242. {% endblock table_index_functions %}
  243. {% block principal_heading %}
  244. {% endblock %}