Reworking the empties cart and active table link stuff

This commit is contained in:
Will Marshall
2014-06-17 16:33:31 +10:00
parent b195ac3a84
commit 75366b96e1
3 changed files with 18 additions and 9 deletions

View File

@@ -0,0 +1,12 @@
Darkswarm.directive "activeTableHubLink", (CurrentHub, CurrentOrder) ->
restrict: "A"
scope:
hub: '=activeTableHubLink'
template: "{{action}} <strong>{{hub.name}}</strong>"
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

View File

@@ -1,17 +1,12 @@
Darkswarm.directive "ofnEmptiesCart", (CurrentHub, CurrentOrder, Navigation, storage) ->
restrict: "A"
scope:
hub: '=ofnEmptiesCart'
template: "{{action}} <strong>{{hub.name}}</strong>"
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

View File

@@ -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