inline_forms 7.2.11 → 7.5.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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +176 -0
  3. data/README.rdoc +4 -2
  4. data/app/assets/javascripts/inline_forms/inline_forms.js +23 -0
  5. data/app/assets/stylesheets/inline_forms/inline_forms.scss +32 -16
  6. data/app/controllers/concerns/versions_concern.rb +2 -1
  7. data/app/controllers/inline_forms_application_controller.rb +5 -1
  8. data/app/controllers/inline_forms_controller.rb +120 -24
  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 +127 -71
  16. data/app/views/devise/sessions/_form.html.erb +4 -1
  17. data/app/views/inline_forms/_close.html.erb +6 -4
  18. data/app/views/inline_forms/_edit.html.erb +7 -40
  19. data/app/views/inline_forms/_list.html.erb +52 -39
  20. data/app/views/inline_forms/_new.html.erb +23 -11
  21. data/app/views/inline_forms/_show.html.erb +13 -11
  22. data/app/views/inline_forms/_versions_list.html.erb +4 -8
  23. data/app/views/inline_forms/create_list_frame.html.erb +3 -0
  24. data/app/views/inline_forms/field_edit.html.erb +3 -0
  25. data/app/views/inline_forms/field_show.html.erb +3 -0
  26. data/app/views/inline_forms/new_record.html.erb +3 -0
  27. data/app/views/inline_forms/row_close.html.erb +5 -0
  28. data/app/views/inline_forms/row_destroyed.html.erb +9 -0
  29. data/app/views/inline_forms/row_show.html.erb +3 -0
  30. data/app/views/inline_forms/versions_list_panel.html.erb +3 -0
  31. data/app/views/inline_forms/versions_panel.html.erb +3 -0
  32. data/app/views/layouts/application.html.erb +0 -1
  33. data/app/views/layouts/inline_forms.html.erb +10 -1
  34. data/bin/inline_forms +22 -1
  35. data/bin/inline_forms_installer_core.rb +38 -3
  36. data/docs/ujs-to-turbo.md +193 -0
  37. data/lib/generators/USAGE +2 -2
  38. data/lib/generators/assets/stylesheets/inline_forms.scss +32 -16
  39. data/lib/inline_forms/version.rb +1 -1
  40. data/lib/inline_forms.rb +58 -2
  41. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_field_turbo_test.rb +74 -0
  42. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_name_list_test.rb +73 -0
  43. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_photos_pagination_test.rb +199 -15
  44. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_row_turbo_test.rb +94 -0
  45. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_top_level_new_test.rb +100 -0
  46. data/lib/installer_templates/example_app_tests/test/integration/example_app_apartment_versions_turbo_test.rb +27 -0
  47. data/lib/installer_templates/example_app_tests/test/models/example_app_plain_text_rich_text_edge_cases_test.rb +46 -0
  48. data/lib/installer_templates/example_app_views/apartments/name_list.html.erb +26 -0
  49. data/lib/installer_templates/example_app_views/inline_forms/_header.html.erb +45 -0
  50. data/test/inline_forms_generator_test.rb +10 -0
  51. data/test/plain_text_configuration_test.rb +90 -0
  52. metadata +21 -5
  53. data/app/views/inline_forms/edit.js.erb +0 -1
  54. data/app/views/inline_forms/show_element.js.erb +0 -1
  55. data/app/views/inline_forms/update.js.erb +0 -1
  56. data/lib/generators/assets/javascripts/ckeditor/config.js +0 -72
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../example_app/example_integration_test_case"
4
+
5
+ class ExampleAppApartmentVersionsTurboTest < ExampleAppIntegrationTestCase
6
+ setup do
7
+ @apartment = Apartment.first || Apartment.create!(name: "Versions Turbo", title: "T")
8
+ @versions_frame = "apartment_#{@apartment.id}_versions"
9
+ @headers = { "Turbo-Frame" => @versions_frame, "Accept" => "text/html" }
10
+ end
11
+
12
+ test "versions list opens inside matching turbo-frame" do
13
+ get list_versions_apartment_path(@apartment, update: @versions_frame), headers: @headers
14
+ assert_response :success
15
+ assert_includes @response.body, %(<turbo-frame id="#{@versions_frame}">)
16
+ assert_includes @response.body, "Changeset"
17
+ refute_includes @response.body, 'data-remote="true"'
18
+ end
19
+
20
+ test "versions list close returns panel header inside turbo-frame" do
21
+ get list_versions_apartment_path(@apartment, update: @versions_frame, close: true),
22
+ headers: @headers
23
+ assert_response :success
24
+ assert_includes @response.body, %(<turbo-frame id="#{@versions_frame}">)
25
+ refute_includes @response.body, "Changeset"
26
+ end
27
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class ExampleAppPlainTextRichTextEdgeCasesTest < ActiveSupport::TestCase
6
+ def with_temporary_inline_forms_attribute_list(klass, temporary_list)
7
+ original = klass.instance_method(:inline_forms_attribute_list)
8
+ klass.define_method(:inline_forms_attribute_list) { temporary_list }
9
+ yield
10
+ ensure
11
+ klass.define_method(:inline_forms_attribute_list, original)
12
+ end
13
+
14
+ test "plain_text mapped to actiontext-backed attribute raises configuration error" do
15
+ with_temporary_inline_forms_attribute_list(
16
+ Apartment,
17
+ [[:description, "description", :plain_text]]
18
+ ) do
19
+ error = assert_raises(InlineForms::PlainTextColumnMissingError) do
20
+ InlineForms.validate_plain_text_configuration_for!(Apartment)
21
+ end
22
+ assert_includes(error.message, "description")
23
+ assert_includes(error.message, ":rich_text")
24
+ end
25
+ end
26
+
27
+ test "plain_text runtime guard raises before assigning unknown DB attribute" do
28
+ apartment = Apartment.create!(name: "Mismatch", title: "Check")
29
+ assert_raises(InlineForms::PlainTextColumnMissingError) do
30
+ InlineForms.assert_plain_text_column!(
31
+ object: apartment,
32
+ attribute: :description,
33
+ form_element: :plain_text
34
+ )
35
+ end
36
+ end
37
+
38
+ test "switching text column field from plain_text to rich_text does not raise" do
39
+ with_temporary_inline_forms_attribute_list(
40
+ Role,
41
+ [[:description, "description", :rich_text]]
42
+ ) do
43
+ InlineForms.validate_plain_text_configuration_for!(Role)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,26 @@
1
+ <% @inline_forms_turbo_field = true %>
2
+ <div class="row">
3
+ <div class="small-12 columns">
4
+ <h2>Apartment names (first 10)</h2>
5
+ <p>
6
+ <%= link_to "Back to full apartment list", apartments_path %>
7
+ </p>
8
+ <p class="help-text">
9
+ Each name is an inline edit via <code>text_field_show</code> — no stock
10
+ <code>_show</code> panel. Click a name to edit it in place.
11
+ </p>
12
+ </div>
13
+ </div>
14
+
15
+ <% @apartments.each do |apartment| %>
16
+ <div class="row">
17
+ <div class="small-2 columns">
18
+ <%= apartment.id %>
19
+ </div>
20
+ <div class="small-10 columns">
21
+ <turbo-frame id="apartment_<%= apartment.id %>_name">
22
+ <%= text_field_show(apartment, :name) %>
23
+ </turbo-frame>
24
+ </div>
25
+ </div>
26
+ <% end %>
@@ -0,0 +1,45 @@
1
+ <div class="contain-to-grid fixed">
2
+ <nav id='inline_forms_application_top_bar' class="top-bar">
3
+ <div class="top-bar-left">
4
+ <ul class="menu">
5
+ <li class="menu-text">
6
+ <h1 style="margin: 0; font-size: inherit;"><a href="/"><%= application_name %> v<%= inline_forms_version %> <%= current_user.name %></a></h1>
7
+ </li>
8
+ </ul>
9
+ </div>
10
+ <div class="top-bar-right">
11
+ <ul class="dropdown menu" data-dropdown-menu>
12
+ <% if current_user.role?(:admin) || current_user.role?(:superadmin) %>
13
+ <li>
14
+ <a href="#"><%= t 'common.more' %></a>
15
+ <ul class="menu">
16
+ <% MODEL_TABS.each do |m| %>
17
+ <% model = m.singularize.camelcase.constantize rescue nil %>
18
+ <% unless model.nil? || model.not_accessible_through_html? %>
19
+ <% if can? :update, model %>
20
+ <li>
21
+ <%= link_to model.model_name.human, '/' + m %>
22
+ </li>
23
+ <% end %>
24
+ <% end %>
25
+ <% end %>
26
+ <% if can? :read, Apartment %>
27
+ <li>
28
+ <%= link_to "Apartment names (first 10)", apartment_name_list_path %>
29
+ </li>
30
+ <% end %>
31
+ </ul>
32
+ </li>
33
+ <% end %>
34
+ <li>
35
+ <a href="#"><%= current_user.name %></a>
36
+ <ul class="menu">
37
+ <li>
38
+ <%= link_to( t("common.logout"), destroy_user_session_path, :method => :delete) if current_user %>
39
+ </li>
40
+ </ul>
41
+ </li>
42
+ </ul>
43
+ </div>
44
+ </nav>
45
+ </div>
@@ -100,6 +100,16 @@ class InlineFormsGeneratorTest < Minitest::Test
100
100
  refute_includes(migration, "t.text :content")
