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.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +31 -16
  3. data/.gitignore +15 -3
  4. data/.rubocop.yml +3 -1
  5. data/.yarnrc +5 -0
  6. data/CHANGELOG.md +53 -2
  7. data/CONTRIBUTING.md +110 -22
  8. data/Dangerfile +5 -5
  9. data/Dockerfile +6 -11
  10. data/Gemfile +5 -23
  11. data/README.md +805 -54
  12. data/RELEASING.md +16 -10
  13. data/Rakefile +7 -6
  14. data/bootstrap_form.gemspec +7 -10
  15. data/docker-compose.yml +9 -48
  16. data/gemfiles/6.0.gemfile +1 -1
  17. data/gemfiles/6.1.gemfile +1 -1
  18. data/gemfiles/7.0.gemfile +5 -0
  19. data/gemfiles/common.gemfile +28 -0
  20. data/gemfiles/edge.gemfile +3 -2
  21. data/lib/bootstrap_form/components/hints.rb +13 -4
  22. data/lib/bootstrap_form/components/labels.rb +4 -10
  23. data/lib/bootstrap_form/components/validation.rb +36 -19
  24. data/lib/bootstrap_form/form_builder.rb +9 -6
  25. data/lib/bootstrap_form/form_group.rb +15 -8
  26. data/lib/bootstrap_form/form_group_builder.rb +10 -7
  27. data/lib/bootstrap_form/helpers/bootstrap.rb +12 -9
  28. data/lib/bootstrap_form/helpers/field.rb +26 -0
  29. data/lib/bootstrap_form/helpers.rb +1 -0
  30. data/lib/bootstrap_form/inputs/check_box.rb +26 -8
  31. data/lib/bootstrap_form/inputs/collection_check_boxes.rb +5 -1
  32. data/lib/bootstrap_form/inputs/collection_select.rb +1 -1
  33. data/lib/bootstrap_form/inputs/grouped_collection_select.rb +1 -1
  34. data/lib/bootstrap_form/inputs/radio_button.rb +15 -10
  35. data/lib/bootstrap_form/version.rb +2 -1
  36. data/lib/bootstrap_form.rb +1 -1
  37. metadata +17 -88
  38. data/demo/.postcssrc.yml +0 -3
  39. data/demo/README.md +0 -17
  40. data/demo/Rakefile +0 -6
  41. data/demo/app/assets/config/manifest.js +0 -1
  42. data/demo/app/assets/stylesheets/actiontext.scss +0 -38
  43. data/demo/app/assets/stylesheets/application.scss +0 -1
  44. data/demo/app/controllers/application_controller.rb +0 -2
  45. data/demo/app/controllers/bootstrap_controller.rb +0 -14
  46. data/demo/app/helpers/bootstrap_helper.rb +0 -27
  47. data/demo/app/javascript/channels/consumer.js +0 -6
  48. data/demo/app/javascript/channels/index.js +0 -5
  49. data/demo/app/javascript/packs/application.js +0 -11
  50. data/demo/app/models/address.rb +0 -3
  51. data/demo/app/models/application_record.rb +0 -3
  52. data/demo/app/models/faux_user.rb +0 -9
  53. data/demo/app/models/super_user.rb +0 -2
  54. data/demo/app/models/user.rb +0 -11
  55. data/demo/app/views/active_storage/blobs/_blob.html.erb +0 -14
  56. data/demo/app/views/bootstrap/form.html.erb +0 -67
  57. data/demo/app/views/layouts/application.html.erb +0 -68
  58. data/demo/bin/bundle +0 -3
  59. data/demo/bin/rails +0 -4
  60. data/demo/bin/rake +0 -4
  61. data/demo/bin/setup +0 -36
  62. data/demo/bin/update +0 -31
  63. data/demo/bin/webpack +0 -15
  64. data/demo/bin/webpack-dev-server +0 -15
  65. data/demo/bin/yarn +0 -11
  66. data/demo/config/application.rb +0 -21
  67. data/demo/config/boot.rb +0 -5
  68. data/demo/config/database.yml +0 -21
  69. data/demo/config/environment.rb +0 -5
  70. data/demo/config/environments/development.rb +0 -60
  71. data/demo/config/environments/production.rb +0 -48
  72. data/demo/config/environments/test.rb +0 -46
  73. data/demo/config/initializers/application_controller_renderer.rb +0 -8
  74. data/demo/config/initializers/assets.rb +0 -14
  75. data/demo/config/initializers/backtrace_silencers.rb +0 -7
  76. data/demo/config/initializers/cookies_serializer.rb +0 -5
  77. data/demo/config/initializers/filter_parameter_logging.rb +0 -4
  78. data/demo/config/initializers/inflections.rb +0 -16
  79. data/demo/config/initializers/mime_types.rb +0 -4
  80. data/demo/config/initializers/wrap_parameters.rb +0 -14
  81. data/demo/config/locales/en.yml +0 -33
  82. data/demo/config/puma.rb +0 -56
  83. data/demo/config/routes.rb +0 -5
  84. data/demo/config/spring.rb +0 -6
  85. data/demo/config/storage.yml +0 -35
  86. data/demo/config/webpack/development.js +0 -5
  87. data/demo/config/webpack/environment.js +0 -3
  88. data/demo/config/webpack/production.js +0 -5
  89. data/demo/config/webpack/test.js +0 -5
  90. data/demo/config/webpacker.yml +0 -92
  91. data/demo/config.ru +0 -5
  92. data/demo/db/schema.rb +0 -69
  93. data/demo/log/.keep +0 -0
  94. data/demo/package.json +0 -17
  95. data/demo/public/favicon.ico +0 -0
  96. data/demo/test/fixtures/action_text/rich_texts.yml +0 -4
  97. data/demo/yarn.lock +0 -6257
  98. 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.concat(check_box_label(name, options, checked_value, &block)) unless options[:skip_label]
