Displaying state of standing orders on index

This commit is contained in:
Rob Harrington
2016-12-08 11:44:11 +11:00
parent b9316422d2
commit 3d8dceb76a
7 changed files with 67 additions and 7 deletions

View File

@@ -0,0 +1,28 @@
.state {
@extend .state;
&.active {
background-color: #9fc820;
&, a { color: #ffffff; }
}
&.paused {
background-color: #ff9300;
&, a { color: #ffffff; }
}
&.canceled {
background-color: #c60f13;
&, a { color: #ffffff; }
}
&.ended {
background-color: #7a7a7a;
&, a { color: #ffffff; }
}
&.pending {
background-color: #7a7a7a;
&, a { color: #ffffff; }
}
}

View File

@@ -1,6 +1,6 @@
class Api::Admin::StandingOrderSerializer < ActiveModel::Serializer
attributes :id, :shop_id, :customer_id, :schedule_id, :payment_method_id, :shipping_method_id, :begins_at, :ends_at
attributes :customer_email, :schedule_name, :edit_path, :canceled_at, :paused_at
attributes :customer_email, :schedule_name, :edit_path, :canceled_at, :paused_at, :state
has_many :standing_line_items, serializer: Api::Admin::StandingLineItemSerializer
has_many :closed_standing_order_orders, serializer: Api::Admin::StandingOrderOrderSerializer

View File

@@ -11,7 +11,7 @@
%thead
%th= t('admin.standing_orders.orders.number')
%th= t('admin.order_cycle')
%th= t('admin.standing_orders.orders.state')
%th= t('admin.status_state')
%th= t('total')
%th.actions
%tbody

View File

@@ -3,14 +3,15 @@
%table.index#standing_orders
%col.customer{ width: "20%", 'ng-show' => 'columns.customer.visible' }
%col.schedule{ width: "15%", 'ng-show' => 'columns.schedule.visible' }
%col.schedule{ width: "20%", 'ng-show' => 'columns.schedule.visible' }
%col.items{ width: "10%", 'ng-show' => 'columns.items.visible' }
%col.orders{ width: "10%", 'ng-show' => 'columns.orders.visible' }
%col.status{ width: "15%", 'ng-show' => 'columns.state.visible' }
%col.begins_on{ width: "10%", 'ng-show' => 'columns.begins_on.visible' }
%col.ends_on{ width: "10%", 'ng-show' => 'columns.ends_on.visible' }
%col.payment_method{ width: "20%", 'ng-show' => 'columns.payment_method.visible' }
%col.shipping_method{ width: "20%", 'ng-show' => 'columns.shipping_method.visible' }
%col.actions{ width: "10%" }
%col.actions{ width: "15%" }
%thead
%tr
-# %th.bulk
@@ -23,6 +24,8 @@
= t('admin.items')
%th.orders{ ng: { show: 'columns.orders.visible', } }
= t('orders')
%th.status{ ng: { show: 'columns.state.visible', } }
= t('admin.status_state')
%th.begins_on{ ng: { show: 'columns.begins_on.visible', } }
= t('admin.begins_on')
%th.ends_on{ ng: { show: 'columns.ends_on.visible', } }
@@ -41,6 +44,8 @@
%h5{ ng: { bind: 'itemCount(standingOrder)' } }
%td.orders.panel-toggle.text-center{ name: 'orders', ng: { show: 'columns.orders.visible' } }
%h5{ ng: { bind: 'standingOrder.not_closed_standing_order_orders.length + standingOrder.closed_standing_order_orders.length' } }
%td.status.text-center{ ng: { show: 'columns.state.visible' } }
%span.state{ ng: { class: "standingOrder.state", bind: "'spree.standing_order_state.' + standingOrder.state | t" } }
%td.begins_on.text-center{ ng: { show: 'columns.begins_on.visible', bind: '::standingOrder.begins_at' } }
%td.ends_on.text-center{ ng: { show: 'columns.ends_on.visible', bind: '::standingOrder.ends_at' } }
%td.payment_method{ ng: { show: 'columns.payment_method.visible', bind: '::paymentMethodsByID[standingOrder.payment_method_id].name' } }

View File

@@ -213,6 +213,7 @@ en:
shipping_method: Shipping Method
shop: Shop
sku: SKU
status_state: State
tags: Tags
variant: Variant
weight: Weight
@@ -811,7 +812,6 @@ en:
product_already_in_order: This product has already been added to the order. Please edit the quantity directly.
orders:
number: Number
status: Status
confirm_cancel_msg: Are you sure you want to cancel this standing order? This action cannot be undone.
cancel_failure_msg: 'Sorry, cancellation failed!'
confirm_pause_msg: Are you sure you want to pause this standing order?
@@ -2381,6 +2381,12 @@ See the %{link} to find out more about %{sitename}'s features and to start using
resumed: resumed
returned: returned
skrill: skrill
standing_order_state:
active: active
pending: pending
ended: ended
paused: paused
canceled: cancelled
payment_states:
balance_due: balance due
completed: completed

View File

@@ -104,8 +104,9 @@ module OpenFoodNetwork
schedule: { name: I18n.t("admin.schedule"), visible: true },
items: { name: I18n.t("items"), visible: true },
orders: { name: I18n.t("orders"), visible: true },
begins_on: { name: I18n.t("admin.begins_on"), visible: true },
ends_on: { name: I18n.t("admin.ends_on"), visible: true },
state: { name: I18n.t("admin.status_state"), visible: true },
begins_on: { name: I18n.t("admin.begins_on"), visible: false },
ends_on: { name: I18n.t("admin.ends_on"), visible: false },
payment_method: { name: I18n.t("admin.payment_method"), visible: false },
shipping_method: { name: I18n.t("admin.shipping_method"), visible: false }
}

View File

@@ -98,6 +98,26 @@ feature 'Standing Orders' do
end
end
# Pausing a standing order
within "tr#so_#{standing_order.id}" do
find("a.pause-standing-order").click
end
click_button "Yes, I'm sure"
within "tr#so_#{standing_order.id}" do
expect(page).to have_selector ".state.paused", text: "PAUSED"
expect(standing_order.reload.paused_at).to be_within(5.seconds).of Time.zone.now
end
# Unpausing a standing order
within "tr#so_#{standing_order.id}" do
find("a.unpause-standing-order").click
end
click_button "Yes, I'm sure"
within "tr#so_#{standing_order.id}" do
expect(page).to have_selector ".state.active", text: "ACTIVE"
expect(standing_order.reload.paused_at).to be nil
end
# Cancelling a standing order
within "tr#so_#{standing_order.id}" do
find("a.cancel-standing-order").click