mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Bring address_states as is from spre_backend
This commit is contained in:
27
app/assets/javascripts/admin/spree/orders/address_states.js
Normal file
27
app/assets/javascripts/admin/spree/orders/address_states.js
Normal file
@@ -0,0 +1,27 @@
|
||||
var update_state = function(region) {
|
||||
var country = $('span#' + region + 'country .select2').select2('val');
|
||||
|
||||
var state_select = $('span#' + region + 'state select.select2');
|
||||
var state_input = $('span#' + region + 'state input.state_name');
|
||||
|
||||
$.get(Spree.routes.states_search + "?country_id=" + country, function(data) {
|
||||
var states = data["states"]
|
||||
if (states.length > 0) {
|
||||
state_select.html('');
|
||||
var states_with_blank = [{name: '', id: ''}].concat(states);
|
||||
$.each(states_with_blank, function(pos,state) {
|
||||
var opt = $(document.createElement('option'))
|
||||
.attr('value', state.id)
|
||||
.html(state.name);
|
||||
state_select.append(opt);
|
||||
});
|
||||
state_select.prop("disabled", false).show();
|
||||
state_select.select2();
|
||||
state_input.hide().prop("disabled", true);
|
||||
|
||||
} else {
|
||||
state_input.prop("disabled", false).show();
|
||||
state_select.select2('destroy').hide();
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -25,4 +25,4 @@
|
||||
= button Spree.t('actions.update'), 'icon-refresh'
|
||||
|
||||
- content_for :head do
|
||||
= javascript_include_tag 'admin/address_states.js'
|
||||
= javascript_include_tag 'admin/spree/orders/address_states.js'
|
||||
|
||||
Reference in New Issue
Block a user