Class: Adminpanel::AdminpanelFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Adminpanel::AdminpanelFormBuilder
show all
- Includes:
- ApplicationHelper
- Defined in:
- app/helpers/adminpanel/adminpanel_form_builder.rb
Instance Method Summary
collapse
-
#body(&block) ⇒ Object
-
#boolean(name, *args) ⇒ Object
-
#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 = “”.
-
#datepicker(name, *args) ⇒ Object
-
#email_field(name, *args) ⇒ Object
-
#email_field_original ⇒ Object
-
#enum_field(name, *args) ⇒ Object
-
#file_field(name, *args) ⇒ Object
-
#file_field_original ⇒ Object
-
#footer(&block) ⇒ Object
-
#gallery_field(name, *args) ⇒ Object
-
#non_image_file_field(name, *args) ⇒ Object
-
#number_field(name, *args) ⇒ Object
-
#number_field_original ⇒ Object
-
#password_field(name, *args) ⇒ Object
-
#password_field_original ⇒ Object
-
#resource_select(name, *args) ⇒ Object
-
#select(name, select_options, *args) ⇒ Object
-
#submit(name, *args) ⇒ Object
-
#text_area(name, *args) ⇒ Object
-
#text_area_original ⇒ Object
-
#text_field(name, *args) ⇒ Object
-
#text_field_original ⇒ Object
-
#wysiwyg_field(name, *args) ⇒ Object
#adminpanel_form_for, #full_title, #is_current_section?, #link_to_add_fields, #main_root_path, #route_symbol, #symbol_class
#active_tab, #belong_to_object_name, #class_name_downcase, #demodulize_class, #field_value, #get_oauth_link, #is_customized_field?, #pluralize_model, #relationship_ids, #table_type
#breadcrumb_add, #render_breadcrumb
#current_user, #current_user=, #sign_in, #sign_out, #signed_in?
Instance Method Details
#body(&block) ⇒ Object
12
13
14
15
16
17
18
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 12
def body(&block)
@template.content_tag :div, class: 'widget-body' do
@template.content_tag :div, class: 'widget-forms clearfix' do
yield
end
end
end
|
#boolean(name, *args) ⇒ Object
93
94
95
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 93
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
81
82
83
84
85
86
87
88
89
90
91
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 81
def checkbox(checkbox_object, form_object_name, relationship)
@template.content_tag(
: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
150
151
152
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 150
def datepicker(name, *args)
base_layout( name, *args, 'datepickerize_base' )
end
|
#email_field(name, *args) ⇒ Object
134
135
136
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 134
def email_field(name, *args)
base_layout( name, *args, 'email_field_original' )
end
|
#email_field_original ⇒ Object
9
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 9
alias_method :email_field_original, :email_field
|
#enum_field(name, *args) ⇒ Object
97
98
99
100
101
102
103
104
105
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 97
def enum_field(name, *args)
select(
name,
self.object.class.send(name.pluralize).map{|option, value|
[I18n.t("#{self.object.class.name.demodulize.downcase}.#{option}"), option]
},
*args
)
end
|
#file_field(name, *args) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 30
def file_field(name, *args)
image_input = base_layout(name, *args, 'file_field_original')
if !object.nil? && !object.new_record?
"#{thumbnail_layout(name)}#{image_input}".html_safe
else
image_input
end
end
|
#file_field_original ⇒ Object
10
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 10
alias_method :file_field_original, :file_field
|
20
21
22
23
24
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 20
def (&block)
@template.content_tag :div, class: 'widget-footer' do
yield
end
end
|
#gallery_field(name, *args) ⇒ Object
50
51
52
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 50
def gallery_field(name, *args)
base_layout name, *args, 'gallery_base'
end
|
#non_image_file_field(name, *args) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 40
def non_image_file_field(name, *args)
file_input = base_layout(name, *args, 'file_field_original')
if !object.nil? && !object.new_record?
"#{title_layout(name)}#{file_input}".html_safe
else
file_input
end
end
|
#number_field(name, *args) ⇒ Object
126
127
128
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 126
def number_field(name, *args)
base_layout( name, *args, 'number_field_original' )
end
|
#number_field_original ⇒ Object
8
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 8
alias_method :number_field_original, :number_field
|
#password_field(name, *args) ⇒ Object
130
131
132
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 130
def password_field(name, *args)
base_layout( name, *args, 'password_field_original' )
end
|
#password_field_original ⇒ Object
7
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 7
alias_method :password_field_original, :password_field
|
#resource_select(name, *args) ⇒ Object
107
108
109
110
111
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 107
def resource_select(name, *args)
select name, Adminpanel.displayable_resources.map{|resource| [symbol_class(resource).display_name, resource.to_s]}, *args
end
|
#select(name, select_options, *args) ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 113
def select(name, select_options, *args)
options = args.
label = options['label']
options.delete('label')
options.reverse_merge! class: 'span7', include_blank: '(Seleccione por favor)';
@template.content_tag :div, class: "control-group" do
@template.content_tag(:label, label, class: "control-label") +
@template.content_tag(:div, super(name, select_options, options), class: "controls")
end
end
|
#submit(name, *args) ⇒ Object
138
139
140
141
142
143
144
145
146
147
148
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 138
def submit(name, *args)
options = args.
options.reverse_merge!(
class: 'btn btn-primary',
data: {
disable_with: I18n.t('action.submitting')
}
)
super(name, *args << options)
end
|
#text_area(name, *args) ⇒ Object
62
63
64
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 62
def text_area(name, *args)
base_layout name, *args, 'text_area_original'
end
|
#text_area_original ⇒ Object
6
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 6
alias_method :text_area_original, :text_area
|
#text_field(name, *args) ⇒ Object
26
27
28
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 26
def text_field(name, *args)
base_layout name, *args, 'text_field_original'
end
|
#text_field_original ⇒ Object
4
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 4
alias_method :text_field_original, :text_field
|
#wysiwyg_field(name, *args) ⇒ Object
54
55
56
57
58
59
60
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 54
def wysiwyg_field(name, *args)
options = args.
options.reverse_merge! class: 'wysihtml5 span7'
base_layout name, options, 'text_area_original'
end
|