Class: FlexaFormtasticBootstrap::Inputs::LookupInput

Inherits:
Formtastic::Inputs::StringInput
  • Object
show all
Includes:
Base, Base::Stringish
Defined in:
lib/flexa_formtastic_bootstrap/inputs/lookup_input.rb

Overview

class LookupInput < FlexaFormtasticBootstrap::Inputs::StringInput

Instance Method Summary collapse

Methods included from Base::Wrapping

#clearfix_div_wrapping, #generic_input_wrapping, #inline_inputs_div_wrapping, #input_div_wrapping, #prepended_input_wrapping

Methods included from Base::Html

#input_html_options

Methods included from Base::Hints

#hint_html

Methods included from Base::Errors

#error_first_html, #error_html, #error_list_html, #error_none_html, #error_sentence_html

Instance Method Details

#label_html_optionsObject



39
40
41
42
43
44
# File 'lib/flexa_formtastic_bootstrap/inputs/lookup_input.rb', line 39

def label_html_options
  {}.tap do |opts|
    opts[:for] ||= input_html_options[:id]
    opts[:class] = [opts[:class]]
  end
end

#to_htmlObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/flexa_formtastic_bootstrap/inputs/lookup_input.rb', line 8

def to_html
  lookup_feedback_fields = Array.new
  lookup_feedback_fields<<method
  lookup_feedback_fields<<options[:lookup][:display]
  lookup_feedback_fields = lookup_feedback_fields+options[:lookup][:fill].to_a if (options[:lookup][:fill].present?&&options[:lookup][:fill].count>0) 
  lookup_url = options[:lookup][:route]+"?fill="+lookup_feedback_fields.join(",")
  
  generic_input_wrapping do
    ihtml_display = input_html_options
    ihtml_display[:readonly]=true
   if !input_html_options[:readonly]
    ihtml_display[:class] = "readonly"
   end
    ihtml_display[:style]="background-color: white;border: 1px solid #CCC;" if !input_html_options[:readonly]
    ihtml_display[:id]=options[:lookup][:display]
    str = builder.text_field(options[:lookup][:display], ihtml_display) 

   if !input_html_options[:readonly]
    str = str << template.link_to(template.("i", "",:class=>"icon-search icon-white"),"#"+'div_'+method.to_s,
    {:target=>"_blank",:class=>"btn btn-info btnlookup","data-toggle"=>"modal"})<<
    builder.hidden_field(method, {:id=>method})    
    iframe = template.(:iframe,"",:src=>lookup_url,:marginheight=>0,:height=>"350",:width=>"100%",:frameborder=>"0") 
    str << template.(:div,iframe,:id=>'div_'+method.to_s,:class=>"modal hide fade",:style=>"display: none; ")
   end
    
    #se for usar sem o Bootstrap voltar para a linha abaixo
    #label_html << template.content_tag(:div,str,:style=>"margin:0;padding:0;display:inline")
    template.(:div,str,:style=>"margin:0;padding:0;display:inline") 
  end
end

#wrapper_html_optionsObject



46
47
48
# File 'lib/flexa_formtastic_bootstrap/inputs/lookup_input.rb', line 46

def wrapper_html_options
  super.merge(:class => "#{super[:class]}" )
end