bootstrap_form 4.3.0 → 4.4.0

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: 60d4313478eda1a0db587b6c45b7e107aedca0d59683f2231d348c09e9585e59
4
- data.tar.gz: f07b72a464b509975d9a6a573718787b9c245b7b3b1f362e3448d842fff93891
3
+ metadata.gz: 4e064911f3a679f4ecf322d6e3e240b35cf1f33e73908d3bf3494a71a3013781
4
+ data.tar.gz: 044b4a8d8dd6c046f88b45ddd6fb83ed9d619fd6e2872fbd1eb32c84fda50f71
5
5
  SHA512:
6
- metadata.gz: 370f4f419457d0737505add14f48f6ebb879e185f9b132d7409d59b789944dff9a156eabb3c821764f1de8783879729639f99334812077f2c99cccf44da7378c
7
- data.tar.gz: a5ac9f28944a788c996a7da4d57760cb6331bf2d3a490a8a3a96ddaffec2f7357fce07e2e16fcabbe59eb7f12967fc8950f19f4644369981b30eaaa63fd588a4
6
+ metadata.gz: ec13235058d63f5ff4a12991660d10acff7b7576954e3a103d38592cd90a6ee0a8431c93eeb33878d7a228e432bbf590ff248d60445cfacbca278efc73d5fc52
7
+ data.tar.gz: 2b3c704fa1981633bbaaa04dc543d72e9a1e3d535f8d56852752fb9eef65ea4d75089971e073defb193119f80c8cc13a3708a8ac603bcdef0edc8946f2a95958
@@ -20,6 +20,7 @@ AllCops:
20
20
  - "demo/tmp/**/*"
21
21
  - "demo/vendor/**/*"
22
22
  - Gemfile
23
+ - gemfiles/vendor/bundle/**/*
23
24
  - Guardfile
24
25
  - Rakefile
25
26
 
@@ -1,36 +1,36 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.6
4
- - 2.5.6
5
- - 2.6.4
3
+ - 2.7
4
+ - 2.6.5
5
+ - 2.5.7
6
+ - 2.4.9
6
7
  gemfile:
7
- - test/gemfiles/5.0.gemfile
8
- - test/gemfiles/5.1.gemfile
9
- - test/gemfiles/5.2.gemfile
10
- - test/gemfiles/6.0.gemfile
11
- before_install:
12
- - gem i rubygems-update -v '<3' && update_rubygems
13
- - gem install bundler -v 1.17.3 --no-document
8
+ - gemfiles/5.0.gemfile
9
+ - gemfiles/5.1.gemfile
10
+ - gemfiles/5.2.gemfile
11
+ - gemfiles/6.0.gemfile
12
+ cache:
13
+ bundler: true
14
14
  script:
15
15
  - bundle exec rake test
16
16
 
17
17
  matrix:
18
18
  exclude:
19
- - rvm: 2.4.6
20
- gemfile: test/gemfiles/6.0.gemfile
19
+ - rvm: 2.4.9
20
+ gemfile: gemfiles/6.0.gemfile
21
21
 
22
22
  include:
23
23
  # Bleeding edge Ruby
24
24
  - rvm: ruby-head
25
- gemfile: test/gemfiles/6.0.gemfile
25
+ gemfile: gemfiles/6.0.gemfile
26
26
 
27
27
  # Next version of Rails
28
- - rvm: 2.5.0
29
- gemfile: test/gemfiles/edge.gemfile
28
+ - rvm: 2.5.7
29
+ gemfile: gemfiles/edge.gemfile
30
30
 
31
31
  # Running one job to execute DANGER bot and linting
32
- - rvm: 2.5.0
33
- gemfile: test/gemfiles/6.0.gemfile
32
+ - rvm: 2.5.7
33
+ gemfile: gemfiles/6.0.gemfile
34
34
  script:
35
35
  - gem install danger
36
36
  - danger
@@ -38,5 +38,5 @@ matrix:
38
38
 
39
39
  allow_failures:
40
40
  - rvm: ruby-head
41
- - rvm: 2.5.0
42
- gemfile: test/gemfiles/edge.gemfile
41
+ - rvm: 2.5.7
42
+ gemfile: gemfiles/edge.gemfile
@@ -12,7 +12,18 @@
12
12
 
13
13
  * Your contribution here!
14
14
 
