rails_bootstrap_form 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +111 -2
  3. data/Gemfile.lock +9 -3
  4. data/README.md +68 -0
  5. data/Rakefile +2 -0
  6. data/demo/app/views/users/_horizontal_form.html.erb +6 -6
  7. data/demo/app/views/users/_vertical_form.html.erb +8 -8
  8. data/demo/config/database.yml +7 -15
  9. data/demo/db/schema.rb +8 -5
  10. data/gemfiles/common.gemfile +10 -2
  11. data/lib/rails_bootstrap_form/bootstrap_form_builder.rb +1 -1
  12. data/lib/rails_bootstrap_form/{components → helpers}/check_box.rb +1 -3
  13. data/lib/rails_bootstrap_form/{components → helpers}/errors.rb +1 -1
  14. data/lib/rails_bootstrap_form/{components → helpers}/help_text.rb +1 -1
  15. data/lib/rails_bootstrap_form/{components → helpers}/labels.rb +1 -1
  16. data/lib/rails_bootstrap_form/{components → helpers}/radio_button.rb +1 -3
  17. data/lib/rails_bootstrap_form/{components → helpers}/required_field.rb +1 -1
  18. data/lib/rails_bootstrap_form/helpers.rb +15 -0
  19. data/lib/rails_bootstrap_form/inputs/base.rb +33 -0
  20. data/lib/rails_bootstrap_form/inputs/check_box.rb +45 -0
  21. data/lib/rails_bootstrap_form/inputs/collection_check_boxes.rb +41 -0
  22. data/lib/rails_bootstrap_form/inputs/collection_radio_buttons.rb +39 -0
  23. data/lib/rails_bootstrap_form/inputs/collection_select.rb +21 -0
  24. data/lib/rails_bootstrap_form/inputs/color_field.rb +21 -0
  25. data/lib/rails_bootstrap_form/inputs/date_field.rb +15 -0
  26. data/lib/rails_bootstrap_form/inputs/date_select.rb +15 -0
  27. data/lib/rails_bootstrap_form/inputs/datetime_field.rb +15 -0
  28. data/lib/rails_bootstrap_form/inputs/datetime_local_field.rb +15 -0
  29. data/lib/rails_bootstrap_form/inputs/datetime_select.rb +15 -0
  30. data/lib/rails_bootstrap_form/inputs/email_field.rb +15 -0
  31. data/lib/rails_bootstrap_form/inputs/file_field.rb +15 -0
  32. data/lib/rails_bootstrap_form/inputs/grouped_collection_select.rb +21 -0
  33. data/lib/rails_bootstrap_form/inputs/hidden_field.rb +19 -0
  34. data/lib/rails_bootstrap_form/inputs/month_field.rb +15 -0
  35. data/lib/rails_bootstrap_form/inputs/number_field.rb +15 -0
  36. data/lib/rails_bootstrap_form/inputs/password_field.rb +15 -0
  37. data/lib/rails_bootstrap_form/inputs/phone_field.rb +15 -0
  38. data/lib/rails_bootstrap_form/inputs/radio_button.rb +45 -0
  39. data/lib/rails_bootstrap_form/inputs/range_field.rb +21 -0
  40. data/lib/rails_bootstrap_form/inputs/search_field.rb +15 -0
  41. data/lib/rails_bootstrap_form/inputs/select.rb +21 -0
  42. data/lib/rails_bootstrap_form/inputs/static_field.rb +30 -0
  43. data/lib/rails_bootstrap_form/inputs/telephone_field.rb +15 -0
  44. data/lib/rails_bootstrap_form/inputs/text_area.rb +15 -0
  45. data/lib/rails_bootstrap_form/inputs/text_field.rb +15 -0
  46. data/lib/rails_bootstrap_form/inputs/time_field.rb +15 -0
  47. data/lib/rails_bootstrap_form/inputs/time_select.rb +15 -0
  48. data/lib/rails_bootstrap_form/inputs/time_zone_select.rb +21 -0
  49. data/lib/rails_bootstrap_form/inputs/url_field.rb +15 -0
  50. data/lib/rails_bootstrap_form/inputs/week_field.rb +15 -0
  51. data/lib/rails_bootstrap_form/inputs.rb +67 -235
  52. data/lib/rails_bootstrap_form/version.rb +1 -1
  53. data/lib/rails_bootstrap_form.rb +2 -2
  54. metadata +69 -10
  55. data/lib/rails_bootstrap_form/components.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa73fbc58e6dd0b2dc4b823cd6732de17b0e84e52d9177bce4684b61609238e0
