inline_forms 7.2.11 → 7.9.1

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +286 -0
  3. data/README.rdoc +14 -2
  4. data/app/assets/javascripts/inline_forms/inline_forms.js +26 -10
  5. data/app/assets/stylesheets/inline_forms/inline_forms.scss +33 -16
  6. data/app/controllers/concerns/versions_concern.rb +2 -3
  7. data/app/controllers/inline_forms_application_controller.rb +5 -1
  8. data/app/controllers/inline_forms_controller.rb +185 -34
  9. data/app/helpers/form_elements/ckeditor.rb +4 -30
  10. data/app/helpers/form_elements/plain_text.rb +23 -0
  11. data/app/helpers/form_elements/plain_text_area.rb +7 -3
  12. data/app/helpers/form_elements/text_area.rb +4 -44
  13. data/app/helpers/form_elements/text_area_without_ckeditor.rb +5 -4
  14. data/app/helpers/form_elements/text_field.rb +2 -2
  15. data/app/helpers/inline_forms_helper.rb +144 -74
  16. data/app/views/devise/sessions/_form.html.erb +4 -1
  17. data/app/views/inline_forms/_close.html.erb +9 -5
  18. data/app/views/inline_forms/_edit.html.erb +8 -41
  19. data/app/views/inline_forms/_list.html.erb +53 -55
  20. data/app/views/inline_forms/_new.html.erb +22 -12
  21. data/app/views/inline_forms/_show.html.erb +13 -37
  22. data/app/views/inline_forms/_versions.html.erb +5 -4
  23. data/app/views/inline_forms/_versions_list.html.erb +8 -12
  24. data/app/views/inline_forms/create_list_frame.html.erb +3 -0
  25. data/app/views/inline_forms/field_edit.html.erb +3 -0
  26. data/app/views/inline_forms/field_show.html.erb +3 -0
  27. data/app/views/inline_forms/new_record.html.erb +3 -0
  28. data/app/views/inline_forms/row_close.html.erb +13 -0
  29. data/app/views/inline_forms/row_destroyed.html.erb +9 -0
  30. data/app/views/inline_forms/row_show.html.erb +3 -0
  31. data/app/views/inline_forms/versions_list_panel.html.erb +3 -0
  32. data/app/views/inline_forms/versions_panel.html.erb +6 -0
  33. data/app/views/layouts/application.html.erb +2 -5
  34. data/app/views/layouts/inline_forms.html.erb +12 -6
  35. data/archived/README.md +47 -0
  36. data/archived/form_elements/README.md +27 -0
  37. data/archived/form_elements/chicas/README.md +31 -0
  38. data/archived/form_elements/geo_code_curacao/README.md +62 -0
  39. data/{app → archived/form_elements/geo_code_curacao/app}/helpers/form_elements/geo_code_curacao.rb +0 -1
  40. data/archived/form_elements/geo_code_curacao/app/views/geo_code_curacao/list_streets.html.erb +1 -0
  41. data/archived/form_elements/geo_code_curacao/app/views/geo_code_curacao/list_streets.js.erb +1 -0
  42. data/archived/form_elements/kansen_slider/README.md +31 -0
  43. data/archived/form_elements/tree/README.md +47 -0
  44. data/archived/form_elements/tree/app/views/inline_forms/_show_tree.html.erb +30 -0
  45. data/{app → archived/form_elements/tree/app}/views/inline_forms/_tree.html.erb +18 -5
  46. data/bin/inline_forms +22 -1
  47. data/bin/inline_forms_installer_core.rb +108 -8
  48. data/docs/ujs-to-turbo.md +192 -0
  49. data/lib/generators/USAGE +2 -2
  50. data/lib/generators/assets/stylesheets/inline_forms.scss +33 -16
  51. data/lib/inline_forms/archived_form_elements.rb +70 -0
  52. data/lib/inline_forms/version.rb +1 -1
  53. data/lib/inline_forms.rb +60 -2
  54. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_field_turbo_test.rb +73 -0
  55. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_name_list_test.rb +73 -0
  56. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_name_required_test.rb +21 -0
  57. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_photos_pagination_test.rb +227 -15
  58. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_row_turbo_test.rb +103 -0
  59. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_top_level_new_test.rb +70 -0
  60. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_top_level_pagination_test.rb +40 -0
  61. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_versions_turbo_test.rb +120 -0
  62. data/lib/installer_templates/example_app_tests/test/integration/example_app_photo_revert_test.rb +94 -0
  63. data/lib/installer_templates/example_app_tests/test/integration/example_app_turbo_layout_test.rb +6 -9
  64. data/lib/installer_templates/example_app_tests/test/models/example_app_apartment_name_validation_test.rb +16 -0
  65. data/lib/installer_templates/example_app_tests/test/models/example_app_plain_text_rich_text_edge_cases_test.rb +46 -0
  66. data/lib/installer_templates/example_app_views/apartments/name_list.html.erb +26 -0
  67. data/lib/installer_templates/example_app_views/inline_forms/_header.html.erb +45 -0
  68. data/test/archived_form_elements_test.rb +41 -0
  69. data/test/form_element_from_callee_test.rb +2 -2
  70. data/test/inline_forms_generator_test.rb +10 -0
  71. data/test/plain_text_configuration_test.rb +90 -0
  72. metadata +45 -24
  73. data/app/views/geo_code_curacao/list_streets.html.erb +0 -1
  74. data/app/views/geo_code_curacao/list_streets.js.erb +0 -1
  75. data/app/views/inline_forms/close.js.erb +0 -4
  76. data/app/views/inline_forms/edit.js.erb +0 -1
  77. data/app/views/inline_forms/list.js.erb +0 -1
  78. data/app/views/inline_forms/new.js.erb +0 -1
  79. data/app/views/inline_forms/record_destroyed.js.erb +0 -1
  80. data/app/views/inline_forms/show.js.erb +0 -1
  81. data/app/views/inline_forms/show_element.js.erb +0 -1
  82. data/app/views/inline_forms/show_undo.js.erb +0 -1
  83. data/app/views/inline_forms/update.js.erb +0 -1
  84. data/app/views/inline_forms/versions.js.erb +0 -4
  85. data/app/views/inline_forms/versions_list.js.erb +0 -1
  86. data/lib/generators/assets/javascripts/ckeditor/config.js +0 -72
  87. /data/{app → archived/form_elements/chicas/app}/helpers/form_elements/chicas_dropdown_with_family_members.rb +0 -0
  88. /data/{app → archived/form_elements/chicas/app}/helpers/form_elements/chicas_family_photo_list.rb +0 -0
  89. /data/{app → archived/form_elements/chicas/app}/helpers/form_elements/chicas_photo_list.rb +0 -0
  90. /data/{app → archived/form_elements/geo_code_curacao/app}/controllers/geo_code_curacao_controller.rb +0 -0
  91. /data/{app → archived/form_elements/geo_code_curacao/app}/models/geo_code_curacao.rb +0 -0
  92. /data/{app → archived/form_elements/kansen_slider/app}/helpers/form_elements/kansen_slider.rb +0 -0
  93. /data/{app → archived/form_elements/tree/app}/helpers/form_elements/move.rb +0 -0
