inline_forms 7.10.2 → 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.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +81 -0
  4. data/Rakefile +18 -1
  5. data/app/controllers/inline_forms_controller.rb +21 -0
  6. data/app/helpers/inline_forms_helper.rb +1 -6
  7. data/app/views/inline_forms/_versions_list.html.erb +16 -5
  8. data/archived/form_elements/README.md +1 -7
  9. data/docs/prompt/test-the-example-app.md +3 -3
  10. data/inline_forms.gemspec +7 -22
  11. data/lib/generators/inline_forms_generator.rb +1 -1
  12. data/lib/inline_forms/form_element_registry.rb +46 -0
  13. data/lib/inline_forms/form_elements/audio_field_helper.rb +36 -0
  14. data/lib/inline_forms/form_elements/check_box_helper.rb +23 -0
  15. data/lib/inline_forms/form_elements/check_list_helper.rb +45 -0
  16. data/lib/inline_forms/form_elements/ckeditor_helper.rb +23 -0
  17. data/lib/inline_forms/form_elements/date_helper.rb +28 -0
  18. data/lib/inline_forms/form_elements/decimal_field_helper.rb +22 -0
  19. data/lib/inline_forms/form_elements/devise_password_field_helper.rb +26 -0
  20. data/lib/inline_forms/form_elements/dns_records_helper.rb +23 -0
  21. data/lib/inline_forms/form_elements/dropdown_helper.rb +58 -0
  22. data/lib/inline_forms/form_elements/dropdown_with_integers_helper.rb +29 -0
  23. data/lib/inline_forms/form_elements/dropdown_with_other_helper.rb +160 -0
  24. data/lib/inline_forms/form_elements/dropdown_with_values_helper.rb +40 -0
  25. data/lib/inline_forms/form_elements/dropdown_with_values_with_stars_helper.rb +24 -0
  26. data/lib/inline_forms/form_elements/file_field_helper.rb +27 -0
  27. data/lib/inline_forms/form_elements/header_helper.rb +24 -0
  28. data/lib/inline_forms/form_elements/helper_includes.rb +15 -0
  29. data/lib/inline_forms/form_elements/image_field_helper.rb +31 -0
  30. data/lib/inline_forms/form_elements/info_helper.rb +52 -0
  31. data/lib/inline_forms/form_elements/info_list_helper.rb +30 -0
  32. data/lib/inline_forms/form_elements/integer_field_helper.rb +22 -0
  33. data/lib/inline_forms/form_elements/money_field_helper.rb +22 -0
  34. data/lib/inline_forms/form_elements/month_select_helper.rb +24 -0
  35. data/lib/inline_forms/form_elements/month_year_picker_helper.rb +27 -0
  36. data/lib/inline_forms/form_elements/multi_image_field_helper.rb +31 -0
  37. data/lib/inline_forms/form_elements/pdf_link_helper.rb +41 -0
  38. data/lib/inline_forms/form_elements/plain_text_area_helper.rb +26 -0
  39. data/lib/inline_forms/form_elements/plain_text_helper.rb +31 -0
  40. data/lib/inline_forms/form_elements/question_list_helper.rb +52 -0
  41. data/lib/inline_forms/form_elements/radio_button_helper.rb +34 -0
  42. data/lib/inline_forms/form_elements/rich_text_helper.rb +44 -0
  43. data/lib/inline_forms/form_elements/scale_with_integers_helper.rb +30 -0
  44. data/lib/inline_forms/form_elements/scale_with_values_helper.rb +29 -0
  45. data/lib/inline_forms/form_elements/simple_file_field_helper.rb +36 -0
  46. data/lib/inline_forms/form_elements/slider_with_values_helper.rb +99 -0
  47. data/lib/inline_forms/form_elements/text_area_helper.rb +26 -0
  48. data/lib/inline_forms/form_elements/text_area_without_ckeditor_helper.rb +27 -0
  49. data/lib/inline_forms/form_elements/text_field_helper.rb +26 -0
  50. data/lib/inline_forms/form_elements/time_helper.rb +28 -0
  51. data/lib/inline_forms/form_elements.rb +27 -0
  52. data/lib/inline_forms/gem_files.rb +39 -0
  53. data/lib/inline_forms/version.rb +1 -1
  54. data/lib/inline_forms.rb +19 -3
  55. data/script/migrate_form_elements.rb +62 -0
  56. metadata +61 -123
  57. data/app/helpers/form_elements/audio_field.rb +0 -28
  58. data/app/helpers/form_elements/check_box.rb +0 -16
  59. data/app/helpers/form_elements/check_list.rb +0 -37
  60. data/app/helpers/form_elements/ckeditor.rb +0 -15
  61. data/app/helpers/form_elements/date.rb +0 -20
  62. data/app/helpers/form_elements/decimal_field.rb +0 -15
  63. data/app/helpers/form_elements/devise_password_field.rb +0 -19
  64. data/app/helpers/form_elements/dns_records.rb +0 -15
  65. data/app/helpers/form_elements/dropdown.rb +0 -50
  66. data/app/helpers/form_elements/dropdown_with_integers.rb +0 -21
  67. data/app/helpers/form_elements/dropdown_with_other.rb +0 -153
  68. data/app/helpers/form_elements/dropdown_with_values.rb +0 -32
  69. data/app/helpers/form_elements/dropdown_with_values_with_stars.rb +0 -16
  70. data/app/helpers/form_elements/file_field.rb +0 -20
  71. data/app/helpers/form_elements/header.rb +0 -17
  72. data/app/helpers/form_elements/image_field.rb +0 -24
  73. data/app/helpers/form_elements/info.rb +0 -44
  74. data/app/helpers/form_elements/info_list.rb +0 -22
  75. data/app/helpers/form_elements/integer_field.rb +0 -15
  76. data/app/helpers/form_elements/money_field.rb +0 -15
  77. data/app/helpers/form_elements/month_select.rb +0 -16
  78. data/app/helpers/form_elements/month_year_picker.rb +0 -19
  79. data/app/helpers/form_elements/multi_image_field.rb +0 -24
  80. data/app/helpers/form_elements/pdf_link.rb +0 -33
  81. data/app/helpers/form_elements/plain_text.rb +0 -23
  82. data/app/helpers/form_elements/plain_text_area.rb +0 -18
  83. data/app/helpers/form_elements/question_list.rb +0 -44
  84. data/app/helpers/form_elements/radio_button.rb +0 -27
  85. data/app/helpers/form_elements/rich_text.rb +0 -36
  86. data/app/helpers/form_elements/scale_with_integers.rb +0 -23
  87. data/app/helpers/form_elements/scale_with_values.rb +0 -22
  88. data/app/helpers/form_elements/simple_file_field.rb +0 -28
  89. data/app/helpers/form_elements/slider_with_values.rb +0 -91
  90. data/app/helpers/form_elements/text_area.rb +0 -18
  91. data/app/helpers/form_elements/text_area_without_ckeditor.rb +0 -19
  92. data/app/helpers/form_elements/text_field.rb +0 -18
  93. data/app/helpers/form_elements/time.rb +0 -21
  94. data/bin/inline_forms +0 -141
  95. data/bin/inline_forms_app_template.rb +0 -22
  96. data/bin/inline_forms_installer_core.rb +0 -886
  97. data/lib/generators/templates/capistrano/Capfile +0 -39
  98. data/lib/generators/templates/capistrano/deploy.rb +0 -59
  99. data/lib/generators/templates/capistrano/production.rb +0 -7
  100. data/lib/generators/templates/unicorn/production.rb +0 -39
  101. data/lib/installer_templates/dartsass/devise_main.scss +0 -2
  102. data/lib/installer_templates/dartsass/inline_forms_dartsass_builds.rb +0 -14
  103. data/lib/installer_templates/dartsass/inline_forms_main.scss +0 -2
  104. data/lib/installer_templates/example_app_tests/test/example_app/example_integration_test_case.rb +0 -36
  105. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_field_turbo_test.rb +0 -73
  106. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_name_list_test.rb +0 -73
  107. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_name_required_test.rb +0 -21
  108. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_opening_date_test.rb +0 -49
  109. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_photos_pagination_test.rb +0 -440
  110. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_row_turbo_test.rb +0 -103
  111. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_top_level_new_test.rb +0 -70
  112. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_top_level_pagination_test.rb +0 -40
  113. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_versions_turbo_test.rb +0 -120
  114. data/lib/installer_templates/example_app_tests/test/integration/example_app_guest_access_test.rb +0 -21
  115. data/lib/installer_templates/example_app_tests/test/integration/example_app_photo_revert_test.rb +0 -94
  116. data/lib/installer_templates/example_app_tests/test/integration/example_app_photos_test.rb +0 -22
  117. data/lib/installer_templates/example_app_tests/test/integration/example_app_routing_test.rb +0 -15
  118. data/lib/installer_templates/example_app_tests/test/integration/example_app_turbo_layout_test.rb +0 -25
  119. data/lib/installer_templates/example_app_tests/test/integration/example_app_validation_hints_test.rb +0 -40
  120. data/lib/installer_templates/example_app_tests/test/models/example_app_apartment_name_validation_test.rb +0 -16
  121. data/lib/installer_templates/example_app_tests/test/models/example_app_apartment_photo_test.rb +0 -26
  122. data/lib/installer_templates/example_app_tests/test/models/example_app_paper_trail_changeset_test.rb +0 -78
  123. data/lib/installer_templates/example_app_tests/test/models/example_app_plain_text_rich_text_edge_cases_test.rb +0 -46
  124. data/lib/installer_templates/example_app_views/apartments/name_list.html.erb +0 -26
  125. data/lib/installer_templates/example_app_views/inline_forms/_header.html.erb +0 -45
