mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Prompt for clear cart when order cycle changes
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
Darkswarm.directive "ofnChangeOrderCycle", (OrderCycle, Cart, storage) ->
|
||||
# Compares chosen order cycle with pre-set OrderCycle. Will trigger
|
||||
# a confirmation if they are different, and Cart isn't empty
|
||||
restrict: "A"
|
||||
scope: true
|
||||
link: (scope, elm, attr)->
|
||||
order_cycle_id = ->
|
||||
parseInt elm.val()
|
||||
|
||||
cart_needs_emptying = ->
|
||||
OrderCycle.order_cycle?.order_cycle_id && OrderCycle.order_cycle.order_cycle_id != order_cycle_id() && !Cart.empty()
|
||||
|
||||
elm.bind 'change', (ev)->
|
||||
if cart_needs_emptying()
|
||||
if confirm "Are you sure? This will change your selected order cycle and remove any items in your shopping cart."
|
||||
Cart.clear()
|
||||
scope.changeOrderCycle()
|
||||
else
|
||||
scope.changeOrderCycle()
|
||||
@@ -16,7 +16,7 @@
|
||||
/ Will this label should be a variable to reflect 'Ready for pickup / delivery' as appropriate
|
||||
|
||||
%select.avenir#order_cycle_id{"ng-model" => "order_cycle.order_cycle_id",
|
||||
"ng-change" => "changeOrderCycle()",
|
||||
"ofn-change-order-cycle" => true,
|
||||
"ng-options" => "oc.id as oc.time for oc in #{@order_cycles.map {|oc| {time: pickup_time(oc), id: oc.id}}.to_json}",
|
||||
"popover-placement" => "left", "popover" => "Choose when you want your order:", "popover-trigger" => "openTrigger"}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user