@@ -44,7 +44,12 @@ class InlineFormsController < ApplicationController
44
44
  foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key
45
45
  conditions = [ "#{foreign_key} = ?", @parent_id ]
46
46
  end
47
- # if we are using cancan, then make sure to select only accessible records
47
+ # CanCan's load_and_authorize_resource sets @apartments (etc.); keep @objects in sync.
48
+ collection_ivar = :"@#{controller_name}"
49
+ if instance_variable_defined?(collection_ivar)
50
+ loaded = instance_variable_get(collection_ivar)
51
+ @objects = loaded unless loaded.nil?
52
+ end
48
53
  @objects ||= @Klass.accessible_by(current_ability) if cancan_enabled?
49
54
  @objects ||= @Klass
50
55
  @objects = @objects.order(@Klass.table_name + "." + @Klass.order_by_clause) if @Klass.respond_to?(:order_by_clause) && ! @Klass.order_by_clause.nil?
@@ -72,14 +77,21 @@ class InlineFormsController < ApplicationController
72
77
  if @Klass.not_accessible_through_html?
73
78
  format.html do
74
79
  if @parent_class.present?
75
- frame_layout = turbo_frame_request? ? "turbo_rails/frame" : "inline_forms"
76
- render "inline_forms/_list", layout: frame_layout
80
+ render_nested_associated_list_html
77
81
  end