@@ -1,153 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- InlineForms::SPECIAL_COLUMN_TYPES[:dropdown_with_other]=:belongs_to
3
-
4
- # dropdown
5
- def dropdown_with_other_show(object, attribute)
6
- attribute = attribute.to_s
7
- foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.foreign_key.to_sym
8
- id = object[foreign_key]
9
- if id == 0
10
- attribute_value = object[attribute + '_other']
11
- attribute_value = "<i class='fi-plus'></i>".html_safe if attribute_value.nil? || attribute_value.empty?
12
- else
13
- attribute_value = object.send(attribute)._presentation rescue "<i class='fi-plus'></i>".html_safe
14
- end
15
- link_to_inline_edit object, attribute, attribute_value, from_callee: __callee__
16
- end
17
-
18
- def dropdown_with_other_edit(object, attribute)
19
- attribute = attribute.to_s
20
- foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.foreign_key.to_sym
21
- o = attribute.camelcase.constantize
22
- values = o.all
23
- values = o.accessible_by(current_ability) if cancan_enabled?
24
- values.each do |v|
25
- v.name = v._presentation
26
- end
27
- # values.sort_by(&:name)
28
-
29
- collection = values.map {|v|[v.name, v.id]}
30
- collection << [object[attribute + '_other'], 0] unless object[attribute + '_other'].nil? || object[attribute + '_other'].empty?
31
- out = '<div class="ui-widget">'
32
- out << select('_' + object.class.to_s.underscore, foreign_key.to_sym, collection, {selected: object[foreign_key.to_sym]}, {id: '_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + foreign_key.to_s})
33
- out << '</div>
34
- <script>
35
- (function( $ ) {
36
- $.widget( "custom.combobox", {
37
- _create: function() {
38
- this.wrapper = $( "<span>" )
39
- .addClass( "custom-combobox" )
40
- .insertAfter( this.element );
41
-
42
- this.element.hide();
43
- this._createAutocomplete();
44
- this._createShowAllButton();
45
- },
46
-
47
- _createAutocomplete: function() {
48
- var selected = this.element.children( ":selected" ),
49
- value = selected.val() ? selected.text() : "";
50
-
51
- this.input = $( "<input name=\''
52
-
53
- out << '_' + object.class.to_s.underscore + '[' + attribute + '_other]'
54
-
55
- out << '\'>" )
56
- .appendTo( this.wrapper )
57
- .val( value )
58
- .attr( "title", "" )
59
- .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
60
- .autocomplete({
61
- delay: 0,
62
- minLength: 0,
63
- source: $.proxy( this, "_source" )
64
- })
65
- .tooltip({
66
- tooltipClass: "ui-state-highlight"
67
- });
68
-
69
- this._on( this.input, {
70
- autocompleteselect: function( event, ui ) {
71
- ui.item.option.selected = true;
72
- this._trigger( "select", event, {
73
- item: ui.item.option
74
- });
75
- }
76
- });
77
- },
78
-
79
- _createShowAllButton: function() {
80
- var input = this.input,
81
- wasOpen = false;
82
-
83
- $( "<a>" )
84
- .attr( "tabIndex", -1 )
85
- .attr( "title", "Show All Items" )
86
- .tooltip()
87
- .appendTo( this.wrapper )
88
- .button({
89
- icons: {
90
- primary: "ui-icon-triangle-1-s"
91
- },
92
- text: false
93
- })
94
- .removeClass( "ui-corner-all" )
95
- .addClass( "custom-combobox-toggle ui-corner-right" )
96
- .mousedown(function() {
97
- wasOpen = input.autocomplete( "widget" ).is( ":visible" );
98
- })
99
- .click(function() {
100
- input.focus();
101
-
102
- // Close if already visible
103
- if ( wasOpen ) {
104
- return;
105
- }
106
-
107
- // Pass empty string as value to search for, displaying all results
108
- input.autocomplete( "search", "" );
109
- });
110
- },
111
-
112
- _source: function( request, response ) {
113
- var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
114
- response( this.element.children( "option" ).map(function() {
115
- var text = $( this ).text();
116
- if ( this.value && ( !request.term || matcher.test(text) ) )
117
- return {
118
- label: text,
119
- value: text,
120
- option: this
121
- };
122
- }) );
123
- },
124
- });
125
- })( jQuery );
126
-
127
- $(function() {
128
- $( "'
129
- out << '#_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + attribute.foreign_key.to_s
130
- out << '" ).combobox();
131
- });
132
- </script>'
133
- out.html_safe
134
-
135
-
136
- end
137
-
138
- def dropdown_with_other_update(object, attribute)
139
- attribute = attribute.to_s
140
- foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.foreign_key.to_sym
141
- # if there is an attribute attr, then there must be an attribute attr_other
142
- other = params[('_' + object.class.to_s.underscore).to_sym][(attribute + "_other").to_sym]
143
- # see if it matches anything (but we need to look at I18n too!
144
- lookup_model = attribute.camelcase.constantize
145
- name_field = 'name_' + I18n.locale.to_s
146
- name_field = 'name' unless lookup_model.new.respond_to? name_field
147
- puts 'XXXXXXXXXXXXXXXXXXXX ' + name_field.inspect
148
- match = lookup_model.where(name_field.to_sym => other).first # problem if there are dupes!
149
- puts 'XXXXXXXXXXXXXXXXXXXX ' + match.inspect
150
- match.nil? ? object[foreign_key] = 0 : object[foreign_key] = match.id # problem if there is a record with id: 0 !
151
- match.nil? ? object[attribute + '_other'] = other : object[attribute + '_other'] = nil
152
- end
153
-
@@ -1,32 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- InlineForms::SPECIAL_COLUMN_TYPES[:dropdown_with_values]=:integer
3
-
4
- # dropdown_with_values
5
- def dropdown_with_values_show(object, attribute)
6
- values = attribute_values(object, attribute)
7
- link_to_inline_edit object, attribute, object.send(attribute) ? t(values.assoc(object.send(attribute))[1]) : "<i class='fi-plus'></i>".html_safe, from_callee: __callee__
8
- end
9
-
10
- def dropdown_with_values_edit(object, attribute)
11
- # 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!
12
- values = attribute_values(object, attribute)
13
-
14
- attributes = @inline_forms_attribute_list || object.inline_forms_attribute_list
15
- options_disabled = attributes.assoc(attribute.to_sym)[4]
16
-
17
- collection_select( ('_' + object.class.to_s.underscore).to_sym,
18
- attribute.to_sym,
19
- values, 'first', 'last',
20
- :selected => object.send(attribute),
21
- disabled: options_disabled,
22
- )
23
- end
24
-
25
- def dropdown_with_values_update(object, attribute)
26
- object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
27
- end
28
-
29
- def dropdown_with_values_info(object, attribute)
30
- values = attribute_values(object, attribute)
31
- t(values.assoc(object.send(attribute))[1]) rescue '-'
32
- end
@@ -1,16 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- InlineForms::SPECIAL_COLUMN_TYPES[:dropdown_with_values_with_stars]=:integer
3
-
4
- # dropdown_with_values_with_stars
5
- def dropdown_with_values_with_stars_show(object, attribute)
6
- values = attribute_values(object, attribute)
7
- link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute] == 0) ? "<i class='fi-plus'></i>".html_safe : image_tag(object[attribute].to_s + 'stars.png'), from_callee: __callee__
8
- end
9
- def dropdown_with_values_with_stars_edit(object, attribute)
10
- # 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!
11
- values = attribute_values(object, attribute)
12
- collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute))
13
- end
14
- def dropdown_with_values_with_stars_update(object, attribute)
15
- object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
16
- end
@@ -1,20 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- InlineForms::SPECIAL_COLUMN_TYPES[:file_field]=:string
3
-
4
- def file_field_show(object, attribute)
5
- o = object.send(attribute)
6
- msg = o.to_s
7
- if o.send(:present?)
8
- msg = "replace | <a href='#{o.send(:url)}'>#{o.send(:path).gsub(/^.*\//,'')}</a>".html_safe
9
- end
10
- link_to_inline_edit object, attribute, msg, from_callee: __callee__
11
- end
12
-
13
- def file_field_edit(object, attribute)
14
- file_field_tag attribute, :class => 'input_text_field'
15
- end
16
-
17
- def file_field_update(object, attribute)
18
- object.send(attribute.to_s + '=', params[attribute.to_sym])
19
- end
20
-
@@ -1,17 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- # not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:header]=:string
3
-
4
- def header_show(object, attribute)
5
- # show the header which is the translated fake attribute
6
- attribute
7
- end
8
-
9
- def header_edit(object, attribute)
10
- # just show the header
11
- attribute
12
- end
13
-
14
- def header_update(object, attribute)
15
- # do absolutely nothing
16
- end
17
-
@@ -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
-