19
- html.concat(generate_error(name)) if options[:error_message]
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[:wrapper_class] if options[:wrapper_class].present?
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
- hidden_field(args.first, value: "", multiple: true).concat(html)
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
- input_with_error(method) do
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
- input_with_error(method) do
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
- radio_button_options = options.except(:class, :label, :label_class, :error_message, :help,
13
- :inline, :hide_label, :skip_label, :wrapper_class)
14
-
15
- radio_button_options[:class] = radio_button_classes(name, options)
16
-
17
- tag.div(class: radio_button_wrapper_class(options)) do
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[:wrapper_class] if options[:wrapper_class].present?
58
+ classes << options.dig(:wrapper, :class).presence
59
+ classes << options[:wrapper_class].presence
55
60
  classes.flatten.compact
56
61
  end
57
62
  end
@@ -1,3 +1,4 @@
1
1
  module BootstrapForm
2
- VERSION = "5.0.0".freeze
2
+ VERSION = "5.2.0".freeze
3
+ REQUIRED_RAILS_VERSION = ">= 6.0".freeze
3
4
  end
@@ -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 ::Rails::VERSION::STRING > "6"
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.0.0
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: 2021-11-12 00:00:00.000000000 Z
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: '5.2'
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: '5.2'
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: '5.2'
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: '5.2'
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
- post_install_message:
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: '2.5'
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
- rubyforge_project:
217
- rubygems_version: 2.7.6
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
@@ -1,3 +0,0 @@
1
- plugins:
2
- postcss-import: {}
3
- postcss-cssnext: {}
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,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require_relative 'config/application'
5
-
6
- Rails.application.load_tasks
@@ -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,2 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- end
@@ -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,5 +0,0 @@
1
- // Load all the channels within this directory and all subdirectories.
2
- // Channel files must be named *_channel.js.
3
-
4
- const channels = require.context('.', true, /_channel\.js$/)
5
- channels.keys().forEach(channels)
@@ -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")
@@ -1,3 +0,0 @@
1
- class Address < ApplicationRecord
2
- belongs_to :user
3
- end
@@ -1,3 +0,0 @@
1
- class ApplicationRecord < ActiveRecord::Base
2
- self.abstract_class = true
3
- end
@@ -1,9 +0,0 @@
1
- class FauxUser
2
- attr_accessor :email, :password, :comments, :misc
3
-
4
- def initialize(attributes={})
5
- attributes.each do |name, value|
6
- send("#{name}=", value)
7
- end
8
- end
9
- end
@@ -1,2 +0,0 @@
1
- class SuperUser < User
2
- end
@@ -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 %>