Message for users with no orders

This commit is contained in:
Steve Pettitt
2016-01-22 19:49:03 +00:00
parent 667d1c5428
commit c9a8d7efa5
5 changed files with 26 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
class Api::OrderSerializer < ActiveModel::Serializer
attributes :id, :completed_at, :total, :state, :shipment_state, :payment_state, :outstanding_balance, :total_money, :balance_money, :payments
attributes :number, :completed_at, :total, :state, :shipment_state, :payment_state, :outstanding_balance, :total_money, :balance_money, :payments, :path
has_many :payments, serializer: Api::PaymentSerializer
@@ -27,6 +27,10 @@ class Api::OrderSerializer < ActiveModel::Serializer
to_money(object.outstanding_balance)
end
def path
spree.order_url(object.number, only_path: true)
end
private
def to_money(amount)

View File

@@ -10,7 +10,8 @@
%th{"bo-text" => "'balance' | t"}
%tbody{"ng-repeat" => "order in distributor.distributed_orders"}
%tr
%td{"bo-text" => "('order' | t )+ ' ' + order.id"}
%td
%a{"bo-href" => "order.path", "bo-text" => "('order' | t )+ ' ' + order.number"}
%td{"bo-text" => "order.completed_at"}
%td{"bo-text" => "order.payment_state | t"}
%td{"bo-text" => "order.shipment_state | t"}

View File

@@ -4,11 +4,11 @@
.columns.medium-2.large-2
%span.margin-top
%img{"bo-src" => "distributor.logo"}
.columns.small-10.medium-8.large-8
.columns.small-10.medium-8.large-5
%span.margin-top
%strong{"bo-text" => "distributor.name"}
.columns.small-6.medium-3.large-3
%span.margin-top{"bo-text" => "('balance' | t) + ': ' + Orders.currency_symbol + distributor.balance", "ng-class" => "{'credit' : order.outstanding_balance < 0, 'debit' : order.outstanding_balance > 0, 'paid' : order.outstanding_balance == 0}"}
.columns.small-2.medium-2.large-2.text-right
%span.margin-top
%i{"ng-class" => "{'ofn-i_005-caret-down' : !open(), 'ofn-i_006-caret-up' : open()}"}
.columns.small-6.medium-3.large-3
%span.margin-top{"bo-text" => "('balance' | t) + ': ' + Orders.currency_symbol + distributor.balance", "ng-class" => "{'credit' : order.outstanding_balance < 0, 'debit' : order.outstanding_balance > 0, 'paid' : order.outstanding_balance == 0}"}

View File

@@ -15,10 +15,11 @@
.row{bindonce: true}
.small-12.columns
.active_table
%distributor.active_table_node.row.animate-repeat{"ng-repeat" => "(key, distributor) in Orders.orders_by_distributor",
%distributor.active_table_node.row.animate-repeat{"ng-if" => "Orders.orders_by_distributor.length > 0", "ng-repeat" => "(key, distributor) in Orders.orders_by_distributor",
"ng-controller" => "DistributorNodeCtrl",
"ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !distributor.active}",
id: "{{distributor.hash}}"}
.small-12.columns
= render partial: "spree/users/skinny"
= render partial: "spree/users/fat"
.message{"ng-if" => "Orders.orders_by_distributor.length == 0", "bo-text" => "'you_have_no_orders_yet' | t"}

View File

@@ -8,6 +8,7 @@ feature %q{
include UIComponentHelper
include AuthenticationWorkflow
let!(:user) { create(:user)}
let!(:user2) {create(:user)}
let!(:distributor1) { create(:distributor_enterprise) }
let!(:distributor2) { create(:distributor_enterprise) }
let!(:distributor_without_orders) { create(:distributor_enterprise) }
@@ -30,9 +31,20 @@ feature %q{
it "reveals table of orders for distributors when clicked" do
expand_active_table_node distributor1.name
expect(page).to have_content "Order " + d1o1.id.to_s
expect(page).to have_content "Order " + d1o1.number.to_s
expand_active_table_node distributor2.name
expect(page).not_to have_content "Order " + d1o1.id.to_s
expect(page).not_to have_content "Order " + d1o1.number.to_s
end
context "for a user without orders" do
before do
login_as user2
visit "/account"
end
it "displays an appropriate message" do
expect(page).to have_content "You have no orders yet"
end
end
end