Adding 'Cancel Order' button to order confimation interface

This commit is contained in:
Rob Harrington
2017-04-06 12:38:34 +10:00
parent c6afa1849c
commit 5d9f92eaa7
5 changed files with 27 additions and 11 deletions

View File

@@ -290,7 +290,7 @@ Spree::Order.class_eval do
end
def editable?
distributor.andand.allow_order_changes? && order_cycle.andand.open?
complete? && distributor.andand.allow_order_changes? && order_cycle.andand.open?
end
private

View File

@@ -4,11 +4,11 @@
%i.ofn-i_008-caret-left
= t(:back_to_store)
- if order.editable?
.columns.show-for-medium-up.medium-6  
-# .columns.small-12.medium-3  
-# = link_to "#", method: :delete, :class => "button secondary expand" do
-# %i.ofn-i_009-close
-# =t(:cancel_order)
.columns.show-for-medium-up.medium-3  
.columns.small-12.medium-3
= link_to spree.cancel_order_path(@order), method: :put, :class => "button secondary expand" do
%i.ofn-i_009-close
= t(:cancel_order)
.columns.small-12.medium-3
= button_tag :class => 'button primary radius expand', :id => 'update-button' do
%i.ofn-i_051-check-big

View File

@@ -10,8 +10,15 @@
.row
.columns.large-12.text-center
%h2
= t :orders_show_number
= " #" + @order.number
= t(:orders_show_order_number, number: @order.number)
- if @order.canceled?
%span.brick
= t(:orders_show_cancelled)
%i.ofn-i_009-close
- elsif @order.complete?
%span.turquoise
= t(:orders_show_confirmed)
%i.ofn-i_051-check-big
#order{"data-hook" => ""}
- if params.has_key? :checkout_complete

View File

@@ -1047,7 +1047,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using
orders_oc_expired_phone: "Phone:"
orders_show_title: Order Confirmation
orders_show_time: Order ready on
orders_show_number: Order confirmation
orders_show_order_number: "Order #%{number}"
orders_show_cancelled: Cancelled
orders_show_confirmed: Confirmed
orders_your_order_has_been_cancelled: "Your order has been cancelled"
orders_could_not_cancel: "Sorry, the order could not be cancelled"

View File

@@ -38,8 +38,10 @@ feature "Order Management", js: true do
order.distributor.update_attributes(allow_order_changes: true)
end
it "shows already ordered line items" do
it "allows quantity to be changed, items to be removed and the order to be cancelled" do
visit spree.order_path(order)
# Changing the quantity of an item
within "tr.variant-#{item1.variant.id}" do
expect(page).to have_content item1.product.name
expect(page).to have_field 'order_line_items_attributes_0_quantity'
@@ -53,13 +55,18 @@ feature "Order Management", js: true do
expect(find(".order-total.grand-total")).to have_content "$40.00"
expect(item1.reload.quantity).to eq 2
# Deleting an item
within "tr.variant-#{item2.variant.id}" do
click_link "delete_line_item_#{item2.id}"
end
expect(find(".order-total.grand-total")).to have_content "$30.00"
expect(Spree::LineItem.find_by_id(item2.id)).to be nil
# Cancelling the order
click_link(I18n.t(:cancel_order))
expect(page).to have_content I18n.t(:orders_show_cancelled)
expect(order.reload).to be_canceled
end
end
end