Class: FormBuilder::Field
Instance Method Summary
collapse
#get_xeditable_select, #get_xeditable_select_bool
#get_xeditable_checkbox
#a_editable, #a_tag, #a_tag_badge, #a_textarea_editable, #bool_class, #class_bootstrap_contextual, #decision_class_bootstrap, #lf_to_br, #permission_a_editable, #put_editable, #url
Constructor Details
#initialize(rs_campo, sr, cd, user, form_builder) ⇒ Field
Returns a new instance of Field
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/form_builder.rb', line 61
def initialize(rs_campo, sr, cd, user,form_builder)
@rs_campo=rs_campo
@form_builder=form_builder
@sr=sr
@cd=cd
@user=user
@row=@sr.analysis_cd_user_row(@cd,@user)
@value=@row[@rs_campo.name.to_sym]
end
|
Instance Method Details
#add_javascript_to_fb(js) ⇒ Object
71
72
73
|
# File 'lib/form_builder.rb', line 71
def add_javascript_to_fb(js)
@form_builder.add_javascript(js)
end
|
#checkbox_html ⇒ Object
105
106
107
108
109
110
|
# File 'lib/form_builder.rb', line 105
def checkbox_html
value_as_array=@value.nil? ? [] : @value.split(",")
xcheckbox=get_xeditable_checkbox(@rs_campo.options_as_hash, url_update, "xselect_form_#{@rs_campo.name}")
add_javascript_to_fb(xcheckbox.javascript)
xcheckbox.html(@rs_campo.name, value_as_array)
end
|
#description ⇒ Object
74
75
76
|
# File 'lib/form_builder.rb', line 74
def description
@rs_campo.description
end
|
#html ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/form_builder.rb', line 77
def html
case @rs_campo.type
when 'textarea'
textarea_html
when 'text'
text_html
when 'select'
select_html
when 'multiple'
checkbox_html
else
raise 'not implemented'
end
end
|
#select_html ⇒ Object
100
101
102
103
104
|
# File 'lib/form_builder.rb', line 100
def select_html
xselect=get_xeditable_select({nil=>"-- #{I18n::t(:empty)} -- "}.merge(@rs_campo.options_as_hash), url_update, "xcheckbox_form_#{@rs_campo.name}")
add_javascript_to_fb(xselect.javascript)
xselect.html(@rs_campo.name, @value)
end
|
#text_html ⇒ Object
97
98
99
|
# File 'lib/form_builder.rb', line 97
def text_html
a_editable(@rs_campo.name, "form-cd-extraction", url_update, @value)
end
|
#textarea_html ⇒ Object
94
95
96
|
# File 'lib/form_builder.rb', line 94
def textarea_html
a_textarea_editable(@rs_campo.name, "form-cd-extraction",url_update , @value)
end
|
#url_update ⇒ Object
91
92
93
|
# File 'lib/form_builder.rb', line 91
def url_update
"/review/#{@sr[:id]}/extract_information/cd/#{@cd[:id]}/user/#{@user[:id]}/update_field"
end
|