mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-18 04:39:14 +00:00
When a variant is removed from supply to an order cycle, remove it from distribution also
This commit is contained in:
@@ -58,6 +58,9 @@ angular.module('order_cycle', ['ngResource'])
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeExchangeFee(exchange, index)
|
||||
|
||||
$scope.removeDistributionOfVariant = (variant_id) ->
|
||||
OrderCycle.removeDistributionOfVariant(variant_id)
|
||||
|
||||
$scope.submit = ->
|
||||
OrderCycle.create()
|
||||
])
|
||||
@@ -122,6 +125,9 @@ angular.module('order_cycle', ['ngResource'])
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeExchangeFee(exchange, index)
|
||||
|
||||
$scope.removeDistributionOfVariant = (variant_id) ->
|
||||
OrderCycle.removeDistributionOfVariant(variant_id)
|
||||
|
||||
$scope.submit = ->
|
||||
OrderCycle.update()
|
||||
])
|
||||
@@ -198,6 +204,10 @@ angular.module('order_cycle', ['ngResource'])
|
||||
distributors = (exchange.enterprise_id for exchange in this.order_cycle.outgoing_exchanges)
|
||||
jQuery.unique(suppliers.concat(distributors)).sort()
|
||||
|
||||
removeDistributionOfVariant: (variant_id) ->
|
||||
for exchange in this.order_cycle.outgoing_exchanges
|
||||
exchange.variants[variant_id] = false
|
||||
|
||||
load: (order_cycle_id) ->
|
||||
service = this
|
||||
|
||||
@@ -332,4 +342,12 @@ angular.module('order_cycle', ['ngResource'])
|
||||
(scope, element, attrs) ->
|
||||
element.bind 'change', ->
|
||||
scope.$apply(attrs.ofwOnChange)
|
||||
)
|
||||
|
||||
.directive('ofwSyncDistributions', ->
|
||||
(scope, element, attrs) ->
|
||||
element.bind 'change', ->
|
||||
if !$(this).is(':checked')
|
||||
scope.$apply ->
|
||||
scope.removeDistributionOfVariant(attrs.ofwSyncDistributions)
|
||||
)
|
||||
Reference in New Issue
Block a user