4
- data.tar.gz: f190515751e2cbc2bf51c195c8aa0ac7e2459ae040f1ba8dd544532f6887a514
3
+ metadata.gz: 34303679b08cf0617516305e5b4e1f21d8c201ffcd9f4cc8eb90f26a587a7f7a
4
+ data.tar.gz: 4e01e2321eb0318e222e802ce84e8c63648296c50e78de5de9f3c8e14be9570e
5
5
  SHA512:
6
- metadata.gz: f41528a442151162803ec730b18fde0d10cd002446e5a402c037acb4aea7933e5749a5f5d3824762a83fc41a5fc2d87ecedafc7371755c45cdeafcb783f13a7f
7
- data.tar.gz: 139a3f9bd52be5936676ddc8b730a9a211f715f32b8ca8ba12ad6d045233ed9836e90317bf33a43ab07e27ac52c0ae77e5c9c290e9157e75def6b07341a96a30
6
+ metadata.gz: c7f4349d0933eeea1f1965df83eb80ec0fd83392a3a47e2299214a797ec36e5c198e647d727969443779d60910741f91b49f88973a6ebcf6d93a29302f308b46
7
+ data.tar.gz: adab966d0ca4b8064094e7e941296d95e75e594452384e9cb6e7370ca19fd288a4e9d9cea1e56dbf7981804ef58f9cafc1398d1e0203bb1eefb80004f27ab18d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,114 @@
1
- ## [Unreleased]
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
- ## [0.1.0] - 2023-05-15
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.0)
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
@@ -4,7 +4,9 @@
4
4
 
5
5
  require "bundler/gem_tasks"
6
6
  require "rspec/core/rake_task"
7
+ require_relative "demo/config/application"
7
8
 
9
+ Rails.application.load_tasks
8
10
  RSpec::Core::RakeTask.new(:spec)
9
11
 
10
12
  task default: :spec
@@ -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.text_field :email, autocomplete: "new-email" %>
9
- <%= form.text_field :password, autocomplete: "new-password" %>
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, {bootstrap_form: {}, checked: form.object.fruit_id} %>
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, {bootstrap_form: {}} %>
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", bootstrap_form: {}} %>
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, bootstrap_form: {} do |form| %>
7
- <%= form.text_field :name, autocomplete: "new-name", class: "dsds", bootstrap_form: {} %>
8
- <%= form.text_field :email, autocomplete: "new-email", bootstrap_form: {} %>
9
- <%= form.text_field :password, autocomplete: "new-password" %>
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, {bootstrap_form: {}, checked: form.object.fruit_id} %>
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, {bootstrap_form: {}} %>
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", bootstrap_form: {}} %>
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" %>
@@ -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: sqlite3
9
- pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
- timeout: 5000
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
- database: db/development.sqlite3
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
- database: db/test.sqlite3
13
+ url: <%= ENV["DATABASE_URL"] %>
22
14
 
23
15
  production:
24
16
  <<: *default
25
- database: db/production.sqlite3
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.integer "country_id"
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.integer "country_id"
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.integer "user_id"
54
- t.integer "skill_id"
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.integer "fruit_id"
71
+ t.bigint "fruit_id"
69
72
  t.boolean "terms"
70
73
  t.string "excellence"
71
74
  t.string "favorite_color"
@@ -15,8 +15,8 @@ gem "sassc-rails"
15
15
  # Add bootstrap support
16
16
  gem "bootstrap", "~> 5.3.0.alpha3"
17
17
 
18
- # Use sqlite3 as the database for Active Record
19
- gem "sqlite3", "~> 1.4"
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::Components
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 Components
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,7 +3,7 @@
3
3
  # -*- warn_indent: true -*-
4
4
 
5
5
  module RailsBootstrapForm
6
- module Components
6
+ module Helpers
7
7
  module Errors
8
8
  extend ActiveSupport::Concern
9
9
 
@@ -3,7 +3,7 @@
3
3
  # -*- warn_indent: true -*-
4
4
 
5
5
  module RailsBootstrapForm
6
- module Components
6
+ module Helpers
7
7
  module HelpText
8
8
  extend ActiveSupport::Concern
9
9
 
@@ -3,7 +3,7 @@
3
3
  # -*- warn_indent: true -*-
4
4
 
5
5
  module RailsBootstrapForm
6
- module Components
6
+ module Helpers
7
7
  module Labels
8
8
  extend ActiveSupport::Concern
9
9
 
@@ -3,12 +3,10 @@
3
3
  # -*- warn_indent: true -*-
4
4
 
5
5
  module RailsBootstrapForm
6
- module Components
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
@@ -3,7 +3,7 @@
3
3
  # -*- warn_indent: true -*-
4
4
 
5
5
  module RailsBootstrapForm
6
- module Components
6
+ module Helpers
7
7
  module RequiredField
8
8
  extend ActiveSupport::Concern
9
9
 
@@ -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