rails_bootstrap_form 0.4.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- 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 +21 -13
- data/lib/rails_bootstrap_form/version.rb +1 -1
- metadata +4 -2
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
|
@@ -40,7 +40,7 @@ module RailsBootstrapForm
|
|
40
40
|
|
41
41
|
DATE_SELECT_HELPERS.each do |field_tag_name|
|
42
42
|
define_method(field_tag_name) do |attribute, options = {}, html_options = {}, &block|
|
43
|
-
options =
|
43
|
+
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
44
44
|
|
45
45
|
field_wrapper_builder(attribute, options, html_options) do
|
46
46
|
tag.div(class: control_specific_class(field_tag_name)) do
|
@@ -51,7 +51,7 @@ module RailsBootstrapForm
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def select(attribute, choices = nil, options = {}, html_options = {}, &block)
|
54
|
-
options =
|
54
|
+
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
55
55
|
|
56
56
|
field_wrapper_builder(attribute, options, html_options) do
|
57
57
|
super(attribute, choices, options, html_options, &block)
|
@@ -59,34 +59,42 @@ module RailsBootstrapForm
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def collection_select(attribute, collection, value_method, text_method, options = {}, html_options = {})
|
62
|
-
options =
|
62
|
+
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
63
63
|
|
64
64
|
field_wrapper_builder(attribute, options, html_options) do
|
65
65
|
super(attribute, collection, value_method, text_method, options, html_options)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
70
|
-
options =
|
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
71
|
|
72
|
-
field_wrapper_builder(attribute, options) do
|
73
|
-
super(attribute, options)
|
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
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
def
|
78
|
-
options =
|
77
|
+
def time_zone_select(attribute, priority_zones = nil, options = {}, html_options = {})
|
78
|
+
options = {bootstrap_form: {field_class: "form-select"}}.deep_merge!(options)
|
79
|
+
|
80
|
+
field_wrapper_builder(attribute, options, html_options) do
|
81
|
+
super(attribute, priority_zones, options, html_options)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def range_field(attribute, options = {})
|
86
|
+
options = {bootstrap_form: {field_class: "form-range"}}.deep_merge!(options)
|
79
87
|
|
80
88
|
field_wrapper_builder(attribute, options) do
|
81
89
|
super(attribute, options)
|
82
90
|
end
|
83
91
|
end
|
84
92
|
|
85
|
-
def
|
86
|
-
options =
|
93
|
+
def color_field(attribute, options = {})
|
94
|
+
options = {bootstrap_form: {field_class: "form-control form-control-color"}}.deep_merge!(options)
|
87
95
|
|
88
|
-
field_wrapper_builder(attribute, options
|
89
|
-
super(attribute,
|
96
|
+
field_wrapper_builder(attribute, options) do
|
97
|
+
super(attribute, options)
|
90
98
|
end
|
91
99
|
end
|
92
100
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: generator_spec
|
@@ -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
|