mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-23 01:03:21 +00:00
Move JSON line items responses to a new controller
Extracts the JSON response from the admin's line item controller which are only used by the bulk management feature into its own controller. This decouples spree from an OFN-only feature and allows to remove unnecessary code. Furthermore, Admin::LineItemsController is gone in Spree 2.4.0.beta. See: https://github.com/spree/spree/pull/5280
This commit is contained in:
committed by
Rob Harrington
parent
b3c94fd688
commit
8db1fa4e77
@@ -1,5 +1,5 @@
|
||||
angular.module("admin.resources").factory 'LineItemResource', ($resource) ->
|
||||
$resource('/admin/:orders/:order_number/line_items/:id.json', {}, {
|
||||
$resource('/admin/bulk_line_items/:id.json', {}, {
|
||||
'index':
|
||||
method: 'GET'
|
||||
isArray: true
|
||||
|
||||
@@ -26,7 +26,7 @@ angular.module("admin.resources").factory 'LineItems', ($q, LineItemResource) ->
|
||||
save: (lineItem) ->
|
||||
deferred = $q.defer()
|
||||
lineItem.errors = {}
|
||||
lineItem.$update({id: lineItem.id, orders: "orders", order_number: lineItem.order.number})
|
||||
lineItem.$update({id: lineItem.id})
|
||||
.then( (data) =>
|
||||
@pristineByID[lineItem.id] = angular.copy(lineItem)
|
||||
deferred.resolve(data)
|
||||
@@ -54,7 +54,7 @@ angular.module("admin.resources").factory 'LineItems', ($q, LineItemResource) ->
|
||||
|
||||
delete: (lineItem, callback=null) ->
|
||||
deferred = $q.defer()
|
||||
lineItem.$delete({id: lineItem.id, orders: "orders", order_number: lineItem.order.number})
|
||||
lineItem.$delete({id: lineItem.id})
|
||||
.then( (data) =>
|
||||
delete @byID[lineItem.id]
|
||||
delete @pristineByID[lineItem.id]
|
||||
|
||||
Reference in New Issue
Block a user