diff --git a/app/assets/javascripts/darkswarm/directives/active_table_hub_link.js.coffee b/app/assets/javascripts/darkswarm/directives/active_table_hub_link.js.coffee
new file mode 100644
index 0000000000..ee658796b0
--- /dev/null
+++ b/app/assets/javascripts/darkswarm/directives/active_table_hub_link.js.coffee
@@ -0,0 +1,12 @@
+Darkswarm.directive "activeTableHubLink", (CurrentHub, CurrentOrder) ->
+ restrict: "A"
+ scope:
+ hub: '=activeTableHubLink'
+ template: "{{action}} {{hub.name}}"
+ link: (scope, elm, attr)->
+ # Swap out the text of the hub link depending on whether it'll change current hub
+ # To be used with ofnEmptiesCart
+ if CurrentHub.id and CurrentHub.id isnt scope.hub.id
+ scope.action = attr.change
+ else
+ scope.action = attr.shop
diff --git a/app/assets/javascripts/darkswarm/directives/empties_cart.js.coffee b/app/assets/javascripts/darkswarm/directives/empties_cart.js.coffee
index 4691d9b830..4ee4c9ce25 100644
--- a/app/assets/javascripts/darkswarm/directives/empties_cart.js.coffee
+++ b/app/assets/javascripts/darkswarm/directives/empties_cart.js.coffee
@@ -1,17 +1,12 @@
Darkswarm.directive "ofnEmptiesCart", (CurrentHub, CurrentOrder, Navigation, storage) ->
restrict: "A"
- scope:
- hub: '=ofnEmptiesCart'
- template: "{{action}} {{hub.name}}"
link: (scope, elm, attr)->
+ hub = scope.$eval(attr.ofnEmptiesCart)
# A hub is selected, we're changing to a different hub, and the cart isn't empty
- if CurrentHub.id and CurrentHub.id isnt scope.hub.id
- scope.action = attr.change
+ if CurrentHub.id and CurrentHub.id isnt hub.id
unless CurrentOrder.empty()
elm.bind 'click', (ev)->
ev.preventDefault()
if confirm "Are you sure? This will change your selected Hub and remove any items in you shopping cart."
storage.clearAll() # One day this will have to be moar GRANULAR
Navigation.go scope.hub.path
- else
- scope.action = attr.shop
diff --git a/app/views/home/_fat.html.haml b/app/views/home/_fat.html.haml
index 11af6e2454..488547a651 100644
--- a/app/views/home/_fat.html.haml
+++ b/app/views/home/_fat.html.haml
@@ -26,7 +26,8 @@
.row.active_table_row.link{"ng-show" => "open()", "bo-if" => "hub.active"}
.columns.small-11
- %a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub",
+ %a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub",
+ "active-table-hub-link" => "hub",
change: "Change hub to", shop: "Shop at"}
.columns.small-1.text-right
@@ -35,7 +36,8 @@
.row.active_table_row.link{"ng-show" => "open()", "bo-if" => "!hub.active"}
.columns.small-11
- %a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub",
+ %a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub",
+ "active-table-hub-link" => "hub",
change: "Change hub to (disabled)", shop: "Shop at (disabled)"}
.columns.small-1.text-right