-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Spree.routes with Spree.pathFor
This PR replaces all instances of Spree.routes with Spree.pathFor. Spree.routes still exists, we're just preferring to use Spree.pathFor per #3405. It uses Proxy to issue a deprecation warning, however if Proxy isn't defined (in older browsers like IE) will just return the routes without deprecation. Hopefully the developer of the app will have something newer than IE, if they don't I imagine they have bigger problems than JS route deprecations 😬 Also adds Proxy to ESlint so it doesn't trigger the no-undef rule.
- Loading branch information
Showing
21 changed files
with
132 additions
and
60 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Spree.Models.Payment = Backbone.Model.extend({ | ||
urlRoot: function() { | ||
return Spree.routes.payments_api(this.get('order_id')); | ||
return Spree.pathFor('api/orders/' + this.get('order_id') + '/payments') | ||
} | ||
}); |
2 changes: 1 addition & 1 deletion
2
backend/app/assets/javascripts/spree/backend/models/shipment.js
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
2 changes: 1 addition & 1 deletion
2
backend/app/assets/javascripts/spree/backend/models/stock_item.js
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,6 +1,6 @@ | ||
Spree.Models.StockItem = Backbone.Model.extend({ | ||
paramRoot: 'stock_item', | ||
urlRoot: function() { | ||
return Spree.routes.stock_items_api(this.get('stock_location_id')); | ||
return Spree.pathFor('api/stock_locations/' + this.get('stock_location_id') + '/stock_items'); | ||
} | ||
}); |
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 |
---|---|---|
@@ -1,27 +1,66 @@ | ||
Spree.routes.checkouts_api = Spree.pathFor('api/checkouts') | ||
Spree.routes.classifications_api = Spree.pathFor('api/classifications') | ||
Spree.routes.option_value_search = Spree.pathFor('api/option_values') | ||
Spree.routes.option_type_search = Spree.pathFor('api/option_types') | ||
Spree.routes.orders_api = Spree.pathFor('api/orders') | ||
Spree.routes.product_search = Spree.pathFor('api/products') | ||
Spree.routes.admin_product_search = Spree.pathFor('admin/search/products') | ||
Spree.routes.shipments_api = Spree.pathFor('api/shipments') | ||
Spree.routes.checkouts_api = Spree.pathFor('api/checkouts') | ||
Spree.routes.stock_locations_api = Spree.pathFor('api/stock_locations') | ||
Spree.routes.taxon_products_api = Spree.pathFor('api/taxons/products') | ||
Spree.routes.taxons_search = Spree.pathFor('api/taxons') | ||
Spree.routes.user_search = Spree.pathFor('admin/search/users') | ||
Spree.routes.variants_api = Spree.pathFor('api/variants') | ||
Spree.routes.users_api = Spree.pathFor('api/users') | ||
/** | ||
* @deprecated Spree.routes will be removed in a future release. Please use Spree.pathFor instead. | ||
* See: https://github.com/solidusio/solidus/issues/3405 | ||
*/ | ||
if(typeof Proxy == "function") { | ||
Spree.routes = new Proxy({ | ||
states_search: Spree.pathFor('api/states'), | ||
apply_coupon_code: function(order_id) { | ||
return Spree.pathFor("api/orders/" + order_id + "/coupon_codes"); | ||
}, | ||
classifications_api: Spree.pathFor('api/classifications'), | ||
option_value_search: Spree.pathFor('api/option_values'), | ||
option_type_search: Spree.pathFor('api/option_types'), | ||
orders_api: Spree.pathFor('api/orders'), | ||
product_search: Spree.pathFor('api/products'), | ||
admin_product_search: Spree.pathFor('admin/search/products'), | ||
shipments_api: Spree.pathFor('api/shipments'), | ||
checkouts_api: Spree.pathFor('api/checkouts'), | ||
stock_locations_api: Spree.pathFor('api/stock_locations'), | ||
taxon_products_api: Spree.pathFor('api/taxons/products'), | ||
taxons_search: Spree.pathFor('api/taxons'), | ||
user_search: Spree.pathFor('admin/search/users'), | ||
variants_api: Spree.pathFor('api/variants'), | ||
users_api: Spree.pathFor('api/users'), | ||
|
||
Spree.routes.line_items_api = function(order_id) { | ||
return Spree.pathFor('api/orders/' + order_id + '/line_items') | ||
} | ||
line_items_api: function(order_id) { | ||
return Spree.pathFor('api/orders/' + order_id + '/line_items') | ||
}, | ||
|
||
Spree.routes.payments_api = function(order_id) { | ||
return Spree.pathFor('api/orders/' + order_id + '/payments') | ||
} | ||
payments_api: function(order_id) { | ||
return Spree.pathFor('api/orders/' + order_id + '/payments') | ||
}, | ||
|
||
stock_items_api: function(stock_location_id) { | ||
return Spree.pathFor('api/stock_locations/' + stock_location_id + '/stock_items') | ||
} | ||
}, Spree.routesDeprecationProxy); | ||
} else { | ||
Spree.routes.checkouts_api = Spree.pathFor('api/checkouts') | ||
Spree.routes.classifications_api = Spree.pathFor('api/classifications') | ||
Spree.routes.option_value_search = Spree.pathFor('api/option_values') | ||
Spree.routes.option_type_search = Spree.pathFor('api/option_types') | ||
Spree.routes.orders_api = Spree.pathFor('api/orders') | ||
Spree.routes.product_search = Spree.pathFor('api/products') | ||
Spree.routes.admin_product_search = Spree.pathFor('admin/search/products') | ||
Spree.routes.shipments_api = Spree.pathFor('api/shipments') | ||
Spree.routes.checkouts_api = Spree.pathFor('api/checkouts') | ||
Spree.routes.stock_locations_api = Spree.pathFor('api/stock_locations') | ||
Spree.routes.taxon_products_api = Spree.pathFor('api/taxons/products') | ||
Spree.routes.taxons_search = Spree.pathFor('api/taxons') | ||
Spree.routes.user_search = Spree.pathFor('admin/search/users') | ||
Spree.routes.variants_api = Spree.pathFor('api/variants') | ||
Spree.routes.users_api = Spree.pathFor('api/users') | ||
|
||
Spree.routes.line_items_api = function(order_id) { | ||
return Spree.pathFor('api/orders/' + order_id + '/line_items') | ||
} | ||
|
||
Spree.routes.payments_api = function(order_id) { | ||
return Spree.pathFor('api/orders/' + order_id + '/payments') | ||
} | ||
|
||
Spree.routes.stock_items_api = function(stock_location_id) { | ||
return Spree.pathFor('api/stock_locations/' + stock_location_id + '/stock_items') | ||
Spree.routes.stock_items_api = function(stock_location_id) { | ||
return Spree.pathFor('api/stock_locations/' + stock_location_id + '/stock_items') | ||
} | ||
} |
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
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
Oops, something went wrong.