Class: Adminpanel::AdminpanelFormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Includes:
ApplicationHelper
Defined in:
app/helpers/adminpanel/adminpanel_form_builder.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#adminpanel_form_for, #full_title, #is_current_section?, #link_to_add_fields, #main_root_path, #route_symbol, #symbol_class

Methods included from SharedPagesHelper

#active_tab, #belong_to_object_name, #class_name_downcase, #demodulize_class, #get_oauth_link, #pluralize_model, #relationship_ids

Methods included from BreadcrumbsHelper

#breadcrumb_add, #render_breadcrumb

Methods included from SessionsHelper

#current_user, #current_user=, #sign_in, #sign_out, #signed_in?

Instance Method Details

#boolean(name, *args) ⇒ Object



70
71
72
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 70

def boolean name, *args
  base_layout name, *args, 'boolean_base'
end

#checkbox(checkbox_object, form_object_name, relationship) ⇒ Object

def radio_button_group(name, buttons, options) options.reverse_merge! :label => name options.reverse_merge! :html => {} output = “”

buttons.each do |b| output = @template.content_tag(:label, radio_button_original(name, b, options) b.capitalize, :class => “radio”) end

@template.content_tag :div, :class => “control-group” do @template.content_tag(:label, options, :class => “control-label”) + @template.content_tag(:div, output, { :class => “controls”}, false) end end



58
59
60
61
62
63
64
65
66
67
68
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 58

def checkbox checkbox_object, form_object_name, relationship
  @template.(
    :label,
    @template.check_box_tag(
      "#{form_object_name}[#{relationship}][]",
      checkbox_object.id,
      self.object.send(relationship).include?(checkbox_object.id)
      ) + checkbox_object.name,
    :class => "checkbox"
  )
end

#datepicker(name, *args) ⇒ Object



116
117
118
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 116

def datepicker(name, *args)
  base_layout( name, *args, 'datepickerize_base' )
end

#email_field(name, *args) ⇒ Object



105
106
107
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 105

def email_field(name, *args)
  base_layout( name, *args, 'email_field_original' )
end

#email_field_originalObject



9
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 9

alias_method :email_field_original, :email_field

#enum_field(name, *args) ⇒ Object



74
75
76
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 74

def enum_field name, *args
  select name, self.object.class.actions.map{|action, value| [I18n.t("#{self.object.class.name.demodulize.downcase}.#{action}"), action]}, *args
end

#file_field(name, *args) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 17

def file_field name, *args
  image_input = base_layout(name, *args, 'file_field_original')

  if !object.nil? && !object.new_record? #if not new record
    "#{thumbnail_layout(name)}#{image_input}".html_safe
  else
    image_input
  end
end

#file_field_originalObject



10
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 10

alias_method :file_field_original, :file_field


27
28
29
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 27

def gallery_field name, *args
  base_layout name, *args, 'gallery_base'
end

#number_field(name, *args) ⇒ Object



97
98
99
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 97

def number_field(name, *args)
  base_layout( name, *args, 'number_field_original' )
end

#number_field_originalObject



8
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 8

alias_method :number_field_original, :number_field

#password_field(name, *args) ⇒ Object



101
102
103
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 101

def password_field(name, *args)
  base_layout( name, *args, 'password_field_original' )
end

#password_field_originalObject



7
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 7

alias_method :password_field_original, :password_field

#resource_select(name, *args) ⇒ Object



78
79
80
81
82
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 78

def resource_select name, *args
  select name, Adminpanel.displayable_resources.map{|resource| [symbol_class(resource).display_name, resource.to_s]}, *args
  # select name, Adminpanel.displayable_resources.map{|resource| ['resource', 'resource']}, *args

end

#select(name, select_options, *args) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 84

def select(name, select_options, *args)
  options = args.extract_options!
  label = options['label']
  options.delete('label')

  options.reverse_merge! :class => 'span7', :include_blank => '(Seleccione por favor)';

  @template. :div, :class => "control-group" do
    @template.(:label, label, :class => "control-label") +
    @template.(:div, super(name, select_options, options), :class => "controls")
  end
end

#submit(name, *args) ⇒ Object



109
110
111
112
113
114
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 109

def submit(name, *args)
  options = args.extract_options!

  options.reverse_merge! :class => "btn btn-primary"
  super(name, *args << options)
end

#text_area(name, *args) ⇒ Object



39
40
41
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 39

def text_area name, *args
  base_layout name, *args, 'text_area_original'
end

#text_area_originalObject



6
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 6

alias_method :text_area_original, :text_area

#text_field(name, *args) ⇒ Object

alias_method :select_original, :select



13
14
15
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 13

def text_field name, *args
  base_layout name, *args, 'text_field_original'
end

#text_field_originalObject



4
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 4

alias_method :text_field_original, :text_field

#wysiwyg_field(name, *args) ⇒ Object



31
32
33
34
35
36
37
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 31

def wysiwyg_field name, *args

  options = args.extract_options!
  options.reverse_merge! class: 'wysihtml5 span7'

  base_layout name, options, 'text_area_original'
end