view_component-form 0.2.5 → 0.2.6
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 +5 -1
- data/README.md +1 -1
- data/app/components/concerns/view_component/form/element_proc.rb +27 -0
- data/app/components/view_component/form/collection_check_boxes_component.rb +3 -1
- data/app/components/view_component/form/collection_radio_buttons_component.rb +3 -1
- data/app/components/view_component/form/field_component.rb +2 -2
- data/lib/view_component/form/engine.rb +1 -0
- data/lib/view_component/form/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 128d4c769f1fa3e25cf83830db0b8279413dd8da3e9c7e312aeee06f0456336a
|
4
|
+
data.tar.gz: 63d592e4fa33d6bb77262bea0526761d5b251f26f37c6fac42a771f2506b3250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f584160cf5560bf80869e4b98ea86d4ac0ce35b25c97dcbb5f38d4fbbacddfce7c64734697327d500b36e537391ac5c34f81470491b2ed75a3347e6664b53b08
|
7
|
+
data.tar.gz: 9fd72c0345d99a0207c006d916cf7e4f75224a88b4bc0175d3f56ffad491ebc42da14efa3619796896c12d37a8eef88dbd70911f47700eaa5fe520ea9f1277e0
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
|
-
|
8
|
+
|
9
|
+
## [0.2.6] - 2023-10-11
|
10
|
+
### Added
|
11
|
+
- Support for Rails 7.1 (#151)
|
12
|
+
- Add `element_proc` option to `CollectionCheckBoxesComponent` and `CollectionRadioButtonsComponent` to customize the way the elements will be shown (#142)
|
9
13
|
|
10
14
|
## [0.2.5] - 2023-05-01
|
11
15
|
### Changed
|
data/README.md
CHANGED
@@ -413,7 +413,7 @@ For more complex components, we recommend the [`rspec-html-matchers` gem](https:
|
|
413
413
|
|
414
414
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
415
415
|
|
416
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version,
|
416
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, run `bin/release x.x.x`, which will update the `version.rb` file, open the changelog for edition, create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
417
417
|
|
418
418
|
## Contributing
|
419
419
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ViewComponent
|
4
|
+
module Form
|
5
|
+
module ElementProc
|
6
|
+
attr_reader :element_proc
|
7
|
+
|
8
|
+
def initialize(*args, **kwargs)
|
9
|
+
super
|
10
|
+
set_element_proc!
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def set_element_proc!
|
16
|
+
options_element_proc = options.delete(:element_proc)
|
17
|
+
html_options_element_proc = html_options.delete(:element_proc)
|
18
|
+
|
19
|
+
if options_element_proc && html_options_element_proc
|
20
|
+
raise ArgumentError, "#{self.class.name} received :element_proc twice, expected only once"
|
21
|
+
end
|
22
|
+
|
23
|
+
@element_proc = options_element_proc || html_options_element_proc
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module ViewComponent
|
4
4
|
module Form
|
5
5
|
class CollectionCheckBoxesComponent < FieldComponent
|
6
|
+
include ElementProc
|
7
|
+
|
6
8
|
attr_reader :collection, :value_method, :text_method, :html_options
|
7
9
|
|
8
10
|
def initialize( # rubocop:disable Metrics/ParameterLists
|
@@ -36,7 +38,7 @@ module ViewComponent
|
|
36
38
|
options,
|
37
39
|
html_options,
|
38
40
|
&content
|
39
|
-
).render
|
41
|
+
).render(&element_proc)
|
40
42
|
end
|
41
43
|
|
42
44
|
protected
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module ViewComponent
|
4
4
|
module Form
|
5
5
|
class CollectionRadioButtonsComponent < FieldComponent
|
6
|
+
include ElementProc
|
7
|
+
|
6
8
|
attr_reader :collection, :value_method, :text_method, :html_options
|
7
9
|
|
8
10
|
def initialize( # rubocop:disable Metrics/ParameterLists
|
@@ -36,7 +38,7 @@ module ViewComponent
|
|
36
38
|
options,
|
37
39
|
html_options,
|
38
40
|
&content
|
39
|
-
).render
|
41
|
+
).render(&element_proc)
|
40
42
|
end
|
41
43
|
|
42
44
|
protected
|
@@ -71,13 +71,13 @@ module ViewComponent
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def optional?(context: validation_context)
|
74
|
-
return
|
74
|
+
return false if object.nil?
|
75
75
|
|
76
76
|
!required?(context: context)
|
77
77
|
end
|
78
78
|
|
79
79
|
def required?(context: validation_context)
|
80
|
-
return
|
80
|
+
return false if object.nil?
|
81
81
|
|
82
82
|
validators(context: context).any?(ActiveModel::Validations::PresenceValidator)
|
83
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component-form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pantographe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 6.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '7.
|
22
|
+
version: '7.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 6.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '7.
|
32
|
+
version: '7.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 6.0.0
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '7.
|
42
|
+
version: '7.2'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: 6.0.0
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '7.
|
52
|
+
version: '7.2'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: view_component
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- CHANGELOG.md
|
95
95
|
- LICENSE.txt
|
96
96
|
- README.md
|
97
|
+
- app/components/concerns/view_component/form/element_proc.rb
|
97
98
|
- app/components/view_component/form/base_component.rb
|
98
99
|
- app/components/view_component/form/button_component.rb
|
99
100
|
- app/components/view_component/form/check_box_component.rb
|
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
168
|
- !ruby/object:Gem::Version
|
168
169
|
version: '0'
|
169
170
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
171
|
+
rubygems_version: 3.4.10
|
171
172
|
signing_key:
|
172
173
|
specification_version: 4
|
173
174
|
summary: Rails FormBuilder for ViewComponent
|