rails_bootstrap_form 0.5.2 → 0.5.3

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: ed3da45cc2109afbc15026f1a12f80000890c7b7759bc7dbbbe855f3184bf0a2
4
- data.tar.gz: 5e7897c4c60eb47a89f2eaf26a3f3ad46b5cc78cdc5519ff1dfe755302e7ab40
3
+ metadata.gz: 1031de2aa81bb74657e9a45f334c4dc4d67ee673e89874358881d8021388d8b9
4
+ data.tar.gz: 4a5d3c85afb71bd06005eb95c0b8abb76a429a46ea49f22b470943bba2a6f7ae
5
5
  SHA512:
6
- metadata.gz: 6b84a087632ef6236a0b1975910ae6cabe61f5f1f70aa0f2950c765f53c23caa93de366b00517622a5fffabff0fb34794a563d04eb7ebe8bf4061bec6858ef57
7
- data.tar.gz: 288e303d2c86355e5cd4a88d9046a84704d9091954981d7dee818f3f57f583995fa8bde1f28aa7f067ff851724deb6c8e00c03912a6c240da266000d353bd385
6
+ metadata.gz: 188081d3651b5f6977df21c3bfb4436e44b3d96685ef8b6fc36b7805056b205ab77ced5f3ad4d3094217116e47f04e8a07a914db1f073c60be664bd4acf33694
7
+ data.tar.gz: 180295d5dbc0159f5181183be148203565d877d874d978074af43dd31ba0cfb7e7d8d2be3bcf3d3c72e1abe6d4ff58636da8c4386be3b09d64380edc4ef06b2d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_bootstrap_form (0.5.2)
4
+ rails_bootstrap_form (0.5.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -12,13 +12,13 @@
12
12
  <%= form.check_box :terms, bootstrap_form: {switch: false}, required: true %>
13
13
  <%= form.range_field :excellence %>
14
14
  <%= form.url_field :blog_url %>
15
- <%= form.collection_radio_buttons :fruit_id, ::Fruit.all, :id, :name, {bootstrap_form: {layout: :inline}, checked: form.object.fruit_id} %>
15
+ <%= form.collection_radio_buttons :fruit_id, ::Fruit.all, :id, :name, {bootstrap_form: {inline: true}, checked: form.object.fruit_id} %>
16
16
  <%= form.color_field :favorite_color %>
17
- <%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name, {bootstrap_form: {layout: :inline}} %>
17
+ <%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name, {bootstrap_form: {inline: true}} %>
18
18
  <%= form.fields_for :address, include_id: false do |address_form| %>
19
19
  <%= address_form.text_area :street %>
20
20
  <%= address_form.text_field :state %>
21
- <%= address_form.grouped_collection_select :city, ::Country.all, :cities, :name, :id, :name, {include_blank: "Select city"} %>
21
+ <%= address_form.grouped_collection_select :city, ::Country.includes(:cities), :cities, :name, :id, :name, {include_blank: "Select city"} %>
22
22
  <%= address_form.text_field :postal_code %>
23
23
  <%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id),
24
24
  {include_blank: "Select Country", bootstrap_form: {}} %>
@@ -98,23 +98,34 @@ module RailsBootstrapForm
98
98
  # The valid values are `sm` and `lg`. The default value is `nil`.
99
99
  attr_accessor :size
100
100
 
101
+ # Option to render checkboxes and radio buttons inline.
102
+ # The default value if `false`.
103
+ #
104
+ # Example:
105
+ # form.collection_radio_buttons :choices, ["yes", "no"], :to_s, :to_s, bootstrap_form: {inline: true}
106
+ attr_accessor :inline
107
+
101
108
  def initialize(options = {})
102
109
  set_defaults
103
110
  set_bootstrap_form_options(options)
104
111
  end
105
112
 
106
- def horizontal?
113
+ def layout_horizontal?
107
114
  @layout.to_s == "horizontal"
108
115
  end
109
116
 
110
- def inline?
117
+ def layout_inline?
111
118
  @layout.to_s == "inline"
112
119
  end
113
120
 
114
- def vertical?
121
+ def layout_vertical?
115
122
  @layout.to_s == "vertical"
116
123
  end
117
124
 
125
+ def inline?
126
+ self.inline
127
+ end
128
+
118
129
  # This will return a copy of `BootstrapFormOptions` object with new options set
119
130
  # that don't affect original object. This way we can have options specific
120
131
  # to a given form field. For example, we can change grid just for one field:
@@ -160,6 +171,8 @@ module RailsBootstrapForm
160
171
  @wrapper_options = {}
161
172
 
162
173
  @size = nil
174
+
175
+ @inline = false
163
176
  end
164
177
 
165
178
  private :set_defaults
@@ -61,7 +61,8 @@ module RailsBootstrapForm
61
61
  def check_box_wrapper_class(bootstrap_options)
62
62
  classes = Array("form-check")
63
63
  classes << "form-switch" if bootstrap_options.switch
64
- classes << (bootstrap_options.inline? ? "form-check-inline" : "mb-3")
64
+ classes << "form-check-inline" if bootstrap_options.inline?
65
+ classes << "mb-3"
65
66
  classes.flatten.compact
66
67
  end
67
68
 
@@ -57,7 +57,8 @@ module RailsBootstrapForm
57
57
 
58
58
  def radio_button_wrapper_class(bootstrap_options)
59
59
  classes = Array("form-check")
60
- classes << (bootstrap_options.inline? ? "form-check-inline" : "mb-3")
60
+ classes << "form-check-inline" if bootstrap_options.inline?
61
+ classes << "mb-3"
61
62
  classes.flatten.compact
62
63
  end
63
64
 
@@ -3,6 +3,6 @@
3
3
  # -*- warn_indent: true -*-
4
4
 
5
5
  module RailsBootstrapForm
6
- VERSION = "0.5.2".freeze
6
+ VERSION = "0.5.3".freeze
7
7
  REQUIRED_RAILS_VERSION = "~> 7.0".freeze
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_bootstrap_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harshal LADHE (shivam091)