mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Reworking the empties cart and active table link stuff
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user