dsfr-form_builder 0.0.2 → 0.0.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/lib/dsfr-form_builder.rb +40 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b94442f01028ee2af534df452b5511d1f1ea8094b70ac4decd14f05b40d0dfaf
|
4
|
+
data.tar.gz: 7a05902798b6557aed2411ca9fc3ab6ad8b3110c3ae22a7b5108d42d22ee82a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1293988dcb4fefe74c334ab2b6e11a23593f9daddb98594e560ca5d867da7c4328a1edbf5238d006d167d62b0cfc2bce36f809316a602ce3e13f3da1439ca59
|
7
|
+
data.tar.gz: 06d322e2d989dd87ed84c6bdcbb72ba96236a7ddaf00090b2e4cd0970f0ef1e882b2a1c78dc80c24745fbc9c1d8f054d059b54d35b6618268aadbba289d266f1
|
data/lib/dsfr-form_builder.rb
CHANGED
@@ -16,6 +16,10 @@ module Dsfr
|
|
16
16
|
dsfr_input_field(attribute, :text_field, opts)
|
17
17
|
end
|
18
18
|
|
19
|
+
def dsfr_text_area(attribute, opts = {})
|
20
|
+
dsfr_input_field(attribute, :text_area, opts)
|
21
|
+
end
|
22
|
+
|
19
23
|
def dsfr_email_field(attribute, opts = {})
|
20
24
|
dsfr_input_field(attribute, :email_field, opts)
|
21
25
|
end
|
@@ -77,6 +81,42 @@ module Dsfr
|
|
77
81
|
select(attribute, choices, { include_blank: opts[:include_blank] }, class: "fr-select")
|
78
82
|
end
|
79
83
|
|
84
|
+
def dsfr_radio_buttons(attribute, choices, legend: nil, hint: nil, **opts)
|
85
|
+
legend_content = @template.safe_join([
|
86
|
+
legend || @object.class.human_attribute_name(attribute),
|
87
|
+
hint ? hint_tag(hint) : nil
|
88
|
+
].compact)
|
89
|
+
@template.content_tag(:fieldset, class: "fr-fieldset") do
|
90
|
+
@template.safe_join(
|
91
|
+
[
|
92
|
+
@template.content_tag(:legend, legend_content, class: "fr-fieldset__legend--regular fr-fieldset__legend"),
|
93
|
+
choices.map { |c| dsfr_radio_option(attribute, value: c[:value], label_text: c[:label], hint: c[:hint], **opts) }
|
94
|
+
]
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def dsfr_radio_option(attribute, value:, label_text:, hint:, rich: false, **opts)
|
100
|
+
@template.content_tag(:div, class: "fr-fieldset__element") do
|
101
|
+
classes = rich ? "fr-radio-group fr-radio-rich" : "fr-radio-group"
|
102
|
+
@template.content_tag(:div, class: classes) do
|
103
|
+
@template.safe_join(
|
104
|
+
[
|
105
|
+
radio_button(attribute, value, **opts),
|
106
|
+
label([ attribute, value ].join("_").to_sym) do
|
107
|
+
@template.safe_join(
|
108
|
+
[
|
109
|
+
label_text,
|
110
|
+
hint.present? ? @template.content_tag(:span, hint, class: "fr-hint-text") : nil
|
111
|
+
]
|
112
|
+
)
|
113
|
+
end
|
114
|
+
]
|
115
|
+
)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
80
120
|
def dsfr_label_with_hint(attribute, opts = {})
|
81
121
|
label_class = "fr-label #{opts[:class]}"
|
82
122
|
label(attribute, class: label_class) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dsfr-form_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BetaGouv developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|