101
101
  end
102
102
 
103
+ def test_plain_text_generates_text_column_and_plain_text_form_element
104
+ run_generator("Note", "title:string", "description:plain_text")
105
+
106
+ model = read("app/models/note.rb")
107
+ migration = read_single_migration_for("notes")
108
+
109
+ assert_includes(model, "[ :description , \"description\", :plain_text ]")
110
+ assert_includes(migration, "t.text :description")
111
+ end
112
+
103
113
  private
104
114
 
105
115
  def build_destination_skeleton!
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "test_helper"
4
+ require "rails"
5
+ require "inline_forms"
6
+
7
+ class PlainTextConfigurationTest < Minitest::Test
8
+ class PlainTextModelWithColumn
9
+ def self.table_exists?
10
+ true
11
+ end
12
+
13
+ def self.column_names
14
+ %w[id description]
15
+ end
16
+
17
+ def self.table_name
18
+ "plain_text_model_with_columns"
19
+ end
20
+
21
+ def inline_forms_attribute_list
22
+ [
23
+ [:description, "description", :plain_text]
24
+ ]
25
+ end
26
+ end
27
+
28
+ class PlainTextModelWithoutColumn
29
+ def self.table_exists?
30
+ true
31
+ end
32
+
33
+ def self.column_names
34
+ %w[id]
35
+ end
36
+
37
+ def self.table_name
38
+ "plain_text_model_without_columns"
39
+ end
40
+
41
+ def inline_forms_attribute_list
42
+ [
43
+ [:description, "description", :plain_text]
44
+ ]
45
+ end
46
+ end
47
+
48
+ class RichTextModelWithoutColumn
49
+ def self.table_exists?
50
+ true
51
+ end
52
+
53
+ def self.column_names
54
+ %w[id]
55
+ end
56
+
57
+ def inline_forms_attribute_list
58
+ [
59
+ [:description, "description", :rich_text]
60
+ ]
61
+ end
62
+ end
63
+
64
+ def test_plain_text_column_check_passes_when_column_exists
65
+ model = PlainTextModelWithColumn.new
66
+ InlineForms.assert_plain_text_column!(object: model, attribute: :description, form_element: :plain_text)
67
+ end
68
+
69
+ def test_plain_text_column_check_raises_when_column_missing
70
+ model = PlainTextModelWithoutColumn.new
71
+ error = assert_raises(InlineForms::PlainTextColumnMissingError) do
72
+ InlineForms.assert_plain_text_column!(object: model, attribute: :description, form_element: :plain_text)
73
+ end
74
+ assert_includes(error.message, "has no DB column")
75
+ end
76
+
77
+ def test_configuration_check_raises_for_plain_text_without_column
78
+ assert_raises(InlineForms::PlainTextColumnMissingError) do
79
+ InlineForms.validate_plain_text_configuration_for!(PlainTextModelWithoutColumn)
80
+ end
81
+ end
82
+
83
+ def test_configuration_check_allows_rich_text_without_column
84
+ InlineForms.validate_plain_text_configuration_for!(RichTextModelWithoutColumn)
85
+ end
86
+
87
+ def test_text_area_alias_is_not_treated_as_plain_text_column_requirement
88
+ refute InlineForms.plain_text_form_element?(:text_area)
89
+ end
90
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.2.11
4
+ version: 7.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -504,6 +504,7 @@ files:
504
504
  - app/helpers/form_elements/move.rb
