forked from spree/spree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch customer autocomplete in admin backend to use Select2
- Loading branch information
Showing
12 changed files
with
116 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//= require handlebars | ||
Handlebars.registerHelper("t", function(key) { | ||
if (Spree.translations[key]) { | ||
return Spree.translations[key] | ||
} else { | ||
console.error("No translation found for " + key + ". Does it exist within spree/admin/shared/_translations.html.erb?") | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
core/app/views/spree/admin/orders/customer_details/_autocomplete.js.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script type='text/template' id='customer_autocomplete_template'> | ||
<div class='customer-autocomplete-item'> | ||
<div class='customer-details'> | ||
<h5>{{customer.email}}</h5> | ||
{{#if bill_address.firstname }} | ||
<strong>{{t 'bill_address' }}</strong> | ||
{{bill_address.firstname}} {{bill_address.lastname}}<br> | ||
{{bill_address.address1}}, {{bill_address.address2}}<br> | ||
{{bill_address.city}}<br> | ||
{{#if bill_address.state_id }} | ||
{{bill_address.state.name}} | ||
{{else}} | ||
{{bill_address.state_name}} | ||
{{/if}} | ||
{{bill_address.country.name}} | ||
{{/if}} | ||
</div> | ||
</div> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,30 @@ | ||
object false | ||
child @users => :users do | ||
attributes :email, :id | ||
address_fields = [:firstname, :lastname, | ||
:address1, :address2, | ||
:city, :zipcode, | ||
:phone, :state_name, | ||
:state_id, :country_id, | ||
:company] | ||
collection(@users) | ||
attributes :email, :id | ||
address_fields = [:firstname, :lastname, | ||
:address1, :address2, | ||
:city, :zipcode, | ||
:phone, :state_name, | ||
:state_id, :country_id, | ||
:company] | ||
|
||
child :ship_address => :ship_address do | ||
attributes *address_fields | ||
child :state do | ||
attributes :name | ||
end | ||
child :ship_address => :ship_address do | ||
attributes *address_fields | ||
child :state do | ||
attributes :name | ||
end | ||
|
||
child :country do | ||
attributes :name | ||
end | ||
child :country do | ||
attributes :name | ||
end | ||
end | ||
|
||
child :bill_address => :bill_address do | ||
attributes *address_fields | ||
child :state do | ||
attributes :name | ||
end | ||
child :bill_address => :bill_address do | ||
attributes *address_fields | ||
child :state do | ||
attributes :name | ||
end | ||
|
||
child :country do | ||
attributes :name | ||
end | ||
child :country do | ||
attributes :name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,9 @@ | |
create(:order_with_inventory_unit_shipped, :completed_at => "2011-02-01 12:36:15") | ||
ship_address = create(:address, :country => country, :state => state) | ||
bill_address = create(:address, :country => country, :state => state) | ||
create(:user, :email => '[email protected]', | ||
:ship_address => ship_address, | ||
:bill_address => bill_address) | ||
@user = create(:user, :email => '[email protected]', | ||
:ship_address => ship_address, | ||
:bill_address => bill_address) | ||
|
||
visit spree.admin_path | ||
click_link "Orders" | ||
|
@@ -35,9 +35,7 @@ | |
context "editing an order", :js => true do | ||
it "should be able to populate customer details for an existing order" do | ||
click_link "Customer Details" | ||
fill_in "customer_search", :with => "foobar" | ||
sleep(3) | ||
page.execute_script %Q{ $('.ui-menu-item a').last().click(); } | ||
select2("#select-customer", "foobar") | ||
|
||
["ship_address", "bill_address"].each do |address| | ||
find_field("order_#{address}_attributes_firstname").value.should == "John" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters