mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-14 04:04:23 +00:00
Show/hide all products
This commit is contained in:
@@ -7,6 +7,7 @@ angular.module('admin.orderCycles').factory('OrderCycle', ($resource, $window, $
|
||||
|
||||
{
|
||||
order_cycle: {}
|
||||
showProducts: {incoming: false, outgoing: false}
|
||||
|
||||
loaded: false
|
||||
|
||||
@@ -21,6 +22,10 @@ angular.module('admin.orderCycles').factory('OrderCycle', ($resource, $window, $
|
||||
toggleProducts: (exchange) ->
|
||||
exchange.showProducts = !exchange.showProducts
|
||||
|
||||
toggleAllProducts: (direction) ->
|
||||
this.showProducts[direction] = !this.showProducts[direction]
|
||||
exchange.showProducts = this.showProducts[direction] for exchange in this.exchangesByDirection(direction)
|
||||
|
||||
setExchangeVariants: (exchange, variants, selected) ->
|
||||
direction = if exchange.incoming then "incoming" else "outgoing"
|
||||
editable = @order_cycle["editable_variants_for_#{direction}_exchanges"][exchange.enterprise_id] || []
|
||||
@@ -80,6 +85,12 @@ angular.module('admin.orderCycles').factory('OrderCycle', ($resource, $window, $
|
||||
distributors = (exchange.enterprise_id for exchange in this.order_cycle.outgoing_exchanges)
|
||||
jQuery.unique(suppliers.concat(distributors)).sort()
|
||||
|
||||
exchangesByDirection: (direction) ->
|
||||
if direction == 'incoming'
|
||||
this.order_cycle.incoming_exchanges
|
||||
else
|
||||
this.order_cycle.outgoing_exchanges
|
||||
|
||||
removeDistributionOfVariant: (variant_id) ->
|
||||
for exchange in this.order_cycle.outgoing_exchanges
|
||||
exchange.variants[variant_id] = false
|
||||
|
||||
Reference in New Issue
Block a user