mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
When saving an OC from the simple interface, include outgoing variants
This commit is contained in:
@@ -25,3 +25,6 @@ angular.module('admin.order_cycles').controller "AdminSimpleCreateOrderCycleCtrl
|
||||
$scope.enterpriseFeesForEnterprise = (enterprise_id) ->
|
||||
EnterpriseFee.forEnterprise(parseInt(enterprise_id))
|
||||
|
||||
$scope.submit = ->
|
||||
OrderCycle.mirrorIncomingToOutgoingProducts()
|
||||
OrderCycle.create()
|
||||
|
||||
@@ -164,5 +164,14 @@ angular.module('admin.order_cycles').factory('OrderCycle', ($resource, $window)
|
||||
exchange.enterprise_fee_ids = (fee.id for fee in exchange.enterprise_fees)
|
||||
delete exchange.enterprise_fees
|
||||
order_cycle
|
||||
})
|
||||
|
||||
# In the simple UI, we don't list outgoing products. Instead, all products are considered
|
||||
# part of both incoming and outgoing enterprises. This method mirrors the former to the
|
||||
# latter **for order cycles with a single incoming and outgoing exchange only**.
|
||||
mirrorIncomingToOutgoingProducts: ->
|
||||
incoming = this.order_cycle.incoming_exchanges[0]
|
||||
outgoing = this.order_cycle.outgoing_exchanges[0]
|
||||
|
||||
for id, active of incoming.variants
|
||||
outgoing.variants[id] = active
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user