bootstrap_concerns 0.5.5 → 0.5.7
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/bootstrap_concerns/form_builder.rb +25 -5
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 707af3be707adde6b5fd86783f9d950253315464cd906e6a65057537f13cc9ff
|
|
4
|
+
data.tar.gz: c072837ef9eb4547bf7a460b6ba94d18e3ef7b18b7b5749c84ef6fe295725973
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8869c35220c6cb217d9532ca0ab6517860071e001b3a74fd1f527811d804fb7cfe9bca893dc8a7c2e7a9c426259254cd45572315275113931f1299f0c71586f7
|
|
7
|
+
data.tar.gz: 937efce856f940a04d3dc37a1503a32f36fd0b43b70a39af46e2680083e265e58e0f86536047a89716f264dee0b972c457b92812b798f61a67db407b9edca83b
|
|
@@ -7,6 +7,8 @@ module BootstrapConcerns
|
|
|
7
7
|
FORM_SELECT_BASE_CLASS = "form-select".freeze
|
|
8
8
|
REQUIRED_CLASS = "required".freeze
|
|
9
9
|
|
|
10
|
+
delegate :content_tag, :concat, to: :@template, private: true
|
|
11
|
+
|
|
10
12
|
def bs_button(value = nil, options = {}, &)
|
|
11
13
|
normalized_options = value.is_a?(Hash) ? value : options
|
|
12
14
|
normalized_options.deep_merge!(Option.options_with_button_class(normalized_options))
|
|
@@ -53,11 +55,21 @@ module BootstrapConcerns
|
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
def bs_form_group(method, type, *args)
|
|
56
|
-
options = args.find { it.is_a?(Hash) && it.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
options = args.find { it.is_a?(Hash) && it.key?(:required) }.to_h
|
|
59
|
+
input_group = args.find { it.is_a?(Hash) && it[:input_group] } || {}
|
|
60
|
+
input_group_flag = input_group[:input_group].present?
|
|
61
|
+
|
|
62
|
+
content_tag(:div, class: ComponentsHelper::MARGIN) do
|
|
63
|
+
concat bs_label(method, options.slice(:required))
|
|
64
|
+
if input_group_flag
|
|
65
|
+
concat(content_tag(:div, class: "input-group") do
|
|
66
|
+
public_send("bs_#{type}", method, *args)
|
|
67
|
+
end)
|
|
68
|
+
concat error_message(method, outside: true)
|
|
69
|
+
else
|
|
70
|
+
concat(public_send("bs_#{type}", method, *args))
|
|
71
|
+
concat error_message(method)
|
|
72
|
+
end
|
|
61
73
|
end
|
|
62
74
|
end
|
|
63
75
|
|
|
@@ -165,6 +177,14 @@ module BootstrapConcerns
|
|
|
165
177
|
|
|
166
178
|
private
|
|
167
179
|
|
|
180
|
+
def error_message(method, outside: false)
|
|
181
|
+
return "".html_safe if object.errors[method].blank?
|
|
182
|
+
|
|
183
|
+
classes = ["invalid-feedback"]
|
|
184
|
+
classes << "d-block" if outside
|
|
185
|
+
content_tag(:div, object.errors[method].join(", "), class: classes.join(" "))
|
|
186
|
+
end
|
|
187
|
+
|
|
168
188
|
def options_with_form_check_input_class(options)
|
|
169
189
|
Option.options_with_base_class(options, FORM_CHECK_INPUT_BASE_CLASS)
|
|
170
190
|
end
|
metadata
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bootstrap_concerns
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Evan Brooks
|
|
8
8
|
- Robert Keresnyei
|
|
9
|
+
- Yuriy Kharchenko
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
12
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
@@ -92,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
92
93
|
- !ruby/object:Gem::Version
|
|
93
94
|
version: '0'
|
|
94
95
|
requirements: []
|
|
95
|
-
rubygems_version:
|
|
96
|
+
rubygems_version: 4.0.3
|
|
96
97
|
specification_version: 4
|
|
97
98
|
summary: Concerns for building Bootstrap components with Ruby on Rails.
|
|
98
99
|
test_files: []
|