When saving an OC from the simple interface, include outgoing variants

This commit is contained in:
Rohan Mitchell
2014-10-22 17:08:16 +11:00
parent 8fb95769bf
commit 549ef4b79d
2 changed files with 13 additions and 1 deletions

View File

@@ -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()

View File

@@ -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
})