mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Clear variants when order cycle changed, not when products are initially loaded
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# TODO this SUCKS. Fix it
|
||||
|
||||
Darkswarm.controller "OrderCycleCtrl", ($scope, OrderCycle, $timeout) ->
|
||||
Darkswarm.controller "OrderCycleCtrl", ($scope, $timeout, OrderCycle) ->
|
||||
$scope.order_cycle = OrderCycle.order_cycle
|
||||
$scope.OrderCycle = OrderCycle
|
||||
|
||||
@@ -9,11 +9,15 @@ Darkswarm.controller "OrderCycleCtrl", ($scope, OrderCycle, $timeout) ->
|
||||
# That takes an expression instead of a trigger, and binds to that
|
||||
$timeout =>
|
||||
if !$scope.OrderCycle.selected()
|
||||
$("#order_cycle_id").trigger("openTrigger")
|
||||
$("#order_cycle_id").trigger("openTrigger")
|
||||
|
||||
|
||||
Darkswarm.controller "OrderCycleChangeCtrl", ($scope, OrderCycle, Products, $timeout) ->
|
||||
Darkswarm.controller "OrderCycleChangeCtrl", ($scope, $timeout, OrderCycle, Products, Variants) ->
|
||||
$scope.changeOrderCycle = ->
|
||||
OrderCycle.push_order_cycle Products.update
|
||||
OrderCycle.push_order_cycle $scope.orderCycleChanged
|
||||
$timeout ->
|
||||
$("#order_cycle_id").trigger("closeTrigger")
|
||||
$("#order_cycle_id").trigger("closeTrigger")
|
||||
|
||||
$scope.orderCycleChanged = ->
|
||||
Variants.clear()
|
||||
Products.update()
|
||||
|
||||
@@ -12,8 +12,6 @@ Darkswarm.factory 'Products', ($resource, Enterprises, Dereferencer, Taxons, Pro
|
||||
@loading = true
|
||||
@products = []
|
||||
$resource("/shop/products").query (products)=>
|
||||
Variants.clear()
|
||||
|
||||
@products = products
|
||||
|
||||
@extend()
|
||||
|
||||
Reference in New Issue
Block a user