rails_bootstrap_form 0.4.1 → 0.4.2
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/Gemfile.lock +1 -1
- data/demo/app/models/city.rb +17 -0
- data/demo/app/models/country.rb +1 -0
- data/demo/app/views/users/_vertical_form.html.erb +5 -3
- data/demo/db/migrate/20230516044126_create_cities.rb +13 -0
- data/demo/db/schema.rb +9 -1
- data/demo/db/seeds.rb +7 -0
- data/lib/rails_bootstrap_form/inputs.rb +8 -0
- data/lib/rails_bootstrap_form/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5874a38745d73c1b0bb05c751711cdc380be8684c71187069e07224e9d40333a
|
4
|
+
data.tar.gz: ffe2043c13700e6015d7741b51550c52642098c412f29b1921a7e98ed20ec9cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 657b116576955954f11ecd923cd61277613bd732d7b986effe3d5b908ed38531549413baa47436167fd7d675fb5aab709863cc53bfb19f99d4a39abb2148de63
|
7
|
+
data.tar.gz: '09d24eb35c72a56c834d0031ce85152e1a0241a1d4614dc69ebb5bc820b45780380d80132a9c882086b6524d8bb9fd5826d41c339f45bd87b335fcb0ceb97eeb'
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# -*- frozen_string_literal: true -*-
|
3
|
+
# -*- warn_indent: true -*-
|
4
|
+
|
5
|
+
class City < ApplicationRecord
|
6
|
+
DEFAULT_OPTIONS = {
|
7
|
+
"India" => ["Mumbai", "New Delhi", "Kolkata", "Chennai"],
|
8
|
+
"Ireland" => ["Dublin", "Galway", "Cork", "Belfast"],
|
9
|
+
"United States" => ["New York", "Los Angeles", "San Francisco", "Chicago"],
|
10
|
+
"United Kingdom" => ["London", "Edinburgh", "Manchester", "Bristol"],
|
11
|
+
"Spain" => ["Barcelona", "Madrid", "Seville", "Granada"],
|
12
|
+
"France" => ["Paris", "Nice", "Lyon", "Marseille"],
|
13
|
+
"Canada" => ["Toronto", "Montreal", "Vancouver", "Calgary"],
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
belongs_to :country
|
17
|
+
end
|
data/demo/app/models/country.rb
CHANGED
@@ -13,16 +13,18 @@
|
|
13
13
|
<%= form.range_field :excellence %>
|
14
14
|
<%= form.url_field :blog_url %>
|
15
15
|
<%= form.color_field :favorite_color %>
|
16
|
-
<%= form.select :fruit_id, options_for_select(::Fruit.pluck(:name, :id), form.object.fruit_id),
|
16
|
+
<%= form.select :fruit_id, options_for_select(::Fruit.pluck(:name, :id), form.object.fruit_id),
|
17
|
+
{include_blank: "Select Favorite Fruit"} %>
|
17
18
|
<%= form.collection_check_boxes :skill_ids, ::Skill.all, :id, :name do |b| %>
|
18
19
|
<%= b.check_box + b.text %>
|
19
20
|
<% end %>
|
20
21
|
<%= form.fields_for :address, include_id: false do |address_form| %>
|
21
22
|
<%= address_form.text_area :street %>
|
22
23
|
<%= address_form.text_field :state %>
|
23
|
-
<%= address_form.
|
24
|
+
<%= address_form.grouped_collection_select :city, ::Country.all, :cities, :name, :id, :name %>
|
24
25
|
<%= address_form.text_field :postal_code %>
|
25
|
-
<%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id),
|
26
|
+
<%= address_form.select :country_id, options_for_select(::Country.pluck(:name, :id), address_form.object.country_id),
|
27
|
+
{include_blank: "Select Country", bootstrap_form: {}} %>
|
26
28
|
<% end %>
|
27
29
|
<div class="mt-3">
|
28
30
|
<%= form.submit "Register", class: "btn btn-primary" %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# -*- frozen_string_literal: true -*-
|
3
|
+
# -*- warn_indent: true -*-
|
4
|
+
|
5
|
+
class CreateCities < ActiveRecord::Migration[7.0]
|
6
|
+
def change
|
7
|
+
create_table :cities do |t|
|
8
|
+
t.string :name
|
9
|
+
t.references :country
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/demo/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema[7.0].define(version:
|
13
|
+
ActiveRecord::Schema[7.0].define(version: 2023_05_16_044126) do
|
14
14
|
create_table "addresses", primary_key: "user_id", force: :cascade do |t|
|
15
15
|
t.integer "country_id"
|
16
16
|
t.string "street"
|
@@ -23,6 +23,14 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_14_061100) do
|
|
23
23
|
t.index ["user_id"], name: "index_addresses_on_user_id"
|
24
24
|
end
|
25
25
|
|
26
|
+
create_table "cities", force: :cascade do |t|
|
27
|
+
t.string "name"
|
28
|
+
t.integer "country_id"
|
29
|
+
t.datetime "created_at", null: false
|
30
|
+
t.datetime "updated_at", null: false
|
31
|
+
t.index ["country_id"], name: "index_cities_on_country_id"
|
32
|
+
end
|
33
|
+
|
26
34
|
create_table "countries", force: :cascade do |t|
|
27
35
|
t.string "name"
|
28
36
|
t.datetime "created_at", null: false
|
data/demo/db/seeds.rb
CHANGED
@@ -13,3 +13,10 @@ end
|
|
13
13
|
::Skill::DEFAULT_OPTIONS.each do |skill|
|
14
14
|
::Skill.find_or_create_by(name: skill)
|
15
15
|
end
|
16
|
+
|
17
|
+
::City::DEFAULT_OPTIONS.each do |country, cities|
|
18
|
+
country = ::Country.find_by(name: country)
|
19
|
+
country.present? && cities.each do |city|
|
20
|
+
country.cities.find_or_create_by(name: city)
|
21
|
+
end
|
22
|
+
end
|
@@ -66,6 +66,14 @@ module RailsBootstrapForm
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
def grouped_collection_select(attribute, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
|
70
|
+
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
71
|
+
|
72
|
+
field_wrapper_builder(attribute, options, html_options) do
|
73
|
+
super(attribute, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
69
77
|
def time_zone_select(attribute, priority_zones = nil, options = {}, html_options = {})
|
70
78
|
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
71
79
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_bootstrap_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harshal LADHE (shivam091)
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- demo/app/mailers/application_mailer.rb
|
57
57
|
- demo/app/models/address.rb
|
58
58
|
- demo/app/models/application_record.rb
|
59
|
+
- demo/app/models/city.rb
|
59
60
|
- demo/app/models/country.rb
|
60
61
|
- demo/app/models/fruit.rb
|
61
62
|
- demo/app/models/skill.rb
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- demo/db/migrate/20230514055840_create_addresses.rb
|
98
99
|
- demo/db/migrate/20230514060556_create_skills.rb
|
99
100
|
- demo/db/migrate/20230514061100_create_user_skills.rb
|
101
|
+
- demo/db/migrate/20230516044126_create_cities.rb
|
100
102
|
- demo/db/schema.rb
|
101
103
|
- demo/db/seeds.rb
|
102
104
|
- demo/public/favicon.ico
|