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(method, *args) ⇒ Object
-
#collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ Object
def radio_button_group(name, buttons, options) options.reverse_merge! :label => name options.reverse_merge! :html => {} output = “”.
-
#datepicker(method, *args) ⇒ Object
-
#email_field(method, *args) ⇒ Object
-
#email_field_original ⇒ Object
-
#enum_field(method, *args) ⇒ Object
-
#file_field(method, *args) ⇒ Object
-
#file_field_original ⇒ Object
-
#footer(&block) ⇒ Object
-
#gallery_field(method, *args) ⇒ Object
-
#hours_select(method, *args) ⇒ Object
-
#image_field(method, *args) ⇒ Object
-
#number_field(method, *args) ⇒ Object
-
#number_field_original ⇒ Object
-
#password_field(method, *args) ⇒ Object
-
#password_field_original ⇒ Object
-
#resource_select(method, *args) ⇒ Object
-
#select(method, select_options, *args) ⇒ Object
-
#submit(method, *args) ⇒ Object
-
#text_area(method, *args) ⇒ Object
-
#text_area_original ⇒ Object
-
#text_field(method, *args) ⇒ Object
-
#text_field_original ⇒ Object
-
#wysiwyg_field(method, *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
13
14
15
16
17
18
19
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 13
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(method, *args) ⇒ Object
98
99
100
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 98
def boolean(method, *args)
base_layout method, *args, 'boolean_base'
end
|
#collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}) ⇒ 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
89
90
91
92
93
94
95
96
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 89
def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {})
super method, collection, value_method, text_method, options, html_options do |b|
b.label class: 'checkbox' do
b.check_box +
b.label
end
end
end
|
#datepicker(method, *args) ⇒ Object
153
154
155
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 153
def datepicker(method, *args)
base_layout( method, *args, 'datepickerize_base' )
end
|
#email_field(method, *args) ⇒ Object
137
138
139
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 137
def email_field(method, *args)
base_layout( method, *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(method, *args) ⇒ Object
102
103
104
105
106
107
108
109
110
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 102
def enum_field(method, *args)
select(
method,
self.object.class.send(method.to_s.pluralize).map{|option, value|
[I18n.t("#{self.object.class.name.demodulize.downcase}.#{option}"), option]
},
*args
)
end
|
#file_field(method, *args) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 41
def file_field(method, *args)
file_input = base_layout(method, *args, 'file_field_original')
if !object.nil? && !object.new_record? "#{title_layout(method)}#{file_input}".html_safe
else
file_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
|
21
22
23
24
25
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 21
def (&block)
@template.content_tag :div, class: 'widget-footer' do
yield
end
end
|
#gallery_field(method, *args) ⇒ Object
51
52
53
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 51
def gallery_field(method, *args)
base_layout method, *args, 'gallery_base'
end
|
#hours_select(method, *args) ⇒ Object
157
158
159
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 157
def hours_select(method, *args)
base_layout( method, *args, 'time_select_original' )
end
|
#image_field(method, *args) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 31
def image_field(method, *args)
image_input = base_layout(method, *args, 'file_field_original')
if !object.nil? && !object.new_record? "#{thumbnail_layout(method)}#{image_input}".html_safe
else
image_input
end
end
|
#number_field(method, *args) ⇒ Object
129
130
131
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 129
def number_field(method, *args)
base_layout( method, *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(method, *args) ⇒ Object
133
134
135
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 133
def password_field(method, *args)
base_layout( method, *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(method, *args) ⇒ Object
112
113
114
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 112
def resource_select(method, *args)
select method, Adminpanel.displayable_resources.map{|resource| [symbol_class(resource).display_name, resource.to_s]}, *args
end
|
#select(method, select_options, *args) ⇒ Object
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 116
def select(method, 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(method, select_options, options), class: "controls")
end
end
|
#submit(method, *args) ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 141
def submit(method, *args)
options = args.
options.reverse_merge!(
class: 'btn btn-primary',
data: {
disable_with: I18n.t('action.submitting')
}
)
super(method, *args << options)
end
|
#text_area(method, *args) ⇒ Object
70
71
72
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 70
def text_area(method, *args)
base_layout method, *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(method, *args) ⇒ Object
27
28
29
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 27
def text_field(method, *args)
base_layout method, *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(method, *args) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 55
def wysiwyg_field(method, *args)
options = args.
options[:trix_id] = "trix-#{method}-#{self.object.object_id}"
hidden_field(
method,
id: options[:trix_id]
) + base_layout(
method,
options,
'trix_field'
)
end
|