78
82
  end
79
83
  else
80
- format.html { render 'inline_forms/_list', :layout => 'inline_forms' }
84
+ format.html do
85
+ if @parent_class.present?
86
+ render_nested_associated_list_html
87
+ elsif turbo_frame_request? && list_frame_id?(params[:update])
88
+ @ul_needed = true
89
+ render "inline_forms/_list", layout: "turbo_rails/frame"
90
+ else
91
+ render "inline_forms/_list", layout: "inline_forms"
92
+ end
93
+ end
81
94
  end
82
- format.js { render :list }
83
95
  end
84
96
  end
85
97
 
@@ -98,8 +110,7 @@ class InlineFormsController < ApplicationController
98
110
 
99
111
  @object.inline_forms_attribute_list = @inline_forms_attribute_list if @inline_forms_attribute_list
100
112
  respond_to do |format|
101
- format.html { render 'inline_forms/_new', :layout => 'inline_forms' } unless @Klass.not_accessible_through_html?
102
- format.js { }
113
+ format.html { render_turbo_new } if html_list_flow_allowed?
103
114
  end
104
115
  end
105
116
 
@@ -111,8 +122,7 @@ class InlineFormsController < ApplicationController
111
122
  @sub_id = params[:sub_id]
112
123
  @update_span = params[:update]
113
124
  respond_to do |format|
114
- format.html { } unless @Klass.not_accessible_through_html?
115
- format.js { }
125
+ format.html { render_turbo_field(:field_edit) }
116
126
  end
117
127
  end
118
128
 
@@ -123,7 +133,8 @@ class InlineFormsController < ApplicationController
123
133
  @update_span = params[:update]
124
134
  attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list
125
135
  attributes.each do | attribute, name, form_element |
126
- send("#{form_element.to_s}_update", @object, attribute) unless form_element == :tree || form_element == :associated || (cancan_enabled? && cannot?(:read, @object, attribute))
136
+ InlineForms.assert_plain_text_column!(object: @object, attribute: attribute, form_element: form_element)
137
+ send("#{form_element.to_s}_update", @object, attribute) unless form_element == :associated || (cancan_enabled? && cannot?(:read, @object, attribute))
127
138
  end
128
139
  @parent_class = params[:parent_class]
129
140
  @parent_id = params[:parent_id]
@@ -145,14 +156,14 @@ class InlineFormsController < ApplicationController
145
156
  @objects = @objects.where(conditions).paginate(:page => params[:page])
146
157
  @object = nil
147
158
  respond_to do |format|
148
- format.js { render :list}
159
+ format.html { render_list_frame_after_save } if html_list_flow_allowed?
149
160
  end
150
161
  else
151
162
  flash.now[:header] = ["Kan #{@object.class.to_s.underscore} niet aanmaken."]
152
163
  flash.now[:error] = @object.errors.to_a
153
164
  respond_to do |format|
154
165
  @object.inline_forms_attribute_list = attributes
155
- format.js { render :new}
166
+ format.html { render_turbo_new } if html_list_flow_allowed?
156
167
  end
157
168
  end
158
169
  end
@@ -164,11 +175,11 @@ class InlineFormsController < ApplicationController
164
175
  @form_element = params[:form_element]
165
176
  @sub_id = params[:sub_id]
166
177
  @update_span = params[:update]
178
+ InlineForms.assert_plain_text_column!(object: @object, attribute: @attribute, form_element: @form_element)
167
179
  send("#{@form_element.to_s}_update", @object, @attribute)
168
180
  @object.save
169
181
  respond_to do |format|
170
- format.html { } unless @Klass.not_accessible_through_html?
171
- format.js { }
182
+ format.html { render_turbo_field(:field_show, turbo_field_show: true) }
172
183
  end
173
184
  end
174
185
 
@@ -195,15 +206,14 @@ class InlineFormsController < ApplicationController
195
206
  respond_to do |format|
196
207
  @attributes = @object.inline_forms_attribute_list
197
208
  if close
198
- format.js { render :close }
209
+ format.html { render_row_turbo(:close) } if row_html_turbo_allowed?
199
210
  else
200
- format.js { }
211
+ format.html { render_row_turbo(:show) } if row_html_turbo_allowed?
201
212
  end
