mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +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
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
%thead
|
||||
%tr
|
||||
%th Supplier
|
||||
%th Products
|
||||
%th
|
||||
Products
|
||||
= surround '(', ')' do
|
||||
%a{href: '#', 'ng-click' => "OrderCycle.toggleAllProducts('incoming')"}
|
||||
%span{'ng-show' => "OrderCycle.showProducts['incoming']"} Collapse all
|
||||
%span{'ng-hide' => "OrderCycle.showProducts['incoming']"} Expand all
|
||||
%th Receival details
|
||||
%th Fees
|
||||
%th.actions
|
||||
@@ -28,7 +33,12 @@
|
||||
%thead
|
||||
%tr
|
||||
%th Distributor
|
||||
%th Products
|
||||
%th
|
||||
Products
|
||||
= surround '(', ')' do
|
||||
%a{href: '#', 'ng-click' => "OrderCycle.toggleAllProducts('outgoing')"}
|
||||
%span{'ng-show' => "OrderCycle.showProducts['outgoing']"} Collapse all
|
||||
%span{'ng-hide' => "OrderCycle.showProducts['outgoing']"} Expand all
|
||||
%th Pickup / Delivery details
|
||||
%th Fees
|
||||
%th.actions
|
||||
|
||||
Reference in New Issue
Block a user