comfy_bootstrap_form 4.0.3 → 4.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 +5 -5
- data/.rubocop.yml +3 -3
- data/.travis.yml +3 -4
- data/Gemfile +2 -0
- data/LICENSE.md +1 -1
- data/README.md +0 -2
- data/Rakefile +3 -1
- data/{bootstrap_form.gemspec → comfy_bootstrap_form.gemspec} +6 -4
- data/lib/comfy_bootstrap_form.rb +15 -1
- data/lib/{bootstrap_form → comfy_bootstrap_form}/bootstrap_options.rb +3 -1
- data/lib/{bootstrap_form → comfy_bootstrap_form}/form_builder.rb +20 -14
- data/lib/comfy_bootstrap_form/version.rb +7 -0
- data/lib/{bootstrap_form → comfy_bootstrap_form}/view_helper.rb +5 -3
- metadata +9 -10
- data/lib/bootstrap_form.rb +0 -13
- data/lib/bootstrap_form/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 52ad6eec307301d06755be3fbd82a3c62372be79
|
4
|
+
data.tar.gz: 7b66272d0bea20d173bc39c64636c6fc79f3cb64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b74b016d644a1fadfa212ba3abf1cd97be4d252d8b03813105aa22d20f013bf55529e5b5394f4b8750cf131d8e612b0373924e8134c30d0d58f553be3ac4192
|
7
|
+
data.tar.gz: ce6aee4bef4cdb53e603c0d209c142f9f22955ed16d0036e83d76987728ece5758d5b8845d0f4ff564347acb922fc28af636c4a7309de1f43a4f686196e6855d
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.3
|
3
3
|
Exclude:
|
4
4
|
- demo/**/*
|
5
5
|
|
@@ -94,8 +94,8 @@ Style/AsciiComments:
|
|
94
94
|
# -- Exceptions ----------------------------------------------------------------
|
95
95
|
Performance/RedundantMerge:
|
96
96
|
Exclude:
|
97
|
-
- 'lib/
|
97
|
+
- 'lib/comfy_bootstrap_form/view_helper.rb'
|
98
98
|
|
99
99
|
Naming/AccessorMethodName:
|
100
100
|
Exclude:
|
101
|
-
- 'lib/
|
101
|
+
- 'lib/comfy_bootstrap_form/bootstrap_options.rb'
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -6,8 +6,6 @@
|
|
6
6
|
[](http://rubygems.org/gems/comfy_bootstrap_form)
|
7
7
|
[](http://rubygems.org/gems/comfy_bootstrap_form)
|
8
8
|
[](https://travis-ci.org/comfy/comfy-bootstrap-form)
|
9
|
-
[](https://gemnasium.com/comfy/comfy-bootstrap-form)
|
10
|
-
[](https://codeclimate.com/github/comfy/comfy-bootstrap-form)
|
11
9
|
[](https://coveralls.io/r/comfy/comfy-bootstrap-form?branch=master)
|
12
10
|
[](https://gitter.im/comfy/comfortable-mexican-sofa)
|
13
11
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
begin
|
2
4
|
require "bundler/setup"
|
3
5
|
rescue LoadError
|
@@ -8,7 +10,7 @@ require "rdoc/task"
|
|
8
10
|
|
9
11
|
RDoc::Task.new(:rdoc) do |rdoc|
|
10
12
|
rdoc.rdoc_dir = "rdoc"
|
11
|
-
rdoc.title = "
|
13
|
+
rdoc.title = "ComfyBootstrapForm"
|
12
14
|
rdoc.options << "--line-numbers"
|
13
15
|
rdoc.rdoc_files.include("README.md")
|
14
16
|
rdoc.rdoc_files.include("lib/**/*.rb")
|
@@ -1,11 +1,13 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
|
4
|
-
require "
|
6
|
+
require "comfy_bootstrap_form/version"
|
5
7
|
|
6
8
|
Gem::Specification.new do |s|
|
7
9
|
s.name = "comfy_bootstrap_form"
|
8
|
-
s.version =
|
10
|
+
s.version = ComfyBootstrapForm::VERSION
|
9
11
|
s.authors = ["Oleg Khabarov"]
|
10
12
|
s.email = ["oleg@khabarov.ca"]
|
11
13
|
s.homepage = "https://github.com/comfy/comfy-bootstrap-form"
|
@@ -22,7 +24,7 @@ Gem::Specification.new do |s|
|
|
22
24
|
s.bindir = "exe"
|
23
25
|
s.require_paths = ["lib"]
|
24
26
|
|
25
|
-
s.required_ruby_version = ">= 2.
|
27
|
+
s.required_ruby_version = ">= 2.3.0"
|
26
28
|
|
27
29
|
s.add_dependency "rails", ">= 5.0.0"
|
28
30
|
end
|
data/lib/comfy_bootstrap_form.rb
CHANGED
@@ -1 +1,15 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "comfy_bootstrap_form/form_builder"
|
4
|
+
require "comfy_bootstrap_form/view_helper"
|
5
|
+
|
6
|
+
module ComfyBootstrapForm
|
7
|
+
module Rails
|
8
|
+
class Engine < ::Rails::Engine
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
ActiveSupport.on_load(:action_view) do
|
14
|
+
include ComfyBootstrapForm::ViewHelper
|
15
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ComfyBootstrapForm
|
2
4
|
# Container for bootstrap specific form builder options. It controls options
|
3
5
|
# that define form layout and grid sizing. They are passed-in into form helper
|
4
6
|
# and field helpers via `:bootstrap` option. For example:
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "bootstrap_options"
|
2
4
|
|
3
|
-
module
|
5
|
+
module ComfyBootstrapForm
|
4
6
|
class FormBuilder < ActionView::Helpers::FormBuilder
|
5
7
|
|
6
8
|
FIELD_HELPERS = %w[
|
@@ -15,7 +17,7 @@ module BootstrapForm
|
|
15
17
|
attr_accessor :form_bootstrap
|
16
18
|
|
17
19
|
def initialize(object_name, object, template, options)
|
18
|
-
@form_bootstrap =
|
20
|
+
@form_bootstrap = ComfyBootstrapForm::BootstrapOptions.new(options.delete(:bootstrap))
|
19
21
|
super(object_name, object, template, options)
|
20
22
|
end
|
21
23
|
|
@@ -44,6 +46,9 @@ module BootstrapForm
|
|
44
46
|
#
|
45
47
|
def select(method, choices = nil, options = {}, html_options = {}, &block)
|
46
48
|
bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
|
49
|
+
|
50
|
+
add_css_class!(html_options, "custom-select") if bootstrap.custom_control
|
51
|
+
|
47
52
|
draw_form_group(bootstrap, method, html_options) do
|
48
53
|
super(method, choices, options, html_options, &block)
|
49
54
|
end
|
@@ -93,8 +98,8 @@ module BootstrapForm
|
|
93
98
|
end
|
94
99
|
|
95
100
|
fieldset_css_class = "form-group"
|
96
|
-
fieldset_css_class
|
97
|
-
fieldset_css_class
|
101
|
+
fieldset_css_class += " row" if bootstrap.horizontal?
|
102
|
+
fieldset_css_class += " #{bootstrap.inline_margin_class}" if bootstrap.inline?
|
98
103
|
|
99
104
|
content_tag(:fieldset, class: fieldset_css_class) do
|
100
105
|
draw_control_column(bootstrap, offset: true) do
|
@@ -197,7 +202,7 @@ module BootstrapForm
|
|
197
202
|
add_css_class!(options, "btn")
|
198
203
|
|
199
204
|
form_group_class = "form-group"
|
200
|
-
form_group_class
|
205
|
+
form_group_class += " row" if bootstrap.horizontal?
|
201
206
|
|
202
207
|
content_tag(:div, class: form_group_class) do
|
203
208
|
draw_control_column(bootstrap, offset: true) do
|
@@ -241,8 +246,8 @@ module BootstrapForm
|
|
241
246
|
end
|
242
247
|
|
243
248
|
form_group_class = "form-group"
|
244
|
-
form_group_class
|
245
|
-
form_group_class
|
249
|
+
form_group_class += " row" if bootstrap.horizontal?
|
250
|
+
form_group_class += " mr-sm-2" if bootstrap.inline?
|
246
251
|
|
247
252
|
content_tag(:div, class: form_group_class) do
|
248
253
|
content = "".html_safe
|
@@ -265,8 +270,8 @@ module BootstrapForm
|
|
265
270
|
end
|
266
271
|
|
267
272
|
form_group_class = "form-group"
|
268
|
-
form_group_class
|
269
|
-
form_group_class
|
273
|
+
form_group_class += " row" if bootstrap.horizontal?
|
274
|
+
form_group_class += " mr-sm-2" if bootstrap.inline?
|
270
275
|
|
271
276
|
content_tag(:div, class: form_group_class) do
|
272
277
|
concat label
|
@@ -275,7 +280,8 @@ module BootstrapForm
|
|
275
280
|
end
|
276
281
|
|
277
282
|
def draw_errors(method)
|
278
|
-
return unless
|
283
|
+
return unless object.present?
|
284
|
+
return unless (errors = object.errors[method]).present?
|
279
285
|
|
280
286
|
content_tag(:div, class: "invalid-feedback") do
|
281
287
|
errors.join(", ")
|
@@ -327,7 +333,7 @@ module BootstrapForm
|
|
327
333
|
def draw_control_column(bootstrap, offset:)
|
328
334
|
return yield unless bootstrap.horizontal?
|
329
335
|
css_class = bootstrap.control_col_class.to_s
|
330
|
-
css_class
|
336
|
+
css_class += " #{bootstrap.offset_col_class}" if offset
|
331
337
|
content_tag(:div, class: css_class) do
|
332
338
|
yield
|
333
339
|
end
|
@@ -393,13 +399,13 @@ module BootstrapForm
|
|
393
399
|
label_css_class = "custom-control-label"
|
394
400
|
|
395
401
|
form_check_css_class = "custom-control"
|
396
|
-
form_check_css_class
|
402
|
+
form_check_css_class +=
|
397
403
|
case type
|
398
404
|
when :radio_button then " custom-radio"
|
399
405
|
when :check_box then " custom-checkbox"
|
400
406
|
end
|
401
407
|
|
402
|
-
form_check_css_class
|
408
|
+
form_check_css_class += " custom-control-inline" if bootstrap.check_inline
|
403
409
|
|
404
410
|
add_css_class!(html_options, "custom-control-input")
|
405
411
|
|
@@ -407,7 +413,7 @@ module BootstrapForm
|
|
407
413
|
label_css_class = "form-check-label"
|
408
414
|
|
409
415
|
form_check_css_class = "form-check"
|
410
|
-
form_check_css_class
|
416
|
+
form_check_css_class += " form-check-inline" if bootstrap.check_inline
|
411
417
|
|
412
418
|
add_css_class!(html_options, "form-check-input")
|
413
419
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ComfyBootstrapForm
|
2
4
|
module ViewHelper
|
3
5
|
|
4
6
|
# Wrapper for `form_with`. Passing in Bootstrap form builder.
|
@@ -11,7 +13,7 @@ module BootstrapForm
|
|
11
13
|
css_classes = [css_classes, "form-inline"].compact.join(" ")
|
12
14
|
end
|
13
15
|
|
14
|
-
form_options = options.reverse_merge(builder:
|
16
|
+
form_options = options.reverse_merge(builder: ComfyBootstrapForm::FormBuilder)
|
15
17
|
form_options.merge!(class: css_classes) unless css_classes.blank?
|
16
18
|
|
17
19
|
supress_form_field_errors do
|
@@ -30,7 +32,7 @@ module BootstrapForm
|
|
30
32
|
css_classes = [css_classes, "form-inline"].compact.join(" ")
|
31
33
|
end
|
32
34
|
|
33
|
-
options.reverse_merge!(builder:
|
35
|
+
options.reverse_merge!(builder: ComfyBootstrapForm::FormBuilder)
|
34
36
|
options[:html].merge!(class: css_classes) unless css_classes.blank?
|
35
37
|
|
36
38
|
supress_form_field_errors do
|
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.
|
4
|
+
version: 4.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Khabarov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -40,13 +40,12 @@ files:
|
|
40
40
|
- LICENSE.md
|
41
41
|
- README.md
|
42
42
|
- Rakefile
|
43
|
-
-
|
44
|
-
- lib/bootstrap_form.rb
|
45
|
-
- lib/bootstrap_form/bootstrap_options.rb
|
46
|
-
- lib/bootstrap_form/form_builder.rb
|
47
|
-
- lib/bootstrap_form/version.rb
|
48
|
-
- lib/bootstrap_form/view_helper.rb
|
43
|
+
- comfy_bootstrap_form.gemspec
|
49
44
|
- lib/comfy_bootstrap_form.rb
|
45
|
+
- lib/comfy_bootstrap_form/bootstrap_options.rb
|
46
|
+
- lib/comfy_bootstrap_form/form_builder.rb
|
47
|
+
- lib/comfy_bootstrap_form/version.rb
|
48
|
+
- lib/comfy_bootstrap_form/view_helper.rb
|
50
49
|
homepage: https://github.com/comfy/comfy-bootstrap-form
|
51
50
|
licenses:
|
52
51
|
- MIT
|
@@ -59,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
58
|
requirements:
|
60
59
|
- - ">="
|
61
60
|
- !ruby/object:Gem::Version
|
62
|
-
version: 2.
|
61
|
+
version: 2.3.0
|
63
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
63
|
requirements:
|
65
64
|
- - ">="
|
@@ -67,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
66
|
version: '0'
|
68
67
|
requirements: []
|
69
68
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
69
|
+
rubygems_version: 2.6.14
|
71
70
|
signing_key:
|
72
71
|
specification_version: 4
|
73
72
|
summary: Rails form builder that makes it easy to style forms using Bootstrap 4
|
data/lib/bootstrap_form.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require "bootstrap_form/form_builder"
|
2
|
-
require "bootstrap_form/view_helper"
|
3
|
-
|
4
|
-
module BootstrapForm
|
5
|
-
module Rails
|
6
|
-
class Engine < ::Rails::Engine
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
ActiveSupport.on_load(:action_view) do
|
12
|
-
include BootstrapForm::ViewHelper
|
13
|
-
end
|