bootstrap_form 5.0.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +31 -16
- data/.gitignore +15 -3
- data/.rubocop.yml +3 -1
- data/.yarnrc +5 -0
- data/CHANGELOG.md +53 -2
- data/CONTRIBUTING.md +110 -22
- data/Dangerfile +5 -5
- data/Dockerfile +6 -11
- data/Gemfile +5 -23
- data/README.md +805 -54
- data/RELEASING.md +16 -10
- data/Rakefile +7 -6
- data/bootstrap_form.gemspec +7 -10
- data/docker-compose.yml +9 -48
- data/gemfiles/6.0.gemfile +1 -1
- data/gemfiles/6.1.gemfile +1 -1
- data/gemfiles/7.0.gemfile +5 -0
- data/gemfiles/common.gemfile +28 -0
- data/gemfiles/edge.gemfile +3 -2
- data/lib/bootstrap_form/components/hints.rb +13 -4
- data/lib/bootstrap_form/components/labels.rb +4 -10
- data/lib/bootstrap_form/components/validation.rb +36 -19
- data/lib/bootstrap_form/form_builder.rb +9 -6
- data/lib/bootstrap_form/form_group.rb +15 -8
- data/lib/bootstrap_form/form_group_builder.rb +10 -7
- data/lib/bootstrap_form/helpers/bootstrap.rb +12 -9
- data/lib/bootstrap_form/helpers/field.rb +26 -0
- data/lib/bootstrap_form/helpers.rb +1 -0
- data/lib/bootstrap_form/inputs/check_box.rb +26 -8
- data/lib/bootstrap_form/inputs/collection_check_boxes.rb +5 -1
- data/lib/bootstrap_form/inputs/collection_select.rb +1 -1
- data/lib/bootstrap_form/inputs/grouped_collection_select.rb +1 -1
- data/lib/bootstrap_form/inputs/radio_button.rb +15 -10
- data/lib/bootstrap_form/version.rb +2 -1
- data/lib/bootstrap_form.rb +1 -1
- metadata +17 -88
- data/demo/.postcssrc.yml +0 -3
- data/demo/README.md +0 -17
- data/demo/Rakefile +0 -6
- data/demo/app/assets/config/manifest.js +0 -1
- data/demo/app/assets/stylesheets/actiontext.scss +0 -38
- data/demo/app/assets/stylesheets/application.scss +0 -1
- data/demo/app/controllers/application_controller.rb +0 -2
- data/demo/app/controllers/bootstrap_controller.rb +0 -14
- data/demo/app/helpers/bootstrap_helper.rb +0 -27
- data/demo/app/javascript/channels/consumer.js +0 -6
- data/demo/app/javascript/channels/index.js +0 -5
- data/demo/app/javascript/packs/application.js +0 -11
- data/demo/app/models/address.rb +0 -3
- data/demo/app/models/application_record.rb +0 -3
- data/demo/app/models/faux_user.rb +0 -9
- data/demo/app/models/super_user.rb +0 -2
- data/demo/app/models/user.rb +0 -11
- data/demo/app/views/active_storage/blobs/_blob.html.erb +0 -14
- data/demo/app/views/bootstrap/form.html.erb +0 -67
- data/demo/app/views/layouts/application.html.erb +0 -68
- data/demo/bin/bundle +0 -3
- data/demo/bin/rails +0 -4
- data/demo/bin/rake +0 -4
- data/demo/bin/setup +0 -36
- data/demo/bin/update +0 -31
- data/demo/bin/webpack +0 -15
- data/demo/bin/webpack-dev-server +0 -15
- data/demo/bin/yarn +0 -11
- data/demo/config/application.rb +0 -21
- data/demo/config/boot.rb +0 -5
- data/demo/config/database.yml +0 -21
- data/demo/config/environment.rb +0 -5
- data/demo/config/environments/development.rb +0 -60
- data/demo/config/environments/production.rb +0 -48
- data/demo/config/environments/test.rb +0 -46
- data/demo/config/initializers/application_controller_renderer.rb +0 -8
- data/demo/config/initializers/assets.rb +0 -14
- data/demo/config/initializers/backtrace_silencers.rb +0 -7
- data/demo/config/initializers/cookies_serializer.rb +0 -5
- data/demo/config/initializers/filter_parameter_logging.rb +0 -4
- data/demo/config/initializers/inflections.rb +0 -16
- data/demo/config/initializers/mime_types.rb +0 -4
- data/demo/config/initializers/wrap_parameters.rb +0 -14
- data/demo/config/locales/en.yml +0 -33
- data/demo/config/puma.rb +0 -56
- data/demo/config/routes.rb +0 -5
- data/demo/config/spring.rb +0 -6
- data/demo/config/storage.yml +0 -35
- data/demo/config/webpack/development.js +0 -5
- data/demo/config/webpack/environment.js +0 -3
- data/demo/config/webpack/production.js +0 -5
- data/demo/config/webpack/test.js +0 -5
- data/demo/config/webpacker.yml +0 -92
- data/demo/config.ru +0 -5
- data/demo/db/schema.rb +0 -69
- data/demo/log/.keep +0 -0
- data/demo/package.json +0 -17
- data/demo/public/favicon.ico +0 -0
- data/demo/test/fixtures/action_text/rich_texts.yml +0 -4
- data/demo/yarn.lock +0 -6257
- data/gemfiles/5.2.gemfile +0 -4
@@ -9,14 +9,11 @@ module BootstrapForm
|
|
9
9
|
included do
|
10
10
|
def check_box_with_bootstrap(name, options={}, checked_value="1", unchecked_value="0", &block)
|
11
11
|
options = options.symbolize_keys!
|
12
|
-
check_box_options = options.except(:class, :label, :label_class, :error_message, :help,
|
13
|
-
:inline, :hide_label, :skip_label, :wrapper_class, :switch)
|
14
|
-
check_box_options[:class] = check_box_classes(name, options)
|
15
12
|
|
16
|
-
tag.div(class: check_box_wrapper_class(options)) do
|
17
|
-
html = check_box_without_bootstrap(name, check_box_options, checked_value, unchecked_value)
|
18
|
-
html
|
19
|
-
html
|
13
|
+
tag.div(class: check_box_wrapper_class(options), **options[:wrapper].to_h.except(:class)) do
|
14
|
+
html = check_box_without_bootstrap(name, check_box_options(name, options), checked_value, unchecked_value)
|
15
|
+
html << check_box_label(name, options, checked_value, &block) unless options[:skip_label]
|
16
|
+
html << generate_error(name) if options[:error_message]
|
20
17
|
html
|
21
18
|
end
|
22
19
|
end
|
@@ -26,6 +23,13 @@ module BootstrapForm
|
|
26
23
|
|
27
24
|
private
|
28
25
|
|
26
|
+
def check_box_options(name, options)
|
27
|
+
check_box_options = options.except(:class, :label, :label_class, :error_message, :help,
|
28
|
+
:inline, :hide_label, :skip_label, :wrapper, :wrapper_class, :switch)
|
29
|
+
check_box_options[:class] = check_box_classes(name, options)
|
30
|
+
check_box_options.merge!(required_field_options(options, name))
|
31
|
+
end
|
32
|
+
|
29
33
|
def check_box_label(name, options, checked_value, &block)
|
30
34
|
label_name = if options[:multiple]
|
31
35
|
check_box_value(name, checked_value)
|
@@ -59,6 +63,7 @@ module BootstrapForm
|
|
59
63
|
def check_box_label_class(options)
|
60
64
|
classes = ["form-check-label"]
|
61
65
|
classes << options[:label_class]
|
66
|
+
classes << "required" if options[:required]
|
62
67
|
classes << hide_class if options[:hide_label]
|
63
68
|
classes.flatten.compact
|
64
69
|
end
|
@@ -66,10 +71,23 @@ module BootstrapForm
|
|
66
71
|
def check_box_wrapper_class(options)
|
67
72
|
classes = ["form-check"]
|
68
73
|
classes << "form-check-inline" if layout_inline?(options[:inline])
|
74
|
+
classes << "mb-3" unless options[:multiple] || layout == :horizontal
|
69
75
|
classes << "form-switch" if options[:switch]
|
70
|
-
classes << options
|
76
|
+
classes << options.dig(:wrapper, :class).presence
|
77
|
+
classes << options[:wrapper_class].presence
|
71
78
|
classes.flatten.compact
|
72
79
|
end
|
80
|
+
|
81
|
+
def checkbox_required(options, method)
|
82
|
+
if options[:skip_required]
|
83
|
+
warn "`:skip_required` is deprecated, use `:required: false` instead"
|
84
|
+
false
|
85
|
+
elsif options.key?(:required)
|
86
|
+
options[:required]
|
87
|
+
else
|
88
|
+
required_attribute?(object, method)
|
89
|
+
end
|
90
|
+
end
|
73
91
|
end
|
74
92
|
end
|
75
93
|
end
|
@@ -13,7 +13,11 @@ module BootstrapForm
|
|
13
13
|
options[:multiple] = true
|
14
14
|
check_box(name, options, value, nil)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
|
+
if args.extract_options!.symbolize_keys!.delete(:include_hidden) { true }
|
18
|
+
html.prepend hidden_field(args.first, value: "", multiple: true)
|
19
|
+
end
|
20
|
+
html
|
17
21
|
end
|
18
22
|
|
19
23
|
bootstrap_alias :collection_check_boxes
|
@@ -12,7 +12,7 @@ module BootstrapForm
|
|
12
12
|
def collection_select_with_bootstrap(method, collection, value_method, text_method, options={}, html_options={})
|
13
13
|
html_options = html_options.reverse_merge(control_class: "form-select")
|
14
14
|
form_group_builder(method, options, html_options) do
|
15
|
-
|
15
|
+
prepend_and_append_input(method, options) do
|
16
16
|
collection_select_without_bootstrap(method, collection, value_method, text_method, options, html_options)
|
17
17
|
end
|
18
18
|
end
|
@@ -14,7 +14,7 @@ module BootstrapForm
|
|
14
14
|
option_value_method, options={}, html_options={})
|
15
15
|
html_options = html_options.reverse_merge(control_class: "form-select")
|
16
16
|
form_group_builder(method, options, html_options) do
|
17
|
-
|
17
|
+
prepend_and_append_input(method, options) do
|
18
18
|
grouped_collection_select_without_bootstrap(method, collection, group_method,
|
19
19
|
group_label_method, option_key_method,
|
20
20
|
option_value_method, options, html_options)
|
@@ -9,15 +9,12 @@ module BootstrapForm
|
|
9
9
|
included do
|
10
10
|
def radio_button_with_bootstrap(name, value, *args)
|
11
11
|
options = args.extract_options!.symbolize_keys!
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
html = radio_button_without_bootstrap(name, value, radio_button_options)
|
19
|
-
html.concat(radio_button_label(name, value, options)) unless options[:skip_label]
|
20
|
-
html.concat(generate_error(name)) if options[:error_message]
|
12
|
+
wrapper_attributes = options[:wrapper] || {}
|
13
|
+
wrapper_attributes[:class] = radio_button_wrapper_class(options)
|
14
|
+
tag.div(**wrapper_attributes) do
|
15
|
+
html = radio_button_without_bootstrap(name, value, radio_button_options(name, options))
|
16
|
+
html << radio_button_label(name, value, options) unless options[:skip_label]
|
17
|
+
html << generate_error(name) if options[:error_message]
|
21
18
|
html
|
22
19
|
end
|
23
20
|
end
|
@@ -27,6 +24,13 @@ module BootstrapForm
|
|
27
24
|
|
28
25
|
private
|
29
26
|
|
27
|
+
def radio_button_options(name, options)
|
28
|
+
radio_button_options = options.except(:class, :label, :label_class, :error_message, :help,
|
29
|
+
:inline, :hide_label, :skip_label, :wrapper, :wrapper_class)
|
30
|
+
radio_button_options[:class] = radio_button_classes(name, options)
|
31
|
+
radio_button_options.merge!(required_field_options(options, name))
|
32
|
+
end
|
33
|
+
|
30
34
|
def radio_button_label(name, value, options)
|
31
35
|
label_options = { value: value, class: radio_button_label_class(options) }
|
32
36
|
label_options[:for] = options[:id] if options[:id].present?
|
@@ -51,7 +55,8 @@ module BootstrapForm
|
|
51
55
|
classes = ["form-check"]
|
52
56
|
classes << "form-check-inline" if layout_inline?(options[:inline])
|
53
57
|
classes << "disabled" if options[:disabled]
|
54
|
-
classes << options
|
58
|
+
classes << options.dig(:wrapper, :class).presence
|
59
|
+
classes << options[:wrapper_class].presence
|
55
60
|
classes.flatten.compact
|
56
61
|
end
|
57
62
|
end
|
data/lib/bootstrap_form.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# NOTE: The rich_text_area and rich_text_area_tag helpers are defined in a file with a different
|
2
2
|
# name and not in the usual autoload-reachable way.
|
3
3
|
# The following line is definitely need to make `bootstrap_form` work.
|
4
|
-
if
|
4
|
+
if Rails::VERSION::STRING > "6"
|
5
5
|
require "#{Gem::Specification.find_by_name('actiontext').gem_dir}/app/helpers/action_text/tag_helper"
|
6
6
|
end
|
7
7
|
require "action_view"
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Potenza
|
8
8
|
- Carlos Lopes
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-05-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -17,42 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '6.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '6.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: activemodel
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '6.0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: rails
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - ">="
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '5.2'
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '5.2'
|
41
|
+
version: '6.0'
|
56
42
|
description: bootstrap_form is a rails form builder that makes it super easy to create
|
57
43
|
beautiful-looking forms using Bootstrap 5
|
58
44
|
email:
|
@@ -66,6 +52,7 @@ files:
|
|
66
52
|
- ".github/workflows/ruby.yml"
|
67
53
|
- ".gitignore"
|
68
54
|
- ".rubocop.yml"
|
55
|
+
- ".yarnrc"
|
69
56
|
- CHANGELOG.md
|
70
57
|
- CODE_OF_CONDUCT.md
|
71
58
|
- CONTRIBUTING.md
|
@@ -81,70 +68,11 @@ files:
|
|
81
68
|
- UPGRADE-5.0.md
|
82
69
|
- app/assets/stylesheets/rails_bootstrap_forms.css
|
83
70
|
- bootstrap_form.gemspec
|
84
|
-
- demo/.postcssrc.yml
|
85
|
-
- demo/README.md
|
86
|
-
- demo/Rakefile
|
87
|
-
- demo/app/assets/config/manifest.js
|
88
|
-
- demo/app/assets/stylesheets/actiontext.scss
|
89
|
-
- demo/app/assets/stylesheets/application.scss
|
90
|
-
- demo/app/controllers/application_controller.rb
|
91
|
-
- demo/app/controllers/bootstrap_controller.rb
|
92
|
-
- demo/app/helpers/bootstrap_helper.rb
|
93
|
-
- demo/app/javascript/channels/consumer.js
|
94
|
-
- demo/app/javascript/channels/index.js
|
95
|
-
- demo/app/javascript/packs/application.js
|
96
|
-
- demo/app/models/address.rb
|
97
|
-
- demo/app/models/application_record.rb
|
98
|
-
- demo/app/models/faux_user.rb
|
99
|
-
- demo/app/models/super_user.rb
|
100
|
-
- demo/app/models/user.rb
|
101
|
-
- demo/app/views/active_storage/blobs/_blob.html.erb
|
102
|
-
- demo/app/views/bootstrap/form.html.erb
|
103
|
-
- demo/app/views/layouts/application.html.erb
|
104
|
-
- demo/bin/bundle
|
105
|
-
- demo/bin/rails
|
106
|
-
- demo/bin/rake
|
107
|
-
- demo/bin/setup
|
108
|
-
- demo/bin/update
|
109
|
-
- demo/bin/webpack
|
110
|
-
- demo/bin/webpack-dev-server
|
111
|
-
- demo/bin/yarn
|
112
|
-
- demo/config.ru
|
113
|
-
- demo/config/application.rb
|
114
|
-
- demo/config/boot.rb
|
115
|
-
- demo/config/database.yml
|
116
|
-
- demo/config/environment.rb
|
117
|
-
- demo/config/environments/development.rb
|
118
|
-
- demo/config/environments/production.rb
|
119
|
-
- demo/config/environments/test.rb
|
120
|
-
- demo/config/initializers/application_controller_renderer.rb
|
121
|
-
- demo/config/initializers/assets.rb
|
122
|
-
- demo/config/initializers/backtrace_silencers.rb
|
123
|
-
- demo/config/initializers/cookies_serializer.rb
|
124
|
-
- demo/config/initializers/filter_parameter_logging.rb
|
125
|
-
- demo/config/initializers/inflections.rb
|
126
|
-
- demo/config/initializers/mime_types.rb
|
127
|
-
- demo/config/initializers/wrap_parameters.rb
|
128
|
-
- demo/config/locales/en.yml
|
129
|
-
- demo/config/puma.rb
|
130
|
-
- demo/config/routes.rb
|
131
|
-
- demo/config/spring.rb
|
132
|
-
- demo/config/storage.yml
|
133
|
-
- demo/config/webpack/development.js
|
134
|
-
- demo/config/webpack/environment.js
|
135
|
-
- demo/config/webpack/production.js
|
136
|
-
- demo/config/webpack/test.js
|
137
|
-
- demo/config/webpacker.yml
|
138
|
-
- demo/db/schema.rb
|
139
|
-
- demo/log/.keep
|
140
|
-
- demo/package.json
|
141
|
-
- demo/public/favicon.ico
|
142
|
-
- demo/test/fixtures/action_text/rich_texts.yml
|
143
|
-
- demo/yarn.lock
|
144
71
|
- docker-compose.yml
|
145
|
-
- gemfiles/5.2.gemfile
|
146
72
|
- gemfiles/6.0.gemfile
|
147
73
|
- gemfiles/6.1.gemfile
|
74
|
+
- gemfiles/7.0.gemfile
|
75
|
+
- gemfiles/common.gemfile
|
148
76
|
- gemfiles/edge.gemfile
|
149
77
|
- lib/bootstrap_form.rb
|
150
78
|
- lib/bootstrap_form/action_view_extensions/form_helper.rb
|
@@ -160,6 +88,7 @@ files:
|
|
160
88
|
- lib/bootstrap_form/form_group_builder.rb
|
161
89
|
- lib/bootstrap_form/helpers.rb
|
162
90
|
- lib/bootstrap_form/helpers/bootstrap.rb
|
91
|
+
- lib/bootstrap_form/helpers/field.rb
|
163
92
|
- lib/bootstrap_form/inputs.rb
|
164
93
|
- lib/bootstrap_form/inputs/base.rb
|
165
94
|
- lib/bootstrap_form/inputs/check_box.rb
|
@@ -197,8 +126,9 @@ files:
|
|
197
126
|
homepage: https://github.com/bootstrap-ruby/bootstrap_form
|
198
127
|
licenses:
|
199
128
|
- MIT
|
200
|
-
metadata:
|
201
|
-
|
129
|
+
metadata:
|
130
|
+
rubygems_mfa_required: 'true'
|
131
|
+
post_install_message:
|
202
132
|
rdoc_options: []
|
203
133
|
require_paths:
|
204
134
|
- lib
|
@@ -206,16 +136,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
206
136
|
requirements:
|
207
137
|
- - ">="
|
208
138
|
- !ruby/object:Gem::Version
|
209
|
-
version: '
|
139
|
+
version: '3.0'
|
210
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
141
|
requirements:
|
212
142
|
- - ">="
|
213
143
|
- !ruby/object:Gem::Version
|
214
144
|
version: '0'
|
215
145
|
requirements: []
|
216
|
-
|
217
|
-
|
218
|
-
signing_key:
|
146
|
+
rubygems_version: 3.4.10
|
147
|
+
signing_key:
|
219
148
|
specification_version: 4
|
220
149
|
summary: Rails form builder that makes it easy to style forms using Bootstrap 5
|
221
150
|
test_files: []
|
data/demo/.postcssrc.yml
DELETED
data/demo/README.md
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# DEMO APP (Rails 5.2)
|
2
|
-
|
3
|
-
### Usage
|
4
|
-
|
5
|
-
- `rake db:schema:load`
|
6
|
-
- `rails s`
|
7
|
-
- Navigate to http://localhost:3000
|
8
|
-
|
9
|
-
### Following files were added or changed:
|
10
|
-
|
11
|
-
- db/schema.rb
|
12
|
-
- config/{application, routes, boot}.rb
|
13
|
-
- config/environments/{development, test}.rb
|
14
|
-
- app/models/{address,user,super_user,faux_user}.rb
|
15
|
-
- app/controllers/bootstrap_controller.rb
|
16
|
-
- app/views/layouts/application.html.erb
|
17
|
-
- app/views/bootstrap/form.html.erb
|
data/demo/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
//= link application.css
|
@@ -1,38 +0,0 @@
|
|
1
|
-
//
|
2
|
-
// Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
|
3
|
-
// the trix-editor content (whether displayed or under editing). Feel free to incorporate this
|
4
|
-
// inclusion directly in any other asset bundle and remove this file.
|
5
|
-
//
|
6
|
-
//= require trix/dist/trix
|
7
|
-
// When using `application.scss`, this has to be `import`, not `require`.
|
8
|
-
@import "trix/dist/trix";
|
9
|
-
|
10
|
-
// We need to override trix.css’s image gallery styles to accommodate the
|
11
|
-
// <action-text-attachment> element we wrap around attachments. Otherwise,
|
12
|
-
// images in galleries will be squished by the max-width: 33%; rule.
|
13
|
-
.trix-content {
|
14
|
-
.attachment-gallery {
|
15
|
-
> action-text-attachment,
|
16
|
-
> .attachment {
|
17
|
-
flex: 1 0 33%;
|
18
|
-
padding: 0 0.5em;
|
19
|
-
max-width: 33%;
|
20
|
-
}
|
21
|
-
|
22
|
-
&.attachment-gallery--2,
|
23
|
-
&.attachment-gallery--4 {
|
24
|
-
> action-text-attachment,
|
25
|
-
> .attachment {
|
26
|
-
flex-basis: 50%;
|
27
|
-
max-width: 50%;
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
action-text-attachment {
|
33
|
-
.attachment {
|
34
|
-
padding: 0 !important;
|
35
|
-
max-width: 100% !important;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
@import "actiontext";
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class BootstrapController < ApplicationController
|
2
|
-
def form
|
3
|
-
@collection = [
|
4
|
-
Address.new(id: 1, street: "Foo"),
|
5
|
-
Address.new(id: 2, street: "Bar")
|
6
|
-
]
|
7
|
-
|
8
|
-
@user = User.new
|
9
|
-
|
10
|
-
@user_with_error = User.new
|
11
|
-
@user_with_error.errors.add(:email)
|
12
|
-
@user_with_error.errors.add(:misc)
|
13
|
-
end
|
14
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module BootstrapHelper
|
2
|
-
def form_with_source(&block)
|
3
|
-
form_html = capture(&block)
|
4
|
-
|
5
|
-
tag.div(class: "example") do
|
6
|
-
concat(form_html)
|
7
|
-
concat(toggle)
|
8
|
-
concat(codemirror(form_html))
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def codemirror(form_html)
|
15
|
-
tag.div(class: "code", style: "display: none") do
|
16
|
-
tag.textarea(class: "codemirror") do
|
17
|
-
HtmlBeautifier.beautify(form_html.strip.gsub(">", ">\n").gsub("<", "\n<"))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def toggle
|
23
|
-
tag.button(class: "toggle btn btn-sm btn-info") do
|
24
|
-
"Show Source Code"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
-
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
-
|
4
|
-
import { createConsumer } from "@rails/actioncable"
|
5
|
-
|
6
|
-
export default createConsumer()
|
@@ -1,11 +0,0 @@
|
|
1
|
-
// This file is automatically compiled by Webpack, along with any other files
|
2
|
-
// present in this directory. You're encouraged to place your actual application logic in
|
3
|
-
// a relevant structure within app/javascript and only use these pack files to reference
|
4
|
-
// that code so it'll be compiled.
|
5
|
-
|
6
|
-
require("@rails/ujs").start()
|
7
|
-
require("turbolinks").start()
|
8
|
-
require("@rails/activestorage").start()
|
9
|
-
require("channels")
|
10
|
-
require("trix")
|
11
|
-
require("@rails/actiontext")
|
data/demo/app/models/address.rb
DELETED
data/demo/app/models/user.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
class User < ApplicationRecord
|
2
|
-
serialize :preferences
|
3
|
-
|
4
|
-
validates :email, presence: true, length: { minimum: 5 }
|
5
|
-
validates :terms, acceptance: { accept: true }
|
6
|
-
|
7
|
-
has_one :address
|
8
|
-
accepts_nested_attributes_for :address
|
9
|
-
|
10
|
-
has_rich_text(:life_story) if Rails::VERSION::STRING > "6"
|
11
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
|
2
|
-
<% if blob.representable? %>
|
3
|
-
<%= image_tag blob.representation(resize_to_fit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
|
4
|
-
<% end %>
|
5
|
-
|
6
|
-
<figcaption class="attachment__caption">
|
7
|
-
<% if caption = blob.try(:caption) %>
|
8
|
-
<%= caption %>
|
9
|
-
<% else %>
|
10
|
-
<span class="attachment__name"><%= blob.filename %></span>
|
11
|
-
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
|
12
|
-
<% end %>
|
13
|
-
</figcaption>
|
14
|
-
</figure>
|
@@ -1,67 +0,0 @@
|
|
1
|
-
<h3>Horizontal Form</h3>
|
2
|
-
|
3
|
-
<%= form_with_source do %>
|
4
|
-
<%= bootstrap_form_with model: @user, layout: :horizontal, local: true do |form| %>
|
5
|
-
<%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %>
|
6
|
-
<%= form.password_field :password, placeholder: "Password" %>
|
7
|
-
<%= form.select :status, [['activated', 1], ['blocked', 2]], prompt: "Please Select" %>
|
8
|
-
<%= form.text_area :misc %>
|
9
|
-
<%= form.check_box :terms, label: "Agree to Terms" %>
|
10
|
-
<%= form.collection_check_boxes :misc, @collection, :id, :street %>
|
11
|
-
<%= form.collection_radio_buttons :misc, @collection, :id, :street %>
|
12
|
-
<%= form.file_field :misc %>
|
13
|
-
<%= form.datetime_select :misc, include_blank: true %>
|
14
|
-
|
15
|
-
<%= form.submit %>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
18
|
-
|
19
|
-
<h3>With Validation Error</h3>
|
20
|
-
|
21
|
-
<%= form_with_source do %>
|
22
|
-
<%= bootstrap_form_for @user_with_error, layout: :horizontal do |form| %>
|
23
|
-
<%= form.alert_message "This is an alert" %>
|
24
|
-
<%= form.error_summary %>
|
25
|
-
<%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %>
|
26
|
-
<%= form.collection_check_boxes :misc, @collection, :id, :street %>
|
27
|
-
<%= form.submit %>
|
28
|
-
<% end %>
|
29
|
-
<% end %>
|
30
|
-
|
31
|
-
<h3>Inline Form</h3>
|
32
|
-
|
33
|
-
<%= form_with_source do %>
|
34
|
-
<%= bootstrap_form_for @user, layout: :inline do |form| %>
|
35
|
-
<%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %>
|
36
|
-
<%= form.password_field :password, placeholder: "Password" %>
|
37
|
-
<%= form.check_box :terms, label: "Agree to Terms" %>
|
38
|
-
<%= form.collection_check_boxes :misc, @collection, :id, :street %>
|
39
|
-
<%= form.submit %>
|
40
|
-
<% end %>
|
41
|
-
<% end %>
|
42
|
-
|
43
|
-
<h3>Simple Action Text Example</h3>
|
44
|
-
|
45
|
-
<%= form_with_source do %>
|
46
|
-
<%= bootstrap_form_for @user, url: "/" do |form| %>
|
47
|
-
<%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %>
|
48
|
-
<%= form.password_field :password, placeholder: "Password" %>
|
49
|
-
<%= form.check_box :terms, label: "Agree to Terms" %>
|
50
|
-
<%= form.collection_check_boxes :misc, @collection, :id, :street %>
|
51
|
-
<%= form.rich_text_area(:life_story) if Rails::VERSION::STRING > "6" %>
|
52
|
-
<%= form.submit %>
|
53
|
-
<% end %>
|
54
|
-
<% end %>
|
55
|
-
|
56
|
-
<h3>Floating Labels</h3>
|
57
|
-
|
58
|
-
<%= form_with_source do %>
|
59
|
-
<%= bootstrap_form_for @user do |form| %>
|
60
|
-
<%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else", floating: true %>
|
61
|
-
<%= form.password_field :password, placeholder: "Password", floating: true %>
|
62
|
-
<%= form.text_field :misc, floating: true %>
|
63
|
-
<%= form.text_area :comments, floating: true %>
|
64
|
-
<%= form.select :status, [["Active", 1], ["Inactive", 2]], include_blank: "Select a value", floating: true %>
|
65
|
-
<%= form.submit %>
|
66
|
-
<% end %>
|
67
|
-
<% end %>
|