Adding the last checkout distributor to the account link

This commit is contained in:
Will Marshall
2014-03-28 15:43:28 +11:00
parent 197f1cfa72
commit 6f50c45bba
3 changed files with 16 additions and 3 deletions

View File

@@ -7,3 +7,10 @@ window.AccountSidebarCtrl = Darkswarm.controller "AccountSidebarCtrl", ($scope,
$scope.select = ->
Navigation.navigate($scope.path)
$scope.emptyCart = (href, ev)->
console.log href
if $(ev.delegateTarget).hasClass "empties-cart"
location.href = href if confirm "Changing your collection date will clear your cart."
else
location.href = href

View File

@@ -14,5 +14,9 @@ module Spree
def alternative_available_distributors(order)
DistributionChangeValidator.new(order).available_distributors(Enterprise.all) - [order.distributor]
end
def last_completed_order
spree_current_user.orders.complete.last
end
end
end

View File

@@ -12,10 +12,12 @@
.panel
%p
%strong= link_to "Manage my account", account_path
- if order = spree_current_user.orders.last
- if order = last_completed_order
%dl
%dt Last distributor:
%dt Last hub:
%dd
= link_to "#{order.distributor.name}".html_safe, shop_enterprise_path(order.distributor), {class: distributor_link_class(order.distributor)}
= link_to "#{order.distributor.name}".html_safe, "",
{class: distributor_link_class(order.distributor),
"ng-click" => "emptyCart('#{main_app.shop_enterprise_path(order.distributor)}', $event)"}
= yield :sidebar