inline_forms 7.11.0 → 7.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +70 -0
- data/app/controllers/inline_forms_controller.rb +21 -0
- data/app/helpers/inline_forms_helper.rb +1 -6
- data/app/views/inline_forms/_versions_list.html.erb +16 -5
- data/archived/form_elements/README.md +1 -7
- data/inline_forms.gemspec +3 -3
- data/lib/generators/inline_forms_generator.rb +1 -1
- data/lib/inline_forms/form_element_registry.rb +46 -0
- data/lib/inline_forms/form_elements/audio_field_helper.rb +36 -0
- data/lib/inline_forms/form_elements/check_box_helper.rb +23 -0
- data/lib/inline_forms/form_elements/check_list_helper.rb +45 -0
- data/lib/inline_forms/form_elements/ckeditor_helper.rb +23 -0
- data/lib/inline_forms/form_elements/date_helper.rb +28 -0
- data/lib/inline_forms/form_elements/decimal_field_helper.rb +22 -0
- data/lib/inline_forms/form_elements/devise_password_field_helper.rb +26 -0
- data/lib/inline_forms/form_elements/dns_records_helper.rb +23 -0
- data/lib/inline_forms/form_elements/dropdown_helper.rb +58 -0
- data/lib/inline_forms/form_elements/dropdown_with_integers_helper.rb +29 -0
- data/lib/inline_forms/form_elements/dropdown_with_other_helper.rb +160 -0
- data/lib/inline_forms/form_elements/dropdown_with_values_helper.rb +40 -0
- data/lib/inline_forms/form_elements/dropdown_with_values_with_stars_helper.rb +24 -0
- data/lib/inline_forms/form_elements/file_field_helper.rb +27 -0
- data/lib/inline_forms/form_elements/header_helper.rb +24 -0
- data/lib/inline_forms/form_elements/helper_includes.rb +15 -0
- data/lib/inline_forms/form_elements/image_field_helper.rb +31 -0
- data/lib/inline_forms/form_elements/info_helper.rb +52 -0
- data/lib/inline_forms/form_elements/info_list_helper.rb +30 -0
- data/lib/inline_forms/form_elements/integer_field_helper.rb +22 -0
- data/lib/inline_forms/form_elements/money_field_helper.rb +22 -0
- data/lib/inline_forms/form_elements/month_select_helper.rb +24 -0
- data/lib/inline_forms/form_elements/month_year_picker_helper.rb +27 -0
- data/lib/inline_forms/form_elements/multi_image_field_helper.rb +31 -0
- data/lib/inline_forms/form_elements/pdf_link_helper.rb +41 -0
- data/lib/inline_forms/form_elements/plain_text_area_helper.rb +26 -0
- data/lib/inline_forms/form_elements/plain_text_helper.rb +31 -0
- data/lib/inline_forms/form_elements/question_list_helper.rb +52 -0
- data/lib/inline_forms/form_elements/radio_button_helper.rb +34 -0
- data/lib/inline_forms/form_elements/rich_text_helper.rb +44 -0
- data/lib/inline_forms/form_elements/scale_with_integers_helper.rb +30 -0
- data/lib/inline_forms/form_elements/scale_with_values_helper.rb +29 -0
- data/lib/inline_forms/form_elements/simple_file_field_helper.rb +36 -0
- data/lib/inline_forms/form_elements/slider_with_values_helper.rb +99 -0
- data/lib/inline_forms/form_elements/text_area_helper.rb +26 -0
- data/lib/inline_forms/form_elements/text_area_without_ckeditor_helper.rb +27 -0
- data/lib/inline_forms/form_elements/text_field_helper.rb +26 -0
- data/lib/inline_forms/form_elements/time_helper.rb +28 -0
- data/lib/inline_forms/form_elements.rb +27 -0
- data/lib/inline_forms/version.rb +1 -1
- data/lib/inline_forms.rb +19 -3
- data/script/migrate_form_elements.rb +62 -0
- metadata +52 -48
- data/app/helpers/form_elements/audio_field.rb +0 -28
- data/app/helpers/form_elements/check_box.rb +0 -16
- data/app/helpers/form_elements/check_list.rb +0 -37
- data/app/helpers/form_elements/ckeditor.rb +0 -15
- data/app/helpers/form_elements/date.rb +0 -20
- data/app/helpers/form_elements/decimal_field.rb +0 -15
- data/app/helpers/form_elements/devise_password_field.rb +0 -19
- data/app/helpers/form_elements/dns_records.rb +0 -15
- data/app/helpers/form_elements/dropdown.rb +0 -50
- data/app/helpers/form_elements/dropdown_with_integers.rb +0 -21
- data/app/helpers/form_elements/dropdown_with_other.rb +0 -153
- data/app/helpers/form_elements/dropdown_with_values.rb +0 -32
- data/app/helpers/form_elements/dropdown_with_values_with_stars.rb +0 -16
- data/app/helpers/form_elements/file_field.rb +0 -20
- data/app/helpers/form_elements/header.rb +0 -17
- data/app/helpers/form_elements/image_field.rb +0 -24
- data/app/helpers/form_elements/info.rb +0 -44
- data/app/helpers/form_elements/info_list.rb +0 -22
- data/app/helpers/form_elements/integer_field.rb +0 -15
- data/app/helpers/form_elements/money_field.rb +0 -15
- data/app/helpers/form_elements/month_select.rb +0 -16
- data/app/helpers/form_elements/month_year_picker.rb +0 -19
- data/app/helpers/form_elements/multi_image_field.rb +0 -24
- data/app/helpers/form_elements/pdf_link.rb +0 -33
- data/app/helpers/form_elements/plain_text.rb +0 -23
- data/app/helpers/form_elements/plain_text_area.rb +0 -18
- data/app/helpers/form_elements/question_list.rb +0 -44
- data/app/helpers/form_elements/radio_button.rb +0 -27
- data/app/helpers/form_elements/rich_text.rb +0 -36
- data/app/helpers/form_elements/scale_with_integers.rb +0 -23
- data/app/helpers/form_elements/scale_with_values.rb +0 -22
- data/app/helpers/form_elements/simple_file_field.rb +0 -28
- data/app/helpers/form_elements/slider_with_values.rb +0 -91
- data/app/helpers/form_elements/text_area.rb +0 -18
- data/app/helpers/form_elements/text_area_without_ckeditor.rb +0 -19
- data/app/helpers/form_elements/text_field.rb +0 -18
- data/app/helpers/form_elements/time.rb +0 -21
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:image_field]=:string
|
|
3
|
-
|
|
4
|
-
def image_field_show(object, attribute)
|
|
5
|
-
o = object.send(attribute)
|
|
6
|
-
msg = "<i class='fi-plus'></i>".html_safe
|
|
7
|
-
if o.send(:present?)
|
|
8
|
-
if o.respond_to? :palm
|
|
9
|
-
msg = image_tag(o.send(:palm).send(:url))
|
|
10
|
-
else
|
|
11
|
-
msg = image_tag(o.send(:url))
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
link_to_inline_edit object, attribute, msg, from_callee: __callee__
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def image_field_edit(object, attribute)
|
|
18
|
-
file_field_tag attribute, class: 'input_text_field'
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def image_field_update(object, attribute)
|
|
22
|
-
object.send(attribute.to_s + '=', params[attribute.to_sym])
|
|
23
|
-
end
|
|
24
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
# not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:info]=:string
|
|
3
|
-
|
|
4
|
-
def info_show(object, attribute)
|
|
5
|
-
# show the attribute. if it's a date/time, make it nicer. If it has a _presentation, show that instead
|
|
6
|
-
o = object.send(attribute)
|
|
7
|
-
o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time)
|
|
8
|
-
o = o._presentation if o.respond_to?(:_presentation)
|
|
9
|
-
o
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def info_edit(object, attribute)
|
|
13
|
-
o = object.send(attribute)
|
|
14
|
-
o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time)
|
|
15
|
-
o = o._presentation if o.respond_to?(:_presentation)
|
|
16
|
-
o
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def info_update(object, attribute)
|
|
20
|
-
# do absolutely nothing
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def info_info(object, attribute)
|
|
24
|
-
# show the attribute. if it's a date/time, make it nicer. If it has a _presentation, show that instead
|
|
25
|
-
o = object.send(attribute)
|
|
26
|
-
o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time)
|
|
27
|
-
o = o._presentation if o.respond_to?(:_presentation)
|
|
28
|
-
o
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
#module ActionView::Helpers::DateHelper
|
|
33
|
-
#
|
|
34
|
-
# def distance_of_time_in_words_to_now_with_future(from_time, include_seconds = false)
|
|
35
|
-
# if from_time > Time.now()
|
|
36
|
-
# 'in ' + distance_of_time_in_words_to_now_without_future(from_time, include_seconds)
|
|
37
|
-
# else
|
|
38
|
-
# distance_of_time_in_words_to_now_without_future(from_time, include_seconds) + ' ago'
|
|
39
|
-
# end
|
|
40
|
-
# end
|
|
41
|
-
#
|
|
42
|
-
# alias_method_chain :distance_of_time_in_words_to_now, :future
|
|
43
|
-
#
|
|
44
|
-
#end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
# not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:info]=:string
|
|
3
|
-
|
|
4
|
-
def info_list_show(object, attribute)
|
|
5
|
-
# we would expect
|
|
6
|
-
out = ''
|
|
7
|
-
out = "<div class='row #{cycle('odd', 'even')}'>--</div>" if object.send(attribute).empty?
|
|
8
|
-
object.send(attribute).sort.each do | item |
|
|
9
|
-
out << "<div class='row #{cycle('odd', 'even')}'>"
|
|
10
|
-
out << item._presentation
|
|
11
|
-
out << '</div>'
|
|
12
|
-
end
|
|
13
|
-
out.html_safe
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def info_list_edit(object, attribute)
|
|
17
|
-
# we should raise an error
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def info_list_update(object, attribute)
|
|
21
|
-
# we should raise an errror
|
|
22
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:integer_field]=:integer
|
|
3
|
-
|
|
4
|
-
def integer_field_show(object, attribute)
|
|
5
|
-
link_to_inline_edit object, attribute, object[attribute].nil? ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def integer_field_edit(object, attribute)
|
|
9
|
-
number_field_tag attribute, (object.send attribute.to_sym), :class => 'input_integer_field' # for abide: , :required => true
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def integer_field_update(object, attribute)
|
|
13
|
-
object.send :write_attribute, attribute.to_sym, params[attribute.to_sym]
|
|
14
|
-
end
|
|
15
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:money_field]=:integer
|
|
3
|
-
|
|
4
|
-
def money_field_show(object, attribute)
|
|
5
|
-
link_to_inline_edit object, attribute, humanized_money_with_symbol(object.send attribute), from_callee: __callee__
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def money_field_edit(object, attribute)
|
|
9
|
-
text_field_tag attribute, (object.send attribute), :class => 'input_money_field'
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def money_field_update(object, attribute)
|
|
13
|
-
object.send( "#{attribute}=", params[attribute])
|
|
14
|
-
end
|
|
15
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:month_select]=:integer
|
|
3
|
-
|
|
4
|
-
# date
|
|
5
|
-
def month_select_show(object, attribute)
|
|
6
|
-
link_to_inline_edit object, attribute, (1..12).include?(object[attribute]) ? I18n.localize(Date.new(1970,object[attribute],1), :format => '%B') : "<i class='fi-plus'></i>".html_safe, from_callee: __callee__
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def month_select_edit(object, attribute)
|
|
10
|
-
select_month( (1..12).include?(object[attribute]) ? Date.new(1970, object[attribute], 1) : Date.today, field_name: attribute )
|
|
11
|
-
# ( object.send(attribute).nil? ? "" : object.send(attribute).strftime("%d-%m-%Y") ), :id => css_id, :class =>'datepicker'
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def month_select_update(object, attribute)
|
|
15
|
-
object[attribute.to_sym] = params['date'][attribute] rescue 0
|
|
16
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:month_year_picker]=:date
|
|
3
|
-
|
|
4
|
-
# date
|
|
5
|
-
def month_year_picker_show(object, attribute)
|
|
6
|
-
link_to_inline_edit object, attribute, object.send(attribute).nil? ? "<i class='fi-plus'></i>".html_safe : object.send(attribute).strftime("%B %Y"), from_callee: __callee__
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def month_year_picker_edit(object, attribute)
|
|
10
|
-
css_id = 'datepicker_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + attribute.to_s
|
|
11
|
-
out = text_field_tag attribute, ( object.send(attribute).nil? ? "" : object.send(attribute).strftime("%B %Y") ), :id => css_id, :class =>'datepicker datepicker-month-year'
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def month_year_picker_update(object, attribute)
|
|
15
|
-
puts 'XXXXXXXXXXXXXXXXXXXXXXXXXX' + object[attribute.to_sym].inspect
|
|
16
|
-
puts 'XXXXXXXXXXXXXXXXXXXXXXXXXX' + Date.parse(params[attribute.to_sym].to_s).strftime("%F").to_s
|
|
17
|
-
object[attribute.to_sym] = Date.parse(params[attribute.to_sym].to_s).strftime("%F").to_s
|
|
18
|
-
puts 'XXXXXXXXXXXXXXXXXXXXXXXXXX' + object[attribute.to_sym].inspect
|
|
19
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:multi_image_field]=:string
|
|
3
|
-
|
|
4
|
-
def multi_image_field_show(object, attribute)
|
|
5
|
-
o = object.send(attribute)
|
|
6
|
-
msg = "<i class='fi-plus'></i>".html_safe
|
|
7
|
-
if o.send(:present?)
|
|
8
|
-
if o.respond_to? :palm
|
|
9
|
-
msg = image_tag(o.send(:palm).send(:url))
|
|
10
|
-
else
|
|
11
|
-
msg = image_tag(o.send(:url))
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
link_to_inline_edit object, attribute, msg, from_callee: __callee__
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def multi_image_field_edit(object, attribute)
|
|
18
|
-
file_field_tag attribute, multiple: true, class: 'input_text_field multi_image_field'
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def multi_image_field_update(object, attribute)
|
|
22
|
-
object.send(attribute.to_s + '=', params[attribute.to_sym])
|
|
23
|
-
end
|
|
24
|
-
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
# not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:info]=:string
|
|
3
|
-
|
|
4
|
-
def pdf_link_show(object, attribute)
|
|
5
|
-
# the attribute is the action
|
|
6
|
-
"#{link_to 'preview', "/#{attribute}/#{object.id}", :class => "pdf_preview"} #{link_to 'pdf', "/#{attribute}/#{object.id}.pdf", :class => "pdf_open"}".html_safe
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def pdf_link_edit(object, attribute)
|
|
10
|
-
o = object.send(attribute)
|
|
11
|
-
o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time)
|
|
12
|
-
o = o._presentation if o.respond_to?(:_presentation)
|
|
13
|
-
o
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def pdf_link_update(object, attribute)
|
|
17
|
-
# do absolutely nothing
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
#module ActionView::Helpers::DateHelper
|
|
21
|
-
#
|
|
22
|
-
# def distance_of_time_in_words_to_now_with_future(from_time, include_seconds = false)
|
|
23
|
-
# if from_time > Time.now()
|
|
24
|
-
# 'in ' + distance_of_time_in_words_to_now_without_future(from_time, include_seconds)
|
|
25
|
-
# else
|
|
26
|
-
# distance_of_time_in_words_to_now_without_future(from_time, include_seconds) + ' ago'
|
|
27
|
-
# end
|
|
28
|
-
# end
|
|
29
|
-
#
|
|
30
|
-
# alias_method_chain :distance_of_time_in_words_to_now, :future
|
|
31
|
-
#
|
|
32
|
-
#end
|
|
33
|
-
#
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:plain_text]=:text
|
|
3
|
-
|
|
4
|
-
def plain_text_show(object, attribute)
|
|
5
|
-
InlineForms.assert_plain_text_column!(object: object, attribute: attribute, form_element: :plain_text)
|
|
6
|
-
value = object[attribute]
|
|
7
|
-
link_to_inline_edit object, attribute, (value.nil? || value.empty?) ? "<i class='fi-plus'></i>".html_safe : value, from_callee: __callee__
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def plain_text_edit(object, attribute)
|
|
11
|
-
InlineForms.assert_plain_text_column!(object: object, attribute: attribute, form_element: :plain_text)
|
|
12
|
-
text_area_tag attribute, object[attribute], :class => 'attribute_text_area'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def plain_text_update(object, attribute)
|
|
16
|
-
InlineForms.assert_plain_text_column!(object: object, attribute: attribute, form_element: :plain_text)
|
|
17
|
-
object[attribute.to_sym] = params[attribute.to_sym]
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def plain_text_info(object, attribute)
|
|
21
|
-
InlineForms.assert_plain_text_column!(object: object, attribute: attribute, form_element: :plain_text)
|
|
22
|
-
object[attribute]
|
|
23
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:plain_text_area]=:text
|
|
3
|
-
|
|
4
|
-
def plain_text_area_show(object, attribute)
|
|
5
|
-
plain_text_show(object, attribute)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def plain_text_area_edit(object, attribute)
|
|
9
|
-
plain_text_edit(object, attribute)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def plain_text_area_update(object, attribute)
|
|
13
|
-
plain_text_update(object, attribute)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def plain_text_area_info(object, attribute)
|
|
17
|
-
plain_text_info(object, attribute)
|
|
18
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
#InlineForms::SPECIAL_COLUMN_TYPES[:question_list]=:no_migration
|
|
3
|
-
|
|
4
|
-
# checklist
|
|
5
|
-
def question_list_show(object, attribute)
|
|
6
|
-
out = '<ul class="question_list">'
|
|
7
|
-
out << link_to_inline_edit(object, attribute, from_callee: __callee__) if object.send(attribute).empty?
|
|
8
|
-
object.send(attribute).sort.each do | item |
|
|
9
|
-
out << '<li>'
|
|
10
|
-
out << link_to_inline_edit(object, attribute, item._presentation, from_callee: __callee__ )
|
|
11
|
-
out << '</li>'
|
|
12
|
-
end
|
|
13
|
-
out << '</ul>'
|
|
14
|
-
out.html_safe
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def question_list_edit(object, attribute)
|
|
18
|
-
object.send(attribute).build if object.send(attribute).empty?
|
|
19
|
-
values = object.send(attribute).first.class.name.constantize.find(:all) # TODO bring order
|
|
20
|
-
out = '<div class="edit_form_checklist">'
|
|
21
|
-
out << '<ul>'
|
|
22
|
-
Question.all.each do | question |
|
|
23
|
-
out << '<li>'
|
|
24
|
-
out << h(question._presentation)
|
|
25
|
-
unless question.subquestions.empty?
|
|
26
|
-
out << '<ul>'
|
|
27
|
-
question.subquestions.each do | subquestion |
|
|
28
|
-
out << '<li>'
|
|
29
|
-
out << h(subquestion._presentation)
|
|
30
|
-
out << '</li>'
|
|
31
|
-
end
|
|
32
|
-
out << '</ul>'
|
|
33
|
-
end
|
|
34
|
-
out << '</li>'
|
|
35
|
-
end
|
|
36
|
-
out << '</ul>'
|
|
37
|
-
out << '</div>'
|
|
38
|
-
out.html_safe
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def question_list_update(object, attribute)
|
|
42
|
-
params[attribute] ||= {}
|
|
43
|
-
object.send(attribute.singularize + '_ids=', params[attribute].keys)
|
|
44
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:radio_button]=:integer
|
|
3
|
-
# radio buttons are integers in this version
|
|
4
|
-
# us like this:
|
|
5
|
-
# [ :sex , "gender", :radio_button, { 1 => 'male', 2 => 'female' } ],
|
|
6
|
-
|
|
7
|
-
def radio_button_show(object, attribute)
|
|
8
|
-
values = attribute_values(object, attribute)
|
|
9
|
-
link_to_inline_edit object, attribute, object.send(attribute) ? values.assoc(object.send(attribute))[1] : "", from_callee: __callee__
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def radio_button_edit(object, attribute)
|
|
13
|
-
out =''
|
|
14
|
-
values = attribute_values(object, attribute)
|
|
15
|
-
values.each do |key,value|
|
|
16
|
-
out << "<div class='row #{cycle('odd', 'even')}'>"
|
|
17
|
-
out << radio_button_tag(attribute.to_s, key, key == object.send(attribute))
|
|
18
|
-
out << "<label for=#{key}>#{value}</label>"
|
|
19
|
-
out << '</div>'
|
|
20
|
-
end
|
|
21
|
-
out.html_safe
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def radio_button_update(object, attribute)
|
|
25
|
-
object[attribute.to_s.to_sym] = params[attribute.to_s.to_sym]
|
|
26
|
-
end
|
|
27
|
-
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:rich_text]=:no_migration
|
|
3
|
-
|
|
4
|
-
def rich_text_show(object, attribute)
|
|
5
|
-
rich = object.respond_to?(attribute) ? object.public_send(attribute) : nil
|
|
6
|
-
is_blank =
|
|
7
|
-
rich.nil? ||
|
|
8
|
-
(rich.respond_to?(:blank?) && rich.blank?) ||
|
|
9
|
-
(rich.respond_to?(:to_plain_text) && rich.to_plain_text.to_s.strip.empty?)
|
|
10
|
-
display_value = is_blank ? "<i class='fi-plus'></i>".html_safe : rich.to_s.html_safe
|
|
11
|
-
link_to_inline_edit object, attribute, display_value, from_callee: __callee__
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def rich_text_edit(object, attribute)
|
|
15
|
-
rich = object.respond_to?(attribute) ? object.public_send(attribute) : nil
|
|
16
|
-
body =
|
|
17
|
-
if rich.respond_to?(:body) && !rich.body.nil?
|
|
18
|
-
rich.body.to_s
|
|
19
|
-
elsif rich.respond_to?(:to_s)
|
|
20
|
-
rich.to_s
|
|
21
|
-
else
|
|
22
|
-
''
|
|
23
|
-
end
|
|
24
|
-
input_id = "trix_input_#{object.class.name.underscore}_#{object.id || 'new'}_#{attribute}"
|
|
25
|
-
hidden_field_tag(attribute, body, id: input_id) +
|
|
26
|
-
content_tag(:'trix-editor', ''.html_safe, input: input_id, class: 'trix-content attribute_rich_text_area')
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def rich_text_update(object, attribute)
|
|
30
|
-
object.public_send("#{attribute}=", params[attribute.to_sym])
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def rich_text_info(object, attribute)
|
|
34
|
-
value = object.respond_to?(attribute) ? object.public_send(attribute) : nil
|
|
35
|
-
value.to_s
|
|
36
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:scale_with_integers]=:integer
|
|
3
|
-
|
|
4
|
-
# scale_with_integers generates a scale
|
|
5
|
-
# with the given list of integers as options
|
|
6
|
-
#
|
|
7
|
-
# values must be a Range or a one-dimensional array of Integers
|
|
8
|
-
#
|
|
9
|
-
def scale_with_integers_show(object, attribute)
|
|
10
|
-
values = attribute_values(object, attribute)
|
|
11
|
-
link_to_inline_edit object, attribute, values[object.send(attribute).to_s], from_callee: __callee__
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def scale_with_integers_edit(object, attribute)
|
|
15
|
-
# the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
|
|
16
|
-
values = attribute_values(object, attribute)
|
|
17
|
-
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute))
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def scale_with_integers_update(object, attribute)
|
|
21
|
-
object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
|
|
22
|
-
end
|
|
23
|
-
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:scale_with_values]=:integer
|
|
3
|
-
|
|
4
|
-
# scale_with_values generates a scale
|
|
5
|
-
# with the given list of values as options
|
|
6
|
-
#
|
|
7
|
-
# values must be a hash { integer => string, ... } or an one-dimensional array of strings
|
|
8
|
-
def scale_with_values_show(object, attribute)
|
|
9
|
-
values = attribute_values(object, attribute)
|
|
10
|
-
link_to_inline_edit object, attribute, values[object.send(attribute)][1], from_callee: __callee__
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def scale_with_values_edit(object, attribute)
|
|
14
|
-
# the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
|
|
15
|
-
values = attribute_values(object, attribute)
|
|
16
|
-
collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute))
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def scale_with_values_update(object, attribute)
|
|
20
|
-
object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
|
|
21
|
-
end
|
|
22
|
-
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:simple_file_field]=:string
|
|
3
|
-
|
|
4
|
-
def simple_file_field_show(object, attribute)
|
|
5
|
-
o = object.send(attribute)
|
|
6
|
-
method = attribute_values(object, attribute)[0][1]
|
|
7
|
-
if o.send(:present?)
|
|
8
|
-
filename = o.to_s
|
|
9
|
-
model = object.class.to_s.pluralize.underscore
|
|
10
|
-
link_to filename, "/#{model}/#{method}/#{object.id}" # route must exist!!
|
|
11
|
-
else
|
|
12
|
-
link_to_inline_edit object, attribute, "<i class='fi-plus'></i>".html_safe, from_callee: __callee__
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def simple_file_field_edit(object, attribute)
|
|
17
|
-
file_field_tag attribute, :class => 'input_text_field'
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def simple_file_field_update(object, attribute)
|
|
21
|
-
object.send(attribute.to_s + '=', params[attribute.to_sym])
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# You need to add a route to your routes.rb file:
|
|
25
|
-
# get '/:model/dl/:id' => 'your_controller#download', :as => 'download'
|
|
26
|
-
# and a method to your controller:
|
|
27
|
-
# def download
|
|
28
|
-
# FIXME
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:slider_with_values]=:integer
|
|
3
|
-
|
|
4
|
-
# slider_with_values
|
|
5
|
-
def slider_with_values_show(object, attribute)
|
|
6
|
-
values = attribute_values(object, attribute)
|
|
7
|
-
value = object.send(attribute).to_i # should be an int
|
|
8
|
-
display_value = values.assoc(value)[1] # values should be [ [ 0, value ], [ 3, value2 ] .... ] and we lookup the key, not the place in the array!
|
|
9
|
-
css_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}"
|
|
10
|
-
if value == 0
|
|
11
|
-
out = "?" # we use this as the 'unknown' value. So in the data, 0 should always be the unknown value. This gives problems with sliders where the real value is 0.
|
|
12
|
-
else
|
|
13
|
-
out = "".html_safe
|
|
14
|
-
out << "<div class='slider slider_#{attribute.to_s}' id='slider_#{css_id}'></div>".html_safe
|
|
15
|
-
out << "<div class='slider_value' id='value_#{css_id}'>#{display_value}</div>".html_safe
|
|
16
|
-
out << "<div style='clear: both' />".html_safe
|
|
17
|
-
out << "<input type='hidden' name='_#{object.class.to_s.underscore}[#{attribute}]' value='0' id='input_#{css_id}' />".html_safe
|
|
18
|
-
out << ('<script>
|
|
19
|
-
$(function() {
|
|
20
|
-
var displayvalues = ' + values.collect {|x| x[1]}.inspect + ';
|
|
21
|
-
$( "#slider_' + css_id + '" ).slider(
|
|
22
|
-
{
|
|
23
|
-
value:' + value.to_s + ',
|
|
24
|
-
range: "min",
|
|
25
|
-
disabled: true,
|
|
26
|
-
min: 0,
|
|
27
|
-
max: ' + values.length.to_s + ',
|
|
28
|
-
step: 1,
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
</script>').html_safe
|
|
33
|
-
end
|
|
34
|
-
link_to_inline_edit object, attribute, out, from_callee: __callee__
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def slider_with_values_edit(object, attribute)
|
|
38
|
-
# the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
|
|
39
|
-
values = attribute_values(object, attribute)
|
|
40
|
-
value = object.send(attribute).to_i # should be an int, will be 0 if nil
|
|
41
|
-
css_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}"
|
|
42
|
-
display_value = values.assoc(value)[1] # values should be [ [ 0, value ], [ 3, value2 ] .... ] and we lookup the key, not the place in the array!
|
|
43
|
-
out = "".html_safe
|
|
44
|
-
out << "<div class='slider slider_#{attribute.to_s}' id='slider_#{css_id}'></div>".html_safe
|
|
45
|
-
out << "<div class='slider_value' id='value_#{css_id}'>#{display_value}</div>".html_safe
|
|
46
|
-
out << "<div style='clear: both' />".html_safe
|
|
47
|
-
out << "<input type='hidden' name='_#{object.class.to_s.underscore}[#{attribute}]' value='0' id='input_#{css_id}' />".html_safe
|
|
48
|
-
out << ('<script>
|
|
49
|
-
$(function() {
|
|
50
|
-
var displayvalues = ' + values.collect {|x| x[1]}.inspect + ';
|
|
51
|
-
$( "#slider_' + css_id + '" ).slider(
|
|
52
|
-
{
|
|
53
|
-
value:' + value.to_s + ',
|
|
54
|
-
range: "min",
|
|
55
|
-
min: 0,
|
|
56
|
-
max: 5,
|
|
57
|
-
step: 1,
|
|
58
|
-
slide: function( event, ui ) {
|
|
59
|
-
$( "#input_' + css_id + '" ).val( ui.value );
|
|
60
|
-
$( "#value_' + css_id + '" ).html( displayvalues[ui.value] );
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
);').html_safe
|
|
64
|
-
out << ('$( "#value_' + css_id + '" ).html(displayvalues[' + value.to_s + ']);').html_safe
|
|
65
|
-
out << ('$( "#input_' + css_id + '" ).val(' + value.to_s + ');').html_safe
|
|
66
|
-
out << ('});
|
|
67
|
-
</script>').html_safe
|
|
68
|
-
out
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def slider_with_values_update(object, attribute)
|
|
72
|
-
object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
#<style>
|
|
76
|
-
# #demo-frame > div.demo { padding: 10px !important; };
|
|
77
|
-
# </style>
|
|
78
|
-
#
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
#<div class="demo">
|
|
82
|
-
#
|
|
83
|
-
#<p>
|
|
84
|
-
# <label for="amount">Donation amount ($50 increments):</label>
|
|
85
|
-
# <input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />
|
|
86
|
-
#</p>
|
|
87
|
-
#
|
|
88
|
-
#<div id="slider"></div>
|
|
89
|
-
#
|
|
90
|
-
#</div><!-- End demo -->
|
|
91
|
-
#
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:text_area]=:text
|
|
3
|
-
|
|
4
|
-
def text_area_show(object, attribute)
|
|
5
|
-
rich_text_show(object, attribute)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def text_area_edit(object, attribute)
|
|
9
|
-
rich_text_edit(object, attribute)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def text_area_update(object, attribute)
|
|
13
|
-
rich_text_update(object, attribute)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def text_area_info(object, attribute)
|
|
17
|
-
rich_text_info(object, attribute)
|
|
18
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
# Legacy alias for plain :text_area (CKEditor removed).
|
|
3
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:text_area_without_ckeditor]=:text
|
|
4
|
-
|
|
5
|
-
def text_area_without_ckeditor_show(object, attribute)
|
|
6
|
-
plain_text_show(object, attribute)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def text_area_without_ckeditor_edit(object, attribute)
|
|
10
|
-
plain_text_edit(object, attribute)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def text_area_without_ckeditor_update(object, attribute)
|
|
14
|
-
plain_text_update(object, attribute)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def text_area_without_ckeditor_info(object, attribute)
|
|
18
|
-
plain_text_info(object, attribute)
|
|
19
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:text_field]=:string
|
|
3
|
-
|
|
4
|
-
def text_field_show(object, attribute, turbo_frame: false)
|
|
5
|
-
link_to_inline_edit object, attribute, object[attribute].blank? ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__, turbo_frame: turbo_frame
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def text_field_edit(object, attribute)
|
|
9
|
-
text_field_tag attribute, (object.send attribute.to_sym), :class => 'input_text_field' # for abide: , :required => true
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def text_field_update(object, attribute)
|
|
13
|
-
object.send :write_attribute, attribute.to_sym, params[attribute.to_sym]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def text_field_info(object, attribute)
|
|
17
|
-
object[attribute]
|
|
18
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
|
2
|
-
InlineForms::SPECIAL_COLUMN_TYPES[:time_select]=:time
|
|
3
|
-
|
|
4
|
-
# time
|
|
5
|
-
def time_select_show(object, attribute)
|
|
6
|
-
link_to_inline_edit object, attribute, object.send(attribute).nil? ? "<i class='fi-plus'></i>".html_safe : object.send(attribute).to_datetime.strftime("%l:%M%P"), from_callee: __callee__
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def time_select_edit(object, attribute)
|
|
10
|
-
css_id = 'timepicker_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + attribute.to_s
|
|
11
|
-
out = text_field_tag attribute, ( object.send(attribute).nil? ? "" : object.send(attribute).to_datetime.strftime("%l:%M%P") ), :id => css_id, :class =>'timepicker'
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def time_select_update(object, attribute)
|
|
15
|
-
object[attribute.to_sym] = params[attribute.to_sym]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def time_select_info(object, attribute)
|
|
19
|
-
object.send(attribute).nil? ? "-" : object.send(attribute).to_date
|
|
20
|
-
end
|
|
21
|
-
|