inline_forms 8.1.5 → 8.1.8

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: a67a5a2a208fff953c0ffe9145425d30e7ae8fefae955271436033c1b2a99771
4
- data.tar.gz: a7b359f732f395f368be30c35277b9eecbd1cbd253e388c8f59165b207297a6c
3
+ metadata.gz: 6faae45fc3c25f20b57cc614e61e77a5264c1d866a5fde22a6e634c639fb54b9
4
+ data.tar.gz: a30324d9cc1f598b4a9c5531f0b4fa45fe47186d2a07b8fc956e38c988a52872
5
5
  SHA512:
6
- metadata.gz: 49e2f7a7fb54b318959f5c003793e4190c812f527fa5a36ed9160260ee217d0761bf1f5c28bdf1cc241f650dcde82662b084140903551f17aadf7c2f0a539498
7
- data.tar.gz: bc33c4b2ee408988f01c166f2fcfc5ac07e684c3b966501db41edec5b7eb0e42e8ca50904c9fa5936005974bf0ca527c9abf2086771fea6e051a8fd255ab169f
6
+ metadata.gz: 9777058054bb9d8e1ff3213e0fd7bf420fd060f69a43005aef71e2fc9088aa58ccfb0e60aaa5ac4d57739aaa555bb01820bb1cc328d31543295ca8377c476eff
7
+ data.tar.gz: 3f938ebcb879f72cecd60bd0c2e8eab47c1d01c410c7e32c137953e8f925cda614ce1b32e418bd887d0c833aaeecb0909fb9ba73c75911742473b22cfc9e186c
data/CHANGELOG.md CHANGED
@@ -4,6 +4,83 @@ All notable changes to this project are documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [8.1.8] - 2026-05-27
8
+
9
+ ### Added
10
+
11
+ - **`money_field`, `scale_with_integers`, `scale_with_values` are back in the `FormElementShowcase`.** All three were dropped from 8.1.6 because their `_show` helpers crashed (`humanized_money_with_symbol` undefined, positional-index lookups against `[[key,label]]` pairs). 8.1.7 fixed the two `scale_*` helpers; 8.1.8 wires the missing money-rails dependency:
12
+ - **money-rails wired into the installer Gemfile** (`gem 'money-rails', '~> 3.0'`). Adds the `humanized_money_with_symbol` view helper used by `money_field_show` and the `monetize` macro used in the showcase model.
13
+ - **`config/initializers/money.rb` generated** with `MoneyRails.configure { default_currency = :usd }` so the showcase renders predictably under any host locale.
14
+ - **`amount:money_field` column rewritten to `amount_cents:integer, default: 0, null: false`** in the generated create-table migration, and `monetize :amount_cents` declared on `FormElementShowcase`. That keeps the inline_forms attribute-list entry semantically correct (`[:amount, :money_field]`) — money-rails exposes the `amount`/`amount=` Money-aware accessors on top of the `_cents` column, so `obj.amount = "12.34"` parses to a Money and stores 1234 cents, and `obj.amount` reads back as `$12.34`.
15
+ - **`scale_int:scale_with_integers` (`{ 1 => 'one', … 5 => 'five' }`) and `scale_val:scale_with_values` (`{ 1 => 'red', 2 => 'green', 3 => 'blue' }`)** added to the showcase with value hashes, locale labels, and seed values (`scale_int=3, scale_val=2` on the full demo; both `1` on the empty demo).
16
+ - **Showcase regression tests cover the three re-added fields.**
17
+ - `money_field` round-trips `"12.34"` and asserts `amount_cents == 1234` (skipped if money-rails is not monetizing `:amount`, so the same test file still works for older host apps).
18
+ - `scale_with_integers` and `scale_with_values` get round-trip integration tests structurally identical to the dropdown helper tests.
19
+ - `EXPECTED_ATTRIBUTES` (model test) and `SHOWCASE_FIELD_ATTRIBUTES` (page-render test) updated to require all three frames to render on `/form_element_showcases/:id`.
20
+
21
+ ### Fixed
22
+
23
+ - **`money_field_show` rendered an empty `<a>` when the value was `nil`/zero.** money-rails' `humanized_money_with_symbol(nil)` returns `""`, so the inline-edit link had no visible text. The helper now uses the standard `<i class="fi-plus">` empty-state placeholder for nil/zero values, matching `dropdown_with_values_show` / `radio_button_show` / the 8.1.7 scale fixes.
24
+
25
+ ### Lockstep
26
+
27
+ - `inline_forms`, `inline_forms_installer`, and `validation_hints` bumped from 8.1.7 to 8.1.8 in lockstep, even though `validation_hints` has no behavior change in this release.
28
+
29
+ ## [8.1.7] - 2026-05-27
30
+
31
+ ### Fixed
32
+
33
+ - **`dropdown_with_integers` / `scale_with_integers` / `scale_with_values` `_show` helpers crashed on every non-trivial value.** All three did `attribute_values(object, attribute)[object.send(attribute)][1]` (or `[…].to_s` for `scale_with_integers`), i.e. they used `Array#[N]` against the `[[key, label], …]` array returned by `attribute_values` — that indexes positionally, not by key, so the stored integer was used as an array offset. Symptoms in the wild:
34
+ - `dropdown_with_integers_show` on a `rating_int = 3` against `{1 => "One", 2 => "Two", 3 => "Three"}` returned `values[3]` → `nil`, then `nil[1]` raised `NoMethodError: undefined method '[]' for nil`. With smaller values it silently rendered the *next* label (`rating_int = 1` rendered `"Two"`).
35
+ - `scale_with_integers_show` indexed an array with a string (`values[object.send(attribute).to_s]`), which raised `TypeError: no implicit conversion of String into Integer`.
36
+ - `scale_with_values_show` had the same positional-index bug as `dropdown_with_integers_show` and crashed identically on out-of-range integers.
37
+
38
+ All three now use `values.assoc(object.send(attribute))` so the stored value is matched against the *key* column of the pair, and gracefully fall back to the empty-state `<i class="fi-plus">` placeholder when no pair matches (matches the nil branch in `dropdown_with_values_show` and `radio_button_show`). Showcase row in the example app now renders `"One"` for `rating_int = 1` (was: `"Two"`), and the `scale_*` helpers no longer crash from the showcase page.
39
+
40
+ - **`Versions (N)` header flickered between `N` and `N+M` when the panel was toggled.** On a record whose associated `ActionText::RichText` has at least one PaperTrail version (e.g. the empty `FormElementShowcase` after a description edit), the closed `app/views/inline_forms/_versions.html.erb` partial counted `object.versions.length` (parent only, e.g. `7`) while the open `_versions_list.html.erb` partial counted `inline_forms_versions_for(@object).length` (parent + rich_text merged, e.g. `8`). The visible count therefore changed every time the user opened or closed the panel. Closed partial now uses the same `inline_forms_versions_for(object).length` so the header is stable and matches the number of rows the open panel actually shows. Verified against the running example app at `/form_element_showcases/4` after toggle.
41
+
42
+ - **`month_year_picker_update` left three debug `puts 'XXXXXX…'` lines in the helper.** They printed before/after values to STDOUT on every save (visible during `rails test` and in production logs) and added no diagnostic value. Removed. The helper now also no-ops on an empty/invalid `params[:attribute]` instead of letting `Date.parse("")` raise `Date::Error: invalid date` — the previous "always parse" version forced the showcase numericality test to thread a placeholder `start_month` through the create POST just to keep the unrelated update branch from crashing during the same controller cycle. With the rescue in place the helper degrades to `nil` and the rest of the update path keeps running.
43
+
44
+ ### Lockstep
45
+
46
+ - `inline_forms`, `inline_forms_installer`, and `validation_hints` bumped from 8.1.6 to 8.1.7 in lockstep, even though `inline_forms_installer` and `validation_hints` have no behavior change in this release.
47
+
48
+ ## [8.1.6] - 2026-05-27
49
+
50
+ ### Added
51
+
52
+ - **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:
53
+ - text-shaped: `text_field`, `plain_text_area`
54
+ - numeric: `integer_field`, `decimal_field`
55
+ - date/time: `date_select`, `time_select`, `month_select`, `month_year_picker`
56
+ - choice: `check_box`, `radio_button`, `dropdown_with_integers`, `dropdown_with_values` (normal + `options_disabled`), `dropdown_with_values_with_stars`
57
+ - files: `file_field`, `audio_field`, `image_field` (Cover reuses Photo's `ImageUploader`)
58
+ - rich text: `rich_text`
59
+ - display-only: `header` (6 section headers), `info` (`created_at`/`updated_at`), `info_list` (`has_and_belongs_to_many :roles` rendered read-only)
60
+ - **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.
61
+ - **`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.
62
+ - **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.
63
+ - **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.
64
+
65
+ ### Dropped from previous draft
66
+
67
+ Per user choice:
68
+
69
+ - `text_area`, `text_area_without_ckeditor`, `plain_text` (redundant with `plain_text_area`).
70
+ - `ckeditor` (alias of `rich_text`; no behavior gap to exercise).
71
+ - `slider_with_values` (deferred; complex jQuery UI wiring).
72
+ - `multi_image_field` (deferred; needs array column + `mount_uploaders` plural override).
73
+
74
+ Per implementation discovery (runtime helpers are broken under the current code base; out of scope to fix here):
75
+
76
+ - `money_field` (helper calls `humanized_money_with_symbol`, a `money-rails` view helper that is not declared in the installer Gemfile).
77
+ - `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`).
78
+ - `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).
79
+
80
+ ### Lockstep
81
+
82
+ - `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.
83
+
7
84
  ## [8.1.5] - 2026-05-27
8
85
 
9
86
  ### Changed (hard-breaking)
@@ -1,8 +1,13 @@
1
1
  <% object = local_assigns[:object] || @object -%>
2
2
  <% css_class_id = inline_forms_versions_turbo_frame_id(object) -%>
3
+ <%# Count the same merged set the open list does (`inline_forms_versions_for`
4
+ sums the parent's PaperTrail versions and the versions of any associated
5
+ ActionText::RichText records). Using `object.versions.length` here meant
6
+ the closed header showed N (parent only) and the open header showed N+M
7
+ (parent + rich_text), flickering as the user toggled the panel. -%>
3
8
  <div class="row form_element_header associated_auto_header callout">
4
9
  <div class='medium-11 large-11 column' >
5
- <%= "Versions (#{object.versions.length})" %>
10
+ <%= "Versions (#{inline_forms_versions_for(object).length})" %>
6
11
  </div>
7
12
  <div class='medium-1 large-1 column'>
8
13
  <%= link_to_versions_list(
@@ -10,8 +10,14 @@ module InlineForms
10
10
  #
11
11
  # values must be a Range or a one-dimensional array of Integers
12
12
  def dropdown_with_integers_show(object, attribute)
13
+ # `attribute_values` returns key/label pairs (e.g. [[1,'one'],[2,'two']]);
14
+ # use Array#assoc so the stored integer is matched against the *key*
15
+ # column, not used as a positional array index (which off-by-ones and
16
+ # raises on out-of-range or nil).
13
17
  values = attribute_values(object, attribute)
14
- link_to_inline_edit object, attribute, values[object.send(attribute)][1], from_callee: __callee__
18
+ pair = values.assoc(object.send(attribute))
19
+ label = pair ? pair[1] : "<i class='fi-plus'></i>".html_safe
20
+ link_to_inline_edit object, attribute, label, from_callee: __callee__
15
21
  end
16
22
 
17
23
  def dropdown_with_integers_edit(object, attribute)
@@ -6,13 +6,24 @@ module InlineForms
6
6
  # -*- encoding : utf-8 -*-
7
7
 
8
8
  def money_field_show(object, attribute)
9
- link_to_inline_edit object, attribute, humanized_money_with_symbol(object.send attribute), from_callee: __callee__
9
+ # `humanized_money_with_symbol` (money-rails) returns "" for nil/blank
10
+ # which renders as an empty anchor — show the empty-state placeholder
11
+ # instead, matching the nil branch on dropdown/radio show helpers.
12
+ value = object.send(attribute)
13
+ label = if defined?(humanized_money_with_symbol) && value.respond_to?(:zero?) && !value.zero?
14
+ humanized_money_with_symbol(value)
15
+ elsif value.blank?
16
+ "<i class='fi-plus'></i>".html_safe
17
+ else
18
+ humanized_money_with_symbol(value)
19
+ end
20
+ link_to_inline_edit object, attribute, label, from_callee: __callee__
10
21
  end
11
-
22
+
12
23
  def money_field_edit(object, attribute)
13
24
  text_field_tag attribute, (object.send attribute), :class => 'input_money_field'
14
25
  end
15
-
26
+
16
27
  def money_field_update(object, attribute)
17
28
  object.send( "#{attribute}=", params[attribute])
18
29
  end
@@ -16,10 +16,10 @@ module InlineForms
16
16
  end
17
17
 
18
18
  def month_year_picker_update(object, attribute)
19
- puts 'XXXXXXXXXXXXXXXXXXXXXXXXXX' + object[attribute.to_sym].inspect
20
- puts 'XXXXXXXXXXXXXXXXXXXXXXXXXX' + Date.parse(params[attribute.to_sym].to_s).strftime("%F").to_s
21
- object[attribute.to_sym] = Date.parse(params[attribute.to_sym].to_s).strftime("%F").to_s
22
- puts 'XXXXXXXXXXXXXXXXXXXXXXXXXX' + object[attribute.to_sym].inspect
19
+ raw = params[attribute.to_sym].to_s
20
+ object[attribute.to_sym] = raw.empty? ? nil : Date.parse(raw).strftime("%F").to_s
21
+ rescue Date::Error
22
+ object[attribute.to_sym] = nil
23
23
  end
24
24
  INLINE_FORMS_FORM_ELEMENT
25
25
  end
@@ -11,8 +11,13 @@ module InlineForms
11
11
  # values must be a Range or a one-dimensional array of Integers
12
12
  #
13
13
  def scale_with_integers_show(object, attribute)
14
+ # `attribute_values` returns key/label pairs; match by key with
15
+ # Array#assoc rather than Array#[N] (which would index positionally
16
+ # and raise on out-of-range/nil).
14
17
  values = attribute_values(object, attribute)
15
- link_to_inline_edit object, attribute, values[object.send(attribute).to_s], from_callee: __callee__
18
+ pair = values.assoc(object.send(attribute))
19
+ label = pair ? pair[1] : "<i class='fi-plus'></i>".html_safe
20
+ link_to_inline_edit object, attribute, label, from_callee: __callee__
16
21
  end
17
22
 
18
23
  def scale_with_integers_edit(object, attribute)
@@ -10,8 +10,14 @@ module InlineForms
10
10
  #
11
11
  # values must be a hash { integer => string, ... } or an one-dimensional array of strings
12
12
  def scale_with_values_show(object, attribute)
13
+ # `attribute_values` returns [[key, label], ...] pairs. With a hash
14
+ # input the keys are the user-defined integers; with an array input
15
+ # they are the positional 0..N-1. Either way Array#assoc looks up
16
+ # by the stored value rather than treating it as a positional index.
13
17
  values = attribute_values(object, attribute)
14
- link_to_inline_edit object, attribute, values[object.send(attribute)][1], from_callee: __callee__
18
+ pair = values.assoc(object.send(attribute))
19
+ label = pair ? pair[1] : "<i class='fi-plus'></i>".html_safe
20
+ link_to_inline_edit object, attribute, label, from_callee: __callee__
15
21
  end
16
22
 
17
23
  def scale_with_values_edit(object, attribute)
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "8.1.5"
3
+ VERSION = "8.1.8"
4
4
  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.5
4
+ version: 8.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares