Skip to content

Commit

Permalink
Merge pull request sharetribe#3905 from sharetribe/stripe-change-to-d…
Browse files Browse the repository at this point in the history
…ropdown-for-state-values-for-canada-and-australia

[Stripe] Change to dropdown for state values for Canada and Australia
  • Loading branch information
aivils authored Oct 31, 2019
2 parents 7f93f32 + c7fa405 commit a6c84f5
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 61 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/stripe_form2.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ window.ST.stripe_form_i18n = window.ST.stripe_form_i18n || {
$("#stripe_account_form_address_country").change(function(){
var showElement = function (el, show) {
if (show) {
$(el).find('input').prop('disabled', false);
$(el).find('input, select').prop('disabled', false);
$(el).show();
} else {
$(el).find('input').prop('disabled', true);
$(el).find('input, select').prop('disabled', true);
$(el).hide();
}
};
Expand Down
57 changes: 0 additions & 57 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -746,63 +746,6 @@ def format_local_date(value)
value.present? ? value.strftime(format) : nil
end

def us_states
[
['Alabama', 'AL'],
['Alaska', 'AK'],
['Arizona', 'AZ'],
['Arkansas', 'AR'],
['California', 'CA'],
['Colorado', 'CO'],
['Connecticut', 'CT'],
['Delaware', 'DE'],
['District of Columbia', 'DC'],
['Florida', 'FL'],
['Georgia', 'GA'],
['Hawaii', 'HI'],
['Idaho', 'ID'],
['Illinois', 'IL'],
['Indiana', 'IN'],
['Iowa', 'IA'],
['Kansas', 'KS'],
['Kentucky', 'KY'],
['Louisiana', 'LA'],
['Maine', 'ME'],
['Maryland', 'MD'],
['Massachusetts', 'MA'],
['Michigan', 'MI'],
['Minnesota', 'MN'],
['Mississippi', 'MS'],
['Missouri', 'MO'],
['Montana', 'MT'],
['Nebraska', 'NE'],
['Nevada', 'NV'],
['New Hampshire', 'NH'],
['New Jersey', 'NJ'],
['New Mexico', 'NM'],
['New York', 'NY'],
['North Carolina', 'NC'],
['North Dakota', 'ND'],
['Ohio', 'OH'],
['Oklahoma', 'OK'],
['Oregon', 'OR'],
['Pennsylvania', 'PA'],
['Puerto Rico', 'PR'],
['Rhode Island', 'RI'],
['South Carolina', 'SC'],
['South Dakota', 'SD'],
['Tennessee', 'TN'],
['Texas', 'TX'],
['Utah', 'UT'],
['Vermont', 'VT'],
['Virginia', 'VA'],
['Washington', 'WA'],
['West Virginia', 'WV'],
['Wisconsin', 'WI'],
['Wyoming', 'WY']
]
end

def regex_definition_to_js(string)
string.gsub('\A', '^').gsub('\z', '$').gsub('\\', '\\\\')
end
Expand Down
19 changes: 19 additions & 0 deletions app/helpers/country_i18n_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,23 @@ def us_states
['Wyoming', 'WY']
]
end

def ca_states
['AB', 'BC', 'MB', 'NB', 'NL', 'NS', 'NT', 'NU', 'ON', 'PE', 'QC', 'SK', 'YT'].map do |state|
[I18n.t("canada_states.#{state}"), state]
end
end

def au_states
[
["Australian Capital Territory", "ACT"],
["New South Wales", "NSW"],
["Northern Territory", "NT"],
["Queensland", "QLD"],
["South Australia", "SA"],
["Tasmania", "TAS"],
["Victoria", "VIC"],
["Western Australia", "WA"]
]
end
end
8 changes: 6 additions & 2 deletions app/views/payment_settings/_address_fields_form.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@
.col-12
= form.label :address_city, t("stripe_accounts.form_new.address_city")+"*"
= form.text_field :address_city, class: 'required'
.row.country-dependent{"data-country-only" => "AU,IE"}
.row.country-dependent{"data-country-only" => "IE"}
.col-12
= form.label :address_state, t("stripe_accounts.form_new.address_state")+"*"
= form.text_field :address_state, required: true
.row.country-dependent{"data-country-only" => "AU"}
.col-12
= form.label :address_state, t("stripe_accounts.form_new.address_state")+"*"
= form.select :address_state, au_states, { include_blank: true }, required: true
.row.country-dependent{"data-country-only" => "US"}
.col-12
= form.label :address_state, t("stripe_accounts.form_new.address_state")+"*"
= form.select :address_state, us_states.select{|x| x[1] != 'PR'}, { include_blank: true }, required: true
.row.country-dependent{"data-country-only" => "CA"}
.col-12
= form.label :address_state, t("stripe_accounts.form_new.address_province")+"*"
= form.text_field :address_state, required: true
= form.select :address_state, ca_states, { include_blank: true }, required: true
.country-dependent{"data-country-only" => "JP"}
- [:address_kana_postal_code, :address_kana_state, :address_kana_city, :address_kana_town, :address_kana_line1].each do |field|
.row
Expand Down
15 changes: 15 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3120,3 +3120,18 @@ en:
landing_page_version/section/video:
text: Text
youtube_video_id: "Youtube video ID"
canada_states:
AB: Alberta
BC: British Columbia
MB: Manitoba
NB: New Brunswick
NL: Newfoundland and Labrador
NS: Nova Scotia
NT: Northwest Territories
NU: Nunavut
'ON': Ontario
PE: Prince Edward Island
QC: Quebec
SK: Saskatchewan
YT: Yukon Territory
15 changes: 15 additions & 0 deletions config/locales/fr-CA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3058,3 +3058,18 @@ fr-CA:
landing_page_version/section/video:
text: ~
youtube_video_id: ~
canada_states:
AB: Alberta
BC: Colombie-Britannique
MB: Manitoba
NB: Nouveau-Brunswick
NL: Terre-Neuve-et-Labrador
NS: Nouvelle-Écosse
NT: Territoires du Nord-Ouest
NU: Nunavut
'ON': Ontario
PE: Île-du-Prince-Édouard
QC: Québec
SK: Saskatchewan
YT: Yukon

15 changes: 15 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3117,3 +3117,18 @@ fr:
landing_page_version/section/video:
text: ~
youtube_video_id: ~
canada_states:
AB: Alberta
BC: Colombie-Britannique
MB: Manitoba
NB: Nouveau-Brunswick
NL: Terre-Neuve-et-Labrador
NS: Nouvelle-Écosse
NT: Territoires du Nord-Ouest
NU: Nunavut
'ON': Ontario
PE: Île-du-Prince-Édouard
QC: Québec
SK: Saskatchewan
YT: Yukon

0 comments on commit a6c84f5

Please sign in to comment.