Top Level Namespace
Defined Under Namespace
Modules: InlineForms, InlineFormsHelper, Kernel
Classes: CuracaoIdNumberValidator, GeoCodeCuracao, GeoCodeCuracaoController, InlineFormsApplicationController, InlineFormsController, IsCuracaoPhoneValidator, IsEmailAddressValidator, MustBeAValueValidator
Constant Summary
collapse
- APP_ROOT =
File.expand_path(File.dirname(File.dirname(__FILE__)))
Instance Method Summary
collapse
-
#check_box_edit(object, attribute) ⇒ Object
-
#check_box_show(object, attribute) ⇒ Object
boolean, bit unaptly named check_box.
-
#check_box_update(object, attribute) ⇒ Object
-
#check_list_edit(object, attribute) ⇒ Object
-
#check_list_show(object, attribute) ⇒ Object
-
#check_list_update(object, attribute) ⇒ Object
-
#date_select_edit(object, attribute) ⇒ Object
-
#date_select_show(object, attribute) ⇒ Object
-
#date_select_update(object, attribute) ⇒ Object
-
#devise_password_field_edit(object, attribute) ⇒ Object
-
#devise_password_field_show(object, attribute) ⇒ Object
-
#devise_password_field_update(object, attribute) ⇒ Object
-
#dnsrecords_edit(object, attribute) ⇒ Object
-
#dnsrecords_show(object, attribute) ⇒ Object
-
#dnsrecords_update(object, attribute) ⇒ Object
-
#dropdown_edit(object, attribute) ⇒ Object
-
#dropdown_show(object, attribute) ⇒ Object
-
#dropdown_update(object, attribute) ⇒ Object
-
#dropdown_with_integers_edit(object, attribute) ⇒ Object
-
#dropdown_with_integers_show(object, attribute) ⇒ Object
dropdown_with_integers generates a dropdown menu with the given list of integers as options.
-
#dropdown_with_integers_update(object, attribute) ⇒ Object
-
#dropdown_with_values_edit(object, attribute) ⇒ Object
-
#dropdown_with_values_show(object, attribute) ⇒ Object
-
#dropdown_with_values_update(object, attribute) ⇒ Object
-
#file_field_edit(object, attribute) ⇒ Object
-
#file_field_show(object, attribute) ⇒ Object
-
#file_field_update(object, attribute) ⇒ Object
-
#geo_code_curacao_edit(object, attribute) ⇒ Object
-
#geo_code_curacao_show(object, attribute) ⇒ Object
-
#geo_code_curacao_update(object, attribute) ⇒ Object
-
#header_edit(object, attribute) ⇒ Object
-
#header_show(object, attribute) ⇒ Object
-
#header_update(object, attribute, ) ⇒ Object
-
#image_field_edit(object, attribute) ⇒ Object
-
#image_field_show(object, attribute) ⇒ Object
-
#image_field_update(object, attribute) ⇒ Object
-
#info_edit(object, attribute) ⇒ Object
-
#info_show(object, attribute) ⇒ Object
-
#info_update(object, attribute, ) ⇒ Object
-
#money_field_edit(object, attribute) ⇒ Object
-
#money_field_show(object, attribute) ⇒ Object
-
#money_field_update(object, attribute) ⇒ Object
-
#pdf_link_edit(object, attribute) ⇒ Object
-
#pdf_link_show(object, attribute) ⇒ Object
-
#pdf_link_update(object, attribute) ⇒ Object
-
#plain_text_area_edit(object, attribute) ⇒ Object
-
#plain_text_area_show(object, attribute) ⇒ Object
-
#plain_text_area_update(object, attribute) ⇒ Object
-
#question_list_edit(object, attribute) ⇒ Object
-
#question_list_show(object, attribute) ⇒ Object
-
#question_list_update(object, attribute) ⇒ Object
-
#radio_button_edit(object, attribute) ⇒ Object
-
#radio_button_show(object, attribute) ⇒ Object
[ :sex , “gender”, :radio_button, { 1 => ‘male’, 2 => ‘female’ } ],.
-
#radio_button_update(object, attribute) ⇒ Object
-
#scale_with_integers_edit(object, attribute) ⇒ Object
-
#scale_with_integers_show(object, attribute) ⇒ Object
scale_with_integers generates a scale with the given list of integers as options.
-
#scale_with_integers_update(object, attribute) ⇒ Object
-
#scale_with_values_edit(object, attribute) ⇒ Object
-
#scale_with_values_show(object, attribute) ⇒ Object
scale_with_values generates a scale with the given list of values as options.
-
#scale_with_values_update(object, attribute) ⇒ Object
-
#slider_with_values_edit(object, attribute) ⇒ Object
-
#slider_with_values_show(object, attribute) ⇒ Object
-
#slider_with_values_update(object, attribute) ⇒ Object
-
#text_area_edit(object, attribute) ⇒ Object
-
#text_area_show(object, attribute) ⇒ Object
-
#text_area_update(object, attribute) ⇒ Object
-
#text_area_without_ckeditor_edit(object, attribute) ⇒ Object
-
#text_area_without_ckeditor_show(object, attribute) ⇒ Object
-
#text_area_without_ckeditor_update(object, attribute) ⇒ Object
-
#text_field_edit(object, attribute) ⇒ Object
-
#text_field_show(object, attribute) ⇒ Object
-
#text_field_update(object, attribute) ⇒ Object
Instance Method Details
#check_box_edit(object, attribute) ⇒ Object
9
10
11
|
# File 'lib/app/helpers/form_elements/check_box.rb', line 9
def check_box_edit(object, attribute)
check_box_tag attribute.to_s, 1, object.send(attribute)
end
|
#check_box_show(object, attribute) ⇒ Object
boolean, bit unaptly named check_box
4
5
6
7
|
# File 'lib/app/helpers/form_elements/check_box.rb', line 4
def check_box_show(object, attribute)
values = attribute_values(object, attribute)
link_to_inline_edit object, attribute, values[object.send(attribute) ? 1 : 0 ][1]
end
|
#check_box_update(object, attribute) ⇒ Object
13
14
15
|
# File 'lib/app/helpers/form_elements/check_box.rb', line 13
def check_box_update(object, attribute)
object[attribute.to_s.to_sym] = params[attribute.to_s.to_sym].nil? ? 0 : 1
end
|
#check_list_edit(object, attribute) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/app/helpers/form_elements/check_list.rb', line 17
def check_list_edit(object, attribute)
object.send(attribute).build if object.send(attribute).empty?
if cancan_enabled?
values = object.send(attribute).first.class.name.constantize.accessible_by(current_ability).order(attribute.to_s.singularize.camelcase.constantize.order_by_clause)
else
values = object.send(attribute).first.class.name.constantize.order(attribute.to_s.singularize.camelcase.constantize.order_by_clause)
end
out = '<div class="edit_form_checklist">'
out << '<ul>'
values.each do | item |
out << '<li>'
out << check_box_tag( attribute.to_s + '[' + item.id.to_s + ']', 1, object.send(attribute.to_s.singularize + "_ids").include?(item.id) )
out << '<div class="edit_form_checklist_text">'
out << h(item._presentation)
out << '</div>'
out << '<div style="clear: both;"></div>'
out << '</li>'
end
out << '</ul>'
out << '</div>'
out.html_safe
end
|
#check_list_show(object, attribute) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/app/helpers/form_elements/check_list.rb', line 5
def check_list_show(object, attribute)
out = '<ul class="checklist">'
out << link_to_inline_edit(object, attribute) if object.send(attribute).empty?
object.send(attribute).sort.each do | item |
out << '<li>'
out << link_to_inline_edit(object, attribute, item._presentation )
out << '</li>'
end
out << '</ul>'
out.html_safe
end
|
#check_list_update(object, attribute) ⇒ Object
40
41
42
43
|
# File 'lib/app/helpers/form_elements/check_list.rb', line 40
def check_list_update(object, attribute)
params[attribute] ||= {}
object.send(attribute.to_s.singularize + '_ids=', params[attribute].keys)
end
|
#date_select_edit(object, attribute) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/app/helpers/form_elements/date.rb', line 9
def date_select_edit(object, attribute)
css_id = 'datepicker_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + attribute.to_s
out = text_field_tag attribute, ( object.send(attribute).nil? ? "" : object.send(attribute).strftime("%d-%m-%Y") ), :id => css_id
out << '<SCRIPT>'.html_safe
out << "$(function() { ".html_safe
out << '$("#'.html_safe + css_id.html_safe + '").datepicker({ yearRange: "-100:+5" });'.html_safe
out << '});'.html_safe
out << '</SCRIPT>'.html_safe
return out
end
|
#date_select_show(object, attribute) ⇒ Object
5
6
7
|
# File 'lib/app/helpers/form_elements/date.rb', line 5
def date_select_show(object, attribute)
link_to_inline_edit object, attribute, object.send(attribute).nil? ? "" : object.send(attribute).strftime("%d-%m-%Y")
end
|
#date_select_update(object, attribute) ⇒ Object
20
21
22
|
# File 'lib/app/helpers/form_elements/date.rb', line 20
def date_select_update(object, attribute)
object[attribute.to_sym] = params[attribute.to_sym]
end
|
#devise_password_field_edit(object, attribute) ⇒ Object
8
9
10
|
# File 'lib/app/helpers/form_elements/devise_password_field.rb', line 8
def devise_password_field_edit(object, attribute)
password_field_tag attribute, '', :class => 'input_devise_password_field'
end
|
#devise_password_field_show(object, attribute) ⇒ Object
4
5
6
|
# File 'lib/app/helpers/form_elements/devise_password_field.rb', line 4
def devise_password_field_show(object, attribute)
link_to_inline_edit object, attribute, ''
end
|
#devise_password_field_update(object, attribute) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/app/helpers/form_elements/devise_password_field.rb', line 12
def devise_password_field_update(object, attribute)
if params[attribute.to_sym].blank?
else
object.password = params[attribute.to_sym]
end
end
|
#dnsrecords_edit(object, attribute) ⇒ Object
10
11
|
# File 'lib/app/helpers/form_elements/dns_records.rb', line 10
def dnsrecords_edit(object, attribute)
end
|
#dnsrecords_show(object, attribute) ⇒ Object
2
3
4
5
6
7
8
|
# File 'lib/app/helpers/form_elements/dns_records.rb', line 2
def dnsrecords_show(object, attribute)
out = ""
[object.a_records,object.template_a_records].flatten.collect do |r|
out << r.djbdns_line(object.name) + "<br/>"
end
raw out
end
|
#dnsrecords_update(object, attribute) ⇒ Object
13
14
|
# File 'lib/app/helpers/form_elements/dns_records.rb', line 13
def dnsrecords_update(object, attribute)
end
|
#dropdown_edit(object, attribute) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/app/helpers/form_elements/dropdown.rb', line 10
def dropdown_edit(object, attribute)
object.send('build_' + attribute.to_s) unless object.send(attribute)
o = object.send(attribute).class.name.constantize
if cancan_enabled?
values = o.accessible_by(current_ability).order(o.order_by_clause)
else
values = o.order(o.order_by_clause)
end
values.each do |v|
v.name = v._presentation
end
values.sort_by! &:name
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', 'name', :selected => object.send(attribute).id)
end
|
#dropdown_show(object, attribute) ⇒ Object
5
6
7
8
|
# File 'lib/app/helpers/form_elements/dropdown.rb', line 5
def dropdown_show(object, attribute)
attribute_value = object.send(attribute)._presentation rescue nil
link_to_inline_edit object, attribute, attribute_value
end
|
#dropdown_update(object, attribute) ⇒ Object
26
27
28
29
|
# File 'lib/app/helpers/form_elements/dropdown.rb', line 26
def dropdown_update(object, attribute)
foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.to_s.foreign_key.to_sym
object[foreign_key] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_s.foreign_key.to_sym]
end
|
#dropdown_with_integers_edit(object, attribute) ⇒ Object
13
14
15
16
17
|
# File 'lib/app/helpers/form_elements/dropdown_with_integers.rb', line 13
def dropdown_with_integers_edit(object, attribute)
values = attribute_values(object, attribute)
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute))
end
|
#dropdown_with_integers_show(object, attribute) ⇒ Object
dropdown_with_integers generates a dropdown menu with the given list of integers as options
values must be a Range or a one-dimensional array of Integers
8
9
10
11
|
# File 'lib/app/helpers/form_elements/dropdown_with_integers.rb', line 8
def dropdown_with_integers_show(object, attribute)
values = attribute_values(object, attribute)
link_to_inline_edit object, attribute, values[object.send(attribute)][1]
end
|
#dropdown_with_integers_update(object, attribute) ⇒ Object
19
20
21
|
# File 'lib/app/helpers/form_elements/dropdown_with_integers.rb', line 19
def dropdown_with_integers_update(object, attribute)
object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
end
|
#dropdown_with_values_edit(object, attribute) ⇒ Object
9
10
11
12
13
|
# File 'lib/app/helpers/form_elements/dropdown_with_values.rb', line 9
def dropdown_with_values_edit(object, attribute)
values = attribute_values(object, attribute)
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute))
end
|
#dropdown_with_values_show(object, attribute) ⇒ Object
5
6
7
8
|
# File 'lib/app/helpers/form_elements/dropdown_with_values.rb', line 5
def dropdown_with_values_show(object, attribute)
values = attribute_values(object, attribute)
link_to_inline_edit object, attribute, object.send(attribute) ? values.assoc(object.send(attribute))[1] : ""
end
|
#dropdown_with_values_update(object, attribute) ⇒ Object
14
15
16
|
# File 'lib/app/helpers/form_elements/dropdown_with_values.rb', line 14
def dropdown_with_values_update(object, attribute)
object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
end
|
#file_field_edit(object, attribute) ⇒ Object
13
14
15
|
# File 'lib/app/helpers/form_elements/file_field.rb', line 13
def file_field_edit(object, attribute)
file_field_tag attribute, :class => 'input_text_field'
end
|
#file_field_show(object, attribute) ⇒ Object
4
5
6
7
8
9
10
11
|
# File 'lib/app/helpers/form_elements/file_field.rb', line 4
def file_field_show(object, attribute)
o = object.send(attribute)
msg = o.to_s
if o.send(:present?)
msg = "<a href='#{o.send(:url)}'>#{o.send(:path).gsub(/^.*\//,'')}</a>".html_safe
end
link_to_inline_edit object, attribute, msg
end
|
#file_field_update(object, attribute) ⇒ Object
17
18
19
|
# File 'lib/app/helpers/form_elements/file_field.rb', line 17
def file_field_update(object, attribute)
object.send(attribute.to_s + '=', params[attribute.to_sym])
end
|
#geo_code_curacao_edit(object, attribute) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/app/helpers/form_elements/geo_code_curacao.rb', line 9
def geo_code_curacao_edit(object, attribute)
attribute_value = object.send(attribute).presentation rescue nil
out = text_field_tag attribute, attribute_value
out << '<script>
$( "#geo_code_curacao" ).autocomplete({
source: "/geo_code_curacao",
minLength: 2,
});
</script>'.html_safe
end
|
#geo_code_curacao_show(object, attribute) ⇒ Object
5
6
7
8
|
# File 'lib/app/helpers/form_elements/geo_code_curacao.rb', line 5
def geo_code_curacao_show(object, attribute)
attribute_value = GeoCodeCuracao.new(object.send(attribute)).presentation rescue nil
link_to_inline_edit object, attribute, attribute_value
end
|
#geo_code_curacao_update(object, attribute) ⇒ Object
20
21
22
23
24
|
# File 'lib/app/helpers/form_elements/geo_code_curacao.rb', line 20
def geo_code_curacao_update(object, attribute)
geo_code = params[attribute].scan(/\d\d\d\d\d\d/).first || nil
object[attribute.to_sym] = GeoCodeCuracao.new(geo_code).valid? ? geo_code : nil
end
|
9
10
11
12
|
# File 'lib/app/helpers/form_elements/header.rb', line 9
def (object, attribute)
attribute
end
|
4
5
6
7
|
# File 'lib/app/helpers/form_elements/header.rb', line 4
def (object, attribute)
attribute
end
|
14
15
16
|
# File 'lib/app/helpers/form_elements/header.rb', line 14
def (object, attribute)
end
|
#image_field_edit(object, attribute) ⇒ Object
17
18
19
|
# File 'lib/app/helpers/form_elements/image_field.rb', line 17
def image_field_edit(object, attribute)
file_field_tag attribute, :class => 'input_text_field'
end
|
#image_field_show(object, attribute) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/app/helpers/form_elements/image_field.rb', line 4
def image_field_show(object, attribute)
o = object.send(attribute)
msg = o.to_s
if o.send(:present?)
if o.respond_to? :palm
msg = image_tag(o.send(:palm).send(:url))
else
msg = image_tag(o.send(:url))
end
end
link_to_inline_edit object, attribute, msg
end
|
#image_field_update(object, attribute) ⇒ Object
21
22
23
|
# File 'lib/app/helpers/form_elements/image_field.rb', line 21
def image_field_update(object, attribute)
object.send(attribute.to_s + '=', params[attribute.to_sym])
end
|
#info_edit(object, attribute) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/app/helpers/form_elements/info.rb', line 12
def info_edit(object, attribute)
o = object.send(attribute)
o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time)
o = o._presentation if o.respond_to?(:_presentation)
o
end
|
#info_show(object, attribute) ⇒ Object
4
5
6
7
8
9
10
|
# File 'lib/app/helpers/form_elements/info.rb', line 4
def info_show(object, attribute)
o = object.send(attribute)
o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time)
o = o._presentation if o.respond_to?(:_presentation)
o
end
|
#info_update(object, attribute, ) ⇒ Object
19
20
21
|
# File 'lib/app/helpers/form_elements/info.rb', line 19
def info_update(object, attribute)
end
|
#money_field_edit(object, attribute) ⇒ Object
8
9
10
|
# File 'lib/app/helpers/form_elements/money_field.rb', line 8
def money_field_edit(object, attribute)
text_field_tag attribute, (object.send attribute), :class => 'input_money_field'
end
|
#money_field_show(object, attribute) ⇒ Object
4
5
6
|
# File 'lib/app/helpers/form_elements/money_field.rb', line 4
def money_field_show(object, attribute)
link_to_inline_edit object, attribute, humanized_money_with_symbol(object.send attribute)
end
|
#money_field_update(object, attribute) ⇒ Object
12
13
14
|
# File 'lib/app/helpers/form_elements/money_field.rb', line 12
def money_field_update(object, attribute)
object.send( "#{attribute}=", params[attribute])
end
|
#pdf_link_edit(object, attribute) ⇒ Object
9
10
11
12
13
14
|
# File 'lib/app/helpers/form_elements/pdf_link.rb', line 9
def pdf_link_edit(object, attribute)
o = object.send(attribute)
o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time)
o = o._presentation if o.respond_to?(:_presentation)
o
end
|
#pdf_link_show(object, attribute) ⇒ Object
4
5
6
7
|
# File 'lib/app/helpers/form_elements/pdf_link.rb', line 4
def pdf_link_show(object, attribute)
"#{link_to 'preview', "/#{attribute}/#{object.id}", :class => "pdf_preview"} #{link_to 'pdf', "/#{attribute}/#{object.id}.pdf", :class => "pdf_open"}".html_safe
end
|
#pdf_link_update(object, attribute) ⇒ Object
16
17
18
|
# File 'lib/app/helpers/form_elements/pdf_link.rb', line 16
def pdf_link_update(object, attribute)
end
|
#plain_text_area_edit(object, attribute) ⇒ Object
8
9
10
|
# File 'lib/app/helpers/form_elements/plain_text_area.rb', line 8
def plain_text_area_edit(object, attribute)
text_area_tag attribute, object[attribute], :class => 'attribute_text_area'
end
|
#plain_text_area_show(object, attribute) ⇒ Object
4
5
6
|
# File 'lib/app/helpers/form_elements/plain_text_area.rb', line 4
def plain_text_area_show(object, attribute)
link_to_inline_edit object, attribute, object[attribute]
end
|
#plain_text_area_update(object, attribute) ⇒ Object
12
13
14
|
# File 'lib/app/helpers/form_elements/plain_text_area.rb', line 12
def plain_text_area_update(object, attribute)
object[attribute.to_sym] = params[attribute.to_sym]
end
|
#question_list_edit(object, attribute) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/app/helpers/form_elements/question_list.rb', line 17
def question_list_edit(object, attribute)
object.send(attribute).build if object.send(attribute).empty?
values = object.send(attribute).first.class.name.constantize.find(:all)
out = '<div class="edit_form_checklist">'
out << '<ul>'
Question.all.each do | question |
out << '<li>'
out << h(question._presentation)
unless question.subquestions.empty?
out << '<ul>'
question.subquestions.each do | subquestion |
out << '<li>'
out << h(subquestion._presentation)
out << '</li>'
end
out << '</ul>'
end
out << '</li>'
end
out << '</ul>'
out << '</div>'
out.html_safe
end
|
#question_list_show(object, attribute) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/app/helpers/form_elements/question_list.rb', line 5
def question_list_show(object, attribute)
out = '<ul class="question_list">'
out << link_to_inline_edit(object, attribute) if object.send(attribute).empty?
object.send(attribute).sort.each do | item |
out << '<li>'
out << link_to_inline_edit(object, attribute, item._presentation )
out << '</li>'
end
out << '</ul>'
out.html_safe
end
|
#question_list_update(object, attribute) ⇒ Object
41
42
43
44
|
# File 'lib/app/helpers/form_elements/question_list.rb', line 41
def question_list_update(object, attribute)
params[attribute] ||= {}
object.send(attribute.singularize + '_ids=', params[attribute].keys)
end
|
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/app/helpers/form_elements/radio_button.rb', line 12
def radio_button_edit(object, attribute)
out ='<ul class="radio_list">'
values = attribute_values(object, attribute)
values.each do |key,value|
out << '<li>'
out << radio_button_tag(attribute.to_s, key, key == object.send(attribute))
out << value
out << '</li>'
end
out << '</ul>'
raw out
end
|
[ :sex , “gender”, :radio_button, { 1 => ‘male’, 2 => ‘female’ } ],
7
8
9
10
|
# File 'lib/app/helpers/form_elements/radio_button.rb', line 7
def radio_button_show(object, attribute)
values = attribute_values(object, attribute)
link_to_inline_edit object, attribute, object.send(attribute) ? values.assoc(object.send(attribute))[1] : ""
end
|
25
26
27
|
# File 'lib/app/helpers/form_elements/radio_button.rb', line 25
def radio_button_update(object, attribute)
object[attribute.to_s.to_sym] = params[attribute.to_s.to_sym]
end
|
#scale_with_integers_edit(object, attribute) ⇒ Object
14
15
16
17
18
|
# File 'lib/app/helpers/form_elements/scale_with_integers.rb', line 14
def scale_with_integers_edit(object, attribute)
values = attribute_values(object, attribute)
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute))
end
|
#scale_with_integers_show(object, attribute) ⇒ Object
scale_with_integers generates a scale with the given list of integers as options
values must be a Range or a one-dimensional array of Integers
9
10
11
12
|
# File 'lib/app/helpers/form_elements/scale_with_integers.rb', line 9
def scale_with_integers_show(object, attribute)
values = attribute_values(object, attribute)
link_to_inline_edit object, attribute, values[object.send(attribute).to_s]
end
|
#scale_with_integers_update(object, attribute) ⇒ Object
20
21
22
|
# File 'lib/app/helpers/form_elements/scale_with_integers.rb', line 20
def scale_with_integers_update(object, attribute)
object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
end
|
#scale_with_values_edit(object, attribute) ⇒ Object
13
14
15
16
17
|
# File 'lib/app/helpers/form_elements/scale_with_values.rb', line 13
def scale_with_values_edit(object, attribute)
values = attribute_values(object, attribute)
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute))
end
|
#scale_with_values_show(object, attribute) ⇒ Object
scale_with_values generates a scale with the given list of values as options
values must be a hash { integer => string, … } or an one-dimensional array of strings
8
9
10
11
|
# File 'lib/app/helpers/form_elements/scale_with_values.rb', line 8
def scale_with_values_show(object, attribute)
values = attribute_values(object, attribute)
link_to_inline_edit object, attribute, values[object.send(attribute)][1]
end
|
#scale_with_values_update(object, attribute) ⇒ Object
19
20
21
|
# File 'lib/app/helpers/form_elements/scale_with_values.rb', line 19
def scale_with_values_update(object, attribute)
object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
end
|
#slider_with_values_edit(object, attribute) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/app/helpers/form_elements/slider_with_values.rb', line 37
def slider_with_values_edit(object, attribute)
values = attribute_values(object, attribute)
value = object.send(attribute).to_i
css_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}"
display_value = values.assoc(value)[1]
out = "".html_safe
out << "<div class='slider slider_#{attribute.to_s}' id='slider_#{css_id}'></div>".html_safe
out << "<div class='slider_value' id='value_#{css_id}'>#{display_value}</div>".html_safe
out << "<div style='clear: both' />".html_safe
out << "<input type='hidden' name='_#{object.class.to_s.underscore}[#{attribute}]' value='0' id='input_#{css_id}' />".html_safe
out << ('<script>
$(function() {
var displayvalues = ' + values.collect {|x| x[1]}.inspect + ';
$( "#slider_' + css_id + '" ).slider(
{
value:' + value.to_s + ',
range: "min",
min: 0,
max: 5,
step: 1,
slide: function( event, ui ) {
$( "#input_' + css_id + '" ).val( ui.value );
$( "#value_' + css_id + '" ).html( displayvalues[ui.value] );
}
}
);').html_safe
out << ('$( "#value_' + css_id + '" ).html(displayvalues[' + value.to_s + ']);').html_safe
out << ('$( "#input_' + css_id + '" ).val(' + value.to_s + ');').html_safe
out << ('});
</script>').html_safe
out
end
|
#slider_with_values_show(object, attribute) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/app/helpers/form_elements/slider_with_values.rb', line 5
def slider_with_values_show(object, attribute)
values = attribute_values(object, attribute)
value = object.send(attribute).to_i
display_value = values.assoc(value)[1]
css_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}"
if value == 0
out = "?"
else
out = "".html_safe
out << "<div class='slider slider_#{attribute.to_s}' id='slider_#{css_id}'></div>".html_safe
out << "<div class='slider_value' id='value_#{css_id}'>#{display_value}</div>".html_safe
out << "<div style='clear: both' />".html_safe
out << "<input type='hidden' name='_#{object.class.to_s.underscore}[#{attribute}]' value='0' id='input_#{css_id}' />".html_safe
out << ('<script>
$(function() {
var displayvalues = ' + values.collect {|x| x[1]}.inspect + ';
$( "#slider_' + css_id + '" ).slider(
{
value:' + value.to_s + ',
range: "min",
disabled: true,
min: 0,
max: 5,
step: 1,
}
);
});
</script>').html_safe
end
link_to_inline_edit object, attribute, out
end
|
#slider_with_values_update(object, attribute) ⇒ Object
71
72
73
|
# File 'lib/app/helpers/form_elements/slider_with_values.rb', line 71
def slider_with_values_update(object, attribute)
object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
end
|
#text_area_edit(object, attribute) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/app/helpers/form_elements/text_area.rb', line 29
def text_area_edit(object, attribute)
if defined? Ckeditor
cktext_area_tag(
attribute,
object[attribute],
:input_html => { :id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}",
:width => '100%'},
:height => '200px'
)
else
text_area_tag attribute, object[attribute], :class => 'attribute_text_area'
end
end
|
#text_area_show(object, attribute) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/app/helpers/form_elements/text_area.rb', line 4
def text_area_show(object, attribute)
if defined? Ckeditor
link_to_inline_edit object,
attribute,
'<div class="ckeditor_area">'.html_safe +
cktext_area_tag(
attribute,
object[attribute],
:input_html => { :id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}",
:width => '100%' },
:height => '200px',
:toolbar => "None",
:readOnly => "true",
:resize_enabled => "false",
:toolbarCanCollapse => "false"
) +
image_tag( 'glass_plate.gif',
:class => "glass_plate",
:title => '' ) +
'</div>'.html_safe
else
link_to_inline_edit object, attribute, object[attribute]
end
end
|
#text_area_update(object, attribute) ⇒ Object
43
44
45
|
# File 'lib/app/helpers/form_elements/text_area.rb', line 43
def text_area_update(object, attribute)
object[attribute.to_sym] = params[attribute.to_sym]
end
|
#text_area_without_ckeditor_edit(object, attribute) ⇒ Object
8
9
10
|
# File 'lib/app/helpers/form_elements/text_area_without_ckeditor.rb', line 8
def text_area_without_ckeditor_edit(object, attribute)
text_area_tag attribute, object[attribute], :class => 'attribute_text_area'
end
|
#text_area_without_ckeditor_show(object, attribute) ⇒ Object
4
5
6
|
# File 'lib/app/helpers/form_elements/text_area_without_ckeditor.rb', line 4
def text_area_without_ckeditor_show(object, attribute)
link_to_inline_edit object, attribute, object[attribute]
end
|
#text_area_without_ckeditor_update(object, attribute) ⇒ Object
12
13
14
|
# File 'lib/app/helpers/form_elements/text_area_without_ckeditor.rb', line 12
def text_area_without_ckeditor_update(object, attribute)
object[attribute.to_sym] = params[attribute.to_sym]
end
|
#text_field_edit(object, attribute) ⇒ Object
8
9
10
|
# File 'lib/app/helpers/form_elements/text_field.rb', line 8
def text_field_edit(object, attribute)
text_field_tag attribute, (object.send attribute.to_sym), :class => 'input_text_field'
end
|
#text_field_show(object, attribute) ⇒ Object
4
5
6
|
# File 'lib/app/helpers/form_elements/text_field.rb', line 4
def text_field_show(object, attribute)
link_to_inline_edit object, attribute, (object.send attribute.to_sym)
end
|
#text_field_update(object, attribute) ⇒ Object
12
13
14
|
# File 'lib/app/helpers/form_elements/text_field.rb', line 12
def text_field_update(object, attribute)
object.send :write_attribute, attribute.to_sym, params[attribute.to_sym]
end
|