country_state_select 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 361ffc00f971f4e6739ba653ec7ab36800aaef54
4
- data.tar.gz: 3b0ad3d7908b8d973d40a975e84b186d78810eb6
2
+ SHA256:
3
+ metadata.gz: ed85481d4b3d53c004780c6136710874ff664538cc4d5d71d921535c27dedc87
4
+ data.tar.gz: 6e2afd926d0a4279653e67411960a4429062dacdded56779e7d7f0b17682e453
5
5
  SHA512:
6
- metadata.gz: 7336813ead81567b3eef7963080f037e1a9859cd1e80ec2c8b61dbeb85265a3f3e39b05f75228990281f3aacdc339584685461192b61792c40495ddb4c998f21
7
- data.tar.gz: 747c28f7f2a11763eb73950aec6404c6d33d496a42a6ab555f055d080fd1a51bfbe11d4a7ff36a31fb755fae5e91c13f62b0afc7faf1cd6c98392f8e057a9f08
6
+ metadata.gz: 2799319fef3bd6077c7b57d51b6f4360c074914dfafe43ee92a1a994b006a19bcf3c73b91307a4e3e533945289e74863bb5933f7162f0be316959d5541bf9432
7
+ data.tar.gz: 841f91d1f43dfbdf20e3bd6c1e4aca56b9d90ca46272ebb40e73e9f298cb3cbf56d2c7e66190cac9c090ca3a89426ff6cb2ebfb9be05dc5b6a00ded427e73d44
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- ##Country State Select [![Build Status](https://travis-ci.org/arvindvyas/Country-State-Select.svg?branch=master)](https://travis-ci.org/arvindvyas/Country-State-Select) [![Code Climate](https://codeclimate.com/github/arvindvyas/Country-State-Select/badges/gpa.svg)](https://codeclimate.com/github/arvindvyas/Country-State-Select)
1
+ ## Country State Select
2
+ [![Build Status](https://travis-ci.org/arvindvyas/Country-State-Select.svg?branch=master)](https://travis-ci.org/arvindvyas/Country-State-Select) [![Code Climate](https://codeclimate.com/github/arvindvyas/Country-State-Select/badges/gpa.svg)](https://codeclimate.com/github/arvindvyas/Country-State-Select)
2
3
 
3
4
  Country State Select is a library that provides an easy API to generate Country , State / Province and City dropdowns for use in forms.
4
5
 
@@ -8,10 +9,10 @@ For instance, if a user chooses "United States of America" for a Country dropdow
8
9
 
9
10
  The data for Countries and States is populated by the excellent [city-state](https://github.com/loureirorg/city-state) gem.
10
11
 
11
- #Demo Of the Gem
12
+ # Demo
12
13
  https://country-state-select.herokuapp.com
13
14
 
14
- #Getting Started
15
+ # Getting Started
15
16
 
16
17
  Country State Select is released as a Ruby Gem and requires the Rails environment as well.
17
18
 
@@ -53,11 +54,11 @@ Don't forget to restart your server after you install it.
53
54
  Implementation in a view is simple.
54
55
 
55
56
  Just create a simple_form object like so:
56
-
57
- <%= simple_form_for @form_object do |f|
58
- f.button :submit
59
- end %>
60
-
57
+ ```ruby
58
+ <%= simple_form_for @form_object do |f|
59
+ f.button :submit
60
+ end %>
61
+ ```
61
62
  Once your form object is created, add in fields for your user to select a Country and State / Province.
62
63
 
63
64
  ## Country Field
@@ -89,18 +90,19 @@ Any options that are valid in simple_form field can be passed into the options h
89
90
  The magic of the library is the JavaScript that is performed on the fields. This JavaScript needs to be included in order for the proper State / Provinces to be selected based upon your Country selection.
90
91
 
91
92
  Add this JavaScript to the page that is loading your form:
92
-
93
- $(document).on('ready page:load', function() {
94
- return CountryStateSelect({
95
- country_id: "country_field_id",
96
- state_id: "state_field_id"
97
- });
98
- });
99
-
93
+ ```javascript
94
+ $(document).on('ready page:load', function() {
95
+ return CountryStateSelect({
96
+ country_id: "country_field_id",
97
+ state_id: "state_field_id"
98
+ });
99
+ });
100
+ ```
100
101
  If you are using CoffeeScript, use the following:
101
-
102
- $(document).on 'ready page:load', ->
103
- CountryStateSelect({ country_id: "country_field_id", state_id: "state_field_id" })
102
+ ```coffescript
103
+ $(document).on 'ready page:load', ->
104
+ CountryStateSelect({ country_id: "country_field_id", state_id: "state_field_id" })
105
+ ```
104
106
 
105
107
  The country_id accepts the form ID for the country field. The state_id accepts the form ID for the state field.
106
108
 
@@ -115,33 +117,32 @@ The ID being referred to is like the following in a select menu:
115
117
  The CountryStateSelect interface offers the option to turn the Chosen library on or off.
116
118
 
117
119
  To turn it on, set it to true:
118
-
119
- $(document).on('ready page:load', function() {
120
- return CountryStateSelect({
121
- chosen_ui: true,
122
- chosen_options: {
123
- disable_search_threshold: 10,
124
- width: '95%'
125
- },
126
- ...
127
- ...
128
- ...
129
- });
130
- });
131
-
120
+ ```javascript
121
+ $(document).on('ready page:load', function() {
122
+ return CountryStateSelect({
123
+ chosen_ui: true,
124
+ chosen_options: {
125
+ disable_search_threshold: 10,
126
+ width: '95%'
127
+ },
128
+ ...
129
+ ...
130
+ ...
131
+ });
132
+ });
133
+ ```
132
134
  To turn it off, set it to false:
133
-
134
- $(document).on('ready page:load', function() {
135
- return CountryStateSelect({
136
- chosen_ui: false,
137
- ...
138
- ...
139
- ...
140
- });
141
- });
142
-
143
-
144
- ##Contributing to Country State Select
145
-
135
+ ```javascript
136
+ $(document).on('ready page:load', function() {
137
+ return CountryStateSelect({
138
+ chosen_ui: false,
139
+ ...
140
+ ...
141
+ ...
142
+ });
143
+ });
144
+ ```
145
+
146
+ ## Contributing
146
147
  Fork, fix, then send a pull request.
147
148
 
@@ -24,8 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'pry'
25
25
 
26
26
  spec.add_runtime_dependency 'rails'
27
- spec.add_runtime_dependency 'simple_form', "~> 3.2"
28
- spec.add_runtime_dependency 'chosen-rails', "~> 1.4"
29
- spec.add_runtime_dependency 'compass-rails', '~> 2.0.4'
30
27
  spec.add_runtime_dependency 'city-state'
31
28
  end
@@ -1,10 +1,6 @@
1
1
  require "country_state_select/version"
2
2
  require "city-state"
3
3
  require "rails"
4
- require "sass-rails"
5
- require "compass-rails"
6
- require "chosen-rails"
7
- require "simple_form"
8
4
 
9
5
  module CountryStateSelect
10
6
 
@@ -15,7 +11,7 @@ module CountryStateSelect
15
11
 
16
12
  #Pass array of unwanted countries to get back all except those in the array
17
13
  def self.countries_except(*except)
18
- countries_collection.collect { |c| c unless except.include?(c.second) }.compact
14
+ countries_collection.collect { |c| c unless except.include?(c[1]) }.compact
19
15
  end
20
16
 
21
17
  #Return either the State (String) or States (Array)
@@ -68,6 +64,8 @@ module CountryStateSelect
68
64
  end
69
65
 
70
66
  case ::Rails.version.to_s
67
+ when /^5/
68
+ require 'country_state_select/engine'
71
69
  when /^4/
72
70
  require 'country_state_select/engine'
73
71
  when /^3\.[12]/
@@ -1,3 +1,3 @@
1
1
  module CountryStateSelect
2
- VERSION = "3.0.2"
2
+ VERSION = "3.0.3"
3
3
  end
@@ -14,8 +14,8 @@ describe CountryStateSelect do
14
14
 
15
15
  it "returns the value first and the key second" do
16
16
  method_call = CountryStateSelect.countries_collection
17
- expect(method_call.first.first).to eq("Andorra")
18
- expect(method_call.first.second).to eq(:AD)
17
+ expect(method_call[0][0]).to eq("Andorra")
18
+ expect(method_call[0][1]).to eq(:AD)
19
19
  end
20
20
  end
21
21
 
@@ -25,6 +25,7 @@ describe CountryStateSelect do
25
25
  let(:exceptions) { [us, sm] }
26
26
 
27
27
  it 'does include the United States ordinarily' do
28
+ binding.pry
28
29
  expect(CountryStateSelect.countries_except([])).to include(us)
29
30
  end
30
31
 
@@ -135,7 +136,7 @@ describe CountryStateSelect do
135
136
 
136
137
  it "returns the diffrent value for the key and value" do
137
138
  method_call = CountryStateSelect.collect_states('US')
138
- expect(method_call.first.first).not_to eq(method_call.first.second)
139
+ expect(method_call[0][0]).not_to eq(method_call[0][1])
139
140
  end
140
141
 
141
142
  it "returns the value part of the key-value pair" do
@@ -23,12 +23,12 @@ group :test do
23
23
  gem "launchy", "~> 2.4"
24
24
  gem "poltergeist", "~> 1.7"
25
25
  gem "selenium-webdriver", "~> 2.47"
26
- gem "capybara-webkit"
27
26
  gem "simplecov", "~> 0.10"
28
27
  end
29
28
 
29
+ gem 'chosen-rails'
30
30
  gem "rails", "~> 4.2"
31
- gem "pg"
31
+ gem 'pg', '~> 0.18'
32
32
  gem "sass-rails", "~> 5.0"
33
33
  gem "uglifier", "~> 2.7"
34
34
  gem "coffee-rails", "~> 4.1"
@@ -39,6 +39,6 @@ gem "sdoc", "~> 0.4", {:group=>:doc}
39
39
  gem "bootstrap-sass", "~> 3.3"
40
40
 
41
41
  gem "simple_form", "~> 3.2"
42
- gem "reform", "~> 2.0"
42
+ gem "reform-rails"
43
43
 
44
44
  gem 'country_state_select', path: '../../'
@@ -1,2 +1,2 @@
1
1
  $(document).on 'ready page:load', ->
2
- CountryStateSelect({ chosen_ui: true, country_id: "location_test_country", state_id: "location_test_state", city_id: "location_test_city" })
2
+ CountryStateSelect({ chosen_ui: true, country_id: "location_test_country", state_id: "location_test_state", city_id: "location_test_city", city_place_holder: "Please select city", state_place_holder: 'Please select state' })
@@ -1,15 +1,24 @@
1
-
2
- development:
1
+ default: &default
3
2
  adapter: postgresql
4
3
  encoding: unicode
5
- database: cy_development_one
6
4
  pool: 5
7
- host: localhost
8
- username: compass
9
- password: test123
5
+ username:
6
+ password:
7
+ prepared_statements: false
8
+
9
+ development:
10
+ <<: *default
11
+ database: cst-development
12
+
13
+ test:
14
+ <<: *default
15
+ database: cst_test
16
+
17
+ staging:
18
+ <<: *default
19
+ database: cst_staging
10
20
 
11
21
  production:
12
- adapter: postgresql
13
- encoding: unicode
14
- database: cy_production
15
- pool: 5
22
+ <<: *default
23
+ database: cst_release_production
24
+
@@ -10,7 +10,6 @@ function CountryStateSelect(options) {
10
10
  var city_name = $('#' + city_id).attr('name');
11
11
  var city_class = $('#' + city_id).attr('class');
12
12
 
13
-
14
13
  return statesDropdown();
15
14
 
16
15
  // ====== ***** METHODS ***** ===================================================================== //
@@ -119,6 +118,7 @@ function CountryStateSelect(options) {
119
118
  html = '<input id="' + state_id + '" name="' + state_name + '" class="' + state_class + '" type="text" type="text" value="" >';
120
119
  } else {
121
120
  html = '<select id="' + state_id + '" name="' + state_name + '" class="' + state_class + '" >';
121
+ html += '<option>'+ find_select_option_text('state') +'</option>'
122
122
 
123
123
  for (i = 0; i < data.length; i++) {
124
124
  html += '<option value='+data[i][0]+'>' + data[i][1] + '</option>';
@@ -142,13 +142,22 @@ function CountryStateSelect(options) {
142
142
 
143
143
  }
144
144
 
145
+ function find_select_option_text(type){
146
+ if (type === 'city'){
147
+ return options['city_place_holder'];
148
+ }else{
149
+ return options['state_place_holder']
150
+ }
151
+
152
+ }
153
+
145
154
  function buildCitiesDropdown(data) {
146
- console.log(data)
155
+
147
156
  if (data.length === 0) {
148
157
  html = '<input id="' + city_id + '" name="' + city_name + '" class="' + city_class + '" type="text" type="text" value="" >';
149
158
  } else {
150
159
  html = '<select id="' + city_id + '" name="' + city_name + '" class="' + city_class + '" >';
151
-
160
+ html += '<option>'+ find_select_option_text('city') +'</option>'
152
161
  for (i = 0; i < data.length; i++) {
153
162
  html += '<option>' + data[i] + '</option>';
154
163
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: country_state_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arvind Vyas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,48 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: simple_form
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '3.2'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '3.2'
97
- - !ruby/object:Gem::Dependency
98
- name: chosen-rails
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1.4'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '1.4'
111
- - !ruby/object:Gem::Dependency
112
- name: compass-rails
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 2.0.4
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 2.0.4
125
83
  - !ruby/object:Gem::Dependency
126
84
  name: city-state
127
85
  requirement: !ruby/object:Gem::Requirement
@@ -247,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
205
  version: '0'
248
206
  requirements: []
249
207
  rubyforge_project:
250
- rubygems_version: 2.4.5
208
+ rubygems_version: 2.7.6
251
209
  signing_key:
252
210
  specification_version: 4
253
211
  summary: Dynamically select Country and State.