inline_forms 8.1.6 → 8.1.9
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 +4 -4
- data/CHANGELOG.md +62 -0
- data/app/views/inline_forms/_versions.html.erb +6 -1
- data/lib/inline_forms/form_elements/dropdown_with_integers_helper.rb +7 -1
- data/lib/inline_forms/form_elements/dropdown_with_values_helper.rb +16 -2
- data/lib/inline_forms/form_elements/money_field_helper.rb +20 -3
- data/lib/inline_forms/form_elements/month_year_picker_helper.rb +4 -4
- data/lib/inline_forms/form_elements/scale_with_integers_helper.rb +6 -1
- data/lib/inline_forms/form_elements/scale_with_values_helper.rb +7 -1
- data/lib/inline_forms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bba19f36ffc279e71b2fe0c0fa9a8ec9501424f5fddab372d50941c1e4905dc3
|
|
4
|
+
data.tar.gz: 6a0473bcf4539bddf580dabaae2a5ecfc9decc36c0e691cd63aa79a3127a8478
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f33889510601ad516280f0727f73a2e33a023d82cae3bf0bf28f46747ecb3e0a53f4b89554b5c016fd04657ecab69bdf171091e252e2efd3abaaa274166f4fe
|
|
7
|
+
data.tar.gz: 3c452681ce7d64bcf4d5716e1e41c2ad4d9d830e6a68cdd2a294d256b20308703d73811ef514f7940b634794cf4521dd18cdd4ee9e8e9e68613692129ca0691b
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,68 @@ All notable changes to this project are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [8.1.9] - 2026-05-27
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **`dropdown_with_values_show` and `dropdown_with_values_info` double-translated their labels.** `attribute_values` already runs each label through `t()` (it has to, so the values hash can use translation keys). The two show/info helpers then ran `t()` again on the *already-translated* string, so a missing translation rendered a bizarre `<span class="translation_missing" title="Low">Low</Span>">Low">Low</Span></span>` blob inside the inline-edit link (visible on `priority` / `priority2` in the showcase). The second `t()` call has been removed and the helpers now nil-guard the lookup, matching the 8.1.7 fixes to `dropdown_with_integers_show` and the two scale helpers.
|
|
12
|
+
- **`money_field_show` dropped cents on whole-dollar amounts.** money-rails defaults `humanized_money_with_symbol` to `no_cents_if_whole: true`, so `Money.from_amount(124.00, "USD")` rendered as `$124` while `Money.from_amount(12.34, "USD")` rendered as `$12.34` — inconsistent, and indistinguishable from a precision bug on values that *rounded* to a whole dollar (e.g. `Money.from_amount(123.999, "USD")` rounds up to 12400 cents because cents are the smallest Money unit; the helper now shows that as `$124.00`). The helper now passes `no_cents_if_whole: false` so the displayed amount always has two decimals.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **`FormElementShowcase` now demos `[:locales, :check_list]` + `[:locales_display, :info_list]` instead of `[:roles, :info_list]`.** Role is reserved for the auth Member/User model — reusing it on the showcase coincidentally shared rows with `roles_users` and obscured how the demo associations were coupled. The example app now seeds four locales (`en`/`nl`/`de`/`fr`, English is the default attached to the full demo) and a `has_and_belongs_to_many :locales` join, so the showcase exercises the editable HABTM editor (`check_list`) and the read-only mirror (`info_list`) side-by-side. The read-only row uses `alias_method :locales_display, :locales` because inline_forms keys turbo frames by attribute name, so two rows for the same association need two distinct names.
|
|
17
|
+
- **`start_month` label renamed to "Start month and year".** The widget is a month_year_picker; the old label hid the year half.
|
|
18
|
+
- **Full-demo seed now populates `attachment` / `jingle` / `cover`.** The installer ships `sample.txt`, `sample.wav` (440Hz / 0.5s mono PCM, generated with ffmpeg), and `sample_cover.png` under `lib/installer_templates/example_app_assets`, copies them into the generated app's `db/seed_uploads/`, and the seed migration hands File handles to CarrierWave so the three file-upload rows in the full demo render thumbnails / links instead of placeholders.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **`ExampleAppShowcaseLocalesAssociationsTest` integration test.** Covers `check_list` toggling the HABTM (`locale_ids` add + remove via two PUTs), `info_list` rendering the `_presentation` for attached records, and the `--` empty-state placeholder. Replaces the dropped `roles`-based assertions in `ExampleAppShowcasePageRenderTest`.
|
|
23
|
+
|
|
24
|
+
### Lockstep
|
|
25
|
+
|
|
26
|
+
- `inline_forms`, `inline_forms_installer`, and `validation_hints` bumped from 8.1.8 to 8.1.9 in lockstep, even though `validation_hints` has no behavior change in this release.
|
|
27
|
+
|
|
28
|
+
## [8.1.8] - 2026-05-27
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- **`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:
|
|
33
|
+
- **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.
|
|
34
|
+
- **`config/initializers/money.rb` generated** with `MoneyRails.configure { default_currency = :usd }` so the showcase renders predictably under any host locale.
|
|
35
|
+
- **`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`.
|
|
36
|
+
- **`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).
|
|
37
|
+
- **Showcase regression tests cover the three re-added fields.**
|
|
38
|
+
- `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).
|
|
39
|
+
- `scale_with_integers` and `scale_with_values` get round-trip integration tests structurally identical to the dropdown helper tests.
|
|
40
|
+
- `EXPECTED_ATTRIBUTES` (model test) and `SHOWCASE_FIELD_ATTRIBUTES` (page-render test) updated to require all three frames to render on `/form_element_showcases/:id`.
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- **`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.
|
|
45
|
+
|
|
46
|
+
### Lockstep
|
|
47
|
+
|
|
48
|
+
- `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.
|
|
49
|
+
|
|
50
|
+
## [8.1.7] - 2026-05-27
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- **`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:
|
|
55
|
+
- `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"`).
|
|
56
|
+
- `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`.
|
|
57
|
+
- `scale_with_values_show` had the same positional-index bug as `dropdown_with_integers_show` and crashed identically on out-of-range integers.
|
|
58
|
+
|
|
59
|
+
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.
|
|
60
|
+
|
|
61
|
+
- **`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.
|
|
62
|
+
|
|
63
|
+
- **`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.
|
|
64
|
+
|
|
65
|
+
### Lockstep
|
|
66
|
+
|
|
67
|
+
- `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.
|
|
68
|
+
|
|
7
69
|
## [8.1.6] - 2026-05-27
|
|
8
70
|
|
|
9
71
|
### Added
|
|
@@ -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.
|
|
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
|
-
|
|
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)
|
|
@@ -7,8 +7,19 @@ module InlineForms
|
|
|
7
7
|
|
|
8
8
|
# dropdown_with_values
|
|
9
9
|
def dropdown_with_values_show(object, attribute)
|
|
10
|
+
# `attribute_values` already runs every label through `t()` (see
|
|
11
|
+
# InlineForms::Helpers#attribute_values). Calling `t()` again here on
|
|
12
|
+
# an already-translated (and possibly already-rendered as
|
|
13
|
+
# `<span class="translation_missing">...</span>`) string used the
|
|
14
|
+
# whole string as an I18n key, so a missing translation rendered the
|
|
15
|
+
# bizarre `<span class="translation_missing" title="Low">Low</Span>">…</span>`
|
|
16
|
+
# blob the user spotted on `priority`/`priority2`. Use the already-
|
|
17
|
+
# translated value as-is and fall back to the empty-state placeholder
|
|
18
|
+
# for nil (mirrors radio_button_show and the 8.1.7 scale fixes).
|
|
10
19
|
values = attribute_values(object, attribute)
|
|
11
|
-
|
|
20
|
+
pair = object.send(attribute) ? values.assoc(object.send(attribute)) : nil
|
|
21
|
+
label = pair ? pair[1] : "<i class='fi-plus'></i>".html_safe
|
|
22
|
+
link_to_inline_edit object, attribute, label, from_callee: __callee__
|
|
12
23
|
end
|
|
13
24
|
|
|
14
25
|
def dropdown_with_values_edit(object, attribute)
|
|
@@ -31,8 +42,11 @@ module InlineForms
|
|
|
31
42
|
end
|
|
32
43
|
|
|
33
44
|
def dropdown_with_values_info(object, attribute)
|
|
45
|
+
# `attribute_values` already translates; do not double-translate here
|
|
46
|
+
# (was the same double-`t()` bug as dropdown_with_values_show).
|
|
34
47
|
values = attribute_values(object, attribute)
|
|
35
|
-
|
|
48
|
+
pair = values.assoc(object.send(attribute))
|
|
49
|
+
pair ? pair[1] : '-'
|
|
36
50
|
end
|
|
37
51
|
INLINE_FORMS_FORM_ELEMENT
|
|
38
52
|
end
|
|
@@ -6,13 +6,30 @@ module InlineForms
|
|
|
6
6
|
# -*- encoding : utf-8 -*-
|
|
7
7
|
|
|
8
8
|
def money_field_show(object, attribute)
|
|
9
|
-
|
|
9
|
+
# Two money-rails-specific quirks the bare helper used to leak:
|
|
10
|
+
# 1. `humanized_money_with_symbol(nil)` returns "", which renders
|
|
11
|
+
# as an empty `<a>` tag. Fall back to the empty-state
|
|
12
|
+
# placeholder used by the other choice helpers instead.
|
|
13
|
+
# 2. `humanized_money_with_symbol` defaults `no_cents_if_whole: true`,
|
|
14
|
+
# so whole-dollar amounts show without cents ("$124" instead of
|
|
15
|
+
# "$124.00"). That's inconsistent with non-whole amounts ("$12.34")
|
|
16
|
+
# and looks like a precision bug on values that rounded up to a
|
|
17
|
+
# whole dollar (e.g. `Money.from_amount(123.999, "USD")` rounds
|
|
18
|
+
# to 12400 cents → "$124" by default; "$124.00" with the override).
|
|
19
|
+
# Always show cents.
|
|
20
|
+
value = object.send(attribute)
|
|
21
|
+
label = if value.blank?
|
|
22
|
+
"<i class='fi-plus'></i>".html_safe
|
|
23
|
+
else
|
|
24
|
+
humanized_money_with_symbol(value, no_cents_if_whole: false)
|
|
25
|
+
end
|
|
26
|
+
link_to_inline_edit object, attribute, label, from_callee: __callee__
|
|
10
27
|
end
|
|
11
|
-
|
|
28
|
+
|
|
12
29
|
def money_field_edit(object, attribute)
|
|
13
30
|
text_field_tag attribute, (object.send attribute), :class => 'input_money_field'
|
|
14
31
|
end
|
|
15
|
-
|
|
32
|
+
|
|
16
33
|
def money_field_update(object, attribute)
|
|
17
34
|
object.send( "#{attribute}=", params[attribute])
|
|
18
35
|
end
|
|
@@ -16,10 +16,10 @@ module InlineForms
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def month_year_picker_update(object, attribute)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
data/lib/inline_forms/version.rb
CHANGED