inline_forms 8.1.4 → 8.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 312520779c0b8e5a1d2ac65ae7baceaaf2c855dd200b0ea26d41920e48a8854d
4
- data.tar.gz: 62441eb7d1dde51a0479c3f7225ff8a13cb7d6e6d72a5a23ce595a14c5b74aef
3
+ metadata.gz: 9493a835a60cc7791e52ea91cb2716a72c3f5e5581fcb6b17b14d31bb8aaa512
4
+ data.tar.gz: d8d4df01e059f92d7dee2da87e4ac7291d276d609f52f15d6bc81229d8a1472d
5
5
  SHA512:
6
- metadata.gz: 3bf891bc7e1c84468cd5685fd73d238f4faa80779386d04dd45ef64f7057c1758b6ff8c2d294a745fe2c0e128cc2b0db28273a0ee4ed42cea4afa464c89f4fb3
7
- data.tar.gz: a6f5f42359b955b53dcd907b44cf07ee3a96081f666edb2e7a01f266c4879973af34db664daed3270c392567734e1dfcdb8daf55d2fd64856f9102296c4f10f4
6
+ metadata.gz: 83979c7e18016408c1b19fc15b4c93798708939cc91903e8d26500ba581c31b6833ee046ee22e9771f173cea2fc190e88fce5d255ba6e838a8ee2cadf6c8786b
7
+ data.tar.gz: 3a6b1df0d6ff46044b225bb8dbe89ae2b64219350df5fbe0db2c942c1ec61052ae4de97bced9d805c64e46199e2f7bc2d48a54c716ce7b31349655539df019bf
data/CHANGELOG.md CHANGED
@@ -4,6 +4,91 @@ All notable changes to this project are documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [8.1.6] - 2026-05-27
8
+
9
+ ### Added
10
+
11
+ - **FormElementShowcase example resource.** `inline_forms create … --example` now generates a fourth example model, `FormElementShowcase`, that declares every kept Tier 1 form_element helper on a single object. Coverage:
12
+ - text-shaped: `text_field`, `plain_text_area`
13
+ - numeric: `integer_field`, `decimal_field`
14
+ - date/time: `date_select`, `time_select`, `month_select`, `month_year_picker`
15
+ - choice: `check_box`, `radio_button`, `dropdown_with_integers`, `dropdown_with_values` (normal + `options_disabled`), `dropdown_with_values_with_stars`
16
+ - files: `file_field`, `audio_field`, `image_field` (Cover reuses Photo's `ImageUploader`)
17
+ - rich text: `rich_text`
18
+ - display-only: `header` (6 section headers), `info` (`created_at`/`updated_at`), `info_list` (`has_and_belongs_to_many :roles` rendered read-only)
19
+ - **First field-level validation in the example app.** `validates :count, numericality: { only_integer: true }, allow_blank: true` on `FormElementShowcase`. The new integration test posts `count: "abc"` through the top-level create form and asserts the response re-renders the new form with the numericality error.
20
+ - **`dropdown_with_values_with_stars` ships its assets.** 5 small `<n>stars.png` PNGs are shipped under `lib/installer_templates/example_app_assets/` and copied into `app/assets/images/` at install time.
21
+ - **Showcase regression tests.** New integration tests cover text, numeric (incl. numericality negative), date/time, and choice/scale helpers, plus a full-page smoke test that asserts every per-attribute `<turbo-frame>` renders and the `info_list` empty-state branch is exercised. New model test pins the attribute list, the 8.1.5 row-shape `options_disabled` slot on `:priority2`, and the new numericality validation.
22
+ - **Showcase seed migration.** Seeds two `FormElementShowcase` rows (one fully populated with a role assigned, one empty), so the rendered demo at `/form_element_showcases/1` exercises every show branch out of the box.
23
+
24
+ ### Dropped from previous draft
25
+
26
+ Per user choice:
27
+
28
+ - `text_area`, `text_area_without_ckeditor`, `plain_text` (redundant with `plain_text_area`).
29
+ - `ckeditor` (alias of `rich_text`; no behavior gap to exercise).
30
+ - `slider_with_values` (deferred; complex jQuery UI wiring).
31
+ - `multi_image_field` (deferred; needs array column + `mount_uploaders` plural override).
32
+
33
+ Per implementation discovery (runtime helpers are broken under the current code base; out of scope to fix here):
34
+
35
+ - `money_field` (helper calls `humanized_money_with_symbol`, a `money-rails` view helper that is not declared in the installer Gemfile).
36
+ - `scale_with_integers` (helper indexes the array returned by `attribute_values` with a string: `values[object.send(attribute).to_s]`, which raises `TypeError: no implicit conversion of String into Integer`).
37
+ - `scale_with_values` (helper does `values[object.send(attribute)][1]`, which raises `NoMethodError: undefined method '[]' for nil` whenever the stored integer is not a valid array index of the post-sorted values).
38
+
39
+ ### Lockstep
40
+
41
+ - `inline_forms`, `inline_forms_installer`, and `validation_hints` bumped from 8.1.5 to 8.1.6 in lockstep, even though `validation_hints` has no behavior change in this release.
42
+
43
+ ## [8.1.5] - 2026-05-27
44
+
45
+ ### Changed (hard-breaking)
46
+
47
+ - **`inline_forms_attribute_list` rows are now 2-element by default.** The empty 2nd element (the unused human-name string) has been removed from every row across the gem, installer, generators, helpers, views, validators, tests, and docs. Labels have come from `Klass.human_attribute_name(attribute)` via locale files for a long time, so the slot was redundant. The migration in 8.1.5 makes that explicit by dropping the slot entirely.
48
+
49
+ Old shape:
50
+
51
+ ```ruby
52
+ [ :name, "name", :text_field ],
53
+ [ :sex, "sex", :radio_button, { 1 => 'f', 2 => 'm' } ],
54
+ [ :sex, "sex", :dropdown_with_values, values_hash, options_disabled ],
55
+ ```
56
+
57
+ New shape:
58
+
59
+ ```ruby
60
+ [ :name, :text_field ],
61
+ [ :sex, :radio_button, { 1 => 'f', 2 => 'm' } ],
62
+ [ :sex, :dropdown_with_values, values_hash, options_disabled ],
63
+ ```
64
+
65
+ **This is a hard break.** Consumers that read positions inside the row (`attributes.assoc(:foo)[3]` for `attribute_values`, `attributes.assoc(:foo)[4]` for `dropdown_with_values`' `options_disabled`) have shifted to `[2]` / `[3]`. Any model file left in the old 3/4/5-element shape will silently misbehave (the empty string `""` will be returned where the values hash or `options_disabled` array used to be), so every existing `inline_forms_attribute_list` in downstream apps must be rewritten.
66
+
67
+ Minimal migration for the common 3-element shape — run this once over `app/models/**/*.rb`:
68
+
69
+ ```ruby
70
+ # In your app's root, with a backup or in a clean git tree:
71
+ Dir.glob("app/models/**/*.rb").each do |path|
72
+ src = File.read(path)
73
+ new = src.gsub(/\[\s*(:\w+)\s*,\s*["'][^"']*["']\s*,\s*(:\w+)\s*\]/) { "[ #{$1}, #{$2} ]" }
74
+ File.write(path, new) if new != src
75
+ end
76
+ ```
77
+
78
+ For 4/5-element rows (`dropdown_with_values`, `radio_button`, `scale_*`, `slider_*`, `check_box`, `simple_file_field`, `must_be_a_value` validator targets), drop only the empty 2nd element and keep the trailing `values` / `options_disabled` arguments unchanged.
79
+
80
+ ### Changed (mechanical follow-through)
81
+
82
+ - **`InlineFormsGenerator`** and **`InlineFormsAddtoGenerator`** emit the new 2-element row shape.
83
+ - **Installer** (`inline_forms_installer/installer_core.rb`): hand-written `User` / `<custom>` model `inline_forms_attribute_list` rewritten; `gsub_file` injections for `Apartment#owner` and `Owner#apartments` updated to the new shape.
84
+ - **Runtime consumers** (`InlineFormsController#create`, `app/views/inline_forms/_show.html.erb`, `_new.html.erb`, `_new_nested.html.erb`, `InlineForms.validate_plain_text_configuration_for!`, `InlineForms.validate_no_archived_form_elements_for!`) updated their row destructuring to `|attribute, form_element|`.
85
+ - **Positional lookups** in `InlineFormsHelper#attribute_values`, `MustBeAValueValidator#attribute_values`, and `DropdownWithValuesHelper#…_edit` shifted from `[3]` / `[4]` to `[2]` / `[3]`.
86
+ - **Tests & docs:** all fixtures, assertions, and code samples (USAGE files, READMEs, `archived/*/README.md`) updated to the new shape.
87
+
88
+ ### Notes
89
+
90
+ - **Example app gate (recorded):** `inline_forms create MyApp -d sqlite --example` against the freshly built **8.1.5** gem trio: install in ~73s, `bundle check: ok`, **88 runs, 502 assertions, 0 failures, 0 errors, 0 skips**. Gem unit tests: 42 runs, 240 assertions, 0 failures.
91
+
7
92
  ## [8.1.4] - 2026-05-26
8
93
 
9
94
  ### Fixed
data/README.rdoc CHANGED
@@ -62,7 +62,7 @@ You can install the example application manually if you like:
62
62
  rails g migration AddOwnerToApartments owner:references
63
63
  # Then in app/models/apartment.rb, add (under has_paper_trail):
64
64
  # belongs_to :owner, optional: true
65
- # and prepend `[ :owner, "owner", :dropdown ],` to inline_forms_attribute_list.
65
+ # and prepend `[ :owner, :dropdown ],` to inline_forms_attribute_list.
66
66
  bundle exec rake db:migrate
67
67
  rails s
68
68
 
@@ -208,7 +208,7 @@ Active-tab highlighting is unchanged from upstream (still driven by +set_tab :fo
208
208
  tab = ALL_TABS.include?(params[:tab].to_s) ? params[:tab].to_s : ALL_TABS.first
209
209
  set_tab tab.to_sym
210
210
  @inline_forms_attribute_list = TAB_FIELDS.fetch(tab).map { |a|
211
- @object.inline_forms_attribute_list.find { |attr, _, _| attr == a }
211
+ @object.inline_forms_attribute_list.find { |attr, _| attr == a }
212
212
  }
213
213
  render "clients/show_with_tabs",
214
214
  layout: turbo_frame_request? ? "turbo_rails/frame" : "inline_forms"
@@ -135,7 +135,7 @@ class InlineFormsController < ApplicationController
135
135
  @object ||= @Klass.new
136
136
  @update_span = params[:update]
137
137
  attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list
138
- attributes.each do | attribute, name, form_element |
138
+ attributes.each do | attribute, form_element |
139
139
  InlineForms.assert_plain_text_column!(object: @object, attribute: attribute, form_element: form_element)
140
140
  send("#{form_element.to_s}_update", @object, attribute) unless form_element == :associated || (cancan_enabled? && cannot?(:read, @object, attribute))
141
141
  end
@@ -310,7 +310,7 @@ module InlineFormsHelper
310
310
  # if we have a hash { 0=>'a', 2=>'b', 3=>'d' } will result in [[0,'a'],[2,'b'],[3,'d']] (it will keep the index and sort on the index)
311
311
  # TODO work this out better!
312
312
  # 2012-01-23 Use Cases
313
- # [ :sex , "sex", :radio_button, { 1 => 'f', 2 => 'm' } ],
313
+ # [ :sex, :radio_button, { 1 => 'f', 2 => 'm' } ],
314
314
  # in this case we want the attribute in the database to be 1 or 2. From that attribute, we need to find the value.
315
315
  # using an array, won't work, since [ 'f', 'm' ][1] would be 'm' in stead of 'f'
316
316
  # so values should be a hash. BUT since we don't have sorted hashes (ruby 1,.8.7), the order of the values in the edit screen will be random.
@@ -326,10 +326,13 @@ module InlineFormsHelper
326
326
  # In the dropdown (or the slider) we definately need the order preserverd.
327
327
  # attribulte_values turns this into
328
328
  # [ [0,'???'], [1, '--'] .... [5, '++'] ]
329
-
329
+ #
330
+ # Row shape (since 8.1.x): [ :attr, :form_element, values, options_disabled ].
331
+ # `values` lives at index 2 (was index 3 before the empty label string was
332
+ # dropped in 8.1.x).
330
333
 
331
334
  attributes = @inline_forms_attribute_list || object.inline_forms_attribute_list # if we do this as a form_element, @inline.. is nil!!!
332
- values = attributes.assoc(attribute.to_sym)[3]
335
+ values = attributes.assoc(attribute.to_sym)[2]
333
336
  raise t("fatal.no_values_defined_in", @Klass, attribute) if values.nil?
334
337
  if values.is_a?(Hash)
335
338
  temp = Array.new
@@ -28,7 +28,7 @@ class MustBeAValueValidator < ActiveModel::EachValidator
28
28
  # if we have a hash { 0=>'a', 2=>'b', 3=>'d' } will result in [[0,'a'],[2,'b'],[3,'d']] (it will keep the index and sort on the index)
29
29
  # TODO work this out better!
30
30
  # 2012-01-23 Use Cases
31
- # [ :sex , "sex", :radio_button, { 1 => 'f', 2 => 'm' } ],
31
+ # [ :sex, :radio_button, { 1 => 'f', 2 => 'm' } ],
32
32
  # in this case we want the attribute in the database to be 1 or 2. From that attribute, we need to find the value.
33
33
  # using an array, won't work, since [ 'v', 'm' ][1] would be 'm' in stead of 'v'
34
34
  # so values should be a hash. BUT since we don't have sorted hashes (ruby 1,.8.7), the order of the values in the edit screen will be random.
@@ -40,8 +40,11 @@ class MustBeAValueValidator < ActiveModel::EachValidator
40
40
  # like value=values.assoc(attribute_from_database)[1] (the [1] is needed since the result of #assoc = [1,'v'] and we need the 'v')
41
41
  # I feel it's ugly but it works.
42
42
 
43
+ # Row shape (since 8.1.x): [ :attr, :form_element, values, options_disabled ].
44
+ # `values` lives at index 2 (was index 3 before the empty label string was
45
+ # dropped in 8.1.x).
43
46
  attributes = @inline_forms_attribute_list || object.inline_forms_attribute_list # if we do this as a form_element, @inline.. is nil!!!
44
- values = attributes.assoc(attribute.to_sym)[3]
47
+ values = attributes.assoc(attribute.to_sym)[2]
45
48
  raise "No Values defined in #{@Klass}, #{attribute}" if values.nil?
46
49
  if values.is_a?(Hash)
47
50
  temp = Array.new
@@ -39,7 +39,7 @@
39
39
  parent_id: @parent_id),
40
40
  new_form_opts do -%>
41
41
  <% attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list -%>
42
- <% attributes.each do | attribute, name, form_element | -%>
42
+ <% attributes.each do | attribute, form_element | -%>
43
43
  <% unless form_element.to_sym == :associated || (cancan_enabled? && cannot?(:read, @object, attribute)) -%>
44
44
  <% css_class_id = "attribute_#{attribute}_#{@object.id}" -%>
45
45
  <% if form_element && form_element.to_sym == :header %>
@@ -14,7 +14,7 @@ This goes in _new.html.erb
14
14
  </div>
15
15
  </div>
16
16
  <% nested_attributes = @nested_object.inline_forms_attribute_list -%>
17
- <% nested_attributes.each do | nested_attribute, nested_name, nested_form_element | -%>
17
+ <% nested_attributes.each do | nested_attribute, nested_form_element | -%>
18
18
  <% @nested_form_element = nested_form_element %>
19
19
  <% @nested_attribute = nested_attribute %>
20
20
  <% unless @nested_form_element.to_sym == :associated -%>
@@ -20,7 +20,7 @@
20
20
  </div>
21
21
  <% end %>
22
22
  <% attributes = @inline_forms_attribute_list || @object.inline_forms_attribute_list -%>
23
- <% attributes.each do | attribute, name, form_element | -%>
23
+ <% attributes.each do | attribute, form_element | -%>
24
24
  <% if cancan_disabled? || can?(:read, @object, attribute) %>
25
25
  <% css_class_id = "#{@object.class.name.underscore}_#{@object.id}_#{attribute}" -%>
26
26
  <% if form_element == :header %>
@@ -5,7 +5,7 @@
5
5
 
6
6
  ## What it did
7
7
 
8
- Declare in `inline_forms_attribute_list`, e.g. `[ :children, "Children", :tree ]`:
8
+ Declare in `inline_forms_attribute_list`, e.g. `[ :children, :tree ]`:
9
9
 
10
10
  - **`_show.html.erb`:** header “Children”, `+` for new child, `<turbo-frame>` wrapping **`_tree.html.erb`**.
11
11
  - **`_tree.html.erb`:** lists `parent.children` with Turbo row open, list-frame pagination (`update=…_list`).
data/lib/generators/USAGE CHANGED
@@ -16,14 +16,14 @@ This will create:
16
16
  def _presentation
17
17
  #define your presentation here
18
18
  end
19
- def inline_forms_field_list
20
- [
21
- [ :name, 'name', :text_field ],
22
- [ :description, 'description', :plain_text ],
23
- [ :yesno, 'yesno', :check_box ],
24
- [ :gender, 'gender', :boolean_with_values ],
19
+ def inline_forms_attribute_list
20
+ @inline_forms_attribute_list ||= [
21
+ [ :name, :text_field ],
22
+ [ :description, :plain_text ],
23
+ [ :yesno, :check_box ],
24
+ [ :gender, :boolean_with_values ],
25
25
  ]
26
- end
26
+ end
27
27
  end
28
28
 
29
29
  app/controllers/things_controller.rb
@@ -0,0 +1,46 @@
1
+ Description:
2
+ Add fields to an existing inline_forms model. The model file must already
3
+ exist (from `rails g inline_forms` or the installer). Generates an additive
4
+ migration (`add_column`, `add_reference` for belongs_to/dropdown, a single
5
+ :string column for image_field/audio_field; no column for rich_text /
6
+ has_many / has_one / habtm) and updates the model: associations,
7
+ `has_rich_text`, `mount_uploader`, and new rows in `inline_forms_attribute_list`.
8
+
9
+ Does NOT create routes, a controller, or MODEL_TABS — those stay as-is for
10
+ the existing model. Use `rails g inline_forms` to scaffold new models.
11
+
12
+ Install-time-only names (`_no_model`, `_no_migration`, `_id`, `_enabled`) are
13
+ rejected. `_presentation`, `_list_order`, `_list_search`, and `_order` are
14
+ skipped unless you pass `--replace`.
15
+
16
+ Example:
17
+ rails generate inline_forms_addto User occupation:text_field birthdate:date organization:dropdown bio:rich_text
18
+
19
+ This will create:
20
+ create db/migrate/20260527120000_inline_forms_add_to_users_occupation_birthdate.rb
21
+ insert app/models/user.rb
22
+
23
+ db/migrate/..._inline_forms_add_to_users_occupation_birthdate.rb:
24
+ class InlineFormsAddToUsersOccupationBirthdate < ActiveRecord::Migration[8.1]
25
+ def change
26
+ add_column :users, :occupation, :string
27
+ add_column :users, :birthdate, :date
28
+ add_reference :users, :organization, foreign_key: true
29
+ end
30
+ end
31
+
32
+ app/models/user.rb (excerpt):
33
+ class User < ApplicationRecord
34
+ belongs_to :organization
35
+ has_rich_text :bio
36
+
37
+ def inline_forms_attribute_list
38
+ @inline_forms_attribute_list ||= [
39
+ ...
40
+ [ :occupation, :text_field ],
41
+ [ :birthdate, :date ],
42
+ [ :organization, :dropdown ],
43
+ [ :bio, :rich_text ],
44
+ ]
45
+ end
46
+ end
@@ -39,7 +39,7 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
39
39
  class_option :replace, type: :boolean, default: false,
40
40
  desc: "Replace existing _presentation/_list_order/_list_search instead of skipping."
41
41
 
42
- source_root File.expand_path("templates", __dir__)
42
+ source_root File.expand_path("inline_forms_addto/templates", __dir__)
43
43
 
44
44
  def validate!
45
45
  unless File.exist?(File.join(destination_root, model_file_path))
@@ -209,7 +209,7 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
209
209
  # `ApplicationRecord`) and no body.
210
210
  def add_attribute_list_row!(attribute)
211
211
  content = File.read(File.join(destination_root, model_file_path))
212
- row = " [ :#{attribute.name} , \"#{attribute.name}\", :#{attribute.attribute_type} ],\n"
212
+ row = " [ :#{attribute.name}, :#{attribute.attribute_type} ],\n"
213
213
 
214
214
  if content.match?(/@inline_forms_attribute_list \|\|=\s*\[/)
215
215
  if content.match?(/\[\s*:#{Regexp.escape(attribute.name)}\s*,/)
@@ -235,7 +235,7 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
235
235
 
236
236
  def inline_forms_attribute_list
237
237
  @inline_forms_attribute_list ||= [
238
- [ :#{attribute.name} , "#{attribute.name}", :#{attribute.attribute_type} ],
238
+ [ :#{attribute.name}, :#{attribute.attribute_type} ],
239
239
  ]
240
240
  end
241
241
  RUBY
@@ -123,8 +123,7 @@ module InlineForms
123
123
  @inline_forms_attribute_list << commenter +
124
124
  ' [ :' +
125
125
  attribute.name +
126
- ' , "' + attribute.name +
127
- '", :' + attribute.attribute_type.to_s +
126
+ ', :' + attribute.attribute_type.to_s +
128
127
  " ], \n"
129
128
  end
130
129
  end
@@ -50,7 +50,7 @@ module InlineForms
50
50
  def self.validate_no_archived_form_elements_for!(klass)
51
51
  return unless klass.instance_methods.include?(:inline_forms_attribute_list)
52
52
 
53
- klass.new.inline_forms_attribute_list.each do |attribute, _label, form_element|
53
+ klass.new.inline_forms_attribute_list.each do |attribute, form_element|
54
54
  key = form_element.to_sym
55
55
  next unless ARCHIVED_FORM_ELEMENTS.key?(key)
56
56
 
@@ -16,7 +16,7 @@ module InlineForms
16
16
  values = attribute_values(object, attribute)
17
17
 
18
18
  attributes = @inline_forms_attribute_list || object.inline_forms_attribute_list
19
- options_disabled = attributes.assoc(attribute.to_sym)[4]
19
+ options_disabled = attributes.assoc(attribute.to_sym)[3]
20
20
 
21
21
  collection_select( ('_' + object.class.to_s.underscore).to_sym,
22
22
  attribute.to_sym,
@@ -6,7 +6,7 @@ module InlineForms
6
6
  # -*- encoding : utf-8 -*-
7
7
  # radio buttons are integers in this version
8
8
  # us like this:
9
- # [ :sex , "gender", :radio_button, { 1 => 'male', 2 => 'female' } ],
9
+ # [ :sex, :radio_button, { 1 => 'male', 2 => 'female' } ],
10
10
 
11
11
  def radio_button_show(object, attribute)
12
12
  values = attribute_values(object, attribute)
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "8.1.4"
3
+ VERSION = "8.1.6"
4
4
  end
data/lib/inline_forms.rb CHANGED
@@ -58,10 +58,10 @@ module InlineForms
58
58
  #
59
59
  # class Example < ApplicationRecord
60
60
  # def inline_forms_attribute_list
61
- # {
62
- # :name => [ "name", :text_field ],
63
- # :price => [ "price", :text_field ],
64
- # }
61
+ # [
62
+ # [ :name, :text_field ],
63
+ # [ :price, :text_field ],
64
+ # ]
65
65
  # end
66
66
  # end
67
67
  # as you see, both :string and :integer are mapped to a :text_field
@@ -92,7 +92,7 @@ module InlineForms
92
92
  # t.belongs_to :country
93
93
  # to the migration. (In fact AR will add t.integer :country_id). And
94
94
  # it will add
95
- # :country => [ "country", :dropdown ],
95
+ # [ :country, :dropdown ],
96
96
  # to the inline_forms_attribute_list in the model.
97
97
  #
98
98
  SPECIAL_COLUMN_TYPES = {
@@ -127,7 +127,7 @@ module InlineForms
127
127
  return unless klass.table_exists?
128
128
 
129
129
  attributes = klass.new.inline_forms_attribute_list
130
- attributes.each do |attribute, _label, form_element|
130
+ attributes.each do |attribute, form_element|
131
131
  next unless plain_text_form_element?(form_element)
132
132
  next if klass.column_names.include?(attribute.to_s)
133
133
 
@@ -6,13 +6,13 @@ require "inline_forms/archived_form_elements"
6
6
  class ArchivedFormElementsTest < Minitest::Test
7
7
  class ModelWithArchivedElement
8
8
  def inline_forms_attribute_list
9
- [[:address, "Address", :geo_code_curacao]]
9
+ [[:address, :geo_code_curacao]]
10
10
  end
11
11
  end
12
12
 
13
13
  class ModelWithArchivedTree
14
14
  def inline_forms_attribute_list
15
- [[:children, "Children", :tree]]
15
+ [[:children, :tree]]
16
16
  end
17
17
  end
18
18
 
@@ -17,8 +17,8 @@ class InlineFormsAddtoGeneratorTest < Minitest::Test
17
17
 
18
18
  def inline_forms_attribute_list
19
19
  @inline_forms_attribute_list ||= [
20
- [ :name , "name", :text_field ],
21
- [ :category , "category", :belongs_to ],
20
+ [ :name, :text_field ],
21
+ [ :category, :belongs_to ],
22
22
  ]
23
23
  end
24
24
 
@@ -38,13 +38,13 @@ class InlineFormsAddtoGeneratorTest < Minitest::Test
38
38
 
39
39
  def inline_forms_attribute_list
40
40
  @inline_forms_attribute_list ||= [
41
- [ :header_user_login, '', :header ],
42
- [ :name, '', :text_field ],
43
- [ :email, '', :text_field ],
44
- [ :locale , '', :dropdown ],
45
- [ :password, '', :devise_password_field ],
46
- [ :header_user_roles, '', :header ],
47
- [ :roles, '', :check_list ],
41
+ [ :header_user_login, :header ],
42
+ [ :name, :text_field ],
43
+ [ :email, :text_field ],
44
+ [ :locale, :dropdown ],
45
+ [ :password, :devise_password_field ],
46
+ [ :header_user_roles, :header ],
47
+ [ :roles, :check_list ],
48
48
  ]
49
49
  end
50
50
 
@@ -94,13 +94,13 @@ class InlineFormsAddtoGeneratorTest < Minitest::Test
94
94
  assert_includes(model, "belongs_to :supplier")
95
95
  assert_includes(model, "has_rich_text :bio")
96
96
  assert_includes(model, "mount_uploader :avatar, AvatarUploader")
97
- assert_includes(model, '[ :occupation , "occupation", :text_field ]')
97
+ assert_includes(model, '[ :occupation, :text_field ]')
98
98
  # :belongs_to is a relation -> no row in inline_forms_attribute_list
99
99
  # (matches InlineFormsGenerator semantics). :dropdown is not a relation
100
100
  # at lookup time, so it does get a row.
101
- refute_includes(model, '[ :organization , "organization", :belongs_to ]')
102
- assert_includes(model, '[ :supplier , "supplier", :dropdown ]')
103
- assert_includes(model, '[ :avatar , "avatar", :image_field ]')
101
+ refute_includes(model, '[ :organization, :belongs_to ]')
102
+ assert_includes(model, '[ :supplier, :dropdown ]')
103
+ assert_includes(model, '[ :avatar, :image_field ]')
104
104
 
105
105
  assert_includes(migration, "add_column :widgets, :occupation, :string")
106
106
  assert_includes(migration, "add_reference :widgets, :organization, foreign_key: true")
@@ -120,7 +120,7 @@ class InlineFormsAddtoGeneratorTest < Minitest::Test
120
120
  model = read("app/models/widget.rb")
121
121
 
122
122
  assert_equal(1, model.scan("belongs_to :organization").size)
123
- assert_equal(1, model.scan('[ :occupation , "occupation", :text_field ]').size)
123
+ assert_equal(1, model.scan('[ :occupation, :text_field ]').size)
124
124
  end
125
125
 
126
126
  def test_appends_row_to_installer_shaped_user_attribute_list
@@ -130,8 +130,8 @@ class InlineFormsAddtoGeneratorTest < Minitest::Test
130
130
 
131
131
  model = read("app/models/user.rb")
132
132
 
133
- assert_includes(model, '[ :occupation , "occupation", :text_field ]')
134
- assert_includes(model, '[ :birthdate , "birthdate", :date_select ]')
133
+ assert_includes(model, '[ :occupation, :text_field ]')
134
+ assert_includes(model, '[ :birthdate, :date_select ]')
135
135
  refute_match(/\]\s*\n\s*\[\s*:occupation/, model)
136
136
 
137
137
  user_array_section = model[/@inline_forms_attribute_list \|\|=\s*\[(.|\n)*?\n\s*\]/]
@@ -150,7 +150,7 @@ class InlineFormsAddtoGeneratorTest < Minitest::Test
150
150
 
151
151
  assert_includes(out, "no inline_forms_attribute_list found")
152
152
  assert_includes(model, "def inline_forms_attribute_list")
153
- assert_includes(model, '[ :occupation , "occupation", :text_field ]')
153
+ assert_includes(model, '[ :occupation, :text_field ]')
154
154
  end
155
155
 
156
156
  def test_unknown_type_raises_thor_error_by_default
@@ -174,7 +174,7 @@ class InlineFormsAddtoGeneratorTest < Minitest::Test
174
174
  model = read("app/models/widget.rb")
175
175
  migration = read_single_addto_migration_for("widgets")
176
176
 
177
- assert_includes(model, '[ :payload , "payload", :unknown ]')
177
+ assert_includes(model, '[ :payload, :unknown ]')
178
178
  assert_includes(migration, "# add_column :widgets, :payload, :unknown")
179
179
  end
180
180
 
@@ -44,8 +44,8 @@ class InlineFormsGeneratorTest < Minitest::Test
44
44
  refute_includes(model, "scope :inline_forms_search")
45
45
  assert_includes(model, "belongs_to :category")
46
46
  assert_includes(model, "has_many :photos")
47
- assert_includes(model, "[ :name , \"name\", :text_field ]")
48
- assert_includes(model, "[ :category , \"category\", :dropdown ]")
47
+ assert_includes(model, "[ :name, :text_field ]")
48
+ assert_includes(model, "[ :category, :dropdown ]")
49
49
 
50
50
  assert_includes(controller, "class ThingsController < InlineFormsController")
51
51
  assert_includes(controller, "set_tab :thing")
@@ -91,7 +91,7 @@ class InlineFormsGeneratorTest < Minitest::Test
91
91
  model = read("app/models/mystery.rb")
92
92
  migration = read_single_migration_for("mysteries")
93
93
 
94
- assert_includes(model, "# [ :payload , \"payload\", :unknown ]")
94
+ assert_includes(model, "# [ :payload, :unknown ]")
95
95
  assert_includes(migration, "# t.unknown :payload")
96
96
  end
97
97
 
@@ -167,7 +167,7 @@ class InlineFormsGeneratorTest < Minitest::Test
167
167
  model = read("app/models/note.rb")
168
168
  migration = read_single_migration_for("notes")
169
169
 
170
- assert_includes(model, "[ :description , \"description\", :plain_text ]")
170
+ assert_includes(model, "[ :description, :plain_text ]")
171
171
  assert_includes(migration, "t.text :description")
172
172
  end
173
173
 
@@ -20,7 +20,7 @@ class PlainTextConfigurationTest < Minitest::Test
20
20
 
21
21
  def inline_forms_attribute_list
22
22
  [
23
- [:description, "description", :plain_text]
23
+ [:description, :plain_text]
24
24
  ]
25
25
  end
26
26
  end
@@ -40,7 +40,7 @@ class PlainTextConfigurationTest < Minitest::Test
40
40
 
41
41
  def inline_forms_attribute_list
42
42
  [
43
- [:description, "description", :plain_text]
43
+ [:description, :plain_text]
44
44
  ]
45
45
  end
46
46
  end
@@ -56,7 +56,7 @@ class PlainTextConfigurationTest < Minitest::Test
56
56
 
57
57
  def inline_forms_attribute_list
58
58
  [
59
- [:description, "description", :rich_text]
59
+ [:description, :rich_text]
60
60
  ]
61
61
  end
62
62
  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: 8.1.4
4
+ version: 8.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -495,11 +495,12 @@ files:
495
495
  - inline_forms.gemspec
496
496
  - lib/generators/USAGE
497
497
  - lib/generators/assets/stylesheets/inline_forms_devise.css
498
+ - lib/generators/inline_forms_addto/USAGE
499
+ - lib/generators/inline_forms_addto/templates/add_columns_migration.erb
498
500
  - lib/generators/inline_forms_addto_generator.rb
499
501
  - lib/generators/inline_forms_attribute_overrides.rb
500
502
  - lib/generators/inline_forms_generator.rb
501
503
  - lib/generators/templates/_inline_forms_tabs.html.erb
502
- - lib/generators/templates/add_columns_migration.erb
503
504
  - lib/generators/templates/application_record.rb
504
505
  - lib/generators/templates/controller.erb
505
506
  - lib/generators/templates/migration.erb