rails_bootstrap_form 0.3.1 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/stylesheets/rails_bootstrap_form.css +6 -0
- data/demo/app/models/user.rb +3 -0
- data/demo/config/locales/en.rb +1 -0
- data/lib/rails_bootstrap_form/bootstrap_form_builder.rb +5 -1
- data/lib/rails_bootstrap_form/bootstrap_form_options.rb +6 -0
- data/lib/rails_bootstrap_form/inputs.rb +74 -1
- data/lib/rails_bootstrap_form/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 258bf9fab2788b0c8cb56a29936c65f5f2db39c4b34f8bf0b0c6cfc1cf9aec0e
|
4
|
+
data.tar.gz: bfe585f59942a256f5f7ed95b393acb993499eddfe1f7f7ad67e97184afa0673
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0d869fb1a264159585ace5eab0a776641358205862bdf072b40c845e922a8e846a2119d32feee31b93dcb35fd9dd1c156669bd05a4260469a15367fdb146650
|
7
|
+
data.tar.gz: a67cbe82b6aec6a4459715085eca05d692cb5f3ad5629972785e81c028163e2dbaaaf56d44f036be93f4f79008d924b78161259c13746742129970763676e1e3
|
data/Gemfile.lock
CHANGED
@@ -14,3 +14,9 @@ label.required::after {
|
|
14
14
|
background-position: right 0.5rem center, center right 2rem !important;
|
15
15
|
background-size: 24px 24px, calc(0.75em + 0.375rem) calc(0.75em + 0.375rem) !important;
|
16
16
|
}
|
17
|
+
.rails-bootstrap-forms-date-select select,
|
18
|
+
.rails-bootstrap-forms-time-select select,
|
19
|
+
.rails-bootstrap-forms-datetime-select select {
|
20
|
+
display: inline-block;
|
21
|
+
width: auto;
|
22
|
+
}
|
data/demo/app/models/user.rb
CHANGED
data/demo/config/locales/en.rb
CHANGED
@@ -25,6 +25,10 @@ module RailsBootstrapForm
|
|
25
25
|
options[:html].reverse_merge!(RailsBootstrapForm.config.default_form_attributes)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
def control_specific_class(field_tag_name)
|
29
|
+
"rails-bootstrap-forms-#{field_tag_name.to_s.tr("_", "-")}"
|
30
|
+
end
|
31
|
+
|
32
|
+
private :apply_default_form_options, :control_specific_class
|
29
33
|
end
|
30
34
|
end
|
@@ -82,6 +82,10 @@ module RailsBootstrapForm
|
|
82
82
|
# Default is false.
|
83
83
|
attr_accessor :floating
|
84
84
|
|
85
|
+
# Default CSS class that will be applied to all static fields.
|
86
|
+
# Default is `form-control-plaintext`.
|
87
|
+
attr_accessor :static_field_class
|
88
|
+
|
85
89
|
def initialize(options = {})
|
86
90
|
set_defaults
|
87
91
|
set_bootstrap_form_options(options)
|
@@ -140,6 +144,8 @@ module RailsBootstrapForm
|
|
140
144
|
@additional_label_class = nil
|
141
145
|
|
142
146
|
@floating = false
|
147
|
+
|
148
|
+
@static_field_class = "form-control-plaintext"
|
143
149
|
end
|
144
150
|
|
145
151
|
private :set_defaults
|
@@ -24,6 +24,12 @@ module RailsBootstrapForm
|
|
24
24
|
week_field
|
25
25
|
].freeze
|
26
26
|
|
27
|
+
DATE_SELECT_HELPERS = %i[
|
28
|
+
date_select
|
29
|
+
time_select
|
30
|
+
datetime_select
|
31
|
+
].freeze
|
32
|
+
|
27
33
|
FIELD_HELPERS.each do |field_tag_name|
|
28
34
|
define_method(field_tag_name) do |attribute, options = {}|
|
29
35
|
field_wrapper_builder(attribute, options) do
|
@@ -32,12 +38,79 @@ module RailsBootstrapForm
|
|
32
38
|
end
|
33
39
|
end
|
34
40
|
|
41
|
+
DATE_SELECT_HELPERS.each do |field_tag_name|
|
42
|
+
define_method(field_tag_name) do |attribute, options = {}, html_options = {}, &block|
|
43
|
+
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
44
|
+
|
45
|
+
field_wrapper_builder(attribute, options, html_options) do
|
46
|
+
tag.div(class: control_specific_class(field_tag_name)) do
|
47
|
+
super(attribute, options, html_options)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
35
53
|
def select(attribute, choices = nil, options = {}, html_options = {}, &block)
|
36
|
-
options =
|
54
|
+
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
37
55
|
|
38
56
|
field_wrapper_builder(attribute, options, html_options) do
|
39
57
|
super(attribute, choices, options, html_options, &block)
|
40
58
|
end
|
41
59
|
end
|
60
|
+
|
61
|
+
def collection_select(attribute, collection, value_method, text_method, options = {}, html_options = {})
|
62
|
+
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
63
|
+
|
64
|
+
field_wrapper_builder(attribute, options, html_options) do
|
65
|
+
super(attribute, collection, value_method, text_method, options, html_options)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def time_zone_select(attribute, priority_zones = nil, options = {}, html_options = {})
|
70
|
+
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
71
|
+
|
72
|
+
field_wrapper_builder(attribute, options, html_options) do
|
73
|
+
super(attribute, priority_zones, options, html_options)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def range_field(attribute, options = {})
|
78
|
+
options = {bootstrap_form: {field_class: "form-range"}}.deep_merge!(options)
|
79
|
+
|
80
|
+
field_wrapper_builder(attribute, options) do
|
81
|
+
super(attribute, options)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def color_field(attribute, options = {})
|
86
|
+
options = {bootstrap_form: {field_class: "form-control form-control-color"}}.deep_merge!(options)
|
87
|
+
|
88
|
+
field_wrapper_builder(attribute, options) do
|
89
|
+
super(attribute, options)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def hidden_field(attribute, options = {})
|
94
|
+
options[:value] = object.send(attribute) unless options.key?(:value)
|
95
|
+
|
96
|
+
super(attribute, options)
|
97
|
+
end
|
98
|
+
|
99
|
+
def static_field(*args)
|
100
|
+
options = args.extract_options!
|
101
|
+
attribute = args.first
|
102
|
+
|
103
|
+
static_options = options.merge(
|
104
|
+
readonly: true,
|
105
|
+
disabled: true,
|
106
|
+
bootstrap_form: {
|
107
|
+
field_class: bootstrap_form_options.static_field_class
|
108
|
+
}
|
109
|
+
)
|
110
|
+
|
111
|
+
static_options[:value] = object.send(attribute) unless options.key?(:value)
|
112
|
+
|
113
|
+
text_field(attribute, static_options)
|
114
|
+
end
|
42
115
|
end
|
43
116
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_bootstrap_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harshal LADHE (shivam091)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: generator_spec
|