phlexi-form 0.14.2 → 0.14.4
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 +19 -0
- data/gemfiles/default.gemfile.lock +21 -15
- data/gemfiles/rails_7.gemfile.lock +35 -16
- data/lib/phlexi/form/components/checkbox.rb +9 -1
- data/lib/phlexi/form/components/input.rb +1 -0
- data/lib/phlexi/form/options/errors.rb +34 -2
- data/lib/phlexi/form/structure/namespace_collection.rb +1 -1
- data/lib/phlexi/form/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b2b5a56ff16834553f8f99764902656bef82869bedb49ccd2ee62c3f9a2bb074
|
|
4
|
+
data.tar.gz: ad2a47b6317b7f12278e5c74ece5f3056a8f18b458bdc1fd5210f3e8b458d453
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e6c0e4adf1cce96a7d8b744bc1f0e965725aca7f3e9ff35aabecb0984a8dfe12e829eee7407d6204c46c9e2bc9465b1b97e42b1b0ac5a416ba4a3fb6bc7d81a7
|
|
7
|
+
data.tar.gz: 17435e4ed5c77af281100a14d54082787a32c33059b4d588d086b022cfd042abf1c8d9158e78a2490bb08385592005d6d16a73f2801a8664bf02b22e0e9e1b2d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.14.4]
|
|
4
|
+
|
|
5
|
+
- A field's full error now names the attribute by the field's own label when it
|
|
6
|
+
is given one (`field(:oidc_issuer, label: "Issuer URL")`), so the message
|
|
7
|
+
under the field matches the label above it. Fields without a label, or with
|
|
8
|
+
`label: false`, keep ActiveModel's `human_attribute_name`. Per-model and
|
|
9
|
+
per-attribute `format` overrides still apply.
|
|
10
|
+
- `input_tag` on a field inferred as `:string` now renders a text input with the
|
|
11
|
+
usual text attributes, instead of falling through to the unhandled-type branch.
|
|
12
|
+
- Fix extracting input from an empty nested collection (`nest_many`), which
|
|
13
|
+
passed `nil` to the block.
|
|
14
|
+
|
|
15
|
+
## [0.14.3]
|
|
16
|
+
|
|
17
|
+
- Fix `Checkbox#checked?` so boolean-ish values from JSON/text columns or params
|
|
18
|
+
(`"f"`, `"F"`, `"FALSE"`, `"off"`, `"OFF"`, `0`, `:false`, ...) render unchecked.
|
|
19
|
+
The recognised falsey set now mirrors Rails' `ActiveModel::Type::Boolean::FALSE_VALUES`
|
|
20
|
+
instead of only `""`, `"0"` and lowercase `"false"`.
|
|
21
|
+
|
|
3
22
|
## [0.2.0] - 2024-07-31
|
|
4
23
|
|
|
5
24
|
- Initial release
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ..
|
|
3
3
|
specs:
|
|
4
|
-
phlexi-form (0.
|
|
4
|
+
phlexi-form (0.14.3)
|
|
5
5
|
activesupport
|
|
6
|
-
phlex (~>
|
|
7
|
-
phlexi-field
|
|
6
|
+
phlex (~> 2.0)
|
|
7
|
+
phlexi-field (~> 0.2.0)
|
|
8
8
|
zeitwerk
|
|
9
9
|
|
|
10
10
|
GEM
|
|
@@ -27,6 +27,8 @@ GEM
|
|
|
27
27
|
erubi (~> 1.11)
|
|
28
28
|
rails-dom-testing (~> 2.2)
|
|
29
29
|
rails-html-sanitizer (~> 1.6)
|
|
30
|
+
activemodel (7.2.1)
|
|
31
|
+
activesupport (= 7.2.1)
|
|
30
32
|
activesupport (7.2.1)
|
|
31
33
|
base64
|
|
32
34
|
bigdecimal
|
|
@@ -38,8 +40,8 @@ GEM
|
|
|
38
40
|
minitest (>= 5.1)
|
|
39
41
|
securerandom (>= 0.3)
|
|
40
42
|
tzinfo (~> 2.0, >= 2.0.5)
|
|
41
|
-
addressable (2.
|
|
42
|
-
public_suffix (>= 2.0.2, <
|
|
43
|
+
addressable (2.9.0)
|
|
44
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
43
45
|
ansi (1.5.0)
|
|
44
46
|
appraisal (2.5.0)
|
|
45
47
|
bundler
|
|
@@ -104,18 +106,18 @@ GEM
|
|
|
104
106
|
parser (3.3.5.0)
|
|
105
107
|
ast (~> 2.4.1)
|
|
106
108
|
racc
|
|
107
|
-
phlex (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
activesupport
|
|
109
|
+
phlex (2.4.1)
|
|
110
|
+
refract (~> 1.0)
|
|
111
|
+
zeitwerk (~> 2.7)
|
|
112
|
+
phlexi-field (0.2.0)
|
|
113
|
+
activesupport (>= 7.1)
|
|
113
114
|
fiber-local
|
|
114
|
-
phlex (~>
|
|
115
|
+
phlex (~> 2.0)
|
|
115
116
|
zeitwerk
|
|
117
|
+
prism (1.9.0)
|
|
116
118
|
psych (5.1.2)
|
|
117
119
|
stringio
|
|
118
|
-
public_suffix (
|
|
120
|
+
public_suffix (7.0.5)
|
|
119
121
|
racc (1.8.1)
|
|
120
122
|
rack (3.1.7)
|
|
121
123
|
rack-session (2.0.0)
|
|
@@ -144,6 +146,9 @@ GEM
|
|
|
144
146
|
rake (13.2.1)
|
|
145
147
|
rdoc (6.7.0)
|
|
146
148
|
psych (>= 4.0.0)
|
|
149
|
+
refract (1.1.0)
|
|
150
|
+
prism
|
|
151
|
+
zeitwerk
|
|
147
152
|
regexp_parser (2.9.2)
|
|
148
153
|
reline (0.5.10)
|
|
149
154
|
io-console (~> 0.5)
|
|
@@ -187,19 +192,20 @@ GEM
|
|
|
187
192
|
webrick (1.8.1)
|
|
188
193
|
xpath (3.2.0)
|
|
189
194
|
nokogiri (~> 1.8)
|
|
190
|
-
zeitwerk (2.
|
|
195
|
+
zeitwerk (2.8.3)
|
|
191
196
|
|
|
192
197
|
PLATFORMS
|
|
193
198
|
arm64-darwin-24
|
|
194
199
|
x86_64-darwin
|
|
195
200
|
|
|
196
201
|
DEPENDENCIES
|
|
202
|
+
activemodel
|
|
197
203
|
appraisal
|
|
198
204
|
bundle-audit
|
|
205
|
+
capybara
|
|
199
206
|
combustion
|
|
200
207
|
minitest
|
|
201
208
|
minitest-reporters
|
|
202
|
-
phlex-testing-capybara
|
|
203
209
|
phlexi-form!
|
|
204
210
|
rake
|
|
205
211
|
standard
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ..
|
|
3
3
|
specs:
|
|
4
|
-
phlexi-form (0.3
|
|
4
|
+
phlexi-form (0.14.3)
|
|
5
5
|
activesupport
|
|
6
|
-
phlex (~>
|
|
6
|
+
phlex (~> 2.0)
|
|
7
|
+
phlexi-field (~> 0.2.0)
|
|
7
8
|
zeitwerk
|
|
8
9
|
|
|
9
10
|
GEM
|
|
@@ -91,8 +92,8 @@ GEM
|
|
|
91
92
|
rake
|
|
92
93
|
thor (>= 0.14.0)
|
|
93
94
|
ast (2.4.2)
|
|
94
|
-
base64 (0.
|
|
95
|
-
bigdecimal (
|
|
95
|
+
base64 (0.3.0)
|
|
96
|
+
bigdecimal (4.1.3)
|
|
96
97
|
builder (3.3.0)
|
|
97
98
|
bundle-audit (0.1.0)
|
|
98
99
|
bundler-audit
|
|
@@ -112,15 +113,18 @@ GEM
|
|
|
112
113
|
activesupport (>= 3.0.0)
|
|
113
114
|
railties (>= 3.0.0)
|
|
114
115
|
thor (>= 0.14.6)
|
|
115
|
-
concurrent-ruby (1.3.
|
|
116
|
-
connection_pool (
|
|
116
|
+
concurrent-ruby (1.3.8)
|
|
117
|
+
connection_pool (3.0.2)
|
|
117
118
|
crass (1.0.6)
|
|
118
119
|
date (3.3.4)
|
|
119
|
-
drb (2.2.
|
|
120
|
+
drb (2.2.3)
|
|
120
121
|
erubi (1.13.0)
|
|
122
|
+
fiber-local (1.1.0)
|
|
123
|
+
fiber-storage
|
|
124
|
+
fiber-storage (1.0.1)
|
|
121
125
|
globalid (1.2.1)
|
|
122
126
|
activesupport (>= 6.1)
|
|
123
|
-
i18n (1.
|
|
127
|
+
i18n (1.15.2)
|
|
124
128
|
concurrent-ruby (~> 1.0)
|
|
125
129
|
io-console (0.7.2)
|
|
126
130
|
irb (1.14.0)
|
|
@@ -140,13 +144,15 @@ GEM
|
|
|
140
144
|
marcel (1.0.4)
|
|
141
145
|
matrix (0.4.2)
|
|
142
146
|
mini_mime (1.1.5)
|
|
143
|
-
minitest (
|
|
147
|
+
minitest (6.0.6)
|
|
148
|
+
drb (~> 2.0)
|
|
149
|
+
prism (~> 1.5)
|
|
144
150
|
minitest-reporters (1.7.1)
|
|
145
151
|
ansi
|
|
146
152
|
builder
|
|
147
153
|
minitest (>= 5.0)
|
|
148
154
|
ruby-progressbar
|
|
149
|
-
mutex_m (0.
|
|
155
|
+
mutex_m (0.3.0)
|
|
150
156
|
net-imap (0.4.16)
|
|
151
157
|
date
|
|
152
158
|
net-protocol
|
|
@@ -157,16 +163,23 @@ GEM
|
|
|
157
163
|
net-smtp (0.5.0)
|
|
158
164
|
net-protocol
|
|
159
165
|
nio4r (2.7.3)
|
|
166
|
+
nokogiri (1.16.7-arm64-darwin)
|
|
167
|
+
racc (~> 1.4)
|
|
160
168
|
nokogiri (1.16.7-x86_64-darwin)
|
|
161
169
|
racc (~> 1.4)
|
|
162
170
|
parallel (1.26.3)
|
|
163
171
|
parser (3.3.5.0)
|
|
164
172
|
ast (~> 2.4.1)
|
|
165
173
|
racc
|
|
166
|
-
phlex (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
phlex (2.4.1)
|
|
175
|
+
refract (~> 1.0)
|
|
176
|
+
zeitwerk (~> 2.7)
|
|
177
|
+
phlexi-field (0.2.0)
|
|
178
|
+
activesupport (>= 7.1)
|
|
179
|
+
fiber-local
|
|
180
|
+
phlex (~> 2.0)
|
|
181
|
+
zeitwerk
|
|
182
|
+
prism (1.9.0)
|
|
170
183
|
psych (5.1.2)
|
|
171
184
|
stringio
|
|
172
185
|
public_suffix (6.0.1)
|
|
@@ -212,6 +225,9 @@ GEM
|
|
|
212
225
|
rake (13.2.1)
|
|
213
226
|
rdoc (6.7.0)
|
|
214
227
|
psych (>= 4.0.0)
|
|
228
|
+
refract (1.1.0)
|
|
229
|
+
prism
|
|
230
|
+
zeitwerk
|
|
215
231
|
regexp_parser (2.9.2)
|
|
216
232
|
reline (0.5.10)
|
|
217
233
|
io-console (~> 0.5)
|
|
@@ -233,6 +249,7 @@ GEM
|
|
|
233
249
|
rubocop (>= 1.48.1, < 2.0)
|
|
234
250
|
rubocop-ast (>= 1.31.1, < 2.0)
|
|
235
251
|
ruby-progressbar (1.13.0)
|
|
252
|
+
sqlite3 (1.7.3-arm64-darwin)
|
|
236
253
|
sqlite3 (1.7.3-x86_64-darwin)
|
|
237
254
|
standard (1.40.0)
|
|
238
255
|
language_server-protocol (~> 3.17.0.2)
|
|
@@ -258,18 +275,20 @@ GEM
|
|
|
258
275
|
websocket-extensions (0.1.5)
|
|
259
276
|
xpath (3.2.0)
|
|
260
277
|
nokogiri (~> 1.8)
|
|
261
|
-
zeitwerk (2.
|
|
278
|
+
zeitwerk (2.8.3)
|
|
262
279
|
|
|
263
280
|
PLATFORMS
|
|
281
|
+
arm64-darwin-24
|
|
264
282
|
x86_64-darwin
|
|
265
283
|
|
|
266
284
|
DEPENDENCIES
|
|
285
|
+
activemodel
|
|
267
286
|
appraisal
|
|
268
287
|
bundle-audit
|
|
288
|
+
capybara
|
|
269
289
|
combustion
|
|
270
290
|
minitest
|
|
271
291
|
minitest-reporters
|
|
272
|
-
phlex-testing-capybara
|
|
273
292
|
phlexi-form!
|
|
274
293
|
rails (~> 7.1.3, >= 7.1.3.4)
|
|
275
294
|
rake
|
|
@@ -27,12 +27,20 @@ module Phlexi
|
|
|
27
27
|
@include_hidden != false
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
# Stringified form of Rails' ActiveModel::Type::Boolean::FALSE_VALUES.
|
|
31
|
+
# Kept as a literal set (rather than depending on activemodel) so a
|
|
32
|
+
# boolean-ish value from a JSON/text column or params — "f", "F",
|
|
33
|
+
# "FALSE", "off", 0, :false, ... — is recognised as unchecked. The
|
|
34
|
+
# component compares field.dom.value, which stringifies the underlying
|
|
35
|
+
# value, so the integer/symbol/boolean forms collapse onto these.
|
|
36
|
+
FALSE_VALUES = ["", "0", "f", "F", "false", "FALSE", "off", "OFF"].freeze
|
|
37
|
+
|
|
30
38
|
def checked?
|
|
31
39
|
return false if field.dom.value == @unchecked_value
|
|
32
40
|
|
|
33
41
|
if @checked_value == "1" # using default values
|
|
34
42
|
# handle nils, numbers and booleans
|
|
35
|
-
!
|
|
43
|
+
!FALSE_VALUES.include?(field.dom.value)
|
|
36
44
|
else # custom value, so explicit match
|
|
37
45
|
field.dom.value == @checked_value
|
|
38
46
|
end
|
|
@@ -24,6 +24,7 @@ module Phlexi
|
|
|
24
24
|
|
|
25
25
|
def build_input_attributes
|
|
26
26
|
attributes.fetch(:type) { attributes[:type] = field.inferred_string_field_type || field.inferred_field_type }
|
|
27
|
+
attributes[:type] = :text if attributes[:type] == :string
|
|
27
28
|
attributes.fetch(:disabled) { attributes[:disabled] = field.disabled? }
|
|
28
29
|
|
|
29
30
|
case attributes[:type]
|
|
@@ -76,7 +76,7 @@ module Phlexi
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
def full_errors_on_attribute
|
|
79
|
-
|
|
79
|
+
full_messages_for(key)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def errors_on_association
|
|
@@ -84,7 +84,39 @@ module Phlexi
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def full_errors_on_association
|
|
87
|
-
association_reflection ?
|
|
87
|
+
association_reflection ? full_messages_for(association_reflection.name) : []
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# ActiveModel names the attribute with human_attribute_name. A field
|
|
91
|
+
# given its own label names it as the form shows it, so the message
|
|
92
|
+
# under the field matches the label above it.
|
|
93
|
+
def full_messages_for(attribute)
|
|
94
|
+
return object.errors.full_messages_for(attribute) unless custom_label?
|
|
95
|
+
|
|
96
|
+
format, *defaults = full_message_formats(attribute)
|
|
97
|
+
object.errors.messages_for(attribute).map do |message|
|
|
98
|
+
I18n.t(format, default: defaults, attribute: label, message: message)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# The format keys ActiveModel::Error.full_message looks up, so per-model
|
|
103
|
+
# and per-attribute formats still apply when the label is swapped in.
|
|
104
|
+
def full_message_formats(attribute)
|
|
105
|
+
formats = []
|
|
106
|
+
if ActiveModel::Error.i18n_customize_full_message && object.class.respond_to?(:i18n_scope)
|
|
107
|
+
scope = "#{object.class.i18n_scope}.errors.models"
|
|
108
|
+
formats = object.class.lookup_ancestors.flat_map do |klass|
|
|
109
|
+
[
|
|
110
|
+
:"#{scope}.#{klass.model_name.i18n_key}.attributes.#{attribute}.format",
|
|
111
|
+
:"#{scope}.#{klass.model_name.i18n_key}.format"
|
|
112
|
+
]
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
formats + [:"errors.format", "%{attribute} %{message}"]
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def custom_label?
|
|
119
|
+
label.present? && label != calculate_label
|
|
88
120
|
end
|
|
89
121
|
|
|
90
122
|
def has_custom_error?
|
data/lib/phlexi/form/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phlexi-form
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.14.
|
|
4
|
+
version: 0.14.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stefan Froelich
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: phlex
|
|
@@ -108,6 +108,20 @@ dependencies:
|
|
|
108
108
|
- - ">="
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: activemodel
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
126
|
name: standard
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -165,7 +179,7 @@ dependencies:
|
|
|
165
179
|
- !ruby/object:Gem::Version
|
|
166
180
|
version: '0'
|
|
167
181
|
- !ruby/object:Gem::Dependency
|
|
168
|
-
name:
|
|
182
|
+
name: capybara
|
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
|
170
184
|
requirements:
|
|
171
185
|
- - ">="
|