202
213
  end
203
214
  else
204
215
  respond_to do |format|
205
- format.html { } unless @Klass.not_accessible_through_html?
206
- format.js { render :show_element }
216
+ format.html { render_turbo_field(:field_show, turbo_field_show: true) }
207
217
  end
208
218
  end
209
219
  end
@@ -212,11 +222,9 @@ class InlineFormsController < ApplicationController
212
222
  def soft_delete
213
223
  @update_span = params[:update]
214
224
  @object = referenced_object
215
- # destroy the object
216
225
  @object.soft_delete(current_user)
217
226
  respond_to do |format|
218
- format.html { } unless @Klass.not_accessible_through_html?
219
- format.js { render :close }
227
+ format.html { render_row_turbo(:close) } if row_html_turbo_allowed?
220
228
  end
221
229
  end
222
230
 
@@ -224,11 +232,9 @@ class InlineFormsController < ApplicationController
224
232
  def soft_restore
225
233
  @update_span = params[:update]
226
234
  @object = referenced_object
227
- # restore the object
228
235
  @object.soft_restore
229
236
  respond_to do |format|
230
- format.html { } unless @Klass.not_accessible_through_html?
231
- format.js { render :close }
237
+ format.html { render_row_turbo(:close) } if row_html_turbo_allowed?
232
238
  end
233
239
  end
234
240
 
@@ -237,29 +243,46 @@ class InlineFormsController < ApplicationController
237
243
  @update_span = params[:update]
238
244
  @object = referenced_object
239
245
  if current_user.role? :superadmin
240
- # destroy the object
241
- @undo_object = @object.versions.last
246
+ @undo_version = @object.versions.last
242
247
  @object.destroy
243
248
  respond_to do |format|
244
- format.html { } unless @Klass.not_accessible_through_html?
245
- format.js { render :record_destroyed }
249
+ format.html { render_row_turbo_destroyed } if row_html_turbo_allowed?
246
250
  end
247
251
  end
248
252
  end
249
253
 
250
254
  # :revert works like undo.
251
255
  # Thanks Ryan Bates: http://railscasts.com/episodes/255-undo-with-paper-trail
256
+ #
257
+ # Two reify paths:
258
+ #
259
+ # * Primary version: the reified object IS the row (Apartment, Photo, ...).
260
+ # Save it and we're done; CarrierWave keeps the previous file on disk
261
+ # (see app/uploaders/image_uploader.rb) so a restored `image` column
262
+ # still points at real bytes.
263
+ # * ActionText (rich_text) version: the reified object is the
264
+ # `ActionText::RichText` row hanging off the parent. Save the rich text,
265
+ # then `touch` the parent so any timestamp display refreshes. Frame ids
266
+ # below derive from `@parent` for both branches.
252
267
  def revert
253
268
  @update_span = params[:update]
254
- @object = referenced_object
255
269
  if current_user.role? :superadmin
256
270
  @version = PaperTrail::Version.find(params[:id])
257
- @version.reify.save!
258
- @object = @Klass.find(@version.item_id)
259
- authorize!(:revert, @object) if cancan_enabled?
271
+ @object = @version.reify
272
+ if defined?(ActionText::RichText) && @object.is_a?(ActionText::RichText)
273
+ @rich_text_record = @object
274
+ @parent = @rich_text_record.record
275
+ @rich_text_record.save!
276
+ @parent.touch if @parent.respond_to?(:touch)
277
+ else
278
+ @parent = @object
279
+ @parent.save!
280
+ end
281
+ authorize!(:revert, @parent) if cancan_enabled?
282
+ return unless row_html_turbo_allowed?
283
+
260
284
  respond_to do |format|
261
- format.html { } unless @Klass.not_accessible_through_html?
262
- format.js { render :close }
285
+ format.turbo_stream { render_revert_turbo_streams }
263
286
  end
264
287
  end
265
288
  end
@@ -277,11 +300,139 @@ class InlineFormsController < ApplicationController
277
300
  end
278
301
 
279
302
  private
