Class: AdminWidgets::Form::FieldsetWidget
Instance Attribute Summary collapse
#form
Instance Method Summary
collapse
#buttons, #fieldset
#autofocus!, #autofocus_done?, #builder, #field, #form_content
Methods inherited from BaseWidget
#capture, #content_block, #helper, #method_missing, #root
#memoize
Methods included from Delegation
#delegate
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class AdminWidgets::BaseWidget
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 5
def name
@name
end
|
#parent ⇒ Object
Returns the value of attribute parent.
4
5
6
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 4
def parent
@parent
end
|
Instance Method Details
#after ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 49
def after
@after = capture do
div :class => 'after' do
yield
end
end
nil
end
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 65
def around_form
wrapper_attrs = { :class => 'fieldset-wrapper' }
wrapper_attrs.merge! :style => 'display: none' unless visible
wrapper_attrs.merge! wrapper_html
div wrapper_attrs do
if legend
element('fieldset') do
element('legend', legend)
inside = capture { yield }
rawtext @before
rawtext inside
rawtext @after
end
else
yield
end
end
end
|
#around_repeatable_collection ⇒ Object
85
86
87
88
89
90
91
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 85
def around_repeatable_collection
return yield unless repeatable
div :class => 'repeatable-collection', :'data-repeatable' => repeatable do
yield
end
end
|
#around_repeatable_group ⇒ Object
93
94
95
96
97
98
99
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 93
def around_repeatable_group
return yield unless repeatable
div :class => ['repeatable-group', form.object.class.name.underscore], :id => form.object._id do
yield
end
end
|
#before ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 40
def before
@before = capture do
div :class => 'before' do
yield
end
end
nil
end
|
#content ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 24
def content
return simple_fieldset unless nested
around_form do
around_repeatable_collection do
parent.form.simple_fields_for(name) do |form|
@form = form
around_repeatable_group do
content_block
end
end
end
end
end
|
#resource ⇒ Object
7
8
9
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 7
def resource
form.object
end
|
#simple_fieldset ⇒ Object
58
59
60
61
62
63
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 58
def simple_fieldset
@form = parent.form
around_form do
content_block
end
end
|
#visible ⇒ Object
18
19
20
21
22
|
# File 'lib/admin_widgets/form/fieldset_widget.rb', line 18
def visible
return @visible = true if @visible.nil?
return @visible = @visible.call(resource) if @visible.respond_to? :call
@visible
end
|