inline_forms 8.1.81 → 8.1.83
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 +20 -0
- data/app/controllers/concerns/suggestions_concern.rb +14 -2
- data/app/controllers/inline_forms_controller.rb +20 -3
- data/app/helpers/inline_forms_helper.rb +24 -2
- data/app/validators/is_curacao_phone_validator.rb +4 -0
- data/app/validators/is_email_address_validator.rb +4 -0
- data/app/validators/must_be_a_value_validator.rb +3 -0
- data/app/views/inline_forms/_versions_list.html.erb +1 -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: 3532bd1d698fa7928f3815b0ff11768480c683e5027b5da39370ba838a5cc4fe
|
|
4
|
+
data.tar.gz: 628c9cdd6dd4a1d9dff64de4fa1d3ca29df787cce9328a226c1b5d709fd5aa8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1cdaa160a5c5768328dc85a87efadbac34ad64fa57926c03caef798bbace22ddc573684fed74dccd6c93dd821e213862db86ca6a215a7a501cb7033a5e31a78
|
|
7
|
+
data.tar.gz: db9338b05cec3cd75d2d17b4a1286091c451d57ccbea02263571a0d6f674bbbb4352083f762b5b212381c29974caefdcf0bc2327447a909f7036a7cc786b301f
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,26 @@ All notable changes to this project are documented in this file.
|
|
|
8
8
|
|
|
9
9
|
- Known issues, parked (local note `stuff/2026-10-31-dropdown-rule-3-parked.md`) with dropdown order rule 3: `includes`, `group` or `select` in `inline_forms_list` make `dropdown` and `dropdown_with_other` raise while `/index` works, so 8.1.65's fix for a list order on a joined table holds only for `joins`, `left_joins` and `eager_load`; a has_many join gives duplicate options. Present since 8.1.60. No host's list scope has these today. Parked; not changed.
|
|
10
10
|
|
|
11
|
+
## [8.1.83] - 2026-11-24
|
|
12
|
+
|
|
13
|
+
From items 13-18 of the RACVS / yavetracker ladder prompt (`ladder/inline_forms-PROMPT-2026-11-24.md`).
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **The form-element helpers are no longer actions.** `InlineFormsController` includes every form-element helper (`text_field_show`, `…_edit`, `…_update`, …) for `assign_field`, and they were public, so they counted as actions (122 of the 177 in RACVS's `ClientsController.action_methods`). They are private in the controller now; views still get them, public, from `InlineFormsHelper`.
|
|
18
|
+
- **Restore stays in the versions panel when the versions table has no `object_changes` column.** Every changeset is empty there, and 7.13's rule "an update that changed nothing gets no Restore link" hid every Restore link (yavetracker kept an app copy of the partial for this). The rule now applies only when the column exists (`inline_forms_empty_changeset?`).
|
|
19
|
+
- **A value without a translation shows as itself.** `attribute_values` ran each label of a values list through `t()`, which in a view gives a `<span class="translation_missing">` for an untranslated value: shown with a tooltip and a capital in a row, and escaped into raw markup in a dropdown's options (`Ja">Ja</Span>` in yavetracker). An untranslated label is now the value itself (`inline_forms_value_label`); a translated one is unchanged, and numbers (a Range) are shown as they are. **Visible change:** an untranslated `"mid"` reads `mid`, no longer `Mid`.
|
|
20
|
+
|
|
21
|
+
## [8.1.82] - 2026-11-24
|
|
22
|
+
|
|
23
|
+
From a review of 8.1.78 to 8.1.81.
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- **An app's list filter on the ability's own column is kept.** 8.1.81 combined the app's `@objects` with CanCan's collection by `merge`, and since Rails 7 a merged condition on the same column replaces the first: with `can :read, Member, group_id: user.group_ids` an app's `where(group_id: 1)` gave way to `group_id IN (1, 2)`. The two are now combined with `and` (both conditions kept), or with an id subquery when they are not structurally compatible (an order or joins of the app's own). A filtered relation of an STI subclass of the list's model counts as the app's filter too.
|
|
28
|
+
- **Search suggestions only from columns the user may read.** The engine's search box (`suggest:`) and `suggest_names` checked only which records the user may see (`accessible_by`): a field rule such as `cannot :read, User, :email` (which the row's show honours) did not stop the e-mail addresses being suggested. A column the ability does not let the user read (`can?(:read, Model, :column)`) is now left out; with none left the answer is `[]`.
|
|
29
|
+
- **The three validators fixed in 8.1.81 leave a blank value alone.** `is_email_address` and `is_curacao_phone` skip a blank value, `must_be_a_value` skips nil and `""` (false and 0 are values), as Rails' own format validators leave blanks to `presence:`. Without this, an app whose optional e-mail or phone was empty could no longer save the record, since these validators were never declared with `allow_blank` while they did nothing.
|
|
30
|
+
|
|
11
31
|
## [8.1.81] - 2026-11-24
|
|
12
32
|
|
|
13
33
|
From the RACVS / yavetracker Rails ladder (`ladder/inline_forms-PROMPT-2026-11-24.md`).
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
# end
|
|
20
20
|
# can :autocomplete_client_last_name, Client
|
|
21
21
|
#
|
|
22
|
-
# Only names of records the user may read (`accessible_by`)
|
|
22
|
+
# Only names of records the user may read (`accessible_by`), and only from a
|
|
23
|
+
# column the user may read (`can?(:read, Model, :column)`), when CanCan is
|
|
23
24
|
# on; `scope:` narrows them further, run in the controller (instance_exec)
|
|
24
25
|
# with the relation, and returns a relation.
|
|
25
26
|
module SuggestionsConcern
|
|
@@ -33,7 +34,9 @@ module SuggestionsConcern
|
|
|
33
34
|
model = model_name.to_s.camelize.constantize
|
|
34
35
|
names = inline_forms_suggestion_scope(model)
|
|
35
36
|
names = instance_exec(names, &scope) if scope
|
|
36
|
-
render_inline_forms_suggestions InlineForms::Suggestions.values(
|
|
37
|
+
render_inline_forms_suggestions InlineForms::Suggestions.values(
|
|
38
|
+
names, inline_forms_readable_columns(model, [ column ]), params[:term], match: match, limit: limit
|
|
39
|
+
)
|
|
37
40
|
end
|
|
38
41
|
end
|
|
39
42
|
end
|
|
@@ -44,6 +47,15 @@ module SuggestionsConcern
|
|
|
44
47
|
cancan_enabled? ? model.accessible_by(current_ability) : model.all
|
|
45
48
|
end
|
|
46
49
|
|
|
50
|
+
# The columns whose values this user may read: `accessible_by` only picks
|
|
51
|
+
# the rows, and a field rule (`cannot :read, User, :email`, as _show asks
|
|
52
|
+
# with can?(:read, record, attribute)) must not leak through suggestions.
|
|
53
|
+
def inline_forms_readable_columns(model, columns)
|
|
54
|
+
return Array(columns) unless cancan_enabled?
|
|
55
|
+
|
|
56
|
+
Array(columns).select { |column| can?(:read, model, column.to_sym) }
|
|
57
|
+
end
|
|
58
|
+
|
|
47
59
|
# A JSON string, so a serializer gem (active_model_serializers 0.9) does
|
|
48
60
|
# not wrap the array.
|
|
49
61
|
def render_inline_forms_suggestions(values)
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
#
|
|
25
25
|
class InlineFormsController < ApplicationController
|
|
26
26
|
include InlineForms::FormElements::HelperIncludes
|
|
27
|
+
# The form-element helpers are here for assign_field (`send("#{element}_update")`),
|
|
28
|
+
# not as actions: private, so they stay out of action_methods (RACVS's
|
|
29
|
+
# ClientsController counted 122 of them). Views get them from InlineFormsHelper.
|
|
30
|
+
private(*InlineForms::FormElements.helper_modules.flat_map(&:public_instance_methods).uniq)
|
|
27
31
|
include CancanConcern
|
|
28
32
|
include VersionsConcern
|
|
29
33
|
include FileSlotsConcern
|
|
@@ -59,8 +63,8 @@ class InlineFormsController < ApplicationController
|
|
|
59
63
|
if instance_variable_defined?(collection_ivar)
|
|
60
64
|
loaded = instance_variable_get(collection_ivar)
|
|
61
65
|
unless loaded.nil?
|
|
62
|
-
app_filtered = @objects.is_a?(ActiveRecord::Relation) && @objects.model
|
|
63
|
-
@objects = app_filtered ? @objects
|
|
66
|
+
app_filtered = @objects.is_a?(ActiveRecord::Relation) && @objects.model <= @Klass
|
|
67
|
+
@objects = app_filtered ? inline_forms_both(@objects, loaded) : loaded
|
|
64
68
|
end
|
|
65
69
|
end
|
|
66
70
|
@objects ||= @Klass.accessible_by(current_ability) if cancan_enabled?
|
|
@@ -780,6 +784,18 @@ class InlineFormsController < ApplicationController
|
|
|
780
784
|
]
|
|
781
785
|
end
|
|
782
786
|
|
|
787
|
+
# The records in both relations: the app's filter AND what the ability
|
|
788
|
+
# allows. Not `merge`: since Rails 7 a merged condition on the same column
|
|
789
|
+
# replaces the first (a group filter would give way to the ability's list
|
|
790
|
+
# of groups). `and` keeps both; when the two are not structurally
|
|
791
|
+
# compatible (different joins), an id subquery does.
|
|
792
|
+
def inline_forms_both(filtered, allowed)
|
|
793
|
+
filtered.and(allowed)
|
|
794
|
+
rescue ArgumentError
|
|
795
|
+
key = filtered.model.primary_key
|
|
796
|
+
filtered.where(key => allowed.unscope(:order, :select).select(key))
|
|
797
|
+
end
|
|
798
|
+
|
|
783
799
|
def associated_list_frame_layout
|
|
784
800
|
# A Turbo frame request gets the bare frame layout: Turbo takes only the
|
|
785
801
|
# matching <turbo-frame id="…"> from the answer, and the full layout would
|
|
@@ -800,7 +816,8 @@ class InlineFormsController < ApplicationController
|
|
|
800
816
|
return head(:not_found) unless options
|
|
801
817
|
|
|
802
818
|
render_inline_forms_suggestions InlineForms::Suggestions.values(
|
|
803
|
-
@objects, options[:on], params[:term],
|
|
819
|
+
@objects, inline_forms_readable_columns(@Klass, options[:on]), params[:term],
|
|
820
|
+
match: options[:match], limit: options[:limit]
|
|
804
821
|
)
|
|
805
822
|
end
|
|
806
823
|
|
|
@@ -354,6 +354,17 @@ module InlineFormsHelper
|
|
|
354
354
|
#
|
|
355
355
|
# or a Range
|
|
356
356
|
#
|
|
357
|
+
# A value of a values list as the user sees it: its translation, or the
|
|
358
|
+
# value itself when there is none. A bare t(value) gave the view helper's
|
|
359
|
+
# <span class="translation_missing"> for an untranslated value ("Ja" in
|
|
360
|
+
# yavetracker), which a select option or a link escaped into raw markup.
|
|
361
|
+
# Numbers (a Range's values) are shown as they are.
|
|
362
|
+
def inline_forms_value_label(value)
|
|
363
|
+
return value unless value.is_a?(String) || value.is_a?(Symbol)
|
|
364
|
+
|
|
365
|
+
t(value, default: value.to_s)
|
|
366
|
+
end
|
|
367
|
+
|
|
357
368
|
def attribute_values(object, attribute)
|
|
358
369
|
# if we have a range 1..6 will result in [[0,1],[1,2],[2,3],...,[5,6]]
|
|
359
370
|
# or range -3..3 will result in [[0,-3],[1,-2],[2,-1],...,[6,3]]
|
|
@@ -391,13 +402,13 @@ module InlineFormsHelper
|
|
|
391
402
|
if values.is_a?(Hash)
|
|
392
403
|
temp = Array.new
|
|
393
404
|
values.to_a.each do |k, v|
|
|
394
|
-
temp << [ k,
|
|
405
|
+
temp << [ k, inline_forms_value_label(v) ]
|
|
395
406
|
end
|
|
396
407
|
values = temp.sort { |a, b| a[0]<=>b[0] }
|
|
397
408
|
else
|
|
398
409
|
temp = Array.new
|
|
399
410
|
values.to_a.each_index do |i|
|
|
400
|
-
temp << [ i,
|
|
411
|
+
temp << [ i, inline_forms_value_label(values.to_a[i]) ]
|
|
401
412
|
end
|
|
402
413
|
values = temp.sort { |a, b| a[1]<=>b[1] }
|
|
403
414
|
end
|
|
@@ -436,6 +447,17 @@ module InlineFormsHelper
|
|
|
436
447
|
InlineForms.application_title
|
|
437
448
|
end
|
|
438
449
|
|
|
450
|
+
# An update version that changed nothing (a `touch`, a callback): the
|
|
451
|
+
# versions panel hides its Restore link. Only when the versions table
|
|
452
|
+
# records changes at all: without an object_changes column every changeset
|
|
453
|
+
# is empty, and Restore (which reifies `object`) must stay.
|
|
454
|
+
def inline_forms_empty_changeset?(version)
|
|
455
|
+
columns = version.class.try(:column_names)
|
|
456
|
+
return false if columns && !columns.include?("object_changes")
|
|
457
|
+
|
|
458
|
+
version.changeset.nil? || version.changeset.except("updated_at").empty?
|
|
459
|
+
end
|
|
460
|
+
|
|
439
461
|
def version_modified_by(id)
|
|
440
462
|
return "Unknown" if id.blank?
|
|
441
463
|
|
|
@@ -14,7 +14,11 @@ class IsCuracaoPhoneValidator < ActiveModel::EachValidator
|
|
|
14
14
|
"Telefoonnummer moet 7 cijfers zijn, bijvoorbeeld 6781256."
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# A blank value is left to `presence:` (the validator says what a filled-in
|
|
18
|
+
# value must look like).
|
|
17
19
|
def validate_each(record, attribute, value)
|
|
20
|
+
return if value.blank?
|
|
21
|
+
|
|
18
22
|
unless value =~ /[4-8][0-9]{6}/
|
|
19
23
|
record.errors.add(attribute, options[:message] || error_message)
|
|
20
24
|
end
|
|
@@ -27,7 +27,11 @@ class IsEmailAddressValidator < ActiveModel::EachValidator
|
|
|
27
27
|
"is not a valid email address."
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
# A blank value is left to `presence:` (the validator says what a filled-in
|
|
31
|
+
# value must look like).
|
|
30
32
|
def validate_each(record, attribute, value)
|
|
33
|
+
return if value.blank?
|
|
34
|
+
|
|
31
35
|
unless value =~ EmailAddress
|
|
32
36
|
record.errors.add(attribute, options[:message] || error_message)
|
|
33
37
|
end
|
|
@@ -13,7 +13,10 @@ class MustBeAValueValidator < ActiveModel::EachValidator
|
|
|
13
13
|
def help_message
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
# No value (nil or "") is left to `presence:`; false and 0 are values.
|
|
16
17
|
def validate_each(record, attribute, value)
|
|
18
|
+
return if value.nil? || value == ""
|
|
19
|
+
|
|
17
20
|
values = attribute_values(record, attribute)
|
|
18
21
|
if values.assoc(value).nil?
|
|
19
22
|
record.errors.add(attribute, options[:message] || error_message)
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
link is hidden here so the action is never offered. -%>
|
|
83
83
|
<% if version.event == "create" && entry[:kind] != :rich_text %>
|
|
84
84
|
|
|
85
|
-
<% elsif
|
|
85
|
+
<% elsif inline_forms_empty_changeset?(version) %>
|
|
86
86
|
|
|
87
87
|
<% else %>
|
|
88
88
|
<% row_id = inline_forms_row_turbo_frame_id(@object) %>
|
data/lib/inline_forms/version.rb
CHANGED