Skip to content

Commit

Permalink
Remove use of deprecated Spree.url in admin js
Browse files Browse the repository at this point in the history
This was deprecated, but errors were only shown in development. This
removes all uses of Spree.url and now will display the warning in the
test environment.
  • Loading branch information
jhawthorn committed Feb 18, 2016
1 parent b714dea commit e5f7f24
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $(@).ready( ->
return if $("#coupon_code").val().length == 0
Spree.ajax
type: 'PUT'
url: Spree.url(Spree.routes.apply_coupon_code(order_number))
url: Spree.routes.apply_coupon_code(order_number)
data:
coupon_code: $("#coupon_code").val()
token: Spree.api_key
Expand Down
20 changes: 10 additions & 10 deletions backend/app/assets/javascripts/spree/backend/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ $(document).ready(function(){
});

window.Spree.advanceOrder = function() {
Spree.ajax({
type: "PUT",
async: false,
data: {
token: Spree.api_key
},
url: Spree.url(Spree.routes.checkouts_api + "/" + order_number + "/advance")
}).done(function() {
window.location.reload();
});
Spree.ajax({
type: "PUT",
async: false,
data: {
token: Spree.api_key
},
url: Spree.routes.checkouts_api + "/" + order_number + "/advance"
}).done(function() {
window.location.reload();
});
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ adjustLineItems = function(order_number, variant_id, quantity, stock_location_qu

Spree.ajax({
type: "POST",
url: Spree.url(url),
url: url,
data: {
line_item: {
variant_id: variant_id,
Expand Down
4 changes: 2 additions & 2 deletions backend/app/assets/javascripts/spree/backend/shipments.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ adjustShipmentItems = function(shipment_number, variant_id, quantity){
if(new_quantity!=0){
Spree.ajax({
type: "PUT",
url: Spree.url(url),
url: url,
data: {
variant_id: variant_id,
quantity: new_quantity,
Expand All @@ -175,7 +175,7 @@ deleteLineItem = function(line_item_id){

Spree.ajax({
type: "DELETE",
url: Spree.url(url),
url: url,
success: function(response) {
window.location.reload();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jQuery ->
el.select2
placeholder: "Find a stock item" # translate
ajax:
url: Spree.url(Spree.routes.stock_items_api(el.data('stock-location-id')))
url: Spree.routes.stock_items_api(el.data('stock-location-id'))
params: { "headers": { "X-Spree-Token": Spree.api_key } }
data: (term, page) ->
q:
Expand Down
16 changes: 10 additions & 6 deletions backend/app/assets/javascripts/spree/backend/taxon_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ var set_taxon_select = function(){
placeholder: Spree.translations.taxon_placeholder,
multiple: true,
initSelection: function (element, callback) {
var url = Spree.url(Spree.routes.taxons_search, {
ids: element.val(),
without_children: true
});
return Spree.getJSON(url, null, function (data) {
return callback(data['taxons']);
Spree.ajax({
type: "GET",
url: Spree.routes.taxons_search,
data: {
ids: element.val(),
without_children: true
},
success: function (data) {
callback(data['taxons']);
}
});
},
ajax: {
Expand Down
2 changes: 1 addition & 1 deletion core/app/assets/javascripts/spree.js.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class window.Spree
# Uses the JSUri library from here: https://github.com/derek-watson/jsUri
# Thanks to Jake Moffat for the suggestion: https://twitter.com/jakeonrails/statuses/321776992221544449
@url: (uri, query) ->
if Spree.env == 'development'
if Spree.env == 'development' || Spree.env == 'test'
console.warn 'Spree.url is deprecated, please use Spree.ajax for your request instead.'
if uri.path == undefined
uri = new Uri(uri)
Expand Down

0 comments on commit e5f7f24

Please sign in to comment.