Files
openfoodnetwork/app/assets/javascripts/admin/subscriptions/controllers/subscriptions_controller.js.coffee
2018-02-09 14:44:13 +11:00

21 lines
819 B
CoffeeScript

angular.module("admin.standingOrders").controller "StandingOrdersController", ($scope, StandingOrders, Columns, RequestMonitor, shops, ShippingMethods, PaymentMethods) ->
$scope.columns = Columns.columns
$scope.shops = shops
$scope.shop_id = if shops.length == 1 then shops[0].id else null
$scope.shippingMethodsByID = ShippingMethods.byID
$scope.paymentMethodsByID = PaymentMethods.byID
$scope.RequestMonitor = RequestMonitor
$scope.query = ''
$scope.$watch "shop_id", ->
if $scope.shop_id?
$scope.standingOrders = StandingOrders.index("q[shop_id_eq]": $scope.shop_id, "q[canceled_at_null]": true)
$scope.itemCount = (standingOrder) ->
standingOrder.standing_line_items.reduce (sum, sli) ->
return sum + sli.quantity
, 0
$scope.filtersApplied = ->
$scope.query != ''