303
+
304
+ # Versions list lives in +<turbo-frame id="…_versions">+; POST +restore+ would otherwise
305
+ # send +Turbo-Frame: …_versions+ while +row_close+ only returns the row frame. Stream
306
+ # replaces both the row and the versions panel in one response.
307
+ def render_revert_turbo_streams
308
+ row_id = helpers.inline_forms_row_turbo_frame_id(@parent)
309
+ versions_id = "#{@parent.class.name.underscore}_#{@parent.id}_versions"
310
+ row_html = render_to_string(
311
+ "inline_forms/row_close",
312
+ layout: false,
313
+ formats: [:html],
314
+ locals: { update_span: row_id, object: @parent, inline_forms_turbo_row: true }
315
+ )
316
+ versions_html = render_to_string(
317
+ "inline_forms/versions_panel",
318
+ layout: false,
319
+ formats: [:html],
320
+ locals: { update_span: versions_id, object: @parent, inline_forms_turbo_row: true }
321
+ )
322
+ render turbo_stream: [
323
+ turbo_stream.replace(row_id, row_html),
324
+ turbo_stream.replace(versions_id, versions_html)
325
+ ]
326
+ end
327
+
328
+ # HTML field edit/show inside a +<turbo-frame>+ (Step 3). Scalar fields no longer
329
+ # use UJS; +format.html+ is always registered for edit/update/single-attribute show.
330
+ #
331
+ # +@inline_forms_turbo_field+ tells +link_to_inline_edit+ (and the per-+form_element+
332
+ # +*_show+ helpers it wraps) to emit Turbo data attributes. The flag is set in
333
+ # +_show.html.erb+ when a row first opens, but bare +field_show+ / +field_edit+
334
+ # responses (on +cancel+ / +update+) do not re-render +_show+. Without setting
335
+ # it here the link in the swapped frame would not target the field frame and
336
+ # inline edit would not open reliably.
337
+ def render_turbo_field(template, turbo_field_show: false)
338
+ @turbo_frame = true if template == :field_edit
339
+ @turbo_field_show_turbo_frame = turbo_field_show
340
+ @inline_forms_turbo_field = true
341
+ render "inline_forms/#{template}", layout: "turbo_rails/frame"
342
+ end
343
+
344
+ # Top-level list row open/close (Step 3): full `_show` / `_close` inside
345
+ # `<turbo-frame id="…">` matching `params[:update]`.
346
+ def render_row_turbo(mode)
347
+ @inline_forms_turbo_row = true
348
+ template = (mode == :close) ? "inline_forms/row_close" : "inline_forms/row_show"
349
+ layout = turbo_frame_request? ? "turbo_rails/frame" : "inline_forms"
350
+ render template, layout: layout
351
+ end
352
+
353
+ def render_row_turbo_destroyed
354
+ @inline_forms_turbo_row = true
355
+ layout = turbo_frame_request? ? "turbo_rails/frame" : "inline_forms"
356
+ render "inline_forms/row_destroyed", layout: layout
357
+ end
358
+
359
+ # Nested has_many +new+ / cancel / +create+ inside a parent +<turbo-frame>+ (e.g. Apartment → Photo).
360
+ def html_list_flow_allowed?
361
+ params[:update].present? && (@parent_class.present? || !@Klass.not_accessible_through_html?)
362
+ end
363
+
364
+ def associated_list_html_allowed?
365
+ @parent_class.present? && params[:update].present?
366
+ end
367
+
368
+ def list_frame_id?(update)
369
+ update.present? && update.to_s.end_with?("_list")
370
+ end
371
+
372
+ def render_list_frame_after_save
373
+ @ul_needed = true
374
+ render "inline_forms/create_list_frame", layout: associated_list_frame_layout
375
+ end
376
+
377
+ def associated_list_frame_layout
378
+ # Use full inline_forms chrome so the swapped frame is styled; Turbo extracts
379
+ # the matching <turbo-frame id="…"> from the response body.
380
+ "inline_forms"
381
+ end
382
+
383
+ def render_turbo_new
384
+ @turbo_frame = true
385
+ render "inline_forms/new_record", layout: associated_list_frame_layout
386
+ end
387
+
388
+ # Nested +index+ / cancel / +create+ HTML inside a parent-associated +<turbo-frame>+.
389
+ def render_nested_associated_list_html
390
+ if turbo_frame_request? && nested_list_frame_id?(params[:update])
391
+ # Pagination and other swaps targeting the inner +…_photos_list+ frame: minimal layout.
392
+ @ul_needed = true
393
+ render "inline_forms/_list", layout: "turbo_rails/frame"
394
+ elsif turbo_frame_request? && params[:update].present?
395
+ # Cancel / +create+ targeting the outer +apartment_<id>_photos+ frame: styled full layout.
396
+ render_associated_list_frame
397
+ else
398
+ frame_layout = turbo_frame_request? ? "turbo_rails/frame" : "inline_forms"
399
+ render "inline_forms/_list", layout: frame_layout
400
+ end
401
+ end
402
+
403
+ # +apartment_1_photos_list+ (inner list) vs +apartment_1_photos+ (outer associated container).
404
+ def nested_list_frame_id?(update)
405
+ update.to_s.end_with?("_list")
406
+ end
407
+
408
+ # After nested +create+ / cancel; restores list inside the outer associated frame.
409
+ def render_associated_list_frame
410
+ @ul_needed = true
411
+ render "inline_forms/create_list_frame", layout: associated_list_frame_layout
412
+ end
413
+
414
+ # HTML row open/close is allowed for normal models, and for +not_accessible_through_html?+
415
+ # models (e.g. Photo) when the request targets a nested associated list row
416
+ # (+params[:update]+ like +apartment_1_photo_5+), not bare top-level CRUD.
417
+ def row_html_turbo_allowed?
418
+ return true unless @Klass.not_accessible_through_html?
419
+ nested_associated_list_row_update?(params[:update])
420
+ end
421
+
422
+ # +apartment_1_photo_5+ → +["apartment","1","photo","5"]+ (≥4 segments, trailing id).
423
+ # Differs from field spans (+apartment_1_photo_5_name+ ends with letters) and
424
+ # top-level rows (+apartment_1+ — too few segments).
425
+ def nested_associated_list_row_update?(update)
426
+ parts = update.to_s.split("_")
427
+ parts.length >= 4 && parts.last.match?(/\A\d+\z/)
428
+ end
429
+
280
430
  # Get the class from the controller name.
