protos-protoform 0.1.0 → 1.0.0
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 +9 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +129 -114
- data/lib/generators/protoform/install/install_generator.rb +1 -1
- data/lib/generators/protoform/install/templates/application_form.rb +2 -2
- data/lib/protoform/field.rb +2 -2
- data/lib/protoform/namespace.rb +8 -8
- data/lib/protoform/namespace_collection.rb +2 -2
- data/lib/protoform/rails/components/label.rb +1 -1
- data/lib/protoform/rails/components/radio_button.rb +2 -4
- data/lib/protoform/rails/components/select.rb +15 -7
- data/lib/protoform/rails/form/field.rb +2 -2
- data/lib/protoform/rails/form.rb +33 -23
- data/lib/protoform/version.rb +1 -1
- data/protos-protoform.gemspec +5 -5
- metadata +13 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9c6a8ce3964ea0d3c2fc908717bbce4d4d8351c44406a771f2c3e3a43317cda
|
4
|
+
data.tar.gz: 6ae4693df543d43e4b1825e58f4a3c859cd9fab82e13e2110b8025a73c3328ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bb2157045f037a1deedd303f1da8d6a20eb446dc2168f1a13f89d238488770e98933196521790bce0e5bfa906ab7f334912281e037153ce207def8e20cf8068
|
7
|
+
data.tar.gz: 2f5cc878190c728c38b15be679cbef642c5587df7d4c1e5010239d667df2e98da0ae2f473ed91b9a4ff0f052d054505c10cc32cc6771c02089ae0fc4bff400f3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.1] - 2025-01-26
|
4
|
+
|
5
|
+
- Bumps `protos` to `~> 0.7`
|
6
|
+
- Bumps `activerecord` and `activesupport` requirements to `~> 8.0`
|
7
|
+
- Hides authenticity token and method field when the form has a GET method
|
8
|
+
automatically
|
9
|
+
- Fixes passing symbol values to labels
|
10
|
+
- Fixes passing wrong values to radio button components
|
11
|
+
|
3
12
|
## [0.1.0] - 2024-09-04
|
4
13
|
|
5
14
|
- Adds tests for all Rails components
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
protos-protoform (
|
5
|
-
activerecord (~>
|
6
|
-
activesupport (~>
|
7
|
-
phlex-rails (~>
|
8
|
-
protos (~>
|
9
|
-
zeitwerk (~> 2
|
4
|
+
protos-protoform (1.0.0)
|
5
|
+
activerecord (~> 8)
|
6
|
+
activesupport (~> 8)
|
7
|
+
phlex-rails (~> 2)
|
8
|
+
protos (~> 1)
|
9
|
+
zeitwerk (~> 2)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
actionpack (
|
15
|
-
actionview (=
|
16
|
-
activesupport (=
|
14
|
+
actionpack (8.0.1)
|
15
|
+
actionview (= 8.0.1)
|
16
|
+
activesupport (= 8.0.1)
|
17
17
|
nokogiri (>= 1.8.5)
|
18
|
-
|
19
|
-
rack (>= 2.2.4, < 3.2)
|
18
|
+
rack (>= 2.2.4)
|
20
19
|
rack-session (>= 1.0.1)
|
21
20
|
rack-test (>= 0.6.3)
|
22
21
|
rails-dom-testing (~> 2.2)
|
23
22
|
rails-html-sanitizer (~> 1.6)
|
24
23
|
useragent (~> 0.16)
|
25
|
-
actionview (
|
26
|
-
activesupport (=
|
24
|
+
actionview (8.0.1)
|
25
|
+
activesupport (= 8.0.1)
|
27
26
|
builder (~> 3.1)
|
28
27
|
erubi (~> 1.11)
|
29
28
|
rails-dom-testing (~> 2.2)
|
30
29
|
rails-html-sanitizer (~> 1.6)
|
31
|
-
activemodel (
|
32
|
-
activesupport (=
|
33
|
-
activerecord (
|
34
|
-
activemodel (=
|
35
|
-
activesupport (=
|
30
|
+
activemodel (8.0.1)
|
31
|
+
activesupport (= 8.0.1)
|
32
|
+
activerecord (8.0.1)
|
33
|
+
activemodel (= 8.0.1)
|
34
|
+
activesupport (= 8.0.1)
|
36
35
|
timeout (>= 0.4.0)
|
37
|
-
activesupport (
|
36
|
+
activesupport (8.0.1)
|
38
37
|
base64
|
38
|
+
benchmark (>= 0.3)
|
39
39
|
bigdecimal
|
40
40
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
41
41
|
connection_pool (>= 2.2.5)
|
@@ -45,11 +45,13 @@ GEM
|
|
45
45
|
minitest (>= 5.1)
|
46
46
|
securerandom (>= 0.3)
|
47
47
|
tzinfo (~> 2.0, >= 2.0.5)
|
48
|
+
uri (>= 0.13.1)
|
48
49
|
addressable (2.8.7)
|
49
50
|
public_suffix (>= 2.0.2, < 7.0)
|
50
51
|
ast (2.4.2)
|
51
52
|
base64 (0.2.0)
|
52
|
-
|
53
|
+
benchmark (0.4.0)
|
54
|
+
bigdecimal (3.1.9)
|
53
55
|
builder (3.3.0)
|
54
56
|
capybara (3.40.0)
|
55
57
|
addressable
|
@@ -60,99 +62,104 @@ GEM
|
|
60
62
|
rack-test (>= 0.6.3)
|
61
63
|
regexp_parser (>= 1.5, < 3.0)
|
62
64
|
xpath (~> 3.2)
|
63
|
-
concurrent-ruby (1.3.
|
64
|
-
connection_pool (2.
|
65
|
+
concurrent-ruby (1.3.5)
|
66
|
+
connection_pool (2.5.0)
|
65
67
|
crass (1.0.6)
|
66
|
-
|
68
|
+
date (3.4.1)
|
69
|
+
debug (1.10.0)
|
67
70
|
irb (~> 1.10)
|
68
71
|
reline (>= 0.3.8)
|
69
|
-
diff-lcs (1.
|
72
|
+
diff-lcs (1.6.0)
|
70
73
|
drb (2.2.1)
|
71
|
-
dry-core (1.0
|
74
|
+
dry-core (1.1.0)
|
72
75
|
concurrent-ruby (~> 1.0)
|
76
|
+
logger
|
73
77
|
zeitwerk (~> 2.6)
|
74
|
-
dry-inflector (1.
|
75
|
-
dry-initializer (3.
|
76
|
-
dry-logic (1.
|
78
|
+
dry-inflector (1.2.0)
|
79
|
+
dry-initializer (3.2.0)
|
80
|
+
dry-logic (1.6.0)
|
81
|
+
bigdecimal
|
77
82
|
concurrent-ruby (~> 1.0)
|
78
|
-
dry-core (~> 1.
|
83
|
+
dry-core (~> 1.1)
|
79
84
|
zeitwerk (~> 2.6)
|
80
|
-
dry-types (1.
|
85
|
+
dry-types (1.8.2)
|
81
86
|
bigdecimal (~> 3.0)
|
82
87
|
concurrent-ruby (~> 1.0)
|
83
88
|
dry-core (~> 1.0)
|
84
89
|
dry-inflector (~> 1.0)
|
85
90
|
dry-logic (~> 1.4)
|
86
91
|
zeitwerk (~> 2.6)
|
87
|
-
erubi (1.13.
|
88
|
-
i18n (1.14.
|
92
|
+
erubi (1.13.1)
|
93
|
+
i18n (1.14.7)
|
89
94
|
concurrent-ruby (~> 1.0)
|
90
|
-
io-console (0.
|
91
|
-
irb (1.
|
95
|
+
io-console (0.8.0)
|
96
|
+
irb (1.15.1)
|
97
|
+
pp (>= 0.6.0)
|
92
98
|
rdoc (>= 4.0.0)
|
93
99
|
reline (>= 0.4.2)
|
94
|
-
json (2.
|
95
|
-
language_server-protocol (3.17.0.
|
96
|
-
|
97
|
-
|
100
|
+
json (2.10.1)
|
101
|
+
language_server-protocol (3.17.0.4)
|
102
|
+
lint_roller (1.1.0)
|
103
|
+
logger (1.6.6)
|
104
|
+
loofah (2.24.0)
|
98
105
|
crass (~> 1.0.2)
|
99
106
|
nokogiri (>= 1.12.0)
|
100
|
-
lru_redux (1.1.0)
|
101
107
|
matrix (0.4.2)
|
102
108
|
mini_mime (1.1.5)
|
103
|
-
|
104
|
-
|
109
|
+
mini_portile2 (2.8.8)
|
110
|
+
minitest (5.25.4)
|
111
|
+
nokogiri (1.18.3)
|
112
|
+
mini_portile2 (~> 2.8.2)
|
105
113
|
racc (~> 1.4)
|
106
|
-
nokogiri (1.
|
114
|
+
nokogiri (1.18.3-aarch64-linux-gnu)
|
107
115
|
racc (~> 1.4)
|
108
|
-
nokogiri (1.
|
116
|
+
nokogiri (1.18.3-arm-linux-gnu)
|
109
117
|
racc (~> 1.4)
|
110
|
-
nokogiri (1.
|
118
|
+
nokogiri (1.18.3-arm64-darwin)
|
111
119
|
racc (~> 1.4)
|
112
|
-
nokogiri (1.
|
120
|
+
nokogiri (1.18.3-x86_64-darwin)
|
113
121
|
racc (~> 1.4)
|
114
|
-
nokogiri (1.
|
122
|
+
nokogiri (1.18.3-x86_64-linux-gnu)
|
115
123
|
racc (~> 1.4)
|
116
124
|
parallel (1.26.3)
|
117
|
-
parser (3.3.
|
125
|
+
parser (3.3.7.1)
|
118
126
|
ast (~> 2.4.1)
|
119
127
|
racc
|
120
|
-
phlex (
|
121
|
-
phlex-rails (
|
122
|
-
phlex (~>
|
123
|
-
railties (>= 6.1, <
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
dry-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
psych (5.1.2)
|
128
|
+
phlex (2.0.2)
|
129
|
+
phlex-rails (2.0.2)
|
130
|
+
phlex (~> 2.0.2)
|
131
|
+
railties (>= 6.1, < 9)
|
132
|
+
pp (0.6.2)
|
133
|
+
prettyprint
|
134
|
+
prettyprint (0.2.0)
|
135
|
+
protos (1.0.1)
|
136
|
+
dry-initializer (~> 3.2)
|
137
|
+
dry-types (~> 1.8)
|
138
|
+
phlex (~> 2)
|
139
|
+
tailwind_merge (~> 1)
|
140
|
+
psych (5.2.3)
|
141
|
+
date
|
135
142
|
stringio
|
136
143
|
public_suffix (6.0.1)
|
137
144
|
racc (1.8.1)
|
138
|
-
rack (3.1.
|
139
|
-
rack-session (2.
|
145
|
+
rack (3.1.10)
|
146
|
+
rack-session (2.1.0)
|
147
|
+
base64 (>= 0.1.0)
|
140
148
|
rack (>= 3.0.0)
|
141
|
-
rack-test (2.
|
149
|
+
rack-test (2.2.0)
|
142
150
|
rack (>= 1.3)
|
143
|
-
rackup (2.1
|
151
|
+
rackup (2.2.1)
|
144
152
|
rack (>= 3)
|
145
|
-
webrick (~> 1.8)
|
146
153
|
rails-dom-testing (2.2.0)
|
147
154
|
activesupport (>= 5.0.0)
|
148
155
|
minitest
|
149
156
|
nokogiri (>= 1.6)
|
150
|
-
rails-html-sanitizer (1.6.
|
157
|
+
rails-html-sanitizer (1.6.2)
|
151
158
|
loofah (~> 2.21)
|
152
|
-
nokogiri (
|
153
|
-
railties (
|
154
|
-
actionpack (=
|
155
|
-
activesupport (=
|
159
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
160
|
+
railties (8.0.1)
|
161
|
+
actionpack (= 8.0.1)
|
162
|
+
activesupport (= 8.0.1)
|
156
163
|
irb (~> 1.13)
|
157
164
|
rackup (>= 1.0.0)
|
158
165
|
rake (>= 12.2)
|
@@ -160,79 +167,87 @@ GEM
|
|
160
167
|
zeitwerk (~> 2.6)
|
161
168
|
rainbow (3.1.1)
|
162
169
|
rake (13.2.1)
|
163
|
-
rdoc (6.
|
170
|
+
rdoc (6.12.0)
|
164
171
|
psych (>= 4.0.0)
|
165
|
-
regexp_parser (2.
|
166
|
-
reline (0.
|
172
|
+
regexp_parser (2.10.0)
|
173
|
+
reline (0.6.0)
|
167
174
|
io-console (~> 0.5)
|
168
175
|
rspec (3.13.0)
|
169
176
|
rspec-core (~> 3.13.0)
|
170
177
|
rspec-expectations (~> 3.13.0)
|
171
178
|
rspec-mocks (~> 3.13.0)
|
172
|
-
rspec-core (3.13.
|
179
|
+
rspec-core (3.13.3)
|
173
180
|
rspec-support (~> 3.13.0)
|
174
|
-
rspec-expectations (3.13.
|
181
|
+
rspec-expectations (3.13.3)
|
175
182
|
diff-lcs (>= 1.2.0, < 2.0)
|
176
183
|
rspec-support (~> 3.13.0)
|
177
|
-
rspec-mocks (3.13.
|
184
|
+
rspec-mocks (3.13.2)
|
178
185
|
diff-lcs (>= 1.2.0, < 2.0)
|
179
186
|
rspec-support (~> 3.13.0)
|
180
|
-
rspec-support (3.13.
|
181
|
-
rubocop (1.
|
187
|
+
rspec-support (3.13.2)
|
188
|
+
rubocop (1.73.1)
|
182
189
|
json (~> 2.3)
|
183
|
-
language_server-protocol (
|
190
|
+
language_server-protocol (~> 3.17.0.2)
|
191
|
+
lint_roller (~> 1.1.0)
|
184
192
|
parallel (~> 1.10)
|
185
193
|
parser (>= 3.3.0.2)
|
186
194
|
rainbow (>= 2.2.2, < 4.0)
|
187
|
-
regexp_parser (>= 2.
|
188
|
-
rubocop-ast (>= 1.
|
195
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
196
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
189
197
|
ruby-progressbar (~> 1.7)
|
190
|
-
unicode-display_width (>= 2.4.0, <
|
191
|
-
rubocop-ast (1.
|
198
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
199
|
+
rubocop-ast (1.38.1)
|
192
200
|
parser (>= 3.3.1.0)
|
193
201
|
rubocop-capybara (2.21.0)
|
194
202
|
rubocop (~> 1.41)
|
195
203
|
rubocop-factory_bot (2.26.1)
|
196
204
|
rubocop (~> 1.61)
|
197
|
-
rubocop-inhouse (0.2.
|
198
|
-
rubocop (>= 1.
|
199
|
-
rubocop-capybara (>= 2.
|
200
|
-
rubocop-factory_bot (>= 2.
|
201
|
-
rubocop-performance (>= 1.
|
205
|
+
rubocop-inhouse (0.2.3)
|
206
|
+
rubocop (>= 1.72)
|
207
|
+
rubocop-capybara (>= 2.21)
|
208
|
+
rubocop-factory_bot (>= 2.26)
|
209
|
+
rubocop-performance (>= 1.24)
|
202
210
|
rubocop-rails (>= 2.2)
|
203
|
-
rubocop-rake (>= 0.
|
204
|
-
rubocop-rspec (>=
|
205
|
-
rubocop-rspec_rails (>= 2.
|
206
|
-
rubocop-performance (1.
|
207
|
-
|
208
|
-
rubocop
|
209
|
-
|
211
|
+
rubocop-rake (>= 0.7)
|
212
|
+
rubocop-rspec (>= 3.5)
|
213
|
+
rubocop-rspec_rails (>= 2.30)
|
214
|
+
rubocop-performance (1.24.0)
|
215
|
+
lint_roller (~> 1.1)
|
216
|
+
rubocop (>= 1.72.1, < 2.0)
|
217
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
218
|
+
rubocop-rails (2.30.2)
|
210
219
|
activesupport (>= 4.2.0)
|
220
|
+
lint_roller (~> 1.1)
|
211
221
|
rack (>= 1.1)
|
212
|
-
rubocop (>= 1.
|
213
|
-
rubocop-ast (>= 1.
|
214
|
-
rubocop-rake (0.
|
215
|
-
|
216
|
-
|
217
|
-
|
222
|
+
rubocop (>= 1.72.1, < 2.0)
|
223
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
224
|
+
rubocop-rake (0.7.1)
|
225
|
+
lint_roller (~> 1.1)
|
226
|
+
rubocop (>= 1.72.1)
|
227
|
+
rubocop-rspec (3.5.0)
|
228
|
+
lint_roller (~> 1.1)
|
229
|
+
rubocop (~> 1.72, >= 1.72.1)
|
218
230
|
rubocop-rspec_rails (2.30.0)
|
219
231
|
rubocop (~> 1.61)
|
220
232
|
rubocop-rspec (~> 3, >= 3.0.1)
|
221
233
|
ruby-progressbar (1.13.0)
|
222
|
-
securerandom (0.
|
223
|
-
|
224
|
-
|
225
|
-
|
234
|
+
securerandom (0.4.1)
|
235
|
+
sin_lru_redux (2.5.0)
|
236
|
+
stringio (3.1.5)
|
237
|
+
tailwind_merge (1.0.0)
|
238
|
+
sin_lru_redux (~> 2.5)
|
226
239
|
thor (1.3.2)
|
227
|
-
timeout (0.4.
|
240
|
+
timeout (0.4.3)
|
228
241
|
tzinfo (2.0.6)
|
229
242
|
concurrent-ruby (~> 1.0)
|
230
|
-
unicode-display_width (
|
231
|
-
|
232
|
-
|
243
|
+
unicode-display_width (3.1.4)
|
244
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
245
|
+
unicode-emoji (4.0.4)
|
246
|
+
uri (1.0.3)
|
247
|
+
useragent (0.16.11)
|
233
248
|
xpath (3.2.0)
|
234
249
|
nokogiri (~> 1.8)
|
235
|
-
zeitwerk (2.
|
250
|
+
zeitwerk (2.7.2)
|
236
251
|
|
237
252
|
PLATFORMS
|
238
253
|
aarch64-linux
|
@@ -244,12 +259,12 @@ PLATFORMS
|
|
244
259
|
|
245
260
|
DEPENDENCIES
|
246
261
|
activemodel
|
262
|
+
capybara
|
247
263
|
debug
|
248
|
-
phlex-testing-capybara
|
249
264
|
protos-protoform!
|
250
265
|
rake
|
251
266
|
rspec
|
252
267
|
rubocop-inhouse
|
253
268
|
|
254
269
|
BUNDLED WITH
|
255
|
-
2.
|
270
|
+
2.6.2
|
@@ -20,7 +20,7 @@ class ApplicationForm < Protoform::Rails::Form
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def around_template(&
|
23
|
+
def around_template(&)
|
24
24
|
super do
|
25
25
|
error_messages
|
26
26
|
yield
|
@@ -34,7 +34,7 @@ class ApplicationForm < Protoform::Rails::Form
|
|
34
34
|
div(style: "color: red;") do
|
35
35
|
h2 do
|
36
36
|
"#{pluralize model.errors.count,
|
37
|
-
|
37
|
+
"error"} prohibited this post from being saved:"
|
38
38
|
end
|
39
39
|
ul do
|
40
40
|
model.errors.each do |error|
|
data/lib/protoform/field.rb
CHANGED
@@ -31,8 +31,8 @@ module Protoform
|
|
31
31
|
|
32
32
|
# Wraps a field that's an array of values with a bunch of fields
|
33
33
|
# that are indexed with the array's index.
|
34
|
-
def collection(&
|
35
|
-
@collection ||= FieldCollection.new(field: self, &
|
34
|
+
def collection(&)
|
35
|
+
@collection ||= FieldCollection.new(field: self, &)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/protoform/namespace.rb
CHANGED
@@ -38,13 +38,13 @@ module Protoform
|
|
38
38
|
# end
|
39
39
|
# end
|
40
40
|
# ```
|
41
|
-
def namespace(key, &
|
41
|
+
def namespace(key, &)
|
42
42
|
create_child(
|
43
43
|
key:,
|
44
44
|
child_class: self.class,
|
45
45
|
field_class: @field_class,
|
46
46
|
object: object_for(key:),
|
47
|
-
&
|
47
|
+
&
|
48
48
|
)
|
49
49
|
end
|
50
50
|
|
@@ -84,12 +84,12 @@ module Protoform
|
|
84
84
|
# ```
|
85
85
|
# The object within the block is a `Namespace` object that maps each object
|
86
86
|
# within the enumerable to another `Namespace` or `Field`.
|
87
|
-
def collection(key, &
|
87
|
+
def collection(key, &)
|
88
88
|
create_child(
|
89
89
|
key:,
|
90
90
|
child_class: NamespaceCollection,
|
91
91
|
field_class: @field_class,
|
92
|
-
&
|
92
|
+
&
|
93
93
|
)
|
94
94
|
end
|
95
95
|
|
@@ -106,8 +106,8 @@ module Protoform
|
|
106
106
|
|
107
107
|
# Iterates through the children of the current namespace, which could be
|
108
108
|
# `Namespace` or `Field` objects.
|
109
|
-
def each(&
|
110
|
-
@children.values.each(&
|
109
|
+
def each(&)
|
110
|
+
@children.values.each(&)
|
111
111
|
end
|
112
112
|
|
113
113
|
# Assigns a hash to the current namespace and children namespace.
|
@@ -120,8 +120,8 @@ module Protoform
|
|
120
120
|
end
|
121
121
|
|
122
122
|
# Creates a root Namespace, which is essentially a form.
|
123
|
-
def self.root(*, **, &
|
124
|
-
new(*, parent: nil, **, &
|
123
|
+
def self.root(*, **, &)
|
124
|
+
new(*, parent: nil, **, &)
|
125
125
|
end
|
126
126
|
|
127
127
|
protected
|
@@ -11,9 +11,7 @@ module Protoform
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def radio_id
|
14
|
-
|
15
|
-
|
16
|
-
[dom.id, dom.value.parameterize.underscore].join("_")
|
14
|
+
[dom.id, value.to_s.parameterize.underscore].join("_")
|
17
15
|
end
|
18
16
|
|
19
17
|
def checked?
|
@@ -24,7 +22,7 @@ module Protoform
|
|
24
22
|
{
|
25
23
|
id: radio_id,
|
26
24
|
name: dom.name,
|
27
|
-
value
|
25
|
+
value:,
|
28
26
|
type: "radio",
|
29
27
|
checked: checked? ? "checked" : false
|
30
28
|
}
|
@@ -31,20 +31,28 @@ module Protoform
|
|
31
31
|
|
32
32
|
def options(*collection)
|
33
33
|
map_options(collection).each do |key, value|
|
34
|
-
option(selected: selected_value_for(key), value: key) { value }
|
34
|
+
option(selected: selected_value_for(key), value: key.to_s) { value }
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def blank_option(&
|
39
|
-
option(selected: field.value.nil?, &
|
38
|
+
def blank_option(&)
|
39
|
+
option(selected: field.value.nil?, &)
|
40
40
|
end
|
41
41
|
|
42
|
-
def true_option(&
|
43
|
-
option(
|
42
|
+
def true_option(&)
|
43
|
+
option(
|
44
|
+
selected: field.value == true,
|
45
|
+
value: true.to_s,
|
46
|
+
&
|
47
|
+
)
|
44
48
|
end
|
45
49
|
|
46
|
-
def false_option(&
|
47
|
-
option(
|
50
|
+
def false_option(&)
|
51
|
+
option(
|
52
|
+
selected: field.value == false,
|
53
|
+
value: false.to_s,
|
54
|
+
&
|
55
|
+
)
|
48
56
|
end
|
49
57
|
|
50
58
|
protected
|
@@ -60,12 +60,12 @@ module Protoform
|
|
60
60
|
Components::Textarea.new(self, ...)
|
61
61
|
end
|
62
62
|
|
63
|
-
def select(*collection, **attributes, &
|
63
|
+
def select(*collection, **attributes, &)
|
64
64
|
Components::Select.new(
|
65
65
|
self,
|
66
66
|
collection:,
|
67
67
|
**attributes,
|
68
|
-
&
|
68
|
+
&
|
69
69
|
)
|
70
70
|
end
|
71
71
|
|
data/lib/protoform/rails/form.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "phlex-rails"
|
4
|
+
|
3
5
|
module Protoform
|
4
6
|
module Rails
|
5
7
|
# A Protos::Component class that accepts a model and sets
|
@@ -14,13 +16,15 @@ module Protoform
|
|
14
16
|
# `authenticity_toklen_field` method and the HTTP verb via the
|
15
17
|
# `_method_field`.
|
16
18
|
class Form < Component
|
19
|
+
include Phlex::Rails::Helpers::URLFor
|
20
|
+
include Phlex::Rails::Helpers::FormAuthenticityToken
|
21
|
+
|
17
22
|
param :model, reader: false
|
18
23
|
option :authenticity_token, reader: false, default: -> { true }
|
19
|
-
option :helpers, reader: false, default: -> { }
|
20
24
|
option :action, reader: false, default: -> { }
|
21
25
|
option :method,
|
22
|
-
|
23
|
-
|
26
|
+
reader: false,
|
27
|
+
default: -> { }
|
24
28
|
option :namespace, reader: false, default: -> do
|
25
29
|
Namespace.root(key, object: @model, field_class: self.class::Field)
|
26
30
|
end
|
@@ -45,35 +49,34 @@ module Protoform
|
|
45
49
|
@namespace.serialize(...)
|
46
50
|
end
|
47
51
|
|
48
|
-
def around_template(&
|
52
|
+
def around_template(&)
|
49
53
|
form_tag do
|
50
|
-
authenticity_token_field if
|
54
|
+
authenticity_token_field if authenticity_token?
|
55
|
+
_method_field if method_field?
|
51
56
|
|
52
|
-
_method_field
|
53
57
|
super
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
57
|
-
def form_tag(&
|
61
|
+
def form_tag(&)
|
58
62
|
form(
|
59
63
|
action: form_action,
|
60
64
|
method: form_method,
|
61
65
|
**attrs,
|
62
|
-
&
|
66
|
+
&
|
63
67
|
)
|
64
68
|
end
|
65
69
|
|
66
|
-
def view_template(&
|
67
|
-
yield_content(&
|
70
|
+
def view_template(&)
|
71
|
+
yield_content(&)
|
68
72
|
end
|
69
73
|
|
70
74
|
def submit(value = submit_value, **attributes)
|
71
75
|
input(
|
72
|
-
**attributes
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
)
|
76
|
+
**attributes,
|
77
|
+
name: "commit",
|
78
|
+
type: "submit",
|
79
|
+
value:
|
77
80
|
)
|
78
81
|
end
|
79
82
|
|
@@ -83,11 +86,24 @@ module Protoform
|
|
83
86
|
|
84
87
|
protected
|
85
88
|
|
89
|
+
def authenticity_token?
|
90
|
+
return false if _method_field_value == :get
|
91
|
+
|
92
|
+
@authenticity_token
|
93
|
+
end
|
94
|
+
|
95
|
+
def method_field?
|
96
|
+
return false if _method_field_value == :post
|
97
|
+
return false if _method_field_value == :get
|
98
|
+
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
86
102
|
def authenticity_token_field
|
87
103
|
input(
|
88
104
|
name: "authenticity_token",
|
89
105
|
type: "hidden",
|
90
|
-
value:
|
106
|
+
value: @authenticity_token || form_authenticity_token
|
91
107
|
)
|
92
108
|
end
|
93
109
|
|
@@ -114,18 +130,12 @@ module Protoform
|
|
114
130
|
end
|
115
131
|
|
116
132
|
def form_action
|
117
|
-
@form_action ||= @action ||
|
133
|
+
@form_action ||= @action || url_for(action: resource_action)
|
118
134
|
end
|
119
135
|
|
120
136
|
def form_method
|
121
137
|
@method == :get ? :get : :post
|
122
138
|
end
|
123
|
-
|
124
|
-
private
|
125
|
-
|
126
|
-
def helpers
|
127
|
-
@helpers ||= super
|
128
|
-
end
|
129
139
|
end
|
130
140
|
end
|
131
141
|
end
|
data/lib/protoform/version.rb
CHANGED
data/protos-protoform.gemspec
CHANGED
@@ -42,10 +42,10 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
43
43
|
spec.require_paths = ["lib"]
|
44
44
|
|
45
|
-
spec.add_dependency "activerecord", "~>
|
46
|
-
spec.add_dependency "activesupport", "~>
|
47
|
-
spec.add_dependency "phlex-rails", "~>
|
48
|
-
spec.add_dependency "protos", "~>
|
49
|
-
spec.add_dependency "zeitwerk", "~> 2
|
45
|
+
spec.add_dependency "activerecord", "~> 8"
|
46
|
+
spec.add_dependency "activesupport", "~> 8"
|
47
|
+
spec.add_dependency "phlex-rails", "~> 2"
|
48
|
+
spec.add_dependency "protos", "~> 1"
|
49
|
+
spec.add_dependency "zeitwerk", "~> 2"
|
50
50
|
spec.metadata["rubygems_mfa_required"] = "true"
|
51
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protos-protoform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nolan Tait
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activerecord
|
@@ -16,70 +15,70 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
18
|
+
version: '8'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
25
|
+
version: '8'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: activesupport
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
32
|
+
version: '8'
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
39
|
+
version: '8'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: phlex-rails
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
46
|
+
version: '2'
|
48
47
|
type: :runtime
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
53
|
+
version: '2'
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: protos
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
58
|
- - "~>"
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
60
|
+
version: '1'
|
62
61
|
type: :runtime
|
63
62
|
prerelease: false
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
65
|
- - "~>"
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
67
|
+
version: '1'
|
69
68
|
- !ruby/object:Gem::Dependency
|
70
69
|
name: zeitwerk
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
72
71
|
requirements:
|
73
72
|
- - "~>"
|
74
73
|
- !ruby/object:Gem::Version
|
75
|
-
version: '2
|
74
|
+
version: '2'
|
76
75
|
type: :runtime
|
77
76
|
prerelease: false
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
79
78
|
requirements:
|
80
79
|
- - "~>"
|
81
80
|
- !ruby/object:Gem::Version
|
82
|
-
version: '2
|
81
|
+
version: '2'
|
83
82
|
description: Build phlex based forms using Rails conventions
|
84
83
|
email:
|
85
84
|
- nolanjtait@gmail.com
|
@@ -133,7 +132,6 @@ metadata:
|
|
133
132
|
source_code_uri: https://github.com/inhouse-work/protos-protoform
|
134
133
|
changelog_uri: https://github.com/inhouse-work/protos-protoform
|
135
134
|
rubygems_mfa_required: 'true'
|
136
|
-
post_install_message:
|
137
135
|
rdoc_options: []
|
138
136
|
require_paths:
|
139
137
|
- lib
|
@@ -148,8 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
146
|
- !ruby/object:Gem::Version
|
149
147
|
version: '0'
|
150
148
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
152
|
-
signing_key:
|
149
|
+
rubygems_version: 3.6.2
|
153
150
|
specification_version: 4
|
154
151
|
summary: Phlex based form builder for Rails
|
155
152
|
test_files: []
|