mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-05 02:41:33 +00:00
Individual StandingOrder orders can be resumed from Standing Order index
This commit is contained in:
@@ -40,3 +40,10 @@ angular.module("admin.standingOrders").factory 'StandingOrderPrototype', ($http,
|
||||
angular.extend(order,response.data)
|
||||
, (response) ->
|
||||
InfoDialog.open 'error', response.data.errors[0]
|
||||
|
||||
resumeOrder: (order) ->
|
||||
if order.id?
|
||||
$http.put("/admin/standing_order_orders/#{order.id}/resume").then (response) =>
|
||||
angular.extend(order,response.data)
|
||||
, (response) ->
|
||||
InfoDialog.open 'error', response.data.errors[0]
|
||||
|
||||
@@ -13,5 +13,17 @@ module Admin
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def resume
|
||||
if @standing_order_order.resume
|
||||
respond_with(@standing_order_order) do |format|
|
||||
format.json { render_as_json @standing_order_order }
|
||||
end
|
||||
else
|
||||
respond_with(@standing_order_order) do |format|
|
||||
format.json { render json: { errors: [t(:could_not_resume_the_order)] }, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,4 +24,5 @@
|
||||
%td.text-center{ ng: { bind: 'order.status' } }
|
||||
%td.text-center{ ng: { bind: 'order.total' } }
|
||||
%td.actions
|
||||
%a.cancel-order.icon-remove.no-text{ href: 'javascript:void(0)', ng: { click: "cancelOrder(order)" }, 'ofn-with-tip' => t(:cancel_order) }
|
||||
%a.cancel-order.icon-remove.no-text{ href: 'javascript:void(0)', ng: { hide: "order.status == 'cancelled'", click: "cancelOrder(order)" }, 'ofn-with-tip' => t(:cancel_order) }
|
||||
%a.resume-order.icon-resume.no-text{ href: 'javascript:void(0)', ng: { show: "order.status == 'cancelled'", click: "resumeOrder(order)" }, 'ofn-with-tip' => t(:resume_order) }
|
||||
|
||||
@@ -79,7 +79,6 @@ feature 'Standing Orders' do
|
||||
within ".standing-order-orders" do
|
||||
expect(page).to have_selector "tr.standing_order_order", count: 1
|
||||
|
||||
# Cancelling an order
|
||||
standing_order_order = standing_order.standing_order_orders.first
|
||||
within "tr#o_#{standing_order_order.id}" do
|
||||
expect(page).to_not have_content 'CANCELLED'
|
||||
@@ -88,6 +87,14 @@ feature 'Standing Orders' do
|
||||
end
|
||||
expect(page).to have_content 'CANCELLED'
|
||||
expect(standing_order_order.reload.cancelled_at).to be_within(5.seconds).of Time.now
|
||||
|
||||
# Resuming an order
|
||||
accept_alert 'Are you sure?' do
|
||||
find("a.resume-order").trigger('click')
|
||||
end
|
||||
# Note: the order itself was not complete when 'cancelled', so state remained as cart
|
||||
expect(page).to have_content 'CART'
|
||||
expect(standing_order_order.reload.cancelled_at).to be nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user