inline_forms 8.1.81 → 8.1.82
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 +10 -0
- data/app/controllers/concerns/suggestions_concern.rb +14 -2
- data/app/controllers/inline_forms_controller.rb +16 -3
- 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/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: 66264da26edac8ccbe7170cfecd08db737c71424e3e77ecb202f2f39c37855cc
|
|
4
|
+
data.tar.gz: 3ab7edbc038f8436ff4df5485295c898ac3fb2c20f19f818533764eeae9dcdc9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 783a5f5a19435702661f98d3a26ecbd2f8cec4c3fc44eac8d22e4b5220ef98b9a06adbf571935e269ea2d70698aca8989cbfd97324f8305c778de5bbc1de9f80
|
|
7
|
+
data.tar.gz: 3a285e6f772bf6f4525d1ec110707275f206c35099a4d5b34822839567cdd27a20fbd4e5a7e81effdae432ccc6ba543258d08551ca89f503ba4e7bf7d5b0cff7
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,16 @@ 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.82] - 2026-11-24
|
|
12
|
+
|
|
13
|
+
From a review of 8.1.78 to 8.1.81.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **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.
|
|
18
|
+
- **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 `[]`.
|
|
19
|
+
- **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.
|
|
20
|
+
|
|
11
21
|
## [8.1.81] - 2026-11-24
|
|
12
22
|
|
|
13
23
|
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)
|
|
@@ -59,8 +59,8 @@ class InlineFormsController < ApplicationController
|
|
|
59
59
|
if instance_variable_defined?(collection_ivar)
|
|
60
60
|
loaded = instance_variable_get(collection_ivar)
|
|
61
61
|
unless loaded.nil?
|
|
62
|
-
app_filtered = @objects.is_a?(ActiveRecord::Relation) && @objects.model
|
|
63
|
-
@objects = app_filtered ? @objects
|
|
62
|
+
app_filtered = @objects.is_a?(ActiveRecord::Relation) && @objects.model <= @Klass
|
|
63
|
+
@objects = app_filtered ? inline_forms_both(@objects, loaded) : loaded
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
@objects ||= @Klass.accessible_by(current_ability) if cancan_enabled?
|
|
@@ -780,6 +780,18 @@ class InlineFormsController < ApplicationController
|
|
|
780
780
|
]
|
|
781
781
|
end
|
|
782
782
|
|
|
783
|
+
# The records in both relations: the app's filter AND what the ability
|
|
784
|
+
# allows. Not `merge`: since Rails 7 a merged condition on the same column
|
|
785
|
+
# replaces the first (a group filter would give way to the ability's list
|
|
786
|
+
# of groups). `and` keeps both; when the two are not structurally
|
|
787
|
+
# compatible (different joins), an id subquery does.
|
|
788
|
+
def inline_forms_both(filtered, allowed)
|
|
789
|
+
filtered.and(allowed)
|
|
790
|
+
rescue ArgumentError
|
|
791
|
+
key = filtered.model.primary_key
|
|
792
|
+
filtered.where(key => allowed.unscope(:order, :select).select(key))
|
|
793
|
+
end
|
|
794
|
+
|
|
783
795
|
def associated_list_frame_layout
|
|
784
796
|
# A Turbo frame request gets the bare frame layout: Turbo takes only the
|
|
785
797
|
# matching <turbo-frame id="…"> from the answer, and the full layout would
|
|
@@ -800,7 +812,8 @@ class InlineFormsController < ApplicationController
|
|
|
800
812
|
return head(:not_found) unless options
|
|
801
813
|
|
|
802
814
|
render_inline_forms_suggestions InlineForms::Suggestions.values(
|
|
803
|
-
@objects, options[:on], params[:term],
|
|
815
|
+
@objects, inline_forms_readable_columns(@Klass, options[:on]), params[:term],
|
|
816
|
+
match: options[:match], limit: options[:limit]
|
|
804
817
|
)
|
|
805
818
|
end
|
|
806
819
|
|
|
@@ -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)
|
data/lib/inline_forms/version.rb
CHANGED