comfy_bootstrap_form 4.0.8 → 4.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f5fa277272eb5da836a4e05b86c6d6ed5b8c83477503a03996b6a6816e62d87
4
- data.tar.gz: dd88bf038a1ac1db7e084a263745a66a45d5bab772cc4eea8b6b897ef8b337b7
3
+ metadata.gz: 2199adf28ef935d5f2aabaac297c8e3efa9e064e6940a69c2ca47ca5048ce4f6
4
+ data.tar.gz: dd9e41ff96a4d230e40fbf1c7de45727303b092b57a8dfd2362d8105a00aa6a2
5
5
  SHA512:
6
- metadata.gz: 396e6c5fb5dfe2568131ef03e2cdb8d994b40cb25e61b5aff2bc72d316ac5a7d7219de86cf4cbfa612b640de08651dabd4485f22ca48911850524e086ccfb976
7
- data.tar.gz: 6052ea69accbea6fd3a9fc830894b7f92df80465d9e6cf8ead442853261d15727aa1d6a379196589397399a28c4ffa0c045e79b771d78613d973a1ab1b9a976f
6
+ metadata.gz: b6ca4fa7be726f57d96a37b72f1e679cce2a1b3720d2d355f7a9d61e9b7c7dba1294bcdd4be167ce00e2933578b4323d33f12dbc7a7d7ec84827cfd843fa8da5
7
+ data.tar.gz: 46018ae921efe5bf76a5233963c95ab27d8b3bc72ba924c233a5f9dfd9a155c6dc69ff473d526c4c08d38a4e27dcbdc315e5c8b5a61f6906cb83377d8e7cce49
data/README.md CHANGED
@@ -98,13 +98,11 @@ date_field month_field range_field time_field
98
98
  datetime_field number_field search_field url_field
99
99
  email_field password_field text_area week_field
100
100
  date_select time_select datetime_select
101
- collection_radio_buttons collection_check_boxes
102
- rich_text_area
101
+ check_box radio_button rich_text_area
102
+ collection_check_boxes
103
+ collection_radio_buttons
103
104
  ```
104
105
 
105
- Singular `radio_button` is not implemented as it doesn't make sense to wrap one
106
- radio button input in Bootstrap markup.
107
-
108
106
  #### Radio Buttons and Checkboxes
109
107
 
110
108
  To render collection of radio buttons or checkboxes we use the same helper that
@@ -314,7 +312,7 @@ Feel free to take a look at the [Demo App](/demo) to see how everything renders.
314
312
  Specifically see [form.html.erb](/demo/app/views/bootstrap/form.html.erb) template
315
313
  for all kinds of different form configurations you can have.
316
314
 
317
- ![Demo Preview](/demo.png)
315
+ ![Demo Preview](/demo/preview.png)
318
316
 
319
317
  ---
320
318
 
@@ -123,6 +123,52 @@ module ComfyBootstrapForm
123
123
  end
124
124
  end
125
125
 
126
+ # Wrapper around radio button. Example usage:
127
+ #
128
+ # radio_button :choice, "value", bootstrap: {label: {text: "Do you agree?"}}
129
+ #
130
+ def radio_button(method, tag_value, options = {})
131
+ bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
132
+ return super if bootstrap.disabled
133
+
134
+ help_text = draw_help(bootstrap)
135
+ errors = draw_errors(bootstrap, method)
136
+
137
+ add_css_class!(options, "form-check-input")
138
+ add_css_class!(options, "is-invalid") if errors.present?
139
+
140
+ label_text = nil
141
+ if (custom_text = bootstrap.label[:text]).present?
142
+ label_text = custom_text
143
+ end
144
+
145
+ fieldset_css_class = "form-group"
146
+ fieldset_css_class += " row" if bootstrap.horizontal?
147
+ fieldset_css_class += " #{bootstrap.inline_margin_class}" if bootstrap.inline?
148
+
149
+ content_tag(:fieldset, class: fieldset_css_class) do
150
+ draw_control_column(bootstrap, offset: true) do
151
+ if bootstrap.custom_control
152
+ content_tag(:div, class: "custom-control custom-radio") do
153
+ add_css_class!(options, "custom-control-input")
154
+ remove_css_class!(options, "form-check-input")
155
+ concat super(method, tag_value, options)
156
+ concat label(method, label_text, value: tag_value, class: "custom-control-label")
157
+ concat errors if errors.present?
158
+ concat help_text if help_text.present?
159
+ end
160
+ else
161
+ content_tag(:div, class: "form-check") do
162
+ concat super(method, tag_value, options)
163
+ concat label(method, label_text, value: tag_value, class: "form-check-label")
164
+ concat errors if errors.present?
165
+ concat help_text if help_text.present?
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
171
+
126
172
  # Wrapper around checkbox. Example usage:
127
173
  #
128
174
  # checkbox :agree, bootstrap: {label: {text: "Do you agree?"}}
@@ -186,7 +232,7 @@ module ComfyBootstrapForm
186
232
 
187
233
  args = [bootstrap, :radio_button, method, collection, value_method, text_method, options, html_options]
188
234
  draw_choices(*args) do |m, v, opts|
189
- radio_button(m, v, opts)
235
+ radio_button(m, v, opts.merge(bootstrap: { disabled: true }))
190
236
  end
191
237
  end
192
238
 
@@ -208,7 +254,7 @@ module ComfyBootstrapForm
208
254
  content << draw_choices(*args) do |m, v, opts|
209
255
  opts[:multiple] = true
210
256
  opts[:include_hidden] = false
211
- ActionView::Helpers::FormBuilder.instance_method(:check_box).bind(self).call(m, opts, v)
257
+ check_box(m, opts.merge(bootstrap: { disabled: true }), v)
212
258
  end
213
259
  end
214
260
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ComfyBootstrapForm
4
4
 
5
- VERSION = "4.0.8"
5
+ VERSION = "4.0.9"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comfy_bootstrap_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.8
4
+ version: 4.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Khabarov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-25 00:00:00.000000000 Z
11
+ date: 2020-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -41,7 +41,6 @@ files:
41
41
  - README.md
42
42
  - Rakefile
43
43
  - comfy_bootstrap_form.gemspec
44
- - demo.png
45
44
  - lib/comfy_bootstrap_form.rb
46
45
  - lib/comfy_bootstrap_form/bootstrap_options.rb
47
46
  - lib/comfy_bootstrap_form/form_builder.rb
data/demo.png DELETED
Binary file