281
431
  # CountryController < InlineFormsController, so what class are we?
282
432
  # TODO think about this a bit more.
283
433
  def getKlass #:doc:
284
434
  @Klass = self.controller_name.classify.constantize
435
+ InlineForms.validate_plain_text_configuration_for!(@Klass)
285
436
  @Klass
286
437
  end
287
438
 
@@ -1,41 +1,15 @@
1
1
  # -*- encoding : utf-8 -*-
2
+ # Legacy type name: CKEditor is removed; behaves like :rich_text.
2
3
  InlineForms::SPECIAL_COLUMN_TYPES[:ckeditor]=:text
3
4
 
4
5
  def ckeditor_show(object, attribute)
5
- link_to_inline_edit object,
6
- attribute,
7
- '<div class="ckeditor_area">'.html_safe +
8
- cktext_area_tag(
9
- attribute,
10
- object[attribute],
11
- :id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}",
12
- :ckeditor => { :width => '100%',
13
- :height => '200px',
14
- :toolbar => "None",
15
- :readOnly => "true",
16
- :resize_enabled => "false",
17
- :toolbarCanCollapse => "false"
18
- }
19
- ) +
20
- image_tag( 'inline_forms/glass_plate.gif',
21
- :class => "glass_plate",
22
- :title => '' ) +
23
- "<script>delete CKEDITOR.instances['textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}']</script>".html_safe +
24
- '</div>'.html_safe,
25
- from_callee: __callee__
6
+ rich_text_show(object, attribute)
26
7
  end
27
8
 
28
9
  def ckeditor_edit(object, attribute)
29
- cktext_area_tag( attribute,
30
- object[attribute],
31
- :id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}",
32
- :ckeditor => { :width => '100%',
33
- :height => '200px'
34
- }
35
- ) +
36
- "<script>delete CKEDITOR.instances['textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}']</script>".html_safe
10
+ rich_text_edit(object, attribute)
37
11
  end
38
12
 
39
13
  def ckeditor_update(object, attribute)
40
- object[attribute.to_sym] = params[attribute.to_sym]
14
+ rich_text_update(object, attribute)
41
15
  end
@@ -0,0 +1,23 @@
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
@@ -2,13 +2,17 @@
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:plain_text_area]=:text
3
3
 
