Commit 00534f94 authored by pascal.carrie@gmail.com's avatar pascal.carrie@gmail.com
Browse files

#22 observe_field con :function

parent 7e7b2ed3
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -165,7 +165,6 @@ var HERRAMIENTAS_GONG = (function() {
    };

    self.observarCampo = function( opciones ) {
        opciones.hasOwnProperty("function") && self.ejecutarFuncion(opciones["function"]);
        opciones.hasOwnProperty("url") && AJAX_GONG.updateAjax(opciones);
    };

+14 −6
Original line number Diff line number Diff line
@@ -40,6 +40,13 @@ module ApplicationHelper

  # observe_field
  def observe_field( field_id, opciones = {} )
    if opciones[:function]
      cadena = content_tag( :script, type: "text/javascript" ) do
        "document.getElementById(\"#{field_id}\").addEventListener('change',function(){
                HERRAMIENTAS_GONG.ejecutarFuncion(#{opciones[:function].to_json});
          });".html_safe
      end
    else
      opciones[:url] = url_for(opciones[:url]) if opciones[:url]
      opciones[:field_id] = field_id
      cadena = content_tag( :script, type: "text/javascript" ) do
@@ -47,6 +54,7 @@ module ApplicationHelper
                HERRAMIENTAS_GONG.observarCampo(#{opciones.to_json});
          });".html_safe
      end
    end
    return cadena
  end

+18 −20
Original line number Diff line number Diff line
@@ -13,12 +13,11 @@
    <%= checkbox _("Implementador"), 'agente', 'implementador', "1", {:izquierda => true, :abajo =>true, :checked => (@agente ? @agente.implementador : false) } %>
    <%= observe_field( "agente_implementador" , :function => '
      if( document.getElementById("agente_implementador").checked ) {
           Element.show("mostrar_moneda");
           Modalbox.resizeToContent({resizeDuration: 0.5});
          document.getElementById("mostrar_moneda").style.display = "block";
      } else {
           Element.hide("mostrar_moneda");
           Modalbox.resizeToContent({resizeDuration: 0.5});
          document.getElementById("mostrar_moneda").style.display = "none";
      }
      HERRAMIENTAS_GONG.resizeModal();
    ' ) %>
    <div id="mostrar_moneda" style="<%= ((@agente && @agente.implementador) ? '' : 'display:none;') %>"  >
      <%= selector _("Moneda"), 'agente', 'moneda_id',   @monedas , false, "1", :obligatorio => true  %>
@@ -32,14 +31,13 @@
    <%= checkbox _("Financiador"), 'agente', 'financiador', "1", {:izquierda => true, :abajo =>true, :checked => (@agente ? @agente.financiador : false) } %>
    <%= observe_field( "agente_financiador" , :function => '
      if( document.getElementById("agente_financiador").checked ) {
           Element.show("mostrar_publico_privado");
           Element.hide("ocultar_publico_privado");
           Modalbox.resizeToContent({resizeDuration: 0.5});
          document.getElementById("mostrar_publico_privado").style.display = "block";
          document.getElementById("ocultar_publico_privado").style.display = "none";
      } else {
           Element.hide("mostrar_publico_privado");
           Element.show("ocultar_publico_privado");
           Modalbox.resizeToContent({resizeDuration: 0.5});
          document.getElementById("mostrar_publico_privado").style.display = "none";
          document.getElementById("ocultar_publico_privado").style.display = "block";
      }
      HERRAMIENTAS_GONG.resizeModal();
    ' ) %>
    <div id="mostrar_publico_privado" style="<%= ((@agente && @agente.financiador) ? '' : 'display:none;') %>"  >
      <%= selector _("Copiar mapeo desde"), 'selector', 'copiar_mapeo', @otros_financiadores.collect{|f| [f.nombre, f.id]}, true, "1", {enriquecido: true} %>
+10 −2
Original line number Diff line number Diff line
@@ -15,7 +15,15 @@
<div class="legend" align= "left"><%= _("Seleccione los criterios para la vista resumen de Arqueo de Caja/Cuenta: ") %></div>
<%= comienzo_formulario "arqueo_caja", nil %>
  <%= selector _('Cuenta/Caja o Agente'), 'selector', 'tipo', [[_("Cuenta/Caja"),"cuenta"], [_("Agente Implementador"),"agente"]], false, '1', {:selected => params[:selector].nil? ? "1" : params[:selector][:tipo]} unless params[:seccion] == "agentes"%>
    <%= observe_field( "selector_tipo" , :function => 'if( document.getElementById("selector_tipo").selectedIndex == 0 ){ Element.hide("opciones_agente"); Element.show("opciones_cuenta"); } else { Element.hide("opciones_cuenta"); Element.show("opciones_agente"); }' ) %>
  <%= observe_field( "selector_tipo" , :function => '
    if( document.getElementById("selector_tipo").selectedIndex == 0 ){
        document.getElementById("opciones_agente").style.display = "none";
        document.getElementById("opciones_cuenta").style.display = "block";
    } else {
        document.getElementById("opciones_cuenta").style.display = "none";
        document.getElementById("opciones_agente").style.display = "block";
    }
  ') %>
  <div id="opciones_cuenta" style="<%= params[:selector] && params[:selector][:tipo] == 'agente' ? 'display:none;' : '' %>">
  <%= selector _('Cuenta/Caja'), 'selector', 'libro', @listado_libros, false , '1', {:selected => (params[:selector][:libro].to_i if params[:selector])}  %>
  </div>
+9 −9
Original line number Diff line number Diff line
@@ -5,11 +5,11 @@
  <%= selector _('Filtrar por'), '', 'seleccion_fecha', [[_("Etapa"), "etapa"], [_("Rango de fechas"), "fecha"]], false, '3_4', {:selected => params[:seleccion_fecha]} %>
  <%= observe_field( "_seleccion_fecha" , :function => '
    if ( document.getElementById("_seleccion_fecha").selectedIndex == 1 ) {
        Element.hide("div_selector_etapa");
        Element.show("div_selector_fecha");
        document.getElementById("div_selector_etapa").style.display = "none";
        document.getElementById("div_selector_fecha").style.display = "block";
    } else {
        Element.hide("div_selector_fecha");
        Element.show("div_selector_etapa");
        document.getElementById("div_selector_fecha").style.display = "none";
        document.getElementById("div_selector_etapa").style.display = "block";
    }
  ' ) %>

Loading