src/Crud/templates/newedit.html.twig line 1

Open in your IDE?
  1. {% extends "@crud\\crud.html.twig" %}
  2. {% block jquery %}
  3.     {{ parent() }}
  4.     <script type="text/javascript">
  5.         $(function()
  6.         {
  7.             $('.hide_item_{{ routeClassName }}').click(function(e){
  8.                 e.preventDefault();
  9.                 if (confirm("{{ 'delete.confirm' | trans({}, 'crud') }}"))
  10.                 {
  11.                     var id=$(this).attr("item_id");
  12.                     var adjunto='hidefile_{{ routeClassName }}_'+id;
  13.                     var control='file_{{ routeClassName }}_'+id;
  14.                     adjunto=document.getElementById(adjunto);
  15.                     $(adjunto).addClass("hide");
  16.                     control=document.getElementById(control);
  17.                     $(control).removeClass("hide");
  18.                     $(control).parents('form').change();
  19.                 }
  20.             });
  21.             $('.just_numbers').keypress(function(e){
  22.                 if (e.which<48 || e.which>57 )
  23.                     e.preventDefault();
  24.             });
  25.             var cargainicial{{ routeClassName }} = true;
  26.             $( "#dialog-mapa-{{ routeClassName }}" ).dialog({
  27.                 autoOpen: false,
  28.                 height: 610,
  29.                 width: 750,
  30.                 modal: true,
  31.                 resizable: false,
  32.                 title_html: true,
  33.                 title: '<div id="texto" class="widget-header widget-header-small"><h4 class="smaller red"><i class="fas fa-globe"></i>&nbsp;Definir Ubicación en Mapa</h4></div>',
  34.                 buttons: {
  35.                     Cancelar: function() {
  36.                         $( "#dialog-mapa-{{ routeClassName }}" ).dialog( "close" );
  37.                     }
  38.                 }
  39.             });
  40.             $( "#dialog-relacion-{{ routeClassName }}" ).dialog({
  41.                 autoOpen: false,
  42.                 height: 500,
  43.                 width: 800,
  44.                 modal: true,
  45.                 resizable: false,
  46.                 title_html: true,
  47.                 title: '<div id="texto" class="widget-header widget-header-small"><h4 class="smaller red"><i class="fas fa-globe"></i>&nbsp;Definir nuevo elemento</h4></div>',
  48.                 beforeClose: function(){
  49.                     $('#dialog_{{ routeClassName }}' ).parent().removeClass("hide");
  50.                 },
  51.                 open: function(){
  52.                     $('#dialog_{{ routeClassName }}' ).parent().addClass("hide");
  53.                 },
  54.                 buttons: {
  55.                     Grabar: function() {
  56.                         var routeClassName = $('#relacionnombre-{{ routeClassName }}').val();
  57.                         var form = $('#crud_form_'+routeClassName);
  58.                         if ($(form).find('.wrong_email').length>0)
  59.                         {
  60.                             alert('Correo electrónico incorrecto');
  61.                             return false;
  62.                         }
  63.                         $( "#dialog-relacion-{{ routeClassName }}" ).parent().mask("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Grabando...");
  64.                         $(form).ajaxSubmit({
  65.                             type: form.attr('method'),
  66.                             url: form.attr('action'),
  67.                             dataType: 'json',
  68.                             data: { _xml_http_request: true },
  69.                             success: function(data) {
  70.                                 if (data.ok)
  71.                                 {
  72.                                     var id_nuevo=data.id;
  73.                                     var combo = $('#relaciontarget-{{ routeClassName }}').val();
  74.                                     $('#'+combo+' option:selected').removeProp('selected');
  75.                                     $('#'+combo).append('<option selected="true" value="'+data.id+'">'+data.txt+'</option>')
  76.                                     $( "#dialog-relacion-{{ routeClassName }}" ).parent().unmask();
  77.                                     $( "#dialog-relacion-{{ routeClassName }}" ).dialog( "close" );
  78.                                  /*   var routeClassName = $('#'+combo).attr('relation');
  79.                                     var baseSite = $('#baseSite').val();
  80.                                     var url = baseSite + "all/items/"+routeClassName+"/"+id_nuevo;
  81.                                     $('#'+combo).load(url, function(){
  82.                                         $( "#dialog-relacion-{{ routeClassName }}" ).parent().unmask();
  83.                                         $( "#dialog-relacion-{{ routeClassName }}" ).dialog( "close" );
  84.                                     });*/
  85.                                 }
  86.                                 else
  87.                                 {
  88.                                     $( "#dialog-relacion-{{ routeClassName }}" ).parent().unmask();
  89.                                     showError(bootbox,data.error);
  90.                                 }
  91.                             }
  92.                         })
  93.                     },
  94.                     Cancelar: function() {
  95.                         $( "#dialog-relacion-{{ routeClassName }}" ).dialog( "close" );
  96.                     }
  97.                 }
  98.             });
  99.             $(".botonmapa").click(function(e){
  100.                 e.preventDefault();
  101.                 var baseSite = $('#baseSite').val();
  102.                 var idcampo = $(this).attr('itemid');
  103.                 var tipoDibujo = $(this).attr('geom');
  104.                 var urlOk = true;
  105.                 {% block url_mapa %}
  106.                     var url = "{{ path('dibujarGeometria', {'tipoDibujo': '__TIPO__', 'idCampo': '__CAMPO__', 'idContenedorMapa': 'dialog-mapa-'~routeClassName}) }}";
  107.                     url =url.replace('__TIPO__', tipoDibujo); 
  108.                     url =url.replace('__CAMPO__', idcampo); 
  109.                 {% endblock url_mapa %}
  110.                 {% block check_url_mapa %}
  111.                 {% endblock check_url_mapa %}
  112.                 if (urlOk)
  113.                 {
  114.                     $("#dialog-mapa-{{ routeClassName }}").dialog("open");
  115.                     if (cargainicial{{ routeClassName }})
  116.                     {
  117.                         $('#dialog-mapa-{{ routeClassName }}').load(url);
  118.                         cargainicial{{ routeClassName }} = false;
  119.                     }
  120.                 }
  121.                 else
  122.                     alert('{% block text_bad_url_mapa %}{% endblock text_bad_url_mapa %}');
  123.             });
  124.             $(".botonmapaPunto").click(function(e){
  125.                 e.preventDefault();
  126.                 var baseSite = $('#baseSite').val();
  127.                 var idcampo = $(this).attr('itemid');
  128.                 var tipoDibujo = $(this).attr('geom');
  129.                 var urlOk = true;
  130.                 {% block url_mapaPunto %}
  131.                     var url = "{{ path('dibujarPunto', {'tipoDibujo': '__TIPO__', 'idCampo': '__CAMPO__', 'idContenedorMapa': 'dialog-mapa-'~routeClassName}) }}";
  132.                     url =url.replace('__TIPO__', tipoDibujo); 
  133.                     url =url.replace('__CAMPO__', idcampo); 
  134.                 {% endblock url_mapaPunto %}
  135.                 {% block check_url_mapaPunto %}
  136.                     if (urlOk)
  137.                     {
  138.                        $("#dialog-mapa-{{ routeClassName }}").parent().mask('Mostrando ubicación, espere....');
  139.                         $("#dialog-mapa-{{ routeClassName }}").dialog("open");
  140.                         if(cargainicial{{ routeClassName }}){
  141.                             $('#dialog-mapa-{{ routeClassName }}').load(url);
  142.                             cargainicial{{ routeClassName }} = false;
  143.                         }
  144.                     }
  145.                     else
  146.                         alert('{% block text_bad_url_mapaPunto %}{% endblock text_bad_url_mapaPunto %}');
  147.                 {% endblock check_url_mapaPunto %}
  148.             });
  149.             $('[data-rel=tooltip]').tooltip({container:'body'});
  150.             $('[data-rel=popover]').popover({container:'body'});
  151. //            $('[data-rel="tooltip"]').tooltip();
  152.             $(".dual-list").each(function () {
  153.                 var lista = $(this).bootstrapDualListbox({infoTextFiltered: '<span class="label label-purple label-lg">{{ 'opciones.filtrado' | trans({}, 'crud') }}</span>'});
  154.                 var container1 = lista.bootstrapDualListbox('getContainer');
  155.                     container1.find('.btn').addClass('btn-white btn-info btn-bold');
  156.                     container1.find('.box1').prepend('<div style="text-align: center">{{ 'opciones.disponibles' | trans({}, 'crud') }}</div>');
  157.                     container1.find('.box2').prepend('<div style="text-align: center">{{ 'opciones.seleccionados' | trans({}, 'crud') }}</div>');
  158.             });
  159.             $('.chosen-select.chosen-pending').chosen({allow_single_deselect:true});
  160.             $('.chosen-select.chosen-pending').removeClass('chosen-pending');
  161.             $('.email').change(function(e){
  162.                 var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9_\.\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  163.                 var email = $(this).val();
  164.                 if (!filter.test(email))
  165.                 {
  166.                     $(this).css('color', 'red');
  167.                     $(this).focus();
  168.                     $(this).addClass('wrong_email');
  169.                 }
  170.                 else
  171.                 {
  172.                     $(this).css('color', 'black');
  173.                     $(this).removeClass('wrong_email');
  174.                 }
  175.             });
  176.             $('#crud_form_{{ routeClassName }}').submit(function(e){
  177.                 if ($(this).find('.wrong_email').length>0)
  178.                 {
  179.                     alert('Correo electrónico incorrecto');
  180.                     e.preventDefault();
  181.                 }
  182.             });
  183.         });
  184.     
  185.     </script>    
  186. {% endblock %}
  187. {% block crud %}
  188.     <div class="widget-box transparent">
  189.         {#% block ico_heading %}
  190.             <div class="widget-header widget-header-flat">
  191.                 <h4 class="widget-title lighter">
  192.                     <i class="fas fa-pencil-alt orange"></i>
  193.                     {% block principal_heading %}
  194.                     {% endblock %}
  195.                 </h4>
  196.                 <!--div class="widget-toolbar">
  197.                     <a href="#" data-action="collapse">
  198.                         <i class="fas fa-chevron-up"></i>
  199.                     </a>
  200.                 </div-->
  201.             </div>
  202.         {% endblock %#}        
  203.         <div class="widget-body" style="display: block;">
  204.             <div class="widget-main no-padding">
  205.                 {% block formulario %}
  206.                 {% endblock formulario %}
  207.             </div>
  208.         </div>
  209.     </div>
  210. {% endblock %}