505
505
  - app/helpers/form_elements/multi_image_field.rb
506
506
  - app/helpers/form_elements/pdf_link.rb
507
+ - app/helpers/form_elements/plain_text.rb
507
508
  - app/helpers/form_elements/plain_text_area.rb
508
509
  - app/helpers/form_elements/question_list.rb
509
510
  - app/helpers/form_elements/radio_button.rb
@@ -550,17 +551,23 @@ files:
550
551
  - app/views/inline_forms/_versions.html.erb
551
552
  - app/views/inline_forms/_versions_list.html.erb
552
553
  - app/views/inline_forms/close.js.erb
553
- - app/views/inline_forms/edit.js.erb
554
+ - app/views/inline_forms/create_list_frame.html.erb
554
555
  - app/views/inline_forms/extract_translations.erb
556
+ - app/views/inline_forms/field_edit.html.erb
557
+ - app/views/inline_forms/field_show.html.erb
555
558
  - app/views/inline_forms/list.js.erb
556
559
  - app/views/inline_forms/new.js.erb
560
+ - app/views/inline_forms/new_record.html.erb
557
561
  - app/views/inline_forms/record_destroyed.js.erb
562
+ - app/views/inline_forms/row_close.html.erb
563
+ - app/views/inline_forms/row_destroyed.html.erb
564
+ - app/views/inline_forms/row_show.html.erb
558
565
  - app/views/inline_forms/show.js.erb
