bootstrap_concerns 0.4.0 → 0.5.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95a72c03e44647232b0738d11cc3a02f73a5a0c4b4f36ca3772dda008d79b123
|
4
|
+
data.tar.gz: f26bdb6a4f6ddc4a0441683dc97e9ab037d0e53089976b52eda0c8f2b511c913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 653a147bcb0d7f3e3c4068fd1538c7a79b7f2a0150ccc081195a6f55647deb9653354fdc3594bfde86e7ded36e0cf1c6e95940e2ec35b7231a41eaa798698daa
|
7
|
+
data.tar.gz: b78ca83f09bd8763b44811a85f77ee313ba81aebba1e462bb1053c6ebd37bcf38ac2552acb4e87fa99c4f03a658c428ba8e59b5de6db536cbe364ff496905657
|
@@ -1,17 +1,30 @@
|
|
1
1
|
module BootstrapConcerns
|
2
2
|
module ComponentsHelper
|
3
|
-
|
3
|
+
MARGIN = "mb-3".freeze
|
4
4
|
|
5
5
|
def assign_icon
|
6
6
|
icon("box-arrow-in-left", "Assign")
|
7
7
|
end
|
8
8
|
|
9
9
|
def boolean_false_icon
|
10
|
-
|
10
|
+
icon("x-circle-fill")
|
11
11
|
end
|
12
12
|
|
13
13
|
def boolean_true_icon
|
14
|
-
|
14
|
+
icon("check-circle-fill")
|
15
|
+
end
|
16
|
+
|
17
|
+
def bs_button_tag(content_or_options = nil, options = nil, &)
|
18
|
+
normalized_options =
|
19
|
+
if content_or_options.is_a?(Hash)
|
20
|
+
content_or_options
|
21
|
+
else
|
22
|
+
options ||= {}
|
23
|
+
end
|
24
|
+
|
25
|
+
normalized_options.merge!(Option.options_with_button_class(normalized_options))
|
26
|
+
|
27
|
+
button_tag(content_or_options, options, &)
|
15
28
|
end
|
16
29
|
|
17
30
|
def bs_button_to(name = nil, options = nil, html_options = nil, &)
|
@@ -21,7 +34,7 @@ module BootstrapConcerns
|
|
21
34
|
def bs_errors(record)
|
22
35
|
return if record.errors.empty?
|
23
36
|
|
24
|
-
content_tag(:div, class: "alert alert-danger alert-dismissible fade show
|
37
|
+
content_tag(:div, class: "alert alert-danger alert-dismissible fade show #{MARGIN}") do
|
25
38
|
concat content_tag(:h5, "Errors")
|
26
39
|
concat(
|
27
40
|
content_tag(:ul, class: "mb-0") do
|
@@ -34,6 +47,19 @@ module BootstrapConcerns
|
|
34
47
|
end
|
35
48
|
end
|
36
49
|
|
50
|
+
def bs_form_with(model: false, **options, &)
|
51
|
+
form_with(model: model, **options) do |form|
|
52
|
+
concat(bs_errors(model)) if model
|
53
|
+
concat(
|
54
|
+
content_tag(:div, class: "row") do
|
55
|
+
content_tag(:div, class: "col-md-6") do
|
56
|
+
yield(form)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
37
63
|
def bs_link_or_button_to(method_name, name, options, html_options, &)
|
38
64
|
normalized_html_options =
|
39
65
|
if block_given?
|
@@ -58,11 +84,11 @@ module BootstrapConcerns
|
|
58
84
|
end
|
59
85
|
|
60
86
|
def bs_search_col(&)
|
61
|
-
content_tag(:div, class: "col-12 col-sm #{
|
87
|
+
content_tag(:div, class: "col-12 col-sm #{MARGIN}", &)
|
62
88
|
end
|
63
89
|
|
64
90
|
def bs_search_submit_col
|
65
|
-
content_tag(:div, class: "col-auto #{
|
91
|
+
content_tag(:div, class: "col-auto #{MARGIN}") do
|
66
92
|
content_tag(:button, BootstrapConcerns::Option.options_with_button_class) do
|
67
93
|
search_icon
|
68
94
|
end
|
@@ -100,8 +126,9 @@ module BootstrapConcerns
|
|
100
126
|
end
|
101
127
|
end
|
102
128
|
|
103
|
-
def icon(name, text)
|
104
|
-
content_tag("i",
|
129
|
+
def icon(name, text = nil)
|
130
|
+
i = content_tag("i", nil, class: "bi bi-#{name}")
|
131
|
+
text ? i + content_tag(:span, text, class: "ms-1 d-none d-sm-inline") : i
|
105
132
|
end
|
106
133
|
|
107
134
|
def import_icon
|
@@ -52,6 +52,15 @@ module BootstrapConcerns
|
|
52
52
|
email_field(method, options_with_form_control_class(options))
|
53
53
|
end
|
54
54
|
|
55
|
+
def bs_form_group(method, type, *args)
|
56
|
+
options = args.find { it.is_a?(Hash) }.to_h
|
57
|
+
|
58
|
+
@template.content_tag(:div, class: ComponentsHelper::MARGIN) do
|
59
|
+
@template.concat bs_label(method, options.slice(:required))
|
60
|
+
@template.concat public_send("bs_#{type}", method, *args)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
55
64
|
def bs_grouped_collection_select(
|
56
65
|
method,
|
57
66
|
collection,
|
@@ -11,7 +11,7 @@ module BootstrapConcerns
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def prefixed_option(options, key:, prefix:, default: nil)
|
14
|
-
(options.delete(key) || default)&.then { "#{prefix}-#{
|
14
|
+
(options.delete(key) || default)&.then { "#{prefix}-#{it}" }
|
15
15
|
end
|
16
16
|
|
17
17
|
def options_with_base_class(options, *base_class)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_concerns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Brooks
|
8
8
|
- Robert Keresnyei
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
|
-
rubygems_version: 3.6.
|
81
|
+
rubygems_version: 3.6.7
|
82
82
|
specification_version: 4
|
83
83
|
summary: Concerns for building Bootstrap components with Ruby on Rails.
|
84
84
|
test_files: []
|