mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Adding the last checkout distributor to the account link
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user