559
- - app/views/inline_forms/show_element.js.erb
560
566
  - app/views/inline_forms/show_undo.js.erb
561
- - app/views/inline_forms/update.js.erb
562
567
  - app/views/inline_forms/versions.js.erb
563
568
  - app/views/inline_forms/versions_list.js.erb
569
+ - app/views/inline_forms/versions_list_panel.html.erb
570
+ - app/views/inline_forms/versions_panel.html.erb
564
571
  - app/views/layouts/application.html.erb
565
572
  - app/views/layouts/devise.html.erb
566
573
  - app/views/layouts/inline_forms.html.erb
@@ -569,9 +576,9 @@ files:
569
576
  - bin/inline_forms_installer_core.rb
570
577
  - docs/prompt/.gitignore
571
578
  - docs/prompt/test-the-example-app.md
579
+ - docs/ujs-to-turbo.md
572
580
  - inline_forms.gemspec
573
581
  - lib/generators/USAGE
574
- - lib/generators/assets/javascripts/ckeditor/config.js
575
582
  - lib/generators/assets/stylesheets/inline_forms.scss
576
583
  - lib/generators/assets/stylesheets/inline_forms_devise.css
577
584
  - lib/generators/inline_forms_generator.rb
@@ -592,13 +599,21 @@ files:
592
599
  - lib/installer_templates/dartsass/inline_forms_dartsass_builds.rb
593
600
  - lib/installer_templates/dartsass/inline_forms_main.scss
594
601
  - lib/installer_templates/example_app_tests/test/example_app/example_integration_test_case.rb
602
+ - lib/installer_templates/example_app_tests/test/integration/example_app_apartment_field_turbo_test.rb
603
+ - lib/installer_templates/example_app_tests/test/integration/example_app_apartment_name_list_test.rb
595
604
  - lib/installer_templates/example_app_tests/test/integration/example_app_apartment_photos_pagination_test.rb
605
+ - lib/installer_templates/example_app_tests/test/integration/example_app_apartment_row_turbo_test.rb
606
+ - lib/installer_templates/example_app_tests/test/integration/example_app_apartment_top_level_new_test.rb
607
+ - lib/installer_templates/example_app_tests/test/integration/example_app_apartment_versions_turbo_test.rb
596
608
  - lib/installer_templates/example_app_tests/test/integration/example_app_guest_access_test.rb
597
609
  - lib/installer_templates/example_app_tests/test/integration/example_app_photos_test.rb
598
610
  - lib/installer_templates/example_app_tests/test/integration/example_app_routing_test.rb