4
4
  def plain_text_area_show(object, attribute)
5
- link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute].empty?) ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__
5
+ plain_text_show(object, attribute)
6
6
  end
7
7
 
8
8
  def plain_text_area_edit(object, attribute)
9
- text_area_tag attribute, object[attribute], :class => 'attribute_text_area'
9
+ plain_text_edit(object, attribute)
10
10
  end
11
11
 
12
12
  def plain_text_area_update(object, attribute)
13
- object[attribute.to_sym] = params[attribute.to_sym]
13
+ plain_text_update(object, attribute)
14
+ end
15
+
16
+ def plain_text_area_info(object, attribute)
17
+ plain_text_info(object, attribute)
14
18
  end
@@ -2,57 +2,17 @@
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:text_area]=:text
3
3
 
4
4
  def text_area_show(object, attribute)
5
- if object.send(attribute).blank?
6
- link_to_inline_edit object, attribute, "<i class='fi-plus'></i>".html_safe, from_callee: __callee__
7
- else
8
- if defined? Ckeditor
9
- link_to_inline_edit object,
10
- attribute,
11
- '<div class="ckeditor_area">'.html_safe +
12
- cktext_area_tag(
13
- attribute,
14
- object[attribute],
15
- :id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}",
16
- :ckeditor => { :width => '100%',
17
- :height => '200px',
18
- :toolbar => "None",
19
- :readOnly => "true",
20
- :resize_enabled => "false",
21
- :toolbarCanCollapse => "false"
22
- }
23
- ) +
24
- image_tag( 'inline_forms/glass_plate.gif',
25
- :class => "glass_plate",
26
- :title => '' ) +
27
- "<script>delete CKEDITOR.instances['textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}']</script>".html_safe +
28
- '</div>'.html_safe,
29
- from_callee: __callee__
30
- else
31
- link_to_inline_edit object, attribute, object[attribute], from_callee: __callee__
32
- end
33
- end
5
+ rich_text_show(object, attribute)
34
6
  end
35
7
 
36
8
  def text_area_edit(object, attribute)
37
- if defined? Ckeditor
38
- cktext_area_tag(
39
- attribute,
40
- object[attribute],
41
- :id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}",
42
- :ckeditor => { :width => '100%',
43
- :height => '200px'
44
- }
45
- ) +
46
- "<script>delete CKEDITOR.instances['textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}']</script>".html_safe
47
- else
48
- text_area_tag attribute, object[attribute], :class => 'attribute_text_area'
49
- end
9
+ rich_text_edit(object, attribute)
50
10
  end
51
11
 
52
12
  def text_area_update(object, attribute)
53
- object[attribute.to_sym] = params[attribute.to_sym]
13
+ rich_text_update(object, attribute)
54
14
  end
55
15
 
56
16
  def text_area_info(object, attribute)
57
- object[attribute]
17
+ rich_text_info(object, attribute)
58
18
  end
@@ -1,18 +1,19 @@
1
1
  # -*- encoding : utf-8 -*-
2
+ # Legacy alias for plain :text_area (CKEditor removed).
2
3
  InlineForms::SPECIAL_COLUMN_TYPES[:text_area_without_ckeditor]=:text
3
4
 
4
5
  def text_area_without_ckeditor_show(object, attribute)
5
- link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute].empty?) ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__
6
+ plain_text_show(object, attribute)
6
7
  end
7
8
 
8
9
  def text_area_without_ckeditor_edit(object, attribute)
9
- text_area_tag attribute, object[attribute], :class => 'attribute_text_area'
10
+ plain_text_edit(object, attribute)
10
11
  end
11
12
 
12
13
  def text_area_without_ckeditor_update(object, attribute)
13
- object[attribute.to_sym] = params[attribute.to_sym]
14
+ plain_text_update(object, attribute)
14
15
  end
15
16
 
16
17
  def text_area_without_ckeditor_info(object, attribute)
17
- object[attribute]
18
+ plain_text_info(object, attribute)
18
19
  end
@@ -1,8 +1,8 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:text_field]=:string
3
3
 
4
- def text_field_show(object, attribute)
5
- link_to_inline_edit object, attribute, object[attribute].blank? ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__
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
6
  end
7
7
 
8
8
  def text_field_edit(object, attribute)