mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-05 22:26:07 +00:00
Remove coordinator fees
This commit is contained in:
@@ -40,6 +40,10 @@ angular.module('order_cycle', ['ngResource'])
|
||||
$event.preventDefault()
|
||||
OrderCycle.addCoordinatorFee()
|
||||
|
||||
$scope.removeCoordinatorFee = ($event, index) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeCoordinatorFee(index)
|
||||
|
||||
$scope.submit = ->
|
||||
OrderCycle.create()
|
||||
])
|
||||
@@ -86,6 +90,10 @@ angular.module('order_cycle', ['ngResource'])
|
||||
$event.preventDefault()
|
||||
OrderCycle.addCoordinatorFee()
|
||||
|
||||
$scope.removeCoordinatorFee = ($event, index) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.removeCoordinatorFee(index)
|
||||
|
||||
$scope.submit = ->
|
||||
OrderCycle.update()
|
||||
])
|
||||
@@ -123,6 +131,9 @@ angular.module('order_cycle', ['ngResource'])
|
||||
addCoordinatorFee: ->
|
||||
this.order_cycle.coordinator_fees.push({})
|
||||
|
||||
removeCoordinatorFee: (index) ->
|
||||
this.order_cycle.coordinator_fees.splice(index, 1)
|
||||
|
||||
productSuppliedToOrderCycle: (product) ->
|
||||
product_variant_ids = (variant.id for variant in product.variants)
|
||||
variant_ids = [product.master_id].concat(product_variant_ids)
|
||||
@@ -192,14 +203,14 @@ angular.module('order_cycle', ['ngResource'])
|
||||
data = this.translateCoordinatorFees(data)
|
||||
data
|
||||
|
||||
removeInactiveExchanges: (order_cycle)->
|
||||
removeInactiveExchanges: (order_cycle) ->
|
||||
order_cycle.incoming_exchanges =
|
||||
(exchange for exchange in order_cycle.incoming_exchanges when exchange.active)
|
||||
order_cycle.outgoing_exchanges =
|
||||
(exchange for exchange in order_cycle.outgoing_exchanges when exchange.active)
|
||||
order_cycle
|
||||
|
||||
translateCoordinatorFees: (order_cycle)->
|
||||
translateCoordinatorFees: (order_cycle) ->
|
||||
order_cycle.coordinator_fee_ids = (fee.id for fee in order_cycle.coordinator_fees)
|
||||
delete order_cycle.coordinator_fees
|
||||
order_cycle
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
%table
|
||||
%tr{'ng-repeat' => 'enterprise_fee in order_cycle.coordinator_fees'}
|
||||
%td= select_tag 'order_cycle_coordinator_fee_{{ $index }}_id', nil, {'ng-model' => 'enterprise_fee.id', 'ng-options' => 'enterprise_fee.id as enterprise_fee.name for enterprise_fee in enterpriseFeesForEnterprise(order_cycle.coordinator_id)'}
|
||||
%td= link_to 'Remove', '#', {'id' => 'order_cycle_coordinator_fee_{{ $index }}_remove', 'ng-click' => 'removeCoordinatorFee($event, $index)'}
|
||||
= f.submit 'Add coordinator fee', 'ng-click' => 'addCoordinatorFee($event)'
|
||||
|
||||
|
||||
|
||||
@@ -196,6 +196,8 @@ feature %q{
|
||||
# And I configure some coordinator fees
|
||||
select 'Coord fee 1', from: 'order_cycle_coordinator_fee_0_id'
|
||||
click_button 'Add coordinator fee'
|
||||
click_button 'Add coordinator fee'
|
||||
click_link 'order_cycle_coordinator_fee_2_remove'
|
||||
select 'Coord fee 2', from: 'order_cycle_coordinator_fee_1_id'
|
||||
|
||||
# And I add a supplier and some products
|
||||
|
||||
@@ -21,6 +21,7 @@ describe 'OrderCycle controllers', ->
|
||||
addSupplier: jasmine.createSpy('addSupplier')
|
||||
addDistributor: jasmine.createSpy('addDistributor')
|
||||
addCoordinatorFee: jasmine.createSpy('addCoordinatorFee')
|
||||
removeCoordinatorFee: jasmine.createSpy('removeCoordinatorFee')
|
||||
create: jasmine.createSpy('create')
|
||||
Enterprise =
|
||||
index: jasmine.createSpy('index').andReturn('enterprises list')
|
||||
@@ -89,6 +90,11 @@ describe 'OrderCycle controllers', ->
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(OrderCycle.addCoordinatorFee).toHaveBeenCalled()
|
||||
|
||||
it 'Removes coordinator fees', ->
|
||||
scope.removeCoordinatorFee(event, 0)
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(OrderCycle.removeCoordinatorFee).toHaveBeenCalledWith(0)
|
||||
|
||||
it 'Submits the order cycle via OrderCycle create', ->
|
||||
scope.submit()
|
||||
expect(OrderCycle.create).toHaveBeenCalled()
|
||||
@@ -118,6 +124,7 @@ describe 'OrderCycle controllers', ->
|
||||
addSupplier: jasmine.createSpy('addSupplier')
|
||||
addDistributor: jasmine.createSpy('addDistributor')
|
||||
addCoordinatorFee: jasmine.createSpy('addCoordinatorFee')
|
||||
removeCoordinatorFee: jasmine.createSpy('removeCoordinatorFee')
|
||||
update: jasmine.createSpy('update')
|
||||
Enterprise =
|
||||
index: jasmine.createSpy('index').andReturn('enterprises list')
|
||||
@@ -185,6 +192,11 @@ describe 'OrderCycle controllers', ->
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(OrderCycle.addCoordinatorFee).toHaveBeenCalled()
|
||||
|
||||
it 'Removes coordinator fees', ->
|
||||
scope.removeCoordinatorFee(event, 0)
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(OrderCycle.removeCoordinatorFee).toHaveBeenCalledWith(0)
|
||||
|
||||
it 'Submits the order cycle via OrderCycle update', ->
|
||||
scope.submit()
|
||||
expect(OrderCycle.update).toHaveBeenCalled()
|
||||
@@ -339,6 +351,19 @@ describe 'OrderCycle services', ->
|
||||
OrderCycle.addCoordinatorFee()
|
||||
expect(OrderCycle.order_cycle.coordinator_fees).toEqual [{}]
|
||||
|
||||
describe 'removing coordinator fees', ->
|
||||
it 'removes a coordinator fee by index', ->
|
||||
OrderCycle.order_cycle.coordinator_fees = [
|
||||
{id: 1}
|
||||
{id: 2}
|
||||
{id: 3}
|
||||
]
|
||||
OrderCycle.removeCoordinatorFee(1)
|
||||
expect(OrderCycle.order_cycle.coordinator_fees).toEqual [
|
||||
{id: 1}
|
||||
{id: 3}
|
||||
]
|
||||
|
||||
describe 'fetching all variants supplied on incoming exchanges', ->
|
||||
it 'collects variants from incoming exchanges', ->
|
||||
OrderCycle.order_cycle.incoming_exchanges = [
|
||||
|
||||
Reference in New Issue
Block a user