599
611
  - lib/installer_templates/example_app_tests/test/integration/example_app_turbo_layout_test.rb
600
612
  - lib/installer_templates/example_app_tests/test/models/example_app_apartment_photo_test.rb
601
613
  - lib/installer_templates/example_app_tests/test/models/example_app_paper_trail_changeset_test.rb
614
+ - lib/installer_templates/example_app_tests/test/models/example_app_plain_text_rich_text_edge_cases_test.rb
615
+ - lib/installer_templates/example_app_views/apartments/name_list.html.erb
616
+ - lib/installer_templates/example_app_views/inline_forms/_header.html.erb
602
617
  - lib/locales/inline_forms.en.yml
603
618
  - lib/locales/inline_forms.nl.yml
604
619
  - lib/otherstuff/20120310065554_inline_forms_create_view_for_translations.rb
@@ -610,6 +625,7 @@ files:
610
625
  - test/form_element_from_callee_test.rb
611
626
  - test/inline_edit_polymorphic_path_test.rb
612
627
  - test/inline_forms_generator_test.rb
628
+ - test/plain_text_configuration_test.rb
613
629
  - test/test_helper.rb
614
630
  homepage: http://github.com/acesuares/inline_forms
615
631
  licenses:
@@ -1 +0,0 @@
1
- $('#<%= @update_span %>').html('<%= escape_javascript(render(:partial => 'inline_forms/edit' ))%>')
@@ -1 +0,0 @@
1
- $('#<%= @update_span %>').html('<%= escape_javascript(send("#{@form_element}_show", @object, @attribute))%>')
@@ -1 +0,0 @@
1
- $('#<%= @update_span %>').html('<%= escape_javascript(send("#{@form_element.to_s}_show", @object, @attribute))%>')
@@ -1,72 +0,0 @@
1
- /*
2
- Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3
- For licensing, see LICENSE.html or http://ckeditor.com/license
4
- */
5
-
6
- CKEDITOR.editorConfig = function( config )
7
- {
8
- // Define changes to default configuration here. For example:
9
- // config.language = 'fr';
10
- // config.uiColor = '#AADC6E';
11
-
12
- /* Filebrowser routes */
13
- // The location of an external file browser, that should be launched when "Browse Server" button is pressed.
14
- config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
15
-
16
- // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
17
- config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
18
-
19
- // The location of a script that handles file uploads in the Flash dialog.
20
- config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";
21
-
22
- // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
23
- config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";
24
-
25
- // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
26
- config.filebrowserImageBrowseUrl = "/ckeditor/pictures";
27
-
28
- // The location of a script that handles file uploads in the Image dialog.
29
- var token = $('meta[name=csrf-token]').attr('content');
30
- var param = $('meta[name=csrf-param]').attr('content');
31
- config.filebrowserImageUploadUrl = "/ckeditor/pictures" + "?" + token + "=" + param;
32
- // The location of a script that handles file uploads.
33
- config.filebrowserUploadUrl = "/ckeditor/attachment_files";
34
-
35
- // Rails CSRF token
36
- config.filebrowserParams = function(){
37
- var csrf_token = $('meta[name=csrf-token]').attr('content'),
38
- csrf_param = $('meta[name=csrf-param]').attr('content'),
39
- params = new Object();
40
-
41
- if (csrf_param !== undefined && csrf_token !== undefined) {
42
- params[csrf_param] = csrf_token;
43
- }
44
-
45
- return params;
46
- };
47
-
48
- config.height = 400;
49
- config.width = 600;
50
-
51
- config.language = 'nl';
52
-
53
- // these two lines needed for spellchecking in the browser!
54
- config.disableNativeSpellChecker = false;
55
- config.removePlugins = 'contextmenu,liststyle,tabletools';
56
-
57
- /* Toolbars */
58
-
59
- config.toolbarCanCollapse = false;
60
-
61
- config.toolbar_Minimal =
62
- [
63
- ['Format','-','Bold','Italic','Underline','-','NumberedList','BulletedList','-','Link'],
64
- ['PasteFromWord','RemoveFormat','Source','-','Undo','Redo','-','Maximize']
65
- ];
66
-
67
- config.toolbar_None =
68
- [ '-' ];
69
-
70
- config.toolbar = 'Minimal';
71
-
72
- };