rails_bootstrap_form 0.6.0 → 0.6.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 +4 -4
- data/CHANGELOG.md +111 -2
- data/Gemfile.lock +9 -3
- data/README.md +68 -0
- data/Rakefile +2 -0
- data/demo/app/views/users/_horizontal_form.html.erb +6 -6
- data/demo/app/views/users/_vertical_form.html.erb +8 -8
- data/demo/config/database.yml +7 -15
- data/demo/db/schema.rb +8 -5
- data/gemfiles/common.gemfile +10 -2
- data/lib/rails_bootstrap_form/bootstrap_form_builder.rb +1 -1
- data/lib/rails_bootstrap_form/{components → helpers}/check_box.rb +1 -3
- data/lib/rails_bootstrap_form/{components → helpers}/errors.rb +1 -1
- data/lib/rails_bootstrap_form/{components → helpers}/help_text.rb +1 -1
- data/lib/rails_bootstrap_form/{components → helpers}/labels.rb +1 -1
- data/lib/rails_bootstrap_form/{components → helpers}/radio_button.rb +1 -3
- data/lib/rails_bootstrap_form/{components → helpers}/required_field.rb +1 -1
- data/lib/rails_bootstrap_form/helpers.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/base.rb +33 -0
- data/lib/rails_bootstrap_form/inputs/check_box.rb +45 -0
- data/lib/rails_bootstrap_form/inputs/collection_check_boxes.rb +41 -0
- data/lib/rails_bootstrap_form/inputs/collection_radio_buttons.rb +39 -0
- data/lib/rails_bootstrap_form/inputs/collection_select.rb +21 -0
- data/lib/rails_bootstrap_form/inputs/color_field.rb +21 -0
- data/lib/rails_bootstrap_form/inputs/date_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/date_select.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/datetime_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/datetime_local_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/datetime_select.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/email_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/file_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/grouped_collection_select.rb +21 -0
- data/lib/rails_bootstrap_form/inputs/hidden_field.rb +19 -0
- data/lib/rails_bootstrap_form/inputs/month_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/number_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/password_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/phone_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/radio_button.rb +45 -0
- data/lib/rails_bootstrap_form/inputs/range_field.rb +21 -0
- data/lib/rails_bootstrap_form/inputs/search_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/select.rb +21 -0
- data/lib/rails_bootstrap_form/inputs/static_field.rb +30 -0
- data/lib/rails_bootstrap_form/inputs/telephone_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/text_area.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/text_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/time_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/time_select.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/time_zone_select.rb +21 -0
- data/lib/rails_bootstrap_form/inputs/url_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs/week_field.rb +15 -0
- data/lib/rails_bootstrap_form/inputs.rb +67 -235
- data/lib/rails_bootstrap_form/version.rb +1 -1
- data/lib/rails_bootstrap_form.rb +2 -2
- metadata +69 -10
- data/lib/rails_bootstrap_form/components.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34303679b08cf0617516305e5b4e1f21d8c201ffcd9f4cc8eb90f26a587a7f7a
|
4
|
+
data.tar.gz: 4e01e2321eb0318e222e802ce84e8c63648296c50e78de5de9f3c8e14be9570e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7f4349d0933eeea1f1965df83eb80ec0fd83392a3a47e2299214a797ec36e5c198e647d727969443779d60910741f91b49f88973a6ebcf6d93a29302f308b46
|
7
|
+
data.tar.gz: adab966d0ca4b8064094e7e941296d95e75e594452384e9cb6e7370ca19fd288a4e9d9cea1e56dbf7981804ef58f9cafc1398d1e0203bb1eefb80004f27ab18d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,114 @@
|
|
1
|
-
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
You can find recent releases with docs in GitHub:
|
4
|
+
|
5
|
+
https://github.com/shivam091/rails_bootstrap_form/releases
|
6
|
+
|
7
|
+
## [0.6.1](https://github.com/shivam091/rails_bootstrap_form/compare/v0.6.0...v0.6.1) - 2023-05-24
|
8
|
+
|
9
|
+
### What's changed
|
10
|
+
- Changes in directory structure
|
11
|
+
- Added test cases
|
12
|
+
- Added README and CHANGELOG
|
13
|
+
|
14
|
+
## [0.6.0](https://github.com/shivam091/rails_bootstrap_form/compare/v0.5.3...v0.6.0) - 2023-05-22
|
15
|
+
|
16
|
+
### What's new
|
17
|
+
- Added support for **`horizontal`** form layout
|
18
|
+
|
19
|
+
## [0.5.3](https://github.com/shivam091/rails_bootstrap_form/compare/v0.5.2...v0.5.3) - 2023-05-21
|
20
|
+
|
21
|
+
### What's changed
|
22
|
+
- Added new option inline to render checkboxes and radio buttons inline
|
23
|
+
|
24
|
+
## [0.5.2](https://github.com/shivam091/rails_bootstrap_form/compare/v0.5.1...v0.5.2) - 2023-05-21
|
25
|
+
|
26
|
+
### What's new
|
27
|
+
- Added option to add custom options to the field's wrapper
|
28
|
+
- Added option to apply user defined CSS class to the field
|
29
|
+
- Added option to control size of input group and field
|
30
|
+
- Added provision to change id of the field and corresponding label
|
31
|
+
|
32
|
+
### What's changed
|
33
|
+
- Added `mb-3` css class to field wrapper if radio buttons or check boxes are not inline
|
34
|
+
|
35
|
+
## [0.5.1](https://github.com/shivam091/rails_bootstrap_form/compare/v0.5.0...v0.5.1) - 2023-05-20
|
36
|
+
|
37
|
+
### What's new
|
38
|
+
- Wrapped `collection_check_boxes` and `collection_radio_buttons` inside field wrapper.
|
39
|
+
|
40
|
+
## [0.5.0](https://github.com/shivam091/rails_bootstrap_form/compare/v0.4.2...v0.5.0) - 2023-05-20
|
41
|
+
|
42
|
+
### What's new
|
43
|
+
- Added wrapper methods for `check_box`, `collection_check_boxes`, `radio_button`, and `collection_radio_buttons` to support Bootstrap 5 form styles
|
44
|
+
|
45
|
+
### What's changed
|
46
|
+
- Replaced HTML tag of help_text component from `<span>` to `<div>`
|
47
|
+
|
48
|
+
## [0.4.2](https://github.com/shivam091/rails_bootstrap_form/compare/v0.4.1...v0.4.2) - 2023-05-16
|
49
|
+
|
50
|
+
### What's new
|
51
|
+
- Added wrapper method for `grouped_collection_select`
|
52
|
+
|
53
|
+
## [0.4.1](https://github.com/shivam091/rails_bootstrap_form/compare/v0.4.0...v0.4.1) - 2023-05-16
|
2
54
|
|
3
|
-
|
55
|
+
### What's fixed
|
56
|
+
- Replaced `reverse_merge` by `deep_merge!` in adding new option values to fix bug causing not to merge options.
|
57
|
+
|
58
|
+
## [0.4.0](https://github.com/shivam091/rails_bootstrap_form/compare/v0.3.1...v0.4.0) - 2023-05-15
|
59
|
+
|
60
|
+
### What's new
|
61
|
+
- Added wrapper methods for `range_field` and `color_field`
|
62
|
+
- Added wrapper methods for `time_zone_select` and `hidden_field`
|
63
|
+
- Added wrapper methods for `date_select`, `time_select`, and `datetime_select`
|
64
|
+
- Added wrapper method to render static control
|
65
|
+
- Added wrapper method for `collection_select`
|
66
|
+
|
67
|
+
## [0.3.1](https://github.com/shivam091/rails_bootstrap_form/compare/v0.3.0...v0.3.1) - 2023-05-15
|
68
|
+
|
69
|
+
### What's fixed
|
70
|
+
- Bug causing fields to wrap in input group even when content to append and prepend is not available.
|
71
|
+
|
72
|
+
## [0.3.0](https://github.com/shivam091/rails_bootstrap_form/compare/v0.2.3...v0.3.0) - 2023-05-15
|
73
|
+
|
74
|
+
### What's new
|
75
|
+
- Added support to wrap field in input group
|
76
|
+
- Added support to display error messages below the field
|
77
|
+
- Added support for floating labels for inputs.
|
78
|
+
|
79
|
+
## [0.2.3](https://github.com/shivam091/rails_bootstrap_form/compare/v0.2.2...v0.2.3) - 2023-05-15
|
80
|
+
|
81
|
+
### What's new
|
82
|
+
- Added component to mark labels as required
|
83
|
+
|
84
|
+
## [0.2.2](https://github.com/shivam091/rails_bootstrap_form/compare/v0.2.1...v0.2.2) - 2023-05-15
|
85
|
+
|
86
|
+
### What's new
|
87
|
+
- Added support to display labels along with the field.
|
88
|
+
|
89
|
+
## [0.2.1](https://github.com/shivam091/rails_bootstrap_form/compare/v0.2.0...v0.2.1) - 2023-05-15
|
90
|
+
|
91
|
+
### What's new
|
92
|
+
- Added FieldWrapperBuilder to create wrapper for placing fields and other related components
|
93
|
+
- Added support to display help text along with the field
|
94
|
+
- Added wrapper methods for simple form fields
|
95
|
+
|
96
|
+
## [0.2.0](https://github.com/shivam091/rails_bootstrap_form/compare/v0.1.1...v0.2.0) - 2023-05-15
|
97
|
+
|
98
|
+
### What's new
|
99
|
+
- Added PORO class `BootstrapFormOptions` to maintain gem specific configuration.
|
100
|
+
- Added BoostrapFormBuilder and extension methods for Rails form builder.
|
101
|
+
- Added required models, controllers, and views in demo application.
|
102
|
+
|
103
|
+
## [0.1.1](https://github.com/shivam091/rails_bootstrap_form/compare/v0.1.0...v0.1.1) - 2023-05-15
|
104
|
+
|
105
|
+
### What's new
|
106
|
+
- Initialized demo application for demonstrating the working.
|
107
|
+
- Added generater to copy initializer file required for maintaining global configuration.
|
108
|
+
- Added Configuration class to maintain configurable options.
|
109
|
+
|
110
|
+
## 0.1.0 - 2023-05-15
|
4
111
|
|
5
112
|
- Initial release
|
113
|
+
|
114
|
+
## [Unreleased]
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails_bootstrap_form (0.6.
|
4
|
+
rails_bootstrap_form (0.6.1)
|
5
|
+
actionpack (~> 7.0)
|
6
|
+
activemodel (~> 7.0)
|
5
7
|
|
6
8
|
GEM
|
7
9
|
remote: http://rubygems.org/
|
@@ -79,6 +81,8 @@ GEM
|
|
79
81
|
sassc-rails (>= 2.0.0)
|
80
82
|
builder (3.2.4)
|
81
83
|
byebug (11.1.3)
|
84
|
+
compare-xml (0.66)
|
85
|
+
nokogiri (~> 1.8)
|
82
86
|
concurrent-ruby (1.2.2)
|
83
87
|
crass (1.0.6)
|
84
88
|
date (3.3.3)
|
@@ -118,6 +122,7 @@ GEM
|
|
118
122
|
nio4r (2.5.9)
|
119
123
|
nokogiri (1.14.4-x86_64-linux)
|
120
124
|
racc (~> 1.4)
|
125
|
+
pg (1.5.3)
|
121
126
|
popper_js (2.11.7)
|
122
127
|
puma (6.2.2)
|
123
128
|
nio4r (~> 2.0)
|
@@ -190,7 +195,6 @@ GEM
|
|
190
195
|
actionpack (>= 5.2)
|
191
196
|
activesupport (>= 5.2)
|
192
197
|
sprockets (>= 3.0.0)
|
193
|
-
sqlite3 (1.6.2-x86_64-linux)
|
194
198
|
thor (1.2.2)
|
195
199
|
tilt (2.1.0)
|
196
200
|
timeout (0.3.2)
|
@@ -207,7 +211,10 @@ PLATFORMS
|
|
207
211
|
DEPENDENCIES
|
208
212
|
bootstrap (~> 5.3.0.alpha3)
|
209
213
|
byebug
|
214
|
+
compare-xml
|
210
215
|
generator_spec
|
216
|
+
nokogiri
|
217
|
+
pg (~> 1.1)
|
211
218
|
puma
|
212
219
|
rails (~> 7.0)
|
213
220
|
rails_bootstrap_form!
|
@@ -216,7 +223,6 @@ DEPENDENCIES
|
|
216
223
|
sassc-rails
|
217
224
|
simplecov
|
218
225
|
sprockets-rails
|
219
|
-
sqlite3 (~> 1.4)
|
220
226
|
|
221
227
|
BUNDLED WITH
|
222
228
|
2.4.10
|
data/README.md
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
# RailsBootstrapForm
|
2
|
+
|
3
|
+
**rails_bootstrap_form** is a Rails form builder that makes it super easy to integrate
|
4
|
+
[Bootstrap 5](https://getbootstrap.com/) forms into your Rails application.
|
5
|
+
|
6
|
+
## Minimum Requirements
|
7
|
+
|
8
|
+
* Ruby 3.2.2+ (https://www.ruby-lang.org/en/downloads/branches/)
|
9
|
+
* Rails 7.0+ (https://guides.rubyonrails.org/maintenance_policy.html)
|
10
|
+
* Bootstrap 5.0+ (https://getbootstrap.com/docs/versions/)
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Install Bootstrap 5. There are many ways to do this, depending on the asset pipeline you're using in your Rails application. One way is to use the gem that works with Sprockets. To do so, in a brand new Rails 7.0 application created _without_ the `--webpacker` option, add the `bootstrap` gem to your `Gemfile`:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem "bootstrap", "~> 5.0"
|
18
|
+
```
|
19
|
+
|
20
|
+
And follow the remaining instructions in the [official bootstrap installation guide](https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails) for setting up `application.scss` and `application.js`.
|
21
|
+
|
22
|
+
Add the `rails_bootstrap_form` gem to your `Gemfile`:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem "rails_bootstrap_form", "~> 0.6.1"
|
26
|
+
```
|
27
|
+
|
28
|
+
Then:
|
29
|
+
|
30
|
+
`bundle install`
|
31
|
+
|
32
|
+
Depending on which CSS pre-processor you are using, adding the bootstrap form styles differs slightly.
|
33
|
+
If you use Rails in the default mode without any pre-processor, you'll have to add the following line to your `application.css` file:
|
34
|
+
|
35
|
+
```css
|
36
|
+
*= require rails_bootstrap_form
|
37
|
+
```
|
38
|
+
|
39
|
+
If you followed the [official bootstrap installation guide](https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails), you'll probably have switched to SCSS. In this case add the following line to your `application.scss`:
|
40
|
+
|
41
|
+
```scss
|
42
|
+
@import "rails_bootstrap_form";
|
43
|
+
```
|
44
|
+
|
45
|
+
## Configuration
|
46
|
+
|
47
|
+
`rails_bootstrap_form` can be used without any configuration. However, `rails_bootstrap_form` does have an optional configuration file at `config/initializers/rails_bootstrap_form.rb` for setting options that affect all generated forms in an application. This configuration file is created using the generator
|
48
|
+
by running the command on the terminal.
|
49
|
+
|
50
|
+
```
|
51
|
+
$ rails generate rails_bootstrap_form:install
|
52
|
+
```
|
53
|
+
|
54
|
+
Example:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
# config/initializers/rails_bootstrap_form.rb
|
58
|
+
RailsBootstrapForm.configure do |config|
|
59
|
+
# to make forms non-compliant with W3C.
|
60
|
+
config.default_form_attributes = {role: "form", novalidate: true}
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
The current configuration options are:
|
65
|
+
|
66
|
+
| Option | Default value | Description |
|
67
|
+
|---------------------------|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
68
|
+
| `default_form_attributes` | | Set this option to `{role: "form"}` to make forms non-compliant with W3C, but generate the `role="form"` attribute. |
|
data/Rakefile
CHANGED
@@ -5,24 +5,24 @@
|
|
5
5
|
<div class="card-body">
|
6
6
|
<%= bootstrap_form_for @user, bootstrap_form: {layout: :horizontal} do |form| %>
|
7
7
|
<%= form.text_field :name, autocomplete: "new-name" %>
|
8
|
-
<%= form.
|
9
|
-
<%= form.
|
8
|
+
<%= form.email_field :email, autocomplete: "new-email" %>
|
9
|
+
<%= form.password_field :password, autocomplete: "new-password" %>
|
10
10
|
<%= form.phone_field :mobile_number %>
|
11
11
|
<%= form.date_field :birth_date %>
|
12
|
-
<%= form.radio_button :terms, 1, required: true %>
|
13
12
|
<%= form.range_field :excellence %>
|
14
13
|
<%= form.url_field :blog_url %>
|
15
|
-
<%= form.collection_radio_buttons :fruit_id, ::Fruit.all, :id, :name, {
|
14
|
+
<%= form.collection_radio_buttons :fruit_id, ::Fruit.all, :id, :name, {checked: form.object.fruit_id} %>
|
16
15
|
<%= form.color_field :favorite_color %>
|
17
|
-
<%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name
|
16
|
+
<%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name %>
|
18
17
|
<%= form.fields_for :address, include_id: false, bootstrap_form: {layout: :horizontal} do |address_form| %>
|
19
18
|
<%= address_form.text_area :street %>
|
20
19
|
<%= address_form.text_field :state %>
|
21
20
|
<%= address_form.grouped_collection_select :city, ::Country.includes(:cities), :cities, :name, :id, :name, {include_blank: "Select city"} %>
|
22
21
|
<%= address_form.text_field :postal_code %>
|
23
22
|
<%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id),
|
24
|
-
{include_blank: "Select Country"
|
23
|
+
{include_blank: "Select Country"} %>
|
25
24
|
<% end %>
|
25
|
+
<%= form.check_box :terms, required: true %>
|
26
26
|
<div class="mt-3">
|
27
27
|
<%= form.submit "Register", class: "btn btn-primary" %>
|
28
28
|
<%= link_to "Cancel", users_path, class: "btn btn-secondary" %>
|
@@ -3,26 +3,26 @@
|
|
3
3
|
Profile Form (Vertical layout)
|
4
4
|
</div>
|
5
5
|
<div class="card-body">
|
6
|
-
<%= bootstrap_form_for @user
|
7
|
-
<%= form.text_field :name, autocomplete: "new-name"
|
8
|
-
<%= form.
|
9
|
-
<%= form.
|
6
|
+
<%= bootstrap_form_for @user do |form| %>
|
7
|
+
<%= form.text_field :name, autocomplete: "new-name" %>
|
8
|
+
<%= form.email_field :email, autocomplete: "new-email" %>
|
9
|
+
<%= form.password_field :password, autocomplete: "new-password" %>
|
10
10
|
<%= form.phone_field :mobile_number %>
|
11
11
|
<%= form.date_field :birth_date %>
|
12
|
-
<%= form.check_box :terms, bootstrap_form: {switch: false}, required: true %>
|
13
12
|
<%= form.range_field :excellence %>
|
14
13
|
<%= form.url_field :blog_url %>
|
15
|
-
<%= form.collection_radio_buttons :fruit_id, ::Fruit.all, :id, :name, {
|
14
|
+
<%= form.collection_radio_buttons :fruit_id, ::Fruit.all, :id, :name, {checked: form.object.fruit_id} %>
|
16
15
|
<%= form.color_field :favorite_color %>
|
17
|
-
<%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name
|
16
|
+
<%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name %>
|
18
17
|
<%= form.fields_for :address, include_id: false do |address_form| %>
|
19
18
|
<%= address_form.text_area :street %>
|
20
19
|
<%= address_form.text_field :state %>
|
21
20
|
<%= address_form.grouped_collection_select :city, ::Country.includes(:cities), :cities, :name, :id, :name, {include_blank: "Select city"} %>
|
22
21
|
<%= address_form.text_field :postal_code %>
|
23
22
|
<%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id),
|
24
|
-
{include_blank: "Select Country"
|
23
|
+
{include_blank: "Select Country"} %>
|
25
24
|
<% end %>
|
25
|
+
<%= form.check_box :terms, required: true %>
|
26
26
|
<div class="mt-3">
|
27
27
|
<%= form.submit "Register", class: "btn btn-primary" %>
|
28
28
|
<%= link_to "Cancel", users_path, class: "btn btn-secondary" %>
|
data/demo/config/database.yml
CHANGED
@@ -1,25 +1,17 @@
|
|
1
|
-
# SQLite. Versions 3.8.0 and up are supported.
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem "sqlite3"
|
6
|
-
#
|
7
1
|
default: &default
|
8
|
-
adapter:
|
9
|
-
|
10
|
-
|
2
|
+
adapter: postgresql
|
3
|
+
encoding: unicode
|
4
|
+
reconnect: false
|
5
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 20 } %>
|
11
6
|
|
12
7
|
development:
|
13
8
|
<<: *default
|
14
|
-
|
9
|
+
url: <%= ENV["DATABASE_URL"] %>
|
15
10
|
|
16
|
-
# Warning: The database defined as "test" will be erased and
|
17
|
-
# re-generated from your development database when you run "rake".
|
18
|
-
# Do not set this db to the same as development or production.
|
19
11
|
test:
|
20
12
|
<<: *default
|
21
|
-
|
13
|
+
url: <%= ENV["DATABASE_URL"] %>
|
22
14
|
|
23
15
|
production:
|
24
16
|
<<: *default
|
25
|
-
|
17
|
+
url: <%= ENV["DATABASE_URL"] %>
|
data/demo/db/schema.rb
CHANGED
@@ -11,8 +11,11 @@
|
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
13
|
ActiveRecord::Schema[7.0].define(version: 2023_05_16_044126) do
|
14
|
+
# These are extensions that must be enabled in order to support this database
|
15
|
+
enable_extension "plpgsql"
|
16
|
+
|
14
17
|
create_table "addresses", primary_key: "user_id", force: :cascade do |t|
|
15
|
-
t.
|
18
|
+
t.bigint "country_id"
|
16
19
|
t.string "street"
|
17
20
|
t.string "city"
|
18
21
|
t.string "state"
|
@@ -25,7 +28,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_16_044126) do
|
|
25
28
|
|
26
29
|
create_table "cities", force: :cascade do |t|
|
27
30
|
t.string "name"
|
28
|
-
t.
|
31
|
+
t.bigint "country_id"
|
29
32
|
t.datetime "created_at", null: false
|
30
33
|
t.datetime "updated_at", null: false
|
31
34
|
t.index ["country_id"], name: "index_cities_on_country_id"
|
@@ -50,8 +53,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_16_044126) do
|
|
50
53
|
end
|
51
54
|
|
52
55
|
create_table "user_skills", force: :cascade do |t|
|
53
|
-
t.
|
54
|
-
t.
|
56
|
+
t.bigint "user_id"
|
57
|
+
t.bigint "skill_id"
|
55
58
|
t.datetime "created_at", null: false
|
56
59
|
t.datetime "updated_at", null: false
|
57
60
|
t.index ["skill_id"], name: "index_user_skills_on_skill_id"
|
@@ -65,7 +68,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_16_044126) do
|
|
65
68
|
t.string "mobile_number"
|
66
69
|
t.string "blog_url"
|
67
70
|
t.date "birth_date"
|
68
|
-
t.
|
71
|
+
t.bigint "fruit_id"
|
69
72
|
t.boolean "terms"
|
70
73
|
t.string "excellence"
|
71
74
|
t.string "favorite_color"
|
data/gemfiles/common.gemfile
CHANGED
@@ -15,8 +15,8 @@ gem "sassc-rails"
|
|
15
15
|
# Add bootstrap support
|
16
16
|
gem "bootstrap", "~> 5.3.0.alpha3"
|
17
17
|
|
18
|
-
# Use
|
19
|
-
gem "
|
18
|
+
# Use postgresql as the database for Active Record
|
19
|
+
gem "pg", "~> 1.1"
|
20
20
|
|
21
21
|
# Library to show coverage of the code.
|
22
22
|
gem "simplecov"
|
@@ -25,6 +25,14 @@ group :development do
|
|
25
25
|
gem "puma"
|
26
26
|
end
|
27
27
|
|
28
|
+
group :test do
|
29
|
+
# make it easy and painless to work with XML and HTML from Ruby.
|
30
|
+
gem "nokogiri"
|
31
|
+
|
32
|
+
# Solve your XML/HTML comparison or diffing needs.
|
33
|
+
gem "compare-xml"
|
34
|
+
end
|
35
|
+
|
28
36
|
group :development, :test do
|
29
37
|
gem "byebug"
|
30
38
|
end
|
@@ -6,7 +6,7 @@ module RailsBootstrapForm
|
|
6
6
|
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder
|
7
7
|
|
8
8
|
include RailsBootstrapForm::FieldWrapperBuilder
|
9
|
-
include RailsBootstrapForm::
|
9
|
+
include RailsBootstrapForm::Helpers
|
10
10
|
include RailsBootstrapForm::InputGroupBuilder
|
11
11
|
include RailsBootstrapForm::Inputs
|
12
12
|
|
@@ -3,12 +3,10 @@
|
|
3
3
|
# -*- warn_indent: true -*-
|
4
4
|
|
5
5
|
module RailsBootstrapForm
|
6
|
-
module
|
6
|
+
module Helpers
|
7
7
|
module CheckBox
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
|
-
include RailsBootstrapForm::Helpers
|
11
|
-
|
12
10
|
def self.included(base_class)
|
13
11
|
def check_box_label(attribute, checked_value, options, bootstrap_options, &block)
|
14
12
|
unless bootstrap_options.skip_label
|
@@ -3,12 +3,10 @@
|
|
3
3
|
# -*- warn_indent: true -*-
|
4
4
|
|
5
5
|
module RailsBootstrapForm
|
6
|
-
module
|
6
|
+
module Helpers
|
7
7
|
module RadioButton
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
|
-
include RailsBootstrapForm::Helpers
|
11
|
-
|
12
10
|
def self.included(base_class)
|
13
11
|
def radio_button_label(attribute, value, options, bootstrap_options)
|
14
12
|
unless bootstrap_options.skip_label
|
@@ -5,6 +5,21 @@
|
|
5
5
|
module RailsBootstrapForm
|
6
6
|
module Helpers
|
7
7
|
extend ActiveSupport::Concern
|
8
|
+
extend ActiveSupport::Autoload
|
9
|
+
|
10
|
+
autoload :HelpText
|
11
|
+
autoload :Labels
|
12
|
+
autoload :RequiredField
|
13
|
+
autoload :Errors
|
14
|
+
autoload :CheckBox
|
15
|
+
autoload :RadioButton
|
16
|
+
|
17
|
+
include HelpText
|
18
|
+
include Labels
|
19
|
+
include RequiredField
|
20
|
+
include Errors
|
21
|
+
include CheckBox
|
22
|
+
include RadioButton
|
8
23
|
|
9
24
|
def self.included(base_class)
|
10
25
|
def collection_input_checked?(checked, obj, input_value)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# -*- frozen_string_literal: true -*-
|
3
|
+
# -*- warn_indent: true -*-
|
4
|
+
|
5
|
+
module RailsBootstrapForm
|
6
|
+
module Inputs
|
7
|
+
module Base
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
class_methods do
|
11
|
+
def bootstrap_field(field_name)
|
12
|
+
define_method(field_name) do |attribute, options = {}|
|
13
|
+
field_wrapper_builder(attribute, options) do
|
14
|
+
super(attribute, options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def bootstrap_select_group(field_name)
|
20
|
+
define_method(field_name) do |attribute, options = {}, html_options = {}|
|
21
|
+
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
22
|
+
|
23
|
+
field_wrapper_builder(attribute, options, html_options) do
|
24
|
+
tag.div(class: control_specific_class(field_name)) do
|
25
|
+
super(attribute, options, html_options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# -*- frozen_string_literal: true -*-
|
3
|
+
# -*- warn_indent: true -*-
|
4
|
+
|
5
|
+
module RailsBootstrapForm
|
6
|
+
module Inputs
|
7
|
+
module CheckBox
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
def check_box(attribute, options = {}, checked_value = "1", unchecked_value = "0", &block)
|
12
|
+
bootstrap_options = bootstrap_form_options.scoped(options.delete(:bootstrap_form))
|
13
|
+
|
14
|
+
options[:class] = check_box_classes(attribute, options)
|
15
|
+
|
16
|
+
check_box_field = super(attribute, options, checked_value, unchecked_value)
|
17
|
+
check_box_help_text = help_text(attribute, bootstrap_options)
|
18
|
+
|
19
|
+
check_box_label = check_box_label(attribute, checked_value, options, bootstrap_options, &block)
|
20
|
+
|
21
|
+
check_box_html = tag.div(**check_box_wrapper_options(bootstrap_options)) do
|
22
|
+
concat(check_box_field)
|
23
|
+
concat(check_box_label)
|
24
|
+
concat(check_box_help_text) unless bootstrap_options.inline?
|
25
|
+
concat(generate_error(attribute)) if (is_invalid?(attribute) && !bootstrap_options.inline?)
|
26
|
+
end
|
27
|
+
|
28
|
+
if bootstrap_options.inline?
|
29
|
+
check_box_html
|
30
|
+
else
|
31
|
+
if bootstrap_options.layout_horizontal?
|
32
|
+
tag.div(class: field_wrapper_classes(bootstrap_options)) do
|
33
|
+
tag.div(class: check_box_container_classes(bootstrap_options)) do
|
34
|
+
check_box_html
|
35
|
+
end
|
36
|
+
end
|
37
|
+
else
|
38
|
+
check_box_html
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# -*- frozen_string_literal: true -*-
|
3
|
+
# -*- warn_indent: true -*-
|
4
|
+
|
5
|
+
module RailsBootstrapForm
|
6
|
+
module Inputs
|
7
|
+
module CollectionCheckBoxes
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
def collection_check_boxes(attribute, collection, value_method, text_method, options = {}, html_options = {}, &block)
|
12
|
+
options[:multiple] = true
|
13
|
+
|
14
|
+
inputs = ActiveSupport::SafeBuffer.new
|
15
|
+
|
16
|
+
collection.each do |object|
|
17
|
+
input_value = value_method.respond_to?(:call) ? value_method.call(object) : object.send(value_method)
|
18
|
+
input_options = {
|
19
|
+
bootstrap_form: {
|
20
|
+
label_text: text_method.respond_to?(:call) ? text_method.call(object) : object.send(text_method),
|
21
|
+
inline: true
|
22
|
+
}
|
23
|
+
}.deep_merge!(options)
|
24
|
+
|
25
|
+
inputs << check_box(attribute, input_options, input_value, nil)
|
26
|
+
end
|
27
|
+
|
28
|
+
if options.delete(:include_hidden) { true }
|
29
|
+
inputs.prepend(hidden_field(attribute, value: "", multiple: options[:multiple]))
|
30
|
+
end
|
31
|
+
|
32
|
+
field_wrapper_builder(attribute, options, html_options) do
|
33
|
+
concat(tag.div(class: control_specific_class(:collection_check_boxes)) do
|
34
|
+
concat(inputs)
|
35
|
+
end)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|