inline_forms 8.1.18 → 8.1.19
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fb00bfea980d5563c8c6efdccfec5f570bf143487d0d25ddb790d38e8bb1e5a6
|
|
4
|
+
data.tar.gz: d843e74f5c4677993a8bc82454adb48db73477f3182dffe56dd0b9a389263258
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b3864e91f61f48eeb3d6914c2f5651dec600ab4de3aeff91ee3bcbc4fa685603cfce59429d4baa7169d761d9e052891e03b8f6b070e693929a7c2638ecd1b70f
|
|
7
|
+
data.tar.gz: d279266cd6030c0464f2db416b4d50da554b539fc8382e77e78c75633d159057b42b7c7d81e671bfe884f598b1180816fca4af79d4e7d69bd6aa0e899ec41794
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ All notable changes to this project are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [8.1.19] - 2026-05-28
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Inline attribute `update` no longer renders a fake success on a failed save.** `InlineFormsController#update` called `@object.save` but ignored its return value, then unconditionally re-rendered `field_show` from the in-memory `@object`. When the save failed validation the user saw a "show" of the unsaved in-memory value while the DB row kept its old value — re-opening the edit surprised the user with the old value. `update` now branches on `@object.save`: on success it renders the show as before; on failure it re-renders the **edit** field (mirroring how `create` handles a failed save) with the validation errors in `flash.now[:error]`, so the user stays in the editor and can correct the input. This is a general fix affecting every form element, not just `money_field`.
|
|
12
|
+
- **`money_field` malformed input regression.** money-rails rejects an unparseable amount such as `"99.ace99"` (the monetized validator fails, so `save` returns false and `amount_cents` is never written). Previously the inline edit showed a "saved" `$99.99` show that did not reflect the database. Now the edit field is re-rendered, and `money_field_edit` prefers the raw submitted `params[attribute]` over `object.send(attribute)` so the rejected input stays visible and editable instead of silently reverting.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **Regression test:** `example_app_showcase_money_update_test.rb` POSTs a malformed `amount: "99.ace99"` inline update for the seeded `$99.95` "Full demo" `FormElementShowcase` and asserts the DB value is unchanged (`amount_cents == 9995`) and the response is the edit/error state (not a fake `$99.99` show), plus a positive path asserting a valid `"12.34"` persists (`amount_cents == 1234`) and renders the show.
|
|
17
|
+
|
|
7
18
|
## [8.1.18] - 2026-05-28
|
|
8
19
|
|
|
9
20
|
### Fixed
|
|
@@ -181,9 +181,25 @@ class InlineFormsController < ApplicationController
|
|
|
181
181
|
@update_span = params[:update]
|
|
182
182
|
InlineForms.assert_plain_text_column!(object: @object, attribute: @attribute, form_element: @form_element)
|
|
183
183
|
send("#{@form_element.to_s}_update", @object, @attribute)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
# Branch on the actual save result. Previously the return value of
|
|
185
|
+
# `@object.save` was ignored and `field_show` was rendered
|
|
186
|
+
# unconditionally from the in-memory `@object`. When a save failed
|
|
187
|
+
# validation (e.g. money-rails rejecting an unparseable amount, or any
|
|
188
|
+
# `validates` failure) the user saw a "show" of the unsaved in-memory
|
|
189
|
+
# value -- a fake success -- while the DB row kept its old value. A
|
|
190
|
+
# subsequent edit then re-read the old value, surprising the user.
|
|
191
|
+
#
|
|
192
|
+
# On failure we keep the user in the edit field with their rejected
|
|
193
|
+
# input visible and surface the validation errors (mirrors `create`).
|
|
194
|
+
if @object.save
|
|
195
|
+
respond_to do |format|
|
|
196
|
+
format.html { render_turbo_field(:field_show, turbo_field_show: true) }
|
|
197
|
+
end
|
|
198
|
+
else
|
|
199
|
+
flash.now[:error] = @object.errors.to_a
|
|
200
|
+
respond_to do |format|
|
|
201
|
+
format.html { render_turbo_field(:field_edit) }
|
|
202
|
+
end
|
|
187
203
|
end
|
|
188
204
|
end
|
|
189
205
|
|
|
@@ -27,7 +27,15 @@ module InlineForms
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def money_field_edit(object, attribute)
|
|
30
|
-
|
|
30
|
+
# On a fresh edit there is no submitted value, so fall back to the
|
|
31
|
+
# current Money value. On a re-render after a *failed* update
|
|
32
|
+
# (money-rails could not parse the input) `object.send(attribute)`
|
|
33
|
+
# no longer reflects what the user typed -- it returns the old/last
|
|
34
|
+
# parsed value -- so the user would silently lose their rejected
|
|
35
|
+
# input. Prefer the raw submitted `params[attribute]` so the bad
|
|
36
|
+
# value stays visible and editable.
|
|
37
|
+
value = params[attribute].presence || (object.send attribute)
|
|
38
|
+
text_field_tag attribute, value, :class => 'input_money_field'
|
|
31
39
|
end
|
|
32
40
|
|
|
33
41
|
def money_field_update(object, attribute)
|
data/lib/inline_forms/version.rb
CHANGED