15
- ## [4.3.0][] (2019-03-08)
15
+ ## [4.4.0][] (2020-03-08)
16
+
17
+ ### New features
18
+
19
+ * [#557](https://github.com/bootstrap-ruby/bootstrap_form/pull/557): Allow prepending and appending multiple items to an input by passing an array to `prepend` and `append` options - [@donv](https://github.com/donv).
20
+ * [#550](https://github.com/bootstrap-ruby/bootstrap_form/pull/550): Add `default_layout` so we can use it for all forms - [@duleorlovic](https://github.com/duleorlovic).
21
+
22
+ ### Bugfixes
23
+
24
+ * Your contribution here!
25
+
26
+ ## [4.3.0][] (2019-09-22)
16
27
 
17
28
  ### New features
18
29
 
@@ -275,7 +286,9 @@ Features:
275
286
  - Added support for bootstrap_form_tag (@baldwindavid)
276
287
 
277
288
 
278
- [Pending Release]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.2.0...HEAD
289
+ [Pending Release]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.4.0...HEAD
290
+ [4.4.0]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.3.0...v4.4.0
291
+ [4.3.0]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.2.0...v4.3.0
279
292
  [4.2.0]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.1.0...v4.2.0
280
293
  [4.1.0]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.0.0...v4.1.0
281
294
  [4.0.0]: https://github.com/bootstrap-ruby/bootstrap_form/compare/v4.0.0.alpha1...v4.0.0
data/README.md CHANGED
@@ -47,12 +47,17 @@ Then:
47
47
 
48
48
  `bundle install`
49
49
 
50
- Then require the CSS in your `application.css` file:
50
+ Depending on which CSS pre-processor you are using, adding the bootstrap form styles differs slightly.
51
+ If you use Rails in the default mode without any pre-processor, you'll have to add the following line to your `application.css` file:
51
52
 
52
53
  ```css
53
- /*
54
- *= require rails_bootstrap_forms
55
- */
54
+ *= require rails_bootstrap_forms
55
+ ```
56
+
57
+ If you followed the [official bootstrap installation guide](https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails), you'll probably have switched to SCSS. In this case add the following line to your `application.scss`:
58
+
59
+ ```scss
60
+ @import "rails_bootstrap_forms";
56
61
  ```
57
62
 
58
63
  ## Usage
@@ -234,7 +239,8 @@ To add help text, use the `help` option:
234
239
  ```
235
240
 
236
241
  This generates:
237
- ```
242
+
243
+ ```html
238
244
  <small class="form-text text-muted">Must be at least 6 characters long</small>
239
245
  ```
240
246
 
@@ -272,6 +278,12 @@ You can pass `prepend` and/or `append` options to input fields:
272
278
  <%= f.text_field :price, prepend: "$", append: ".00" %>
273
279
  ```
274
280
 
281
+ If you want to attach multiple items to the input, pass them as an array:
282
+
283
+ ```erb
284
+ <%= f.text_field :price, prepend: ['Net', '$'], append: ['.00', 'per day'] %>
285
+ ```
286
+
275
287
  You can also prepend and append buttons. Note: The buttons must contain the
276
288
  `btn` class to generate the correct markup.
277
289
 
@@ -308,9 +320,9 @@ If you only want to set the class on the form group div, you can use the `wrappe
308
320
 
309
321
  ### Suppressing the Form Group Altogether
310
322
 
311
- You may have want to define your own form group div around a field. To do so, add the option `wrapper: false` to the input field. For example:
323
+ You may want to define your own form group div around a field. To do so, add the option `wrapper: false` to the input field. For example:
312
324
 
313
- ```
325
+ ```ruby
314
326
  f.form_group :user do
315
327
  f.email_field :email, wrapper: false
316
328
  end
@@ -369,6 +381,7 @@ Check boxes and radio buttons are wrapped in a `div.form-check`. You can add cla
369
381
  ```erb
370
382
  <%= f.radio_button :skill_level, 0, label: "Novice", inline: true, wrapper_class: "w-auto" %>
371
383
  ```
384
+
372
385
  ### Switches
373
386
 
374
387
  To render checkboxes as switches with Bootstrap 4.2+, use `custom: :switch`:
@@ -390,6 +403,7 @@ To render checkboxes as switches with Bootstrap 4.2+, use `custom: :switch`:
390
403
  NOTE: These helpers do not currently support a block, unlike their equivalent Rails helpers. See issue [#477](https://github.com/bootstrap-ruby/bootstrap_form/issues/477). If you need to use the block syntax, use `collection_check_boxes_without_bootstrap` or `collection_radio_buttons_without_bootstrap` for now.
391
404
 
392
405
  Collection methods accept these options:
406
+
393
407
  * `:label`: Customize the `form_group`'s label
394
408
  * `:hide_label`: Pass true to hide the `form_group`'s label
395
409
  * `:help`: Add a help span to the `form_group`
@@ -512,7 +526,6 @@ will be rendered as
512
526
 
513
527
  If you're using Rails 6, `bootstrap_form` supports the `rich_text_area` helper.
514
528
 
515
-
516
529
  ```erb
517
530
  <%= f.rich_text_area(:life_story) %>
518
531
  ```
@@ -617,6 +630,10 @@ module BootstrapForm
617
630
  def default_control_col
618
631
  'col-sm-8'
619
632
  end
633
+ def default_layout
634
+ # :default, :horizontal or :inline
635
+ :horizontal
636
+ end
620
637
  end
621
638
  end
622
639
  ```
@@ -839,4 +856,4 @@ document first.
839
856
 
840
857
  ## License
841
858
 
842
- MIT License. Copyright 2012-2019 Stephen Potenza (https://github.com/potenza)
859
+ MIT License. Copyright 2012-2020 Stephen Potenza (https://github.com/potenza) and others
@@ -16,7 +16,7 @@ Rails.application.configure do
16
16
 
17
17
  # Enable/disable caching. By default caching is disabled.
18
18
  # Run rails dev:cache to toggle caching.
19
- if Rails.root.join("tmp", "caching-dev.txt").exist?
19
+ if Rails.root.join("tmp/caching-dev.txt").exist?
20
20
  config.action_controller.perform_caching = true
21
21
 
22
22
  config.cache_store = :memory_store
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec path: "../"
4
+
5
+ gem "rails", "~> 5.0.0"
6
+
7
+ group :development do
8
+ gem "rubocop-rails", require: false
9
+ end
10
+
11
+ group :test do
12
+ gem "diffy"
13
+ gem "equivalent-xml"
14
+ gem "minitest", "~> 5.10.3"
15
+ gem "mocha"
16
+ gem "sqlite3", "~> 1.3.6"
17
+ gem "timecop", "~> 0.7.1"
18
+ end
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec path: "../"
4
+
5
+ gem "rails", "~> 5.1.0"
6
+
7
+ group :development do
8
+ gem "rubocop-rails", require: false
9
+ end
10
+
11
+ group :test do
12
+ gem "diffy"
13
+ gem "equivalent-xml"
14
+ gem "mocha"
15
+ gem "sqlite3", "~> 1.4"
16
+ gem "timecop", "~> 0.7.1"
17
+ end
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec path: "../"
4
+
5
+ gem "rails", "~> 5.2.0"
6
+
7
+ group :development do
8
+ gem "rubocop-rails", require: false
9
+ end
10
+
11
+ group :test do
12
+ gem "diffy"
13
+ gem "equivalent-xml"
14
+ gem "mocha"
15
+ gem "sqlite3", "~> 1.4"
16
+ gem "timecop", "~> 0.7.1"
17
+ end
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec path: "../"
4
+
5
+ gem "rails", "~> 6.0.0"
6
+
7
+ group :development do
8
+ gem "rubocop-rails", require: false
9
+ gem "sassc"
10
+ gem "webpacker", ">= 4.0.0.rc.3"
11
+ end
12
+
13
+ group :test do
14
+ gem "diffy"
15
+ gem "equivalent-xml"
16
+ gem "mocha"
17
+ gem "sqlite3"
18
+ gem "timecop", "~> 0.7.1"
19
+ end
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec path: "../"
4
+
5
+ gem "rails", git: "https://github.com/rails/rails.git"
6
+
7
+ group :development do
8
+ gem "rubocop-rails", require: false
9
+ gem "sassc-rails"
10
+ gem "webpacker"
11
+ end
12
+
13
+ group :test do
14
+ gem "diffy"
15
+ gem "equivalent-xml"
16
+ gem "mocha"
17
+ gem "sqlite3"
18
+ gem "timecop", "~> 0.7.1"
19
+ end
@@ -20,8 +20,6 @@ module BootstrapForm
20
20
  def bootstrap_form_for(record, options={}, &block)
21
21
  options.reverse_merge!(builder: BootstrapForm::FormBuilder)
22
22
 
23
- options = process_options(options)
24
-
25
23
  with_bootstrap_form_field_error_proc do
26
24
  form_for(record, options, &block)
27
25
  end
@@ -30,8 +28,6 @@ module BootstrapForm
30
28
  def bootstrap_form_with(options={}, &block)
31
29
  options.reverse_merge!(builder: BootstrapForm::FormBuilder)
32
30
 
33
- options = process_options(options)
34
-
35
31
  with_bootstrap_form_field_error_proc do
36
32
  form_with(options, &block)
37
33
  end
@@ -45,16 +41,6 @@ module BootstrapForm
45
41
 
46
42
  private
47
43
 
48
- def process_options(options)
49
- options[:html] ||= {}
50
- options[:html][:role] ||= "form"
51
-
52
- options[:layout] == :inline &&
53
- options[:html][:class] = [options[:html][:class], "form-inline"].compact.join(" ")
54
-
55
- options
56
- end
57
-
58
44
  def with_bootstrap_form_field_error_proc
59
45
  original_proc = ActionView::Base.field_error_proc
60
46
  ActionView::Base.field_error_proc = BootstrapForm.field_error_proc
@@ -8,7 +8,7 @@ module BootstrapForm
8
8
  private
9
9
 
10
10
  def layout_default?(field_layout=nil)
11
- [:default, nil].include? layout_in_effect(field_layout)
11
+ layout_in_effect(field_layout) == :default
12
12
  end
13
13
 
14
14
  def layout_horizontal?(field_layout=nil)
@@ -45,8 +45,9 @@ module BootstrapForm
45
45
 
46
46
  delegate :content_tag, :capture, :concat, to: :@template
47
47
 
48
+ # rubocop:disable Metrics/AbcSize
48
49
  def initialize(object_name, object, template, options)
49
- @layout = options[:layout]
50
+ @layout = options[:layout] || default_layout
50
51
  @label_col = options[:label_col] || default_label_col
51
52
  @control_col = options[:control_col] || default_control_col
52
53
  @label_errors = options[:label_errors] || false
@@ -57,8 +58,19 @@ module BootstrapForm
57
58
  options[:inline_errors] != false
58
59
  end
59
60
  @acts_like_form_tag = options[:acts_like_form_tag]
61
+ add_form_role_and_form_inline options
60
62
  super
61
63
  end
64
+ # rubocop:enable Metrics/AbcSize
65
+
66
+ def add_form_role_and_form_inline(options)
67
+ options[:html] ||= {}
68
+ options[:html][:role] ||= "form"
69
+
70
+ return unless options[:layout] == :inline
71
+
72
+ options[:html][:class] = [options[:html][:class], "form-inline"].compact.join(" ")
73
+ end
62
74
 
63
75
  def fields_for_with_bootstrap(record_name, record_object=nil, fields_options={}, &block)
64
76
  fields_options = fields_for_options(record_object, fields_options)
@@ -86,6 +98,11 @@ module BootstrapForm
86
98
  field_options
87
99
  end
88
100
 
101
+ def default_layout
102
+ # :default, :horizontal or :inline
103
+ :default
104
+ end
105
+
89
106
  def default_label_col
90
107
  "col-sm-2"
91
108
  end
@@ -82,7 +82,7 @@ module BootstrapForm
82
82
 
83
83
  input = capture(&block) || ActiveSupport::SafeBuffer.new
84
84
 
85
- input = prepend_input(options) + input + append_input(options)
85
+ input = attach_input(options, :prepend) + input + attach_input(options, :append)
86
86
  input += generate_error(name)
87
87
  options.present? &&
88
88
  input = content_tag(:div, input, class: ["input-group", options[:input_group_class]].compact)
@@ -106,14 +106,11 @@ module BootstrapForm
106
106
 
107
107
  private
108
108
 
109
- def append_input(options)
110
- html = content_tag(:div, input_group_content(options[:append]), class: "input-group-append") if options[:append]
111
- html || ActiveSupport::SafeBuffer.new
112
- end
113
-
114
- def prepend_input(options)
115
- html = content_tag(:div, input_group_content(options[:prepend]), class: "input-group-prepend") if options[:prepend]
116
- html || ActiveSupport::SafeBuffer.new
109
+ def attach_input(options, key)
110
+ tags = [*options[key]].map do |item|
111
+ content_tag(:div, input_group_content(item), class: "input-group-#{key}")
112
+ end
113
+ ActiveSupport::SafeBuffer.new(tags.join)
117
114
  end
118
115
 
119
116
  def setup_css_class(the_class, options={})
@@ -1,3 +1,3 @@
1
1
  module BootstrapForm
2
- VERSION = "4.3.0".freeze
2
+ VERSION = "4.4.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Potenza
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-09-22 00:00:00.000000000 Z
12
+ date: 2020-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -125,6 +125,11 @@ files:
125
125
  - demo/public/favicon.ico
126
126
  - demo/test/fixtures/action_text/rich_texts.yml
127
127
  - demo/yarn.lock
128
+ - gemfiles/5.0.gemfile
129
+ - gemfiles/5.1.gemfile
130
+ - gemfiles/5.2.gemfile
131
+ - gemfiles/6.0.gemfile
132
+ - gemfiles/edge.gemfile
128
133
  - lib/bootstrap_form.rb
129
134
  - lib/bootstrap_form/action_view_extensions/form_helper.rb
130
135
  - lib/